diff options
author | bptato <nincsnevem662@gmail.com> | 2024-01-24 13:06:39 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-01-24 13:09:20 +0100 |
commit | b4aab9abc237b97a64def0f4ddf2dd7793f30916 (patch) | |
tree | b88133c52689e3e29f399a6b0f1eb62409e49c59 /src/js | |
parent | b69d0cd7e7bbde418c4bbb6d50f6c4270d1edf0f (diff) | |
download | chawan-b4aab9abc237b97a64def0f4ddf2dd7793f30916.tar.gz |
js: update pragma docs
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/javascript.nim | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index 4179f78b..f5a00d80 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -12,8 +12,13 @@ # one. In other words: cross-language reference semantics work seamlessly.) # {.jsfunc.} is used for binding normal functions. Needs a `this' value, as all # following pragmas. As mentioned before, overloading doesn't work but OR -# generics do. Bare objects (returned by value) can't be passed either, for -# now. Otherwise, most types should work. +# generics do. By default, the Nim function name is bound; if this is not +# desired, you can rename the function like this: {.jsfunc: "preferredName".} +# This also works for all other pragmas that define named functions in JS. +# {.jsstfunc.} binds static functions. Unlike .jsfunc, it does not have a +# `this' value. A class name must be specified, e.g. {.jsstfunc: "URL".} to +# define on the URL class. To rename a static function, use the syntax +# "ClassName:funcName", e.g. "Response:error". # {.jsget.}, {.jsfget.} must be specified on object fields; these generate # regular getter & setter functions. # {.jsufget, jsuffget, jsuffunc.} For fields with the [LegacyUnforgeable] @@ -25,7 +30,8 @@ # can only be used on object fields. (I initially wanted to use the same # keyword, unfortunately that didn't work out.) # {.jsgetprop.} for property getters. Called when GetOwnProperty would return -# nothing. The key should probably be either a string or an integer. +# nothing. The key must be either a string or an integer (preferably uint32), +# since it is converted from a JSAtom. # {.jssetprop.} for property setters. Called on SetProperty - in fact this # is the set() method of Proxy, except it always returns true. Same rules as # jsgetprop for keys. |