summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-30 02:36:07 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-30 02:36:07 +0000
commit3c89a278e3d538dcb206753dc3b0466a9476fbc5 (patch)
tree925d1cb9ff6a12d009738c3fc6131784efae0b19 /ext
parent68bc47726b8afef80885a3f698b5c0fceec48d77 (diff)
eban
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/Win32API/Win32API.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index 3f0ceae..d62e60e 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -70,36 +70,44 @@ Win32API_initialize(self, dllname, proc, import, export)
rb_iv_set(self, "__proc__", UINT2NUM((unsigned long)hproc));
a_import = rb_ary_new();
- ptr = RARRAY(import)->ptr;
- for (i = 0, len = RARRAY(import)->len; i < len; i++) {
- int c = *(char *)RSTRING(ptr[i])->ptr;
- switch (c) {
- case 'N': case 'n': case 'L': case 'l':
- rb_ary_push(a_import, INT2FIX(_T_NUMBER));
- break;
- case 'P': case 'p':
- rb_ary_push(a_import, INT2FIX(_T_POINTER));
- break;
- case 'I': case 'i':
- rb_ary_push(a_import, INT2FIX(_T_INTEGER));
- break;
+ if (!NIL_P(import)) {
+ Check_Type(import, T_ARRAY);
+ ptr = RARRAY(import)->ptr;
+ for (i = 0, len = RARRAY(import)->len; i < len; i++) {
+ Check_Type(ptr[i], T_STRING);
+ switch (*(char *)RSTRING(ptr[i])->ptr) {
+ case 'N': case 'n': case 'L': case 'l':
+ rb_ary_push(a_import, INT2FIX(_T_NUMBER));
+ break;
+ case 'P': case 'p':
+ rb_ary_push(a_import, INT2FIX(_T_POINTER));
+ break;
+ case 'I': case 'i':
+ rb_ary_push(a_import, INT2FIX(_T_INTEGER));
+ break;
+ }
}
}
rb_iv_set(self, "__import__", a_import);
- switch (*RSTRING(export)->ptr) {
- case 'V': case 'v':
+ if (NIL_P(export)) {
ex = _T_VOID;
- break;
- case 'N': case 'n': case 'L': case 'l':
- ex = _T_NUMBER;
- break;
- case 'P': case 'p':
- ex = _T_POINTER;
- break;
- case 'I': case 'i':
- ex = _T_INTEGER;
- break;
+ } else {
+ Check_Type(export, T_STRING);
+ switch (*RSTRING(export)->ptr) {
+ case 'V': case 'v':
+ ex = _T_VOID;
+ break;
+ case 'N': case 'n': case 'L': case 'l':
+ ex = _T_NUMBER;
+ break;
+ case 'P': case 'p':
+ ex = _T_POINTER;
+ break;
+ case 'I': case 'i':
+ ex = _T_INTEGER;
+ break;
+ }
}
rb_iv_set(self, "__export__", INT2FIX(ex));