Request patch to Win32API.c

I would like to request an enhancement to Win32API.c to support short integers. This is needed so support an ODBC interface I am working. The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’. Adding support for ‘s’ (short int) corrects this problem. Here is the diff of Win32API.c from Ruby 1.8.1 and my working code with support for short integers. Please let me know if there is any thing I can do to help this enhancement along.

diff Win32API.c Win32API_mjd.c
14a15

#define _T_SHORT 4 // MJD
87a89,91
case ‘S’: case ‘s’: // MJD
rb_ary_push(a_import, INT2FIX(_T_SHORT));
break;
104a109,111
case ‘S’: case ‘s’:
rb_ary_push(a_import, INT2FIX(_T_SHORT)); // MJD
break;
132a140,142
case ‘S’: case ‘s’:
ex = _T_SHORT; // MJD
break;
169a180,182
case _T_SHORT: // MJD
lParam = (short)FIX2INT(rb_ary_entry(args, i));
break;
193a208,209
case _T_SHORT: // MJD
return INT2FIX((short)ret);

Thanks,
Michael

Michael Davis wrote:

I would like to request an enhancement to Win32API.c to support short integers.
The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’.
Adding support for ‘s’ (short int) corrects this problem.

[snippage]

In the meantime …

long = 0x0000fffd
p long

short = [long].pack(‘l’).unpack(‘s’)[0]
p short

#-> 65533
#-> -3

(I don’t know if that’s good for both “big/little-endian” processors.)

daz

Hi,

···

In message “Request patch to Win32API.c” on 04/03/07, Michael Davis mdavis@sevasoftware.com writes:

I would like to request an enhancement to Win32API.c to support short integers. This is needed so support an ODBC interface I am working. The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’. Adding support for ‘s’ (short int) corrects this problem. Here is the diff of Win32API.c from Ruby 1.8.1 and my working code with support for short integers. Please let me know if there is any thing I can do to help this enhancement along.

I’m not the one to decide, but at least you’d better use unified diff
(diff -u) to show your changes.

						matz.

Hello,

In message “Request patch to Win32API.c”

···

on Mar.07,2004 16:29:39, mdavis@sevasoftware.com wrote:

I would like to request an enhancement to Win32API.c to support short integers. This is needed so support an ODBC interface I am working. The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’. Adding support for ‘s’ (short int) corrects this problem. Here is the diff of Win32API.c from Ruby 1.8.1 and my working code with support for short integers. Please let me know if there is any thing I can do to help this enhancement along.

You can use Ruby/DL.
It’s a part of Ruby standard distribution.

We are planning to deprecate Win32API.
So we don’t want to add new features to Win32API.

Regards,

U.Nakamura usa@garbagecollect.jp

daz wrote:

Michael Davis wrote:

I would like to request an enhancement to Win32API.c to support short integers.
The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’.
Adding support for ‘s’ (short int) corrects this problem.

[snippage]

In the meantime …

long = 0x0000fffd
p long

short = [long].pack(‘l’).unpack(‘s’)[0]
p short

#-> 65533
#-> -3

(I don’t know if that’s good for both “big/little-endian” processors.)

daz

Thanks. This very work around help me identify where the real problem was. My only concern with this implementation is the over overhead associated with every function call.

Yukihiro Matsumoto wrote:

Hi,

I would like to request an enhancement to Win32API.c to support short integers. This is needed so support an ODBC interface I am working. The return codes from all ODBC function calls through Win32API are incorrect using ‘i’ or ‘l’. Adding support for ‘s’ (short int) corrects this problem. Here is the diff of Win32API.c from Ruby 1.8.1 and my working code with support for short integers. Please let me know if there is any thing I can do to help this enhancement along.

I’m not the one to decide, but at least you’d better use unified diff
(diff -u) to show your changes.

  					matz.

Thanks.

diff -u Win32API.c Win32API_mjd.c

— Win32API.c Wed Aug 13 04:02:04 2003
+++ Win32API_mjd.c Sun Mar 7 21:27:42 2004
@@ -12,6 +12,7 @@
#define _T_NUMBER 1
#define _T_POINTER 2
#define _T_INTEGER 3
+#define _T_SHORT 4

#include “ruby.h”

@@ -85,6 +86,9 @@
case ‘I’: case ‘i’:
rb_ary_push(a_import, INT2FIX(_T_INTEGER));
break;

  •       case 'S': case 's':
    
  •           rb_ary_push(a_import, INT2FIX(_T_SHORT));
    
  •           break;
          }
      }
       break;
    

@@ -102,6 +106,9 @@
case ‘I’: case ‘i’:
rb_ary_push(a_import, INT2FIX(_T_INTEGER));
break;

  •       case 'S': case 's':
    
  •           rb_ary_push(a_import, INT2FIX(_T_SHORT));
    
  •           break;
          }
      }
       break;
    

@@ -130,6 +137,9 @@
case ‘I’: case ‘i’:
ex = _T_INTEGER;
break;

  •   case 'S': case 's':
    
  •       ex = _T_SHORT;
    
  •       break;
      }
    
    }
    rb_iv_set(self, “export”, INT2FIX(ex));
    @@ -167,6 +177,9 @@
    unsigned long lParam = 0;
    switch (FIX2INT(rb_ary_entry(obj_import, i))) {
    VALUE str;
  •   case _T_SHORT:
    
  •       lParam = (short)FIX2INT(rb_ary_entry(args, i));
    
  •       break;
      case _T_NUMBER:
      case _T_INTEGER:
      default:
    

@@ -191,6 +204,8 @@
ret = ApiFunction(param);

 switch (FIX2INT(obj_export)) {
  •   case _T_SHORT:
    
  •       return INT2FIX((short)ret);
    
    case _T_NUMBER:
    case _T_INTEGER:
    return INT2NUM(ret);
···

In message “Request patch to Win32API.c” > on 04/03/07, Michael Davis mdavis@sevasoftware.com writes:

“U.Nakamura” usa@garbagecollect.jp wrote in message

You can use Ruby/DL.
It’s a part of Ruby standard distribution.

We are planning to deprecate Win32API.
So we don’t want to add new features to Win32API.

When will this deprecation be in effect ?

I have some production code that largely depends on this API
and I will like to start converting it to Ruby/DL …

Any heads up will be of great help.
Thanks,
– shanko

Hello,

In message “Re: Request patch to Win32API.c”

We are planning to deprecate Win32API.
So we don’t want to add new features to Win32API.

When will this deprecation be in effect ?

We are planning to remove Win32API from Ruby distribution.
But we have not determined the time yet.
During 1.8 releases, Win32API will be contained in Ruby distribution.
But it may not be contained in 1.9 releases or 2.0 releases.

I have some production code that largely depends on this API
and I will like to start converting it to Ruby/DL …

You can use lib/win32.rb instead of Win32API.
It is compatible layer for Win32API users.

Regards,

···

on Mar.08,2004 21:09:40, sdate@everestkc.net wrote:

U.Nakamura usa@garbagecollect.jp