1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
/* Automatically generated from Squeak on (1 August 2008 6:20:31 pm) */
#if defined(WIN32) || defined(_WIN32) || defined(Win32)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif /* WIN32 */
#include "sqVirtualMachine.h"
/* memory access macros */
#define byteAt(i) (*((unsigned char *) (i)))
#define byteAtput(i, val) (*((unsigned char *) (i)) = val)
#define longAt(i) (*((int *) (i)))
#define longAtput(i, val) (*((int *) (i)) = val)
int unicodeClipboardGet(unsigned short *utf16, int utf16Length);
void unicodeClipboardPut(unsigned short *utf16, int utf16Length);
int unicodeClipboardSize(void);
void unicodeDrawString(char *utf8, int utf8Length, int *wPtr, int *hPtr, unsigned int *bitmapPtr);
int unicodeGetFontList(char *str, int strLength);
int unicodeGetXRanges(char *utf8, int utf8Length, int *resultPtr, int resultLength);
void unicodeMeasureString(char *utf8, int utf8Length, int *wPtr, int *hPtr);
void unicodeSetColors(int fgRed, int fgGreen, int fgBlue, int bgRed, int bgGreen, int bgBlue, int mapBGToTransparent);
void unicodeSetFont(char *fontName, int fontSize, int boldFlag, int italicFlag, int antiAliasFlag);
/*** Variables ***/
struct VirtualMachine* interpreterProxy;
const char *moduleName = "UnicodePlugin 1 August 2008 (e)";
/*** Functions ***/
static char * asCString(int stringOop);
static void * cWordsPtrminSize(int oop, int minSize);
static int copyStringintomax(int stringOop, char *stringPtr, int maxChars);
EXPORT int primitiveClipboardGet(void);
EXPORT int primitiveClipboardPut(void);
EXPORT int primitiveClipboardSize(void);
EXPORT int primitiveDrawString(void);
EXPORT int primitiveGetFontList(void);
EXPORT int primitiveGetXRanges(void);
EXPORT int primitiveMeasureString(void);
EXPORT int primitiveSetColors(void);
EXPORT int primitiveSetFont(void);
EXPORT int setInterpreter(struct VirtualMachine* anInterpreter);
static char * asCString(int stringOop) {
if (((stringOop & 1)) || (!(interpreterProxy->isBytes(stringOop)))) {
interpreterProxy->success(0);
return 0;
}
return ((char *) (interpreterProxy->firstIndexableField(stringOop)));
}
static void * cWordsPtrminSize(int oop, int minSize) {
interpreterProxy->success((!((oop & 1))) && ((interpreterProxy->isWords(oop)) && ((interpreterProxy->stSizeOf(oop)) >= minSize)));
if (interpreterProxy->failed()) {
return 0;
}
return ((void *) (interpreterProxy->firstIndexableField(oop)));
}
static int copyStringintomax(int stringOop, char *stringPtr, int maxChars) {
char *srcPtr;
int count;
int i;
if (((stringOop & 1)) || (!(interpreterProxy->isBytes(stringOop)))) {
interpreterProxy->success(0);
return 0;
}
count = interpreterProxy->stSizeOf(stringOop);
if (!(count < maxChars)) {
interpreterProxy->success(0);
return 0;
}
srcPtr = ((char *) (interpreterProxy->firstIndexableField(stringOop)));
for (i = 1; i <= count; i += 1) {
*stringPtr++ = *srcPtr++;
}
*stringPtr = 0;
return 0;
}
EXPORT int primitiveClipboardGet(void) {
unsigned short *utf16;
int utf16Length;
int count;
int utf16Oop;
utf16Oop = interpreterProxy->stackValue(0);
if (((utf16Oop & 1)) || (!(interpreterProxy->isWords(utf16Oop)))) {
interpreterProxy->success(0);
}
if (interpreterProxy->failed()) {
return 0;
}
utf16 = ((unsigned short *) (interpreterProxy->firstIndexableField(utf16Oop)));
utf16Length = 2 * (interpreterProxy->stSizeOf(utf16Oop));
count = unicodeClipboardGet(utf16, utf16Length);
interpreterProxy->popthenPush(2, ((count << 1) | 1));
return 0;
}
EXPORT int primitiveClipboardPut(void) {
unsigned short *utf16;
int utf16Length;
int strOop;
int count;
strOop = interpreterProxy->stackValue(1);
count = interpreterProxy->stackIntegerValue(0);
if (((strOop & 1)) || (!(interpreterProxy->isWords(strOop)))) {
interpreterProxy->success(0);
}
if (interpreterProxy->failed()) {
return 0;
}
utf16 = ((unsigned short *) (interpreterProxy->firstIndexableField(strOop)));
utf16Length = 2 * (interpreterProxy->stSizeOf(strOop));
if ((count >= 0) && (count < utf16Length)) {
utf16Length = count;
}
unicodeClipboardPut(utf16, utf16Length);
interpreterProxy->pop(2);
return 0;
}
EXPORT int primitiveClipboardSize(void) {
int count;
count = unicodeClipboardSize();
interpreterProxy->popthenPush(1, ((count << 1) | 1));
return 0;
}
EXPORT int primitiveDrawString(void) {
int bitmapOop;
void *bitmapPtr;
int result;
int h;
int utf8Oop;
int w;
int utf8Length;
char *utf8;
utf8Oop = interpreterProxy->stackValue(3);
utf8 = asCString(utf8Oop);
w = interpreterProxy->stackIntegerValue(2);
h = interpreterProxy->stackIntegerValue(1);
bitmapOop = interpreterProxy->stackValue(0);
bitmapPtr = cWordsPtrminSize(bitmapOop, w * h);
if (interpreterProxy->failed()) {
return 0;
}
utf8Length = interpreterProxy->stSizeOf(utf8Oop);
unicodeDrawString(utf8, utf8Length, &w, &h, bitmapPtr);
result = interpreterProxy->makePointwithxValueyValue(w, h);
interpreterProxy->popthenPush(5, result);
return 0;
}
EXPORT int primitiveGetFontList(void) {
int strOop;
char *str;
int count;
int strLength;
strOop = interpreterProxy->stackValue(0);
str = asCString(strOop);
if (interpreterProxy->failed()) {
return 0;
}
strLength = interpreterProxy->stSizeOf(strOop);
count = unicodeGetFontList(str, strLength);
interpreterProxy->popthenPush(2, ((count << 1) | 1));
return 0;
}
EXPORT int primitiveGetXRanges(void) {
int count;
int utf8Oop;
int resultOop;
int *resultPtr;
int utf8Length;
int resultLength;
char *utf8;
utf8Oop = interpreterProxy->stackValue(1);
utf8 = asCString(utf8Oop);
resultOop = interpreterProxy->stackValue(0);
resultPtr = cWordsPtrminSize(resultOop, 0);
if (interpreterProxy->failed()) {
return 0;
}
utf8Length = interpreterProxy->stSizeOf(utf8Oop);
resultLength = interpreterProxy->stSizeOf(resultOop);
count = unicodeGetXRanges(utf8, utf8Length, resultPtr, resultLength);
interpreterProxy->popthenPush(3, ((count << 1) | 1));
return 0;
}
EXPORT int primitiveMeasureString(void) {
int utf8Length;
int result;
int h;
int utf8Oop;
int w;
char *utf8;
utf8Oop = interpreterProxy->stackValue(0);
utf8 = asCString(utf8Oop);
if (interpreterProxy->failed()) {
return 0;
}
w = h = 0;
utf8Length = interpreterProxy->stSizeOf(utf8Oop);
unicodeMeasureString(utf8, utf8Length, &w, &h);
result = interpreterProxy->makePointwithxValueyValue(w, h);
interpreterProxy->popthenPush(2, result);
return 0;
}
EXPORT int primitiveSetColors(void) {
int fgGreen;
int bgBlue;
int fgBlue;
int bgRed;
int bgGreen;
int mapBGToTransparent;
int fgRed;
fgRed = interpreterProxy->stackIntegerValue(6);
fgGreen = interpreterProxy->stackIntegerValue(5);
fgBlue = interpreterProxy->stackIntegerValue(4);
bgRed = interpreterProxy->stackIntegerValue(3);
bgGreen = interpreterProxy->stackIntegerValue(2);
bgBlue = interpreterProxy->stackIntegerValue(1);
mapBGToTransparent = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0));
if (interpreterProxy->failed()) {
return 0;
}
unicodeSetColors(fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue, mapBGToTransparent);
interpreterProxy->pop(7);
return 0;
}
EXPORT int primitiveSetFont(void) {
int boldFlag;
int fontSize;
char fontName[200];
int antiAliasFlag;
int italicFlag;
copyStringintomax(interpreterProxy->stackValue(4), fontName, 200);
fontSize = interpreterProxy->stackIntegerValue(3);
boldFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(2));
italicFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(1));
antiAliasFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0));
if (interpreterProxy->failed()) {
return 0;
}
unicodeSetFont(fontName, fontSize, boldFlag, italicFlag, antiAliasFlag);
interpreterProxy->pop(5);
return 0;
}
EXPORT int setInterpreter(struct VirtualMachine* anInterpreter) {
int ok;
interpreterProxy = anInterpreter;
ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR;
if (ok == 0) {
return 0;
}
ok = interpreterProxy->minorVersion() >= VM_PROXY_MINOR;
return ok;
}
|