diff options
author | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-30 02:36:07 +0000 |
---|---|---|
committer | eban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-30 02:36:07 +0000 |
commit | 3c89a278e3d538dcb206753dc3b0466a9476fbc5 (patch) | |
tree | 925d1cb9ff6a12d009738c3fc6131784efae0b19 /ext/Win32API/Win32API.c | |
parent | 68bc47726b8afef80885a3f698b5c0fceec48d77 (diff) | |
download | ruby-3c89a278e3d538dcb206753dc3b0466a9476fbc5.tar.gz |
eban
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/Win32API/Win32API.c')
-rw-r--r-- | ext/Win32API/Win32API.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index 3f0ceae9e1..d62e60e2f3 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)); |