Class: Win32::API::Callback

Inherits:
Object
  • Object
show all
Defined in:
ext/win32/api.c

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#Win32::API::Callback.new(prototype) ⇒ Object

Creates and returns a new Win32::API::Callback object. The function is the name of the Windows function.

The prototype is the function prototype for the callback function. This is a string. The possible valid characters are ‘I’ (integer), ‘L’ (long), ‘V’ (void), or ‘P’ (pointer). Unlike API objects, API::Callback objects do not have a default prototype.

The return argument is the return type for the callback function. The valid characters are the same as for the prototype. The default is ‘L’ (long).



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'ext/win32/api.c', line 69

static VALUE callback_init(int argc, VALUE* argv, VALUE self)
{
   VALUE v_proto, v_return, v_proc;
    
   rb_scan_args(argc, argv, "11", &v_proto, &v_return);

   if(NIL_P(v_return) || RARRAY(v_return)->len == 0)
      v_return = rb_str_new2("L");

   if(rb_block_given_p())
      v_proc = rb_block_proc();
   else
      v_proc = Qnil;

    rb_iv_set(self, "@function", v_proc);
    rb_iv_set(self, "@prototype", v_proto);
    rb_iv_set(self, "@return_type", v_return);
    
    return self;
}

Instance Attribute Details

#prototypeObject (readonly)

The prototype, returned as an array of characters

#return_typeObject (readonly)

The return type, returned as a single character, P, L, I, V or B