public class JSFunction extends JSObject
JSPropertyAttributeDontDelete, JSPropertyAttributeDontEnum, JSPropertyAttributeNone, JSPropertyAttributeReadOnly| Constructor and Description | 
|---|
| JSFunction(JSContext ctx)Creates a new function which basically does nothing. | 
| JSFunction(JSContext ctx,
          java.lang.reflect.Method method)Creates a new function object which calls method 'method' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.reflect.Method method,
          java.lang.Class<? extends JSObject> instanceClass)Creates a new function object which calls method 'method' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.reflect.Method method,
          java.lang.Class<? extends JSObject> instanceClass,
          JSObject invokeObject)Creates a new function object which calls method 'method' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.String methodName)Creates a new function object which calls method 'methodName' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.String methodName,
          java.lang.Class<? extends JSObject> instanceClass)Creates a new function object which calls method 'methodName' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.String methodName,
          java.lang.Class<? extends JSObject> instanceClass,
          JSObject invokeObject)Creates a new function object which calls method 'methodName' on this Java object. | 
| JSFunction(JSContext ctx,
          java.lang.String name,
          java.lang.String[] parameterNames,
          java.lang.String body,
          java.lang.String sourceURL,
          int startingLineNumber)Creates a JavaScript function that takes parameters 'parameterNames' and executes the
 JS code in 'body'. | 
| JSFunction(long objRef,
          JSContext context)Wraps an existing object as a JSFunction | 
| Modifier and Type | Method and Description | 
|---|---|
| JSValue | apply(JSObject thiz,
     java.lang.Object[] args)Calls this JavaScript function, similar to 'Function.apply() in JavaScript | 
| JSValue | call()Calls this JavaScript function with no args and 'this' as null | 
| JSValue | call(JSObject thiz,
    java.lang.Object... args)Calls this JavaScript function, similar to 'Function.call()' in JavaScript | 
| JSObject | newInstance(java.lang.Object... args)Calls this JavaScript function as a constructor, i.e. | 
| JSValue | prototype()Gets the prototype object, if it exists | 
| void | prototype(JSValue proto)Sets the prototype object | 
__nullFunc, callAsFunction, callAsFunction, callAsFunction, callAsFunction, deleteProperty, getThis, hashCode, hasProperty, isConstructor, isFunction, property, property, property, propertyAtIndex, propertyAtIndex, propertyNamesequals, getContext, isArray, isBoolean, isDate, isEqual, isInstanceOfConstructor, isNull, isNumber, isObject, isStrictEqual, isString, isUndefined, toBoolean, toFunction, toJSArray, toJSON, toJSON, toNumber, toObject, toString, valueRefpublic JSFunction(JSContext ctx, java.lang.String name, java.lang.String[] parameterNames, java.lang.String body, java.lang.String sourceURL, int startingLineNumber) throws JSException
ctx - The JSContext in which to create the functionname - The name of the functionparameterNames - A String array containing the names of the parametersbody - The JavaScript code to execute in the functionsourceURL - The URI of the source file, only used for reporting in stack trace (optional)startingLineNumber - The beginning line number, only used for reporting in stack trace (optional)JSExceptionpublic JSFunction(JSContext ctx, java.lang.reflect.Method method, java.lang.Class<? extends JSObject> instanceClass, JSObject invokeObject) throws JSException
 var f = function(a) { ... };
 
 
 public class FunctionObject extends JSObject {
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 public class MyFunc extends JSFunction {
     MyFunc(JSContext ctx) {
         super(ctx,
              FunctionObject.class.getMethod("function",int.class), // will call method 'function'
              JSObject.class                                // calling 'new' will create a JSObject
              new FunctionObject(ctx)                       // function will be called on FunctionObject
         );
     }
 }
 
 ctx - The JSContext to create the object inmethod - The method to invokeinstanceClass - The class to be created on 'new' callinvokeObject - The object on which to invoke the methodJSExceptionpublic JSFunction(JSContext ctx, java.lang.reflect.Method method, java.lang.Class<? extends JSObject> instanceClass) throws JSException
 var f = function(a) { ... };
 
 
 public class MyFunc extends JSFunction {
     MyFunc(JSContext ctx) {
         super(ctx,
              MyFunc.class.getMethod("function",int.class), // will call method 'function'
              JSObject.class                                // calling 'new' will create a JSObject
         );
     }
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 
 ctx - The JSContext to create the object inmethod - The method to invokeinstanceClass - The class to be created on 'new' callJSExceptionpublic JSFunction(JSContext ctx, java.lang.reflect.Method method) throws JSException
 var f = function(a) { ... };
 
 
 public class MyFunc extends JSFunction {
     MyFunc(JSContext ctx) {
         super(ctx,
              MyFunc.class.getMethod("function",int.class), // will call method 'function'
              JSObject.class                                // calling 'new' will create a JSObject
         );
     }
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 
 ctx - The JSContext to create the object inmethod - The method to invokeJSExceptionpublic JSFunction(JSContext ctx) throws JSException
 var f = function() {};
 
 
 JSFunction f = new JSFunction(context);
 
 ctx - The JSContext to create the object inJSExceptionpublic JSFunction(JSContext ctx, java.lang.String methodName, java.lang.Class<? extends JSObject> instanceClass, JSObject invokeObject) throws JSException
 var f = function(a) { ... };
 
 
 public class FunctionObject extends JSObject {
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 public class MyFunc extends JSFunction {
     MyFunc(JSContext ctx) {
         super(ctx,
              "function",               // will call method 'function'
              JSObject.class            // calling 'new' will create a JSObject
              new FunctionObject(ctx)   // function will be called on FunctionObject
         );
     }
 }
 
 ctx - The JSContext to create the object inmethodName - The method to invoke (searches for first instance)instanceClass - The class to be created on 'new' callinvokeObject - The object on which to invoke the methodJSExceptionpublic JSFunction(JSContext ctx, java.lang.String methodName, java.lang.Class<? extends JSObject> instanceClass) throws JSException
 var f = function(a) { ... };
 
 
 JSFunction f = new JSFunction(context,"function",JSObject.class) {
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 
 ctx - The JSContext to create the object inmethodName - The method to invoke (searches for first instance)instanceClass - The class to be created on 'new' callJSExceptionpublic JSFunction(JSContext ctx, java.lang.String methodName) throws JSException
 var f = function(a) { ... };
 
 
 JSFunction f = new JSFunction(context,"function") {
     void function(int x) {
         getThis().property("varx",x);
     }
 }
 
 ctx - The JSContext to create the object inmethodName - The method to invoke (searches for first instance)JSExceptionpublic JSFunction(long objRef,
                  JSContext context)
objRef - The JavaScriptCore object referencecontext - The JSContext the objectpublic JSValue call(JSObject thiz, java.lang.Object... args) throws JSException
thiz - The 'this' object on which the function operates, null if not on a constructor objectargs - The argument list to be passed to the functionJSExceptionpublic JSValue apply(JSObject thiz, java.lang.Object[] args) throws JSException
thiz - The 'this' object on which the function operates, null if not on a constructor objectargs - An array of arguments to be passed to the functionJSExceptionpublic JSValue call() throws JSException
JSExceptionpublic JSObject newInstance(java.lang.Object... args)
args - The argument list to be passed to the functionpublic JSValue prototype()