Class: Win32::API::Callback
- Inherits:
-
Object
- Object
- Win32::API::Callback
- Defined in:
- ext/win32/api.c
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#prototype ⇒ Object
readonly
The prototype, returned as an array of characters.
-
#return_type ⇒ Object
readonly
The return type, returned as a single character, P, L, I, V or B.
Instance Method Summary collapse
-
#Win32::API::Callback.new(prototype) ⇒ Object
constructor
Creates and returns a new Win32::API::Callback object.
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 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/win32/api.c', line 69
static VALUE callback_init(int argc, VALUE* argv, VALUE self)
{
VALUE v_proto, v_return, v_proc;
int i;
rb_scan_args(argc, argv, "11", &v_proto, &v_return);
/* Validate prototype characters */
for(i = 0; i < RSTRING(v_proto)->len; i++){
switch(RSTRING(v_proto)->ptr[i]){
case 'I': case 'L': case 'P': case 'V':
break;
default:
rb_raise(cCallbackError, "Illegal prototype '%c'",
RSTRING(v_proto)->ptr[i]);
}
}
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
#prototype ⇒ Object (readonly)
The prototype, returned as an array of characters
#return_type ⇒ Object (readonly)
The return type, returned as a single character, P, L, I, V or B