From 774aad55da0fc62f8de8c95dbbb3d2ad41010e3f Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 26 Dec 2022 19:42:19 +0100 Subject: dom: correct constructors, more create functions --- src/js/javascript.nim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/js/javascript.nim') diff --git a/src/js/javascript.nim b/src/js/javascript.nim index bf81a09d..5e038290 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -1299,6 +1299,25 @@ macro jsctor*(fun: typed) = gen.registerConstructor() result = newStmtList(fun) +macro jsgctor*(fun: typed) = + var gen = setupGenerator(fun, CONSTRUCTOR, thisname = none(string)) + if gen.newName in existing_funcs: + #TODO TODO TODO implement function overloading + error("Function overloading hasn't been implemented yet...") + gen.addFixParam("this") + gen.addRequiredParams() + gen.addOptionalParams() + gen.finishFunCallList() + let jfcl = gen.jsFunCallList + let dl = gen.dielabel + gen.jsCallAndRet = quote do: + block `dl`: + return ctx.toJS(`jfcl`) + return JS_UNDEFINED + discard gen.newJSProc(getJSParams()) + gen.registerConstructor() + result = newStmtList(fun) + macro jshasprop*(fun: typed) = var gen = setupGenerator(fun, PROPERTY_HAS, thisname = some("obj")) if gen.newName in existing_funcs: -- cgit 1.4.1-2-gfad0 e/src/main.nim?id=cea4aa0374a2f8c1df40a30060c34de8ce257090'>tree commit diff stats
path: root/src/main.nim
blob: 990372ee513e84df0122e955cd57d72887a49669 (plain) (blame)
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