Skip to content

Commit

Permalink
Support //extcall to mark a function as externally called
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jun 29, 2024
1 parent 2ef7638 commit 23ff839
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions chocimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function setdefault(obj, key, val) {
const elements = {
FunctionExpression(el, {scopes, sc, ...state}) {
if (sc !== "return") sc = ""; //If we're not *calling* the function, then just probe it, don't process its return value
if (Ctx.source_lines[el.loc.start.line - 1].endsWith("//extcall")) sc = "return"; //But if we're calling it elsewhere, then do.
descend(el.body, {scopes: [...scopes, { }], sc, ...state});
},

Expand Down
4 changes: 3 additions & 1 deletion editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Factory elements, identify this to the importer thus:

chocimport --fix --extcall=render_item --extcall=render_command /some/file.js

Any number of extcall directives can be given.
Any number of extcall directives can be given. You can also adorn individual
function definitions with "//extcall" at the end of the line; this has the same
effect, but can be used with any function, not just one at top level.

SciTE
-----
Expand Down
3 changes: 3 additions & 0 deletions whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Importer feature (JS only): Explicit calls to choc.X() or lindt.X() will mark
their arguments as Choc Factory context.
* Importer feature: A function definition can be marked with `//extcall`. This has
the same effect as giving its name in an `--extcall` parameter, but works for
functions that are defined somewhere other than global scope.
* There is now also a transformation tool available at [convert.html](convert.html)
to aid in turning HTML into dynamically-generated DOM elements.

Expand Down

0 comments on commit 23ff839

Please sign in to comment.