zig-pug 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/binding.gyp +16 -10
  2. package/index.js +20 -0
  3. package/index.mjs +19 -2
  4. package/install.js +58 -0
  5. package/package.json +9 -6
  6. package/prebuilts/darwin-arm64/libzig-pug.a +0 -0
  7. package/prebuilts/darwin-x64/libzig-pug.a +0 -0
  8. package/prebuilts/linux-arm64/libzig-pug.a +0 -0
  9. package/prebuilts/linux-x64/libzig-pug.a +0 -0
  10. package/prebuilts/win32-x64/zig-pug.lib +0 -0
  11. package/vendor/mujs/COPYING +0 -16
  12. package/vendor/mujs/README +0 -50
  13. package/vendor/mujs/astnames.h +0 -92
  14. package/vendor/mujs/jsarray.c +0 -832
  15. package/vendor/mujs/jsboolean.c +0 -38
  16. package/vendor/mujs/jsbuiltin.c +0 -249
  17. package/vendor/mujs/jscompile.c +0 -1428
  18. package/vendor/mujs/jsdate.c +0 -861
  19. package/vendor/mujs/jsdtoa.c +0 -749
  20. package/vendor/mujs/jserror.c +0 -139
  21. package/vendor/mujs/jsfunction.c +0 -231
  22. package/vendor/mujs/jsgc.c +0 -284
  23. package/vendor/mujs/jsi.h +0 -870
  24. package/vendor/mujs/jsintern.c +0 -137
  25. package/vendor/mujs/jslex.c +0 -878
  26. package/vendor/mujs/jsmath.c +0 -194
  27. package/vendor/mujs/jsnumber.c +0 -198
  28. package/vendor/mujs/jsobject.c +0 -560
  29. package/vendor/mujs/json.c +0 -422
  30. package/vendor/mujs/jsparse.c +0 -1065
  31. package/vendor/mujs/jsproperty.c +0 -341
  32. package/vendor/mujs/jsregexp.c +0 -232
  33. package/vendor/mujs/jsrepr.c +0 -285
  34. package/vendor/mujs/jsrun.c +0 -2096
  35. package/vendor/mujs/jsstate.c +0 -334
  36. package/vendor/mujs/jsstring.c +0 -852
  37. package/vendor/mujs/jsvalue.c +0 -708
  38. package/vendor/mujs/libmujs.a +0 -0
  39. package/vendor/mujs/main.c +0 -396
  40. package/vendor/mujs/mujs.h +0 -253
  41. package/vendor/mujs/one.c +0 -25
  42. package/vendor/mujs/opnames.h +0 -85
  43. package/vendor/mujs/pp.c +0 -980
  44. package/vendor/mujs/regexp.c +0 -1277
  45. package/vendor/mujs/regexp.h +0 -46
  46. package/vendor/mujs/utf.c +0 -305
  47. package/vendor/mujs/utf.h +0 -52
  48. package/vendor/mujs/utfdata.h +0 -2209
@@ -1,194 +0,0 @@
1
- #include "jsi.h"
2
-
3
- #if defined(_MSC_VER) && (_MSC_VER < 1700) /* VS2012 has stdint.h */
4
- typedef unsigned int uint32_t;
5
- typedef unsigned __int64 uint64_t;
6
- #else
7
- #include <stdint.h>
8
- #endif
9
-
10
- #include <time.h>
11
-
12
- static double jsM_round(double x)
13
- {
14
- if (isnan(x)) return x;
15
- if (isinf(x)) return x;
16
- if (x == 0) return x;
17
- if (x > 0 && x < 0.5) return 0;
18
- if (x < 0 && x >= -0.5) return -0;
19
- return floor(x + 0.5);
20
- }
21
-
22
- static void Math_abs(js_State *J)
23
- {
24
- js_pushnumber(J, fabs(js_tonumber(J, 1)));
25
- }
26
-
27
- static void Math_acos(js_State *J)
28
- {
29
- js_pushnumber(J, acos(js_tonumber(J, 1)));
30
- }
31
-
32
- static void Math_asin(js_State *J)
33
- {
34
- js_pushnumber(J, asin(js_tonumber(J, 1)));
35
- }
36
-
37
- static void Math_atan(js_State *J)
38
- {
39
- js_pushnumber(J, atan(js_tonumber(J, 1)));
40
- }
41
-
42
- static void Math_atan2(js_State *J)
43
- {
44
- double y = js_tonumber(J, 1);
45
- double x = js_tonumber(J, 2);
46
- js_pushnumber(J, atan2(y, x));
47
- }
48
-
49
- static void Math_ceil(js_State *J)
50
- {
51
- js_pushnumber(J, ceil(js_tonumber(J, 1)));
52
- }
53
-
54
- static void Math_cos(js_State *J)
55
- {
56
- js_pushnumber(J, cos(js_tonumber(J, 1)));
57
- }
58
-
59
- static void Math_exp(js_State *J)
60
- {
61
- js_pushnumber(J, exp(js_tonumber(J, 1)));
62
- }
63
-
64
- static void Math_floor(js_State *J)
65
- {
66
- js_pushnumber(J, floor(js_tonumber(J, 1)));
67
- }
68
-
69
- static void Math_log(js_State *J)
70
- {
71
- js_pushnumber(J, log(js_tonumber(J, 1)));
72
- }
73
-
74
- static void Math_pow(js_State *J)
75
- {
76
- double x = js_tonumber(J, 1);
77
- double y = js_tonumber(J, 2);
78
- if (!isfinite(y) && fabs(x) == 1)
79
- js_pushnumber(J, NAN);
80
- else
81
- js_pushnumber(J, pow(x,y));
82
- }
83
-
84
- static void Math_random(js_State *J)
85
- {
86
- /* Lehmer generator with a=48271 and m=2^31-1 */
87
- /* Park & Miller (1988). Random Number Generators: Good ones are hard to find. */
88
- J->seed = (uint64_t) J->seed * 48271 % 0x7fffffff;
89
- js_pushnumber(J, (double) J->seed / 0x7fffffff);
90
- }
91
-
92
- static void Math_init_random(js_State *J)
93
- {
94
- /* Pick initial seed by scrambling current time with Xorshift. */
95
- /* Marsaglia (2003). Xorshift RNGs. */
96
- J->seed = time(0) + 123;
97
- J->seed ^= J->seed << 13;
98
- J->seed ^= J->seed >> 17;
99
- J->seed ^= J->seed << 5;
100
- J->seed %= 0x7fffffff;
101
- }
102
-
103
- static void Math_round(js_State *J)
104
- {
105
- double x = js_tonumber(J, 1);
106
- js_pushnumber(J, jsM_round(x));
107
- }
108
-
109
- static void Math_sin(js_State *J)
110
- {
111
- js_pushnumber(J, sin(js_tonumber(J, 1)));
112
- }
113
-
114
- static void Math_sqrt(js_State *J)
115
- {
116
- js_pushnumber(J, sqrt(js_tonumber(J, 1)));
117
- }
118
-
119
- static void Math_tan(js_State *J)
120
- {
121
- js_pushnumber(J, tan(js_tonumber(J, 1)));
122
- }
123
-
124
- static void Math_max(js_State *J)
125
- {
126
- int i, n = js_gettop(J);
127
- double x = -INFINITY;
128
- for (i = 1; i < n; ++i) {
129
- double y = js_tonumber(J, i);
130
- if (isnan(y)) {
131
- x = y;
132
- break;
133
- }
134
- if (signbit(x) == signbit(y))
135
- x = x > y ? x : y;
136
- else if (signbit(x))
137
- x = y;
138
- }
139
- js_pushnumber(J, x);
140
- }
141
-
142
- static void Math_min(js_State *J)
143
- {
144
- int i, n = js_gettop(J);
145
- double x = INFINITY;
146
- for (i = 1; i < n; ++i) {
147
- double y = js_tonumber(J, i);
148
- if (isnan(y)) {
149
- x = y;
150
- break;
151
- }
152
- if (signbit(x) == signbit(y))
153
- x = x < y ? x : y;
154
- else if (signbit(y))
155
- x = y;
156
- }
157
- js_pushnumber(J, x);
158
- }
159
-
160
- void jsB_initmath(js_State *J)
161
- {
162
- Math_init_random(J);
163
- js_pushobject(J, jsV_newobject(J, JS_CMATH, J->Object_prototype));
164
- {
165
- jsB_propn(J, "E", 2.7182818284590452354);
166
- jsB_propn(J, "LN10", 2.302585092994046);
167
- jsB_propn(J, "LN2", 0.6931471805599453);
168
- jsB_propn(J, "LOG2E", 1.4426950408889634);
169
- jsB_propn(J, "LOG10E", 0.4342944819032518);
170
- jsB_propn(J, "PI", 3.1415926535897932);
171
- jsB_propn(J, "SQRT1_2", 0.7071067811865476);
172
- jsB_propn(J, "SQRT2", 1.4142135623730951);
173
-
174
- jsB_propf(J, "Math.abs", Math_abs, 1);
175
- jsB_propf(J, "Math.acos", Math_acos, 1);
176
- jsB_propf(J, "Math.asin", Math_asin, 1);
177
- jsB_propf(J, "Math.atan", Math_atan, 1);
178
- jsB_propf(J, "Math.atan2", Math_atan2, 2);
179
- jsB_propf(J, "Math.ceil", Math_ceil, 1);
180
- jsB_propf(J, "Math.cos", Math_cos, 1);
181
- jsB_propf(J, "Math.exp", Math_exp, 1);
182
- jsB_propf(J, "Math.floor", Math_floor, 1);
183
- jsB_propf(J, "Math.log", Math_log, 1);
184
- jsB_propf(J, "Math.max", Math_max, 0); /* 2 */
185
- jsB_propf(J, "Math.min", Math_min, 0); /* 2 */
186
- jsB_propf(J, "Math.pow", Math_pow, 2);
187
- jsB_propf(J, "Math.random", Math_random, 0);
188
- jsB_propf(J, "Math.round", Math_round, 1);
189
- jsB_propf(J, "Math.sin", Math_sin, 1);
190
- jsB_propf(J, "Math.sqrt", Math_sqrt, 1);
191
- jsB_propf(J, "Math.tan", Math_tan, 1);
192
- }
193
- js_defglobal(J, "Math", JS_DONTENUM);
194
- }
@@ -1,198 +0,0 @@
1
- #include "jsi.h"
2
-
3
- #if defined(_MSC_VER) && (_MSC_VER < 1700) /* VS2012 has stdint.h */
4
- typedef unsigned __int64 uint64_t;
5
- #else
6
- #include <stdint.h>
7
- #endif
8
-
9
- static void jsB_new_Number(js_State *J)
10
- {
11
- js_newnumber(J, js_gettop(J) > 1 ? js_tonumber(J, 1) : 0);
12
- }
13
-
14
- static void jsB_Number(js_State *J)
15
- {
16
- js_pushnumber(J, js_gettop(J) > 1 ? js_tonumber(J, 1) : 0);
17
- }
18
-
19
- static void Np_valueOf(js_State *J)
20
- {
21
- js_Object *self = js_toobject(J, 0);
22
- if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
23
- js_pushnumber(J, self->u.number);
24
- }
25
-
26
- static void Np_toString(js_State *J)
27
- {
28
- char buf[100];
29
- js_Object *self = js_toobject(J, 0);
30
- int radix = js_isundefined(J, 1) ? 10 : js_tointeger(J, 1);
31
- double x = 0;
32
- if (self->type != JS_CNUMBER)
33
- js_typeerror(J, "not a number");
34
- x = self->u.number;
35
- if (radix == 10) {
36
- js_pushstring(J, jsV_numbertostring(J, buf, x));
37
- return;
38
- }
39
- if (radix < 2 || radix > 36)
40
- js_rangeerror(J, "invalid radix");
41
-
42
- /* lame number to string conversion for any radix from 2 to 36 */
43
- {
44
- static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
45
- double number = x;
46
- int sign = x < 0;
47
- js_Buffer *sb = NULL;
48
- uint64_t u, limit = ((uint64_t)1<<52);
49
-
50
- int ndigits, exp, point;
51
-
52
- if (number == 0) { js_pushstring(J, "0"); return; }
53
- if (isnan(number)) { js_pushstring(J, "NaN"); return; }
54
- if (isinf(number)) { js_pushstring(J, sign ? "-Infinity" : "Infinity"); return; }
55
-
56
- if (sign)
57
- number = -number;
58
-
59
- /* fit as many digits as we want in an int */
60
- exp = 0;
61
- while (number * pow(radix, exp) > limit)
62
- --exp;
63
- while (number * pow(radix, exp+1) < limit)
64
- ++exp;
65
- u = number * pow(radix, exp) + 0.5;
66
-
67
- /* trim trailing zeros */
68
- while (u > 0 && (u % radix) == 0) {
69
- u /= radix;
70
- --exp;
71
- }
72
-
73
- /* serialize digits */
74
- ndigits = 0;
75
- while (u > 0) {
76
- buf[ndigits++] = digits[u % radix];
77
- u /= radix;
78
- }
79
- point = ndigits - exp;
80
-
81
- if (js_try(J)) {
82
- js_free(J, sb);
83
- js_throw(J);
84
- }
85
-
86
- if (sign)
87
- js_putc(J, &sb, '-');
88
-
89
- if (point <= 0) {
90
- js_putc(J, &sb, '0');
91
- js_putc(J, &sb, '.');
92
- while (point++ < 0)
93
- js_putc(J, &sb, '0');
94
- while (ndigits-- > 0)
95
- js_putc(J, &sb, buf[ndigits]);
96
- } else {
97
- while (ndigits-- > 0) {
98
- js_putc(J, &sb, buf[ndigits]);
99
- if (--point == 0 && ndigits > 0)
100
- js_putc(J, &sb, '.');
101
- }
102
- while (point-- > 0)
103
- js_putc(J, &sb, '0');
104
- }
105
-
106
- js_putc(J, &sb, 0);
107
- js_pushstring(J, sb->s);
108
-
109
- js_endtry(J);
110
- js_free(J, sb);
111
- }
112
- }
113
-
114
- /* Customized ToString() on a number */
115
- static void numtostr(js_State *J, const char *fmt, int w, double n)
116
- {
117
- /* buf needs to fit printf("%.20f", 1e20) */
118
- char buf[50], *e;
119
- sprintf(buf, fmt, w, n);
120
- e = strchr(buf, 'e');
121
- if (e) {
122
- int exp = atoi(e+1);
123
- sprintf(e, "e%+d", exp);
124
- }
125
- js_pushstring(J, buf);
126
- }
127
-
128
- static void Np_toFixed(js_State *J)
129
- {
130
- js_Object *self = js_toobject(J, 0);
131
- int width = js_tointeger(J, 1);
132
- char buf[32];
133
- double x;
134
- if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
135
- if (width < 0) js_rangeerror(J, "precision %d out of range", width);
136
- if (width > 20) js_rangeerror(J, "precision %d out of range", width);
137
- x = self->u.number;
138
- if (isnan(x) || isinf(x) || x <= -1e21 || x >= 1e21)
139
- js_pushstring(J, jsV_numbertostring(J, buf, x));
140
- else
141
- numtostr(J, "%.*f", width, x);
142
- }
143
-
144
- static void Np_toExponential(js_State *J)
145
- {
146
- js_Object *self = js_toobject(J, 0);
147
- int width = js_tointeger(J, 1);
148
- char buf[32];
149
- double x;
150
- if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
151
- if (width < 0) js_rangeerror(J, "precision %d out of range", width);
152
- if (width > 20) js_rangeerror(J, "precision %d out of range", width);
153
- x = self->u.number;
154
- if (isnan(x) || isinf(x))
155
- js_pushstring(J, jsV_numbertostring(J, buf, x));
156
- else
157
- numtostr(J, "%.*e", width, x);
158
- }
159
-
160
- static void Np_toPrecision(js_State *J)
161
- {
162
- js_Object *self = js_toobject(J, 0);
163
- int width = js_tointeger(J, 1);
164
- char buf[32];
165
- double x;
166
- if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
167
- if (width < 1) js_rangeerror(J, "precision %d out of range", width);
168
- if (width > 21) js_rangeerror(J, "precision %d out of range", width);
169
- x = self->u.number;
170
- if (isnan(x) || isinf(x))
171
- js_pushstring(J, jsV_numbertostring(J, buf, x));
172
- else
173
- numtostr(J, "%.*g", width, x);
174
- }
175
-
176
- void jsB_initnumber(js_State *J)
177
- {
178
- J->Number_prototype->u.number = 0;
179
-
180
- js_pushobject(J, J->Number_prototype);
181
- {
182
- jsB_propf(J, "Number.prototype.valueOf", Np_valueOf, 0);
183
- jsB_propf(J, "Number.prototype.toString", Np_toString, 1);
184
- jsB_propf(J, "Number.prototype.toLocaleString", Np_toString, 0);
185
- jsB_propf(J, "Number.prototype.toFixed", Np_toFixed, 1);
186
- jsB_propf(J, "Number.prototype.toExponential", Np_toExponential, 1);
187
- jsB_propf(J, "Number.prototype.toPrecision", Np_toPrecision, 1);
188
- }
189
- js_newcconstructor(J, jsB_Number, jsB_new_Number, "Number", 0); /* 1 */
190
- {
191
- jsB_propn(J, "MAX_VALUE", 1.7976931348623157e+308);
192
- jsB_propn(J, "MIN_VALUE", 5e-324);
193
- jsB_propn(J, "NaN", NAN);
194
- jsB_propn(J, "NEGATIVE_INFINITY", -INFINITY);
195
- jsB_propn(J, "POSITIVE_INFINITY", INFINITY);
196
- }
197
- js_defglobal(J, "Number", JS_DONTENUM);
198
- }