diff -u --recursive smalltalk-1.96/ChangeLog so/ChangeLog --- smalltalk-1.96/ChangeLog Fri May 4 09:42:40 2001 +++ so/ChangeLog Wed Oct 17 19:52:53 2001 @@ -1,3 +1,11 @@ +Wed Oct 17 19:48:14 2001 David Forster (address@hidden) + + * libgst/cint.c: add uInt and uLong support for C interface. + Change longType return to use fromCLong, as maybe should? + * libgst/symc.c: add uIntSymbol and uLongSymbol + * libgst/dict.inl: add toCULong() + * doc/gst.texi: update C callout description + Fri May 4 17:32:00 2001 Paolo Bonzini (address@hidden) * examples/modules/regex.st: added a Regex class diff -u --recursive smalltalk-1.96/doc/gst.texi so/doc/gst.texi --- smalltalk-1.96/doc/gst.texi Fri May 4 09:57:54 2001 +++ so/doc/gst.texi Wed Oct 17 19:44:10 2001 @@ -2107,9 +2107,15 @@ @item int A C int value address@hidden uInt +A C unsigned int value + @item long A C long value address@hidden uLong +A C unsigned long value + @item double A C double, converted to an instance of Float @@ -2169,9 +2175,15 @@ @item int passed as @code{int} address@hidden uInt +passed as @code{unsigned int} + @item long passed as @code{long} address@hidden uLong +passed as @code{unsigned long} + @item double passed as @code{double} @@ -2215,8 +2227,12 @@ @item double @tab Float @tab double (C promotion) @item int @tab Boolean (True, False)@tab int @item int @tab Integer @tab int address@hidden uInt @tab Boolean (True, False)@tab unsigned int address@hidden uInt @tab Integer @tab unsigned int @item long @tab Boolean (True, False)@tab long @item long @tab Integer @tab long address@hidden uLong @tab Boolean (True, False)@tab unsigned long address@hidden uLong @tab Integer @tab unsigned long @item smalltalk, selfSmalltalk @tab anything @tab OOP @item string @tab String @tab char * @item string @tab Symbol @tab char * diff -u --recursive smalltalk-1.96/libgst/cint.c so/libgst/cint.c --- smalltalk-1.96/libgst/cint.c Fri May 4 09:54:17 2001 +++ so/libgst/cint.c Wed Oct 17 18:57:12 2001 @@ -101,7 +101,9 @@ byteArrayOutType, booleanType, intType, + uIntType, longType, + uLongType, floatType, doubleType, voidType, /* valid only as a return type */ @@ -145,12 +147,14 @@ } StringInfo; typedef union CParamUnionUnion { - int intVal; - long longVal; - voidPtr ptrVal; - float floatVal; - double doubleVal; - int valueVec[sizeof(double) / sizeof(int)]; + int intVal; + unsigned int uIntVal; + long longVal; + unsigned long uLongVal; + voidPtr ptrVal; + float floatVal; + double doubleVal; + int valueVec[sizeof(double) / sizeof(int)]; } CParamUnion; /* Element type for the name-to-C-function mapping table. */ @@ -202,7 +206,9 @@ "char *", /* byteArrayOutType */ "int", /* booleanType */ "int", /* intType */ + "unsigned int", /* uIntType */ "long", /* longType */ + "unsigned long", /* uLongType */ "float", /* floatType */ "double", /* doubleType */ "void?", /* voidType */ @@ -225,7 +231,9 @@ { &byteArrayOutSymbol, byteArrayOutType }, { &booleanSymbol, booleanType }, { &intSymbol, intType }, + { &uIntSymbol, uIntType }, { &longSymbol, longType }, + { &uLongSymbol, uLongType }, { &floatSymbol, floatType }, { &doubleSymbol, doubleType }, { &voidSymbol, voidType }, @@ -868,9 +876,15 @@ if (cType == longType || cType == unknownType) { u.longVal = toCLong(oop); pushObj(&u, longAlign); + } else if (cType == uLongType) { + u.uLongVal = toCULong(oop); + pushObj(&u, longAlign); /* uLong's have the same alignment... */ } else if (cType == intType || cType == charType) { u.intVal = toCInt(oop); pushObj(&u, intAlign); + } else if (cType == uIntType) { + u.uIntVal = toCUInt(oop); + pushObj(&u, intAlign); /* uInt's have the same alignment... */ } else { badType(class, cType); } @@ -878,9 +892,15 @@ if (cType == intType || cType == booleanType || cType == charType || cType == unknownType) { u.intVal = (oop == trueOOP); pushObj(&u, intAlign); + } else if (cType == uIntType) { + u.uIntVal = (oop == trueOOP); + pushObj(&u, intAlign); } else if (cType == longType) { u.longVal = (oop == trueOOP); pushObj(&u, longAlign); + } else if (cType == uLongType) { + u.uLongVal = (oop == trueOOP); + pushObj(&u, longAlign); } else { badType(class, cType); } @@ -1039,7 +1059,9 @@ CFuncDescriptor desc; { int intResult; + unsigned int uIntResult; long longResult; + unsigned long uLongResult; double doubleResult; pVoidFunc cFunction; CDataType returnType; @@ -1084,9 +1106,19 @@ setStackTopInt((long)intResult); break; + case uIntType: + uIntResult = doTheCall(unsigned int); + setStackTopInt((long)uIntResult); + break; + case longType: longResult = doTheCall(long); - setStackTop(fromInt(longResult)); + setStackTop(fromCLong(longResult)); + break; + + case uLongType: + uLongResult = doTheCall(unsigned long); + setStackTop(fromCULong(uLongResult)); break; case stringType: diff -u --recursive smalltalk-1.96/libgst/dict.inl so/libgst/dict.inl --- smalltalk-1.96/libgst/dict.inl Sat Feb 17 01:16:21 2001 +++ so/libgst/dict.inl Wed Oct 17 18:52:53 2001 @@ -63,6 +63,7 @@ fromCLong(), fromCULong(); static inline long toCLong(); +static inline unsigned long toCULong(); #include "sym.h" #include "interp.h" @@ -838,13 +839,14 @@ #if SIZEOF_INT < SIZEOF_LONG #define fromCInt(integer) fromInt((signed long) (signed int) integer) -#define fromCUInt(integer) fromInt((signed long) (unsigned int) integer) +#define fromCUInt(integer) fromInt((unsigned long) (unsigned int) integer) #else #define fromCInt(integer) fromCLong((signed long) integer) #define fromCUInt(integer) fromCULong((unsigned long) integer) #endif #define toCInt(integer) ((int) toCLong(integer)) +#define toCUInt(integer) ((unsigned int) toCULong(integer)) #define isCInt(integer) isCLong(integer) mst_Boolean @@ -881,6 +883,27 @@ ba = (ByteArray) oopToObj(oop); return ((long) ( +#if SIZEOF_LONG == 8 + (((unsigned long) ba->bytes[7]) << 56) + (((unsigned long) ba->bytes[6]) << 48) + + (((unsigned long) ba->bytes[5]) << 40) + (((unsigned long) ba->bytes[4]) << 32) + +#endif + (((unsigned long) ba->bytes[3]) << 24) + (((unsigned long) ba->bytes[2]) << 16) + + (((unsigned long) ba->bytes[1]) << 8) + ((unsigned long) ba->bytes[0]) + )); +} + +unsigned long +toCULong(oop) + OOP oop; +{ + ByteArray ba; + + if (isInt(oop)) { + return (toInt(oop)); + } + + ba = (ByteArray) oopToObj(oop); + return ((unsigned long) ( #if SIZEOF_LONG == 8 (((unsigned long) ba->bytes[7]) << 56) + (((unsigned long) ba->bytes[6]) << 48) + (((unsigned long) ba->bytes[5]) << 40) + (((unsigned long) ba->bytes[4]) << 32) + diff -u --recursive smalltalk-1.96/libgst/sym.c so/libgst/sym.c --- smalltalk-1.96/libgst/sym.c Fri May 4 09:55:23 2001 +++ so/libgst/sym.c Wed Oct 17 19:43:41 2001 @@ -105,8 +105,8 @@ doesNotUnderstandColonSymbol, mustBeBooleanSymbol, terminateSymbol, asScaledDecimalSymbol, unknownSymbol, charSymbol, stringSymbol, - stringOutSymbol, symbolSymbol, intSymbol, - longSymbol, floatSymbol, doubleSymbol, + stringOutSymbol, symbolSymbol, intSymbol, uIntSymbol, + longSymbol, uLongSymbol, floatSymbol, doubleSymbol, booleanSymbol, voidSymbol, variadicSymbol, cObjectSymbol, cObjectPtrSymbol, smalltalkSymbol, byteArraySymbol, byteArrayOutSymbol, undeclaredSymbol, @@ -163,10 +163,12 @@ { &ifTrueColonSymbol, "ifTrue:" }, { &integerDivideSymbol, "//" }, { &intSymbol, "int" }, + { &uIntSymbol, "uInt" }, { &isNilSymbol, "isNil" }, { &lessEqualSymbol, "<=" }, { &lessThanSymbol, "<" }, { &longSymbol, "long" }, + { &uLongSymbol, "uLong" }, { &minusSymbol, "-" }, { &mustBeBooleanSymbol, "mustBeBoolean" }, { &newColonSymbol, "new:" }, diff -u --recursive smalltalk-1.96/libgst/sym.h so/libgst/sym.h --- smalltalk-1.96/libgst/sym.h Fri May 4 09:55:12 2001 +++ so/libgst/sym.h Wed Oct 17 20:07:52 2001 @@ -95,8 +95,8 @@ doesNotUnderstandColonSymbol, mustBeBooleanSymbol, terminateSymbol, asScaledDecimalSymbol, unknownSymbol, charSymbol, stringSymbol, - stringOutSymbol, symbolSymbol, intSymbol, - longSymbol, floatSymbol, doubleSymbol, + stringOutSymbol, symbolSymbol, intSymbol, uIntSymbol, + longSymbol, uLongSymbol, floatSymbol, doubleSymbol, booleanSymbol, voidSymbol, variadicSymbol, cObjectSymbol, cObjectPtrSymbol, smalltalkSymbol, byteArraySymbol, byteArrayOutSymbol, undeclaredSymbol,