Skip to content

Commit 3b85c77

Browse files
committed
Add two "addPredefinedFunctions()" methods in the LII
1 parent 8db2b18 commit 3b85c77

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/at/jddev0/lang/LangInterpreter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,6 +3996,18 @@ public InterpretingError getAndClearErrnoErrorObject(final int SCOPE_ID) {
39963996
public void addPredefinedFunction(String funcName, LangNativeFunction function) {
39973997
interpreter.funcs.put(funcName, function);
39983998
}
3999+
/**
4000+
* Adds all static methods which are annotated with @LangFunction the object contains
4001+
*/
4002+
public void addPredefinedFunctions(Class<?> clazz) {
4003+
interpreter.funcs.putAll(LangNativeFunction.getLangFunctionsOfClass(interpreter, clazz));
4004+
}
4005+
/**
4006+
* Adds all non-static methods which are annotated with @LangFunction the object contains
4007+
*/
4008+
public void addPredefinedFunctions(Object obj) {
4009+
interpreter.funcs.putAll(LangNativeFunction.getLangFunctionsFromObject(interpreter, obj));
4010+
}
39994011
/**
40004012
* Creates a function which is accessible globally in the Interpreter (= in all SCOPE_IDs)<br>
40014013
* If function already exists, it will be overridden<br>

0 commit comments

Comments
 (0)