MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuSkinCreate

Function PiuSkinCreate

modules/piu/All/piuSkin.c:32–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30};
31
32void PiuSkinCreate(xsMachine* the)
33{
34 PiuSkinRecord record;
35 PiuSkin self = &record;
36 xsIntegerValue c = xsToInteger(xsArgc);
37 xsIntegerValue integer;
38 xsVars(4);
39 c_memset(self, 0, sizeof(record));
40 self->reference = xsToReference(xsThis);
41 if ((c > 0) && (xsTest(xsArg(0)))) {
42 if (xsFindResult(xsArg(0), xsID_Texture)) {
43 self->flags |= piuSkinPattern;
44 if (!xsIsInstanceOf(xsResult, xsFunctionPrototype))
45 xsUnknownError("Texture is no function");
46 xsResult = xsCallFunction0(xsResult, xsNull);
47 xsVar(0) = xsGet(xsGlobal, xsID_Texture);
48 xsVar(1) = xsGet(xsVar(0), xsID_prototype);
49 if (!xsIsInstanceOf(xsResult, xsVar(1)))
50 xsUnknownError("Texture is no texture template");
51 self->data.pattern.texture = PIU(Texture, xsResult);
52 }
53 else if (xsFindResult(xsArg(0), xsID_texture)) {
54 self->flags |= piuSkinPattern;
55 if (!xsIsInstanceOf(xsResult, xsObjectPrototype))
56 xsUnknownError("texture is no object");
57 xsVar(0) = xsGet(xsGlobal, xsID_Texture);
58 xsVar(1) = xsGet(xsVar(0), xsID_prototype);
59 if (xsIsInstanceOf(xsResult, xsVar(1)))
60 self->data.pattern.texture = PIU(Texture, xsResult);
61 else {
62 xsVar(2) = xsGet(xsGlobal, xsID_assetMap);
63 if (xsTest(xsVar(2)))
64 xsVar(3) = xsCall1(xsVar(2), xsID_get, xsResult);
65 else {
66 xsVar(2) = xsNew0(xsGlobal, xsID_Map);
67 xsSet(xsGlobal, xsID_assetMap, xsVar(2));
68 xsVar(3) = xsUndefined;
69 }
70 if (xsTest(xsVar(3))) {
71 if (!xsIsInstanceOf(xsVar(3), xsVar(1)))
72 xsUnknownError("texture is no texture dictionary");
73 }
74 else {
75 xsVar(3) = xsNewFunction1(xsVar(0), xsResult);
76 xsCall2(xsVar(2), xsID_set, xsResult, xsVar(3));
77 }
78 self->data.pattern.texture = PIU(Texture, xsVar(3));
79 }
80 }
81 if (self->flags & piuSkinPattern) {
82 if (xsFindInteger(xsArg(0), xsID_x, &integer))
83 self->data.pattern.bounds.x = (PiuCoordinate)integer;
84 if (xsFindInteger(xsArg(0), xsID_y, &integer))
85 self->data.pattern.bounds.y = (PiuCoordinate)integer;
86 if (xsFindInteger(xsArg(0), xsID_width, &integer))
87 self->data.pattern.bounds.width = (PiuDimension)integer;
88 if (xsFindInteger(xsArg(0), xsID_height, &integer))
89 self->data.pattern.bounds.height = (PiuDimension)integer;

Callers

nothing calls this directly

Calls 1

PiuColorsDictionaryFunction · 0.85

Tested by

no test coverage detected