Example #1
0
 public static bool InstanceOf(NSJSValue instance, string type)
 {
     if (instance == null || string.IsNullOrEmpty(type))
     {
         return(false);
     }
     return(nsjs_localvalue_instanceof(instance, NSJSString.New(instance.VirtualMachine, type)));
 }
Example #2
0
 public void SetReturnValue(string value)
 {
     if (value == null)
     {
         this.SetReturnValue(NSJSValue.Null(this.VirtualMachine));
         return;
     }
     this.SetReturnValue(NSJSString.New(this.VirtualMachine, value));
 }
Example #3
0
        public virtual bool IsDefined(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(false);
            }
            NSJSFunction function = this.GetFrameworkFunction(RUNTIME_ISDEFINED_PROPERTYKEY);

            return((function.Call(new NSJSValue[] { this, NSJSString.New(this.VirtualMachine, key) }) as NSJSInt32)?.Value == 1);
        }
Example #4
0
        public virtual NSJSObject GetPropertyDescriptor(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(null);
            }
            NSJSFunction function = this.GetFrameworkFunction(RUNTIME_GETPROPERTYDESCRIPTOR_PROPERTYKEY);

            return(function.Call(new NSJSValue[] { this, NSJSString.New(this.VirtualMachine, key) }) as NSJSObject);
        }
Example #5
0
 public virtual void DefineProperty(string key, NSJSFunctionCallback get, NSJSFunctionCallback set)
 {
     this.InternalDefineProperty(key, (machine, function) =>
     {
         NSJSValue[] s = new NSJSValue[]
         {
             this,
             NSJSString.New(machine, key),
             get == null ? NSJSValue.Undefined(machine) : NSJSFunction.New(machine, get),
             set == null ? NSJSValue.Undefined(machine) : NSJSFunction.New(machine, set),
         };
         function.Call(s);
     });
 }
Example #6
0
        public virtual NSJSValue Call(IEnumerable <string> args, out NSJSException exception)
        {
            IList <NSJSValue>  argv    = new List <NSJSValue>();
            NSJSVirtualMachine machine = this.VirtualMachine;

            foreach (string s in args)
            {
                NSJSValue value = null;
                if (s == null)
                {
                    value = NSJSValue.Null(machine);
                }
                else
                {
                    value = NSJSString.New(machine, s);
                }
                if (value == null)
                {
                    continue;
                }
                argv.Add(value);
            }
            return(this.Call(argv, out exception));
        }