public object InvokeProperty(JsObject obj, string name, object[] args) { if (obj == null) throw new ArgumentNullException("obj"); if (name == null) throw new ArgumentNullException("name"); CheckDisposed(); if (obj.Handle == IntPtr.Zero) throw new JsInteropException("wrapped V8 object is empty (IntPtr is Zero)"); JsValue a = JsValue.Null; // Null value unless we're given args. if (args != null) a = _convert.AnyToJsValue(args); JsValue v = jscontext_invoke_property(_context, obj.Handle, name, a); object res = _convert.FromJsValue(v); jsvalue_dispose(v); jsvalue_dispose(a); Exception e = res as JsException; if (e != null) throw e; return res; }
public IEnumerable<string> GetMemberNames(JsObject obj) { if (obj == null) throw new ArgumentNullException("obj"); CheckDisposed(); if (obj.Handle == IntPtr.Zero) throw new JsInteropException("wrapped V8 object is empty (IntPtr is Zero)"); JsValue v = jscontext_get_property_names(_context, obj.Handle); object res = _convert.FromJsValue(v); jsvalue_dispose(v); Exception e = res as JsException; if (e != null) throw e; object[] arr = (object[])res; string[] strArr = new string[arr.Length]; for (int i = arr.Length - 1; i >= 0; --i) { strArr[i] = arr[i].ToString(); } return strArr; }
//protected JsException(SerializationInfo info, StreamingContext context) // : base(info, context) //{ //} internal JsException(string type, string resource, string message, int line, int col, JsObject error) : base(string.Format("{0}: {1} at line: {2} column: {3}.", resource, message, line, col)) { _type = type; _resource = resource; _line = line; _column = col; _nativeException = error; }
public object GetPropertyValue(JsObject obj, string name) { if (obj == null) throw new ArgumentNullException("obj"); if (name == null) throw new ArgumentNullException("name"); CheckDisposed(); if (obj.Handle == IntPtr.Zero) throw new JsInteropException("wrapped V8 object is empty (IntPtr is Zero)"); JsValue v = jscontext_get_property_value(_context, obj.Handle, name); object res = _convert.FromJsValue(v); jsvalue_dispose(v); Exception e = res as JsException; if (e != null) throw e; return res; }
// Native V8 exception objects are wrapped by special instances of JsException. public JsException(JsObject nativeException) { _nativeException = nativeException; }
private JsObject JsDictionaryObject(JsValue v) { JsObject obj = new JsObject(this._context, v.Ptr); int len = v.Length * 2; for (int i = 0; i < len; i += 2) { var key = (JsValue)Marshal.PtrToStructure(new IntPtr(v.Ptr.ToInt64() + (16 * i)), typeof(JsValue)); var value = (JsValue)Marshal.PtrToStructure(new IntPtr(v.Ptr.ToInt64() + (16 * (i + 1))), typeof(JsValue)); obj[(string)FromJsValue(key)] = FromJsValue(value); } return obj; }
internal JsException(string type, string resource, string message, int line, int col, JsObject error) : base(string.Format("{0}: {1} at line: {2} column: {3}.", resource, message, line, col)) { _type = type; _resource = resource; _line = line; _column = col; _nativeException = error; }
public NodeJsBuffer(JsObject jsobj) { _jsobj = jsobj; }