Uses 911K of libraries. Click here for Pure Java version (12637L/70K).
1 | !7 |
2 | |
3 | set flag replaceACCInClassLoader_fullException. |
4 | set flag DynModule. // use central transpiler |
5 | |
6 | cmodule StandardFunction {
|
7 | switchable S functionName; |
8 | transient DynamicCallable f; |
9 | transient Throwable error; |
10 | |
11 | start {
|
12 | dm_registerAs('standardFunctionHolder);
|
13 | onChange(r updateStatuses); |
14 | loadFunction(); |
15 | } |
16 | |
17 | visual |
18 | vstack(centerAndEastWithMargins( |
19 | withLabel("Function:", dm_label('functionName)),
|
20 | jThreadedButton("Choose...", rEnter { dm_stringFieldDialog('functionName, onSet := rEnter newFunctionName) })));
|
21 | |
22 | void newFunctionName() {
|
23 | setField(f := null); |
24 | setField(error := null); |
25 | loadFunction(); |
26 | } |
27 | |
28 | void updateStatuses {
|
29 | setModuleName( |
30 | empty(functionName) ? "Standard function as module" |
31 | : "Function " + functionName + " - " |
32 | + (hasError() ? "Error" : loaded() ? "loaded" : "not loaded")); |
33 | } |
34 | |
35 | void loadFunction() q {
|
36 | try {
|
37 | setField(f := methodAsDynamicCallable(loadFunctions_cached(functionName), functionName)); |
38 | } catch e {
|
39 | setFields(f := null, error := e); |
40 | } |
41 | } |
42 | |
43 | // API |
44 | |
45 | S functionName() { ret functionName; }
|
46 | |
47 | O callTheFunction(O... args) {
|
48 | while (f == null && error == null) sleep(10); |
49 | if (error != null) throw rethrow(error); |
50 | ret callF(f, args); |
51 | } |
52 | |
53 | bool loaded() { ret f != null; }
|
54 | bool hasError() { ret error != null; }
|
55 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1022766 |
| Snippet name: | Standard function as module (transpiled on the spot) |
| Eternal ID of this version: | #1022766/15 |
| Text MD5: | fcd3bc2493fd338eb4808b247e759e14 |
| Transpilation MD5: | 56846eb6a9d088484cc85fd49a8571aa |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-04-06 23:37:52 |
| Source code size: | 1434 bytes / 55 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 565 / 1053 |
| Version history: | 14 change(s) |
| Referenced in: | [show references] |