Skip to content

Commit 183529e

Browse files
Add plugin from VMMaker
Name: VMMaker.oscog-VB.2364 Author: VB Time: 14 April 2018, 12:21:14.814622 pm UUID: d084ec90-dd2d-0048-a171-0dadc3e52888 Ancestors: VMMaker.oscog-eem.2363
1 parent aad3a41 commit 183529e

File tree

1 file changed

+53
-5
lines changed

1 file changed

+53
-5
lines changed

src/plugins/HostWindowPlugin/HostWindowPlugin.c

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Automatically generated by
2-
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.2347 uuid: 062614a7-e3da-4b30-997a-9568911b9ff5
2+
SmartSyntaxPluginCodeGenerator VMMaker.oscog-VB.2364 uuid: d084ec90-dd2d-0048-a171-0dadc3e52888
33
from
4-
HostWindowPlugin VMMaker.oscog-eem.2347 uuid: 062614a7-e3da-4b30-997a-9568911b9ff5
4+
HostWindowPlugin VMMaker.oscog-VB.2364 uuid: d084ec90-dd2d-0048-a171-0dadc3e52888
55
*/
6-
static char __buildInfo[] = "HostWindowPlugin VMMaker.oscog-eem.2347 uuid: 062614a7-e3da-4b30-997a-9568911b9ff5 " __DATE__ ;
6+
static char __buildInfo[] = "HostWindowPlugin VMMaker.oscog-VB.2364 uuid: d084ec90-dd2d-0048-a171-0dadc3e52888 " __DATE__ ;
77

88

99

@@ -34,10 +34,15 @@ static char __buildInfo[] = "HostWindowPlugin VMMaker.oscog-eem.2347 uuid: 06261
3434
#include "sqMemoryAccess.h"
3535

3636

37+
/*** Constants ***/
38+
#define PrimErrBadArgument 3
39+
40+
3741
/*** Function Prototypes ***/
3842
EXPORT(const char*) getModuleName(void);
3943
EXPORT(sqInt) primitiveCloseHostWindow(void);
4044
EXPORT(sqInt) primitiveCreateHostWindow(void);
45+
EXPORT(sqInt) primitiveHostWindowIcon(void);
4146
EXPORT(sqInt) primitiveHostWindowPosition(void);
4247
EXPORT(sqInt) primitiveHostWindowPositionSet(void);
4348
#if TerfVM
@@ -89,6 +94,7 @@ static usqInt (*positive32BitValueOf)(sqInt oop);
8994
static sqInt (*positive64BitIntegerFor)(usqLong integerValue);
9095
static usqLong (*positive64BitValueOf)(sqInt oop);
9196
static sqInt (*primitiveFail)(void);
97+
static sqInt (*primitiveFailFor)(sqInt reasonCode);
9298
static sqInt (*slotSizeOf)(sqInt oop);
9399
static sqInt (*stackIntegerValue)(sqInt offset);
94100
static sqInt (*stackValue)(sqInt offset);
@@ -107,6 +113,7 @@ extern usqInt positive32BitValueOf(sqInt oop);
107113
extern sqInt positive64BitIntegerFor(usqLong integerValue);
108114
extern usqLong positive64BitValueOf(sqInt oop);
109115
extern sqInt primitiveFail(void);
116+
extern sqInt primitiveFailFor(sqInt reasonCode);
110117
extern sqInt slotSizeOf(sqInt oop);
111118
extern sqInt stackIntegerValue(sqInt offset);
112119
extern sqInt stackValue(sqInt offset);
@@ -116,9 +123,9 @@ extern
116123
struct VirtualMachine* interpreterProxy;
117124
static const char *moduleName =
118125
#ifdef SQUEAK_BUILTIN_PLUGIN
119-
"HostWindowPlugin VMMaker.oscog-eem.2347 (i)"
126+
"HostWindowPlugin VMMaker.oscog-VB.2364 (i)"
120127
#else
121-
"HostWindowPlugin VMMaker.oscog-eem.2347 (e)"
128+
"HostWindowPlugin VMMaker.oscog-VB.2364 (e)"
122129
#endif
123130
;
124131

@@ -207,6 +214,44 @@ primitiveCreateHostWindow(void)
207214
}
208215

209216

217+
/* Set the icon of the window by fetching the logo in given path. Fail if the
218+
windowIndex is invalid or the platform routine returns -1 to indicate
219+
failure
220+
*/
221+
222+
/* HostWindowPlugin>>#primitiveHostWindowIcon:path: */
223+
EXPORT(sqInt)
224+
primitiveHostWindowIcon(void)
225+
{
226+
sqInt id;
227+
sqInt pathLength;
228+
char *pathString;
229+
sqInt res;
230+
231+
id = stackIntegerValue(1);
232+
success(isBytes(stackValue(0)));
233+
pathString = ((char *) (firstIndexableField(stackValue(0))));
234+
if (failed()) {
235+
return null;
236+
}
237+
pathLength = slotSizeOf(((sqInt)(sqIntptr_t)(pathString) - BaseHeaderSize));
238+
res = ioSetIconOfWindow(id, pathString, pathLength);
239+
if (res == 0) {
240+
if (failed()) {
241+
return null;
242+
}
243+
pop(2);
244+
return null;
245+
}
246+
if (res == -1) {
247+
primitiveFailFor(PrimErrBadArgument);
248+
return null;
249+
}
250+
primitiveFail();
251+
return null;
252+
}
253+
254+
210255
/* Return the origin position of the user area of the window in pixels from
211256
the topleft corner of the screen. Fail if the windowIndex is invalid or
212257
the platform routine returns -1 to indicate failure
@@ -758,6 +803,7 @@ setInterpreter(struct VirtualMachine*anInterpreter)
758803
positive64BitIntegerFor = interpreterProxy->positive64BitIntegerFor;
759804
positive64BitValueOf = interpreterProxy->positive64BitValueOf;
760805
primitiveFail = interpreterProxy->primitiveFail;
806+
primitiveFailFor = interpreterProxy->primitiveFailFor;
761807
slotSizeOf = interpreterProxy->slotSizeOf;
762808
stackIntegerValue = interpreterProxy->stackIntegerValue;
763809
stackValue = interpreterProxy->stackValue;
@@ -793,6 +839,7 @@ void* HostWindowPlugin_exports[][3] = {
793839
{(void*)_m, "getModuleName", (void*)getModuleName},
794840
{(void*)_m, "primitiveCloseHostWindow\000\000", (void*)primitiveCloseHostWindow},
795841
{(void*)_m, "primitiveCreateHostWindow\000\000", (void*)primitiveCreateHostWindow},
842+
{(void*)_m, "primitiveHostWindowIcon\000\000", (void*)primitiveHostWindowIcon},
796843
{(void*)_m, "primitiveHostWindowPosition\000\000", (void*)primitiveHostWindowPosition},
797844
{(void*)_m, "primitiveHostWindowPositionSet\000\000", (void*)primitiveHostWindowPositionSet},
798845
#if TerfVM
@@ -832,6 +879,7 @@ void* HostWindowPlugin_exports[][3] = {
832879

833880
signed char primitiveCloseHostWindowAccessorDepth = 0;
834881
signed char primitiveCreateHostWindowAccessorDepth = 0;
882+
signed char primitiveHostWindowIconAccessorDepth = 0;
835883
signed char primitiveHostWindowPositionAccessorDepth = 0;
836884
signed char primitiveHostWindowPositionSetAccessorDepth = 0;
837885
#if TerfVM

0 commit comments

Comments
 (0)