Windows API support

Todd Fleming todd at flemingcnc.com
Wed Jan 5 05:49:29 PST 2005


Here it is.

Todd

Brian Rice wrote:

> Okay. I /did/ get some oddness trying to apply it, but I thought I had 
> resolved it. Please try forming a second patch against what's in CVS 
> from your tree, and send it as an attachment so that there's no 
> ambiguity.
>
> On Jan 4, 2005, at 9:04 PM, Todd Fleming wrote:


-------------- next part --------------
? diffs 1-4-05
? diffs2
? orig slatevm.c
? orig slatevm.h
? Slate.pdb
? slatevm.c
? slatevm.h
? ug
? src/mobius/vm/platform/windows/Slate-VS2003.sln
? src/mobius/vm/platform/windows/Slate-VS2003.vcproj
Index: src/lib/extlib.slate
===================================================================
RCS file: /var/lib/cvs/slate/slate/src/lib/extlib.slate,v
retrieving revision 1.7
diff -u -r1.7 extlib.slate
--- src/lib/extlib.slate	5 Jan 2005 03:45:05 -0000	1.7
+++ src/lib/extlib.slate	5 Jan 2005 13:36:42 -0000
@@ -14,9 +14,15 @@
   #Boolean -> 5.
 } do: [| :assoc | ExternalMethod ArgumentFormat addImmutableSlot: assoc key valued: assoc value].
 
+ExternalMethod traits ensureNamespace: #CallFormat.
+{ #C -> 0.
+  #Std -> 1.
+} do: [| :assoc | ExternalMethod CallFormat addImmutableSlot: assoc key valued: assoc value].
+
 ExternalMethod addSlot: #library valued: Nil.
 ExternalMethod addSlot: #name valued: Nil.
 ExternalMethod addSlot: #argumentsFormat valued: {}.
+ExternalMethod addSlot: #callFormat valued: ExternalMethod CallFormat C.
 ExternalMethod addSlot: #resultFormat valued: ExternalMethod ArgumentFormat Void.
 
 d@(ExternalLibrary traits) newNamed: libName
Index: src/mobius/vm/ext/extprim.slate
===================================================================
RCS file: /var/lib/cvs/slate/slate/src/mobius/vm/ext/extprim.slate,v
retrieving revision 1.2
diff -u -r1.2 extprim.slate
--- src/mobius/vm/ext/extprim.slate	2 Nov 2004 21:35:00 -0000	1.2
+++ src/mobius/vm/ext/extprim.slate	5 Jan 2005 13:36:43 -0000
@@ -23,9 +23,9 @@
     ifFalse: [interpreter pushFalse].
 ] `pidginPrimitive.
 
-p at ExternalLibraryTraits primitiveApply: ptr at ByteArrayTraits accepting: argsFormat returning: resultFormat to: args at ArrayTraits
+p at ExternalLibraryTraits primitiveApply: ptr at ByteArrayTraits accepting: argsFormat callFormat: callFormat returning: resultFormat to: args at ArrayTraits
 [
   interpreter stackPush:
-    ('applyExternalLibraryPrimitive((struct ByteArray *) ptr, (struct OopArray *) argsFormat, resultFormat, (struct OopArray *) args)'
+    ('applyExternalLibraryPrimitive((struct ByteArray *) ptr, (struct OopArray *) argsFormat, callFormat, resultFormat, (struct OopArray *) args)'
      directly!ObjectPointer).
 ] `pidginPrimitive.
Index: src/mobius/vm/platform/extprim.c
===================================================================
RCS file: /var/lib/cvs/slate/slate/src/mobius/vm/platform/extprim.c,v
retrieving revision 1.6
diff -u -r1.6 extprim.c
--- src/mobius/vm/platform/extprim.c	15 Dec 2004 23:29:50 -0000	1.6
+++ src/mobius/vm/platform/extprim.c	5 Jan 2005 13:36:43 -0000
@@ -15,7 +15,30 @@
 typedef unsigned (* ext_fn11_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
 typedef unsigned (* ext_fn12_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
 
-ObjectPointer applyExternalLibraryPrimitive (struct ByteArray * fnHandle, struct OopArray * argsFormat, ObjectPointer resultFormat, struct OopArray * argsArr)
+#ifndef _WIN32
+#  define __stdcall
+#endif
+
+typedef unsigned (__stdcall * ext_std_fn0_t) (void);
+typedef unsigned (__stdcall * ext_std_fn1_t) (unsigned);
+typedef unsigned (__stdcall * ext_std_fn2_t) (unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn3_t) (unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn4_t) (unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn5_t) (unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn6_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn7_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn8_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn9_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn10_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn11_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+typedef unsigned (__stdcall * ext_std_fn12_t) (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
+
+ObjectPointer applyExternalLibraryPrimitive (
+	struct ByteArray * fnHandle, 
+	struct OopArray * argsFormat, 
+	ObjectPointer callFormat,
+	ObjectPointer resultFormat, 
+	struct OopArray * argsArr)
 {
   ext_fn0_t fn;
   unsigned args [12]; 
@@ -64,50 +87,102 @@
     }
   }
 
-  switch(argCount)
+  if(callFormat == CALL_FORMAT_C)
   {
-  case 0:
-    result = (* (ext_fn0_t) fn) ();
-    break;
-  case 1:
-    result = (* (ext_fn1_t) fn) (args [0]);
-    break;
-  case 2:
-    result = (* (ext_fn2_t) fn) (args [0], args [1]);
-    break;
-  case 3:
-    result = (* (ext_fn3_t) fn) (args [0], args [1], args [2]);
-    break;
-  case 4:
-    result = (* (ext_fn4_t) fn) (args [0], args [1], args [2], args [3]);
-    break;
-  case 5:
-    result = (* (ext_fn5_t) fn) (args [0], args [1], args [2], args [3], args [4]);
-    break;
-  case 6:
-    result = (* (ext_fn6_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5]);
-    break;
-  case 7:
-    result = (* (ext_fn7_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6]);
-    break;
-  case 8:
-    result = (* (ext_fn8_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7]);
-    break;
-  case 9:
-    result = (* (ext_fn9_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8]);
-    break;
-  case 10:
-    result = (* (ext_fn10_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9]);
-    break;
-  case 11:
-    result = (* (ext_fn11_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10]);
-    break;
-  case 12:
-    result = (* (ext_fn12_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10], args [11]);
-    break;
-  default:
-    return CurrentMemory -> NilObject;
+    switch(argCount)
+    {
+    case 0:
+        result = (* (ext_fn0_t) fn) ();
+        break;
+    case 1:
+        result = (* (ext_fn1_t) fn) (args [0]);
+        break;
+    case 2:
+        result = (* (ext_fn2_t) fn) (args [0], args [1]);
+        break;
+    case 3:
+        result = (* (ext_fn3_t) fn) (args [0], args [1], args [2]);
+        break;
+    case 4:
+        result = (* (ext_fn4_t) fn) (args [0], args [1], args [2], args [3]);
+        break;
+    case 5:
+        result = (* (ext_fn5_t) fn) (args [0], args [1], args [2], args [3], args [4]);
+        break;
+    case 6:
+        result = (* (ext_fn6_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5]);
+        break;
+    case 7:
+        result = (* (ext_fn7_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6]);
+        break;
+    case 8:
+        result = (* (ext_fn8_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7]);
+        break;
+    case 9:
+        result = (* (ext_fn9_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8]);
+        break;
+    case 10:
+        result = (* (ext_fn10_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9]);
+        break;
+    case 11:
+        result = (* (ext_fn11_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10]);
+        break;
+    case 12:
+        result = (* (ext_fn12_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10], args [11]);
+        break;
+    default:
+        return CurrentMemory -> NilObject;
+    }
   }
+  else if(callFormat == CALL_FORMAT_STD)
+  {
+    switch(argCount)
+    {
+    case 0:
+        result = (* (ext_std_fn0_t) fn) ();
+        break;
+    case 1:
+        result = (* (ext_std_fn1_t) fn) (args [0]);
+        break;
+    case 2:
+        result = (* (ext_std_fn2_t) fn) (args [0], args [1]);
+        break;
+    case 3:
+        result = (* (ext_std_fn3_t) fn) (args [0], args [1], args [2]);
+        break;
+    case 4:
+        result = (* (ext_std_fn4_t) fn) (args [0], args [1], args [2], args [3]);
+        break;
+    case 5:
+        result = (* (ext_std_fn5_t) fn) (args [0], args [1], args [2], args [3], args [4]);
+        break;
+    case 6:
+        result = (* (ext_std_fn6_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5]);
+        break;
+    case 7:
+        result = (* (ext_std_fn7_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6]);
+        break;
+    case 8:
+        result = (* (ext_std_fn8_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7]);
+        break;
+    case 9:
+        result = (* (ext_std_fn9_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8]);
+        break;
+    case 10:
+        result = (* (ext_std_fn10_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9]);
+        break;
+    case 11:
+        result = (* (ext_std_fn11_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10]);
+        break;
+    case 12:
+        result = (* (ext_std_fn12_t) fn) (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10], args [11]);
+        break;
+    default:
+        return CurrentMemory -> NilObject;
+    }
+  }
+  else
+    return CurrentMemory -> NilObject;
   
   switch (resultFormat)
   {
Index: src/mobius/vm/platform/includes/extprim.h
===================================================================
RCS file: /var/lib/cvs/slate/slate/src/mobius/vm/platform/includes/extprim.h,v
retrieving revision 1.4
diff -u -r1.4 extprim.h
--- src/mobius/vm/platform/includes/extprim.h	5 Jan 2005 03:19:49 -0000	1.4
+++ src/mobius/vm/platform/includes/extprim.h	5 Jan 2005 13:36:44 -0000
@@ -18,6 +18,12 @@
   ARG_FORMAT_BOOLEAN = (5 << 1) | 1
 };
 
+enum CallFormat
+{
+  CALL_FORMAT_C = (0 << 1) | 1,
+  CALL_FORMAT_STD = (1 << 1) | 1,
+};
+
 struct ByteArray;
 struct OopArray;
 


More information about the Slate mailing list