// -------------------------------------------------------------------------------------------------------------------- /// <summary> /// Returns an existing or new handle to wrap the proxy reference. /// </summary> internal Handle _GetHandle(HandleProxy* hp) { _DoWorkStep(); // (attempt to dispose of at least one handle on each call to attempt to keep reusing handles whenever possible) if (hp == null) return null; if (hp->ManagedHandleID >= 0) return _Handles[hp->ManagedHandleID].Object._Reset(); Handle handle; switch (hp->ValueType) { case JSValueType.Bool: handle = new Handle<bool>(this); break; case JSValueType.Date: handle = new Handle<DateTime>(this); break; case JSValueType.Int32: handle = new Handle<Int32>(this); break; case JSValueType.Number: handle = new Handle<double>(this); break; case JSValueType.String: handle = new Handle<string>(this); break; case JSValueType.CompilerError: handle = new Handle<string>(this); break; case JSValueType.ExecutionError: handle = new Handle<string>(this); break; case JSValueType.InternalError: handle = new Handle<string>(this); break; default: handle = new Handle<object>(this); break; } handle._Initialize(hp); lock (_Handles) // (whole list may be affected internally, so this needs to be thread protected) { hp->ManagedHandleID = handle._ID = _Handles.Add(new ObservableWeakReference<Handle>(handle)); } return handle; }
public static extern bool DeleteObjectPropertyByIndex(HandleProxy* proxy, Int32 index);
public static unsafe extern void SetObjectTemplateProperty(NativeObjectTemplateProxy* proxy, string name, HandleProxy* value, V8PropertyAttributes attributes = V8PropertyAttributes.None);
public static extern void UpdateHandleValue(HandleProxy* handle);
public static extern void MakeStrongHandle(HandleProxy* handleProxy);
public static extern HandleProxy* CreateArray(NativeV8EngineProxy* engine, HandleProxy** items = null, Int32 length = 0);
public static extern HandleProxy* CreateFunctionInstance(NativeFunctionTemplateProxy* functionTemplateProxy, Int32 objId, Int32 argCount = 0, HandleProxy** args = null);
public static extern V8PropertyAttributes GetPropertyAttributes(HandleProxy* proxy, string name);
public static extern HandleProxy* GetObjectPrototype(HandleProxy* handleProxy);
public static extern void ConnectObject(HandleProxy* handleProxy, Int32 objId, void* templateProxy = null);
public static extern HandleProxy* V8ExecuteCompiledScript(NativeV8EngineProxy* engine, HandleProxy* script);
public static unsafe extern HandleProxy* CreateFunctionInstance(NativeFunctionTemplateProxy* functionTemplateProxy, Int32 objID, Int32 argCount, HandleProxy** args);
public static unsafe extern HandleProxy* GetPropertyNames(HandleProxy* proxy);
public static extern void SetObjectAccessor(HandleProxy* proxy, Int32 managedObjectId, string name, ManagedAccessorGetter getter, ManagedAccessorSetter setter, V8AccessControl access, V8PropertyAttributes attributes);
public static extern HandleProxy* Call(HandleProxy* subject, string functionName, HandleProxy* _this, Int32 argCount, HandleProxy** args);
public static extern HandleProxy* GetOwnPropertyNames(HandleProxy* proxy);
public static extern bool SetObjectPropertyByName(HandleProxy* proxy, string name, HandleProxy* value, V8PropertyAttributes attributes = V8PropertyAttributes.None);
public static extern Int32 GetArrayLength(HandleProxy* proxy);
public static extern bool SetObjectPropertyByIndex(HandleProxy* proxy, Int32 index, HandleProxy* value);
public static extern void SetFunctionTemplateProperty(NativeFunctionTemplateProxy* proxy, string name, HandleProxy* value, V8PropertyAttributes attributes = V8PropertyAttributes.None);
public static extern HandleProxy* GetObjectPropertyByName(HandleProxy* proxy, string name);
public static extern void MakeWeakHandle(HandleProxy* handleProxy);
public static extern HandleProxy* GetObjectPropertyByIndex(HandleProxy* proxy, Int32 index);
public static extern void DisposeHandleProxy(HandleProxy* handle);
public static extern bool DeleteObjectPropertyByName(HandleProxy* proxy, string name);
public static extern int GetHandleManagedObjectID(HandleProxy* handle);
public static unsafe extern void ConnectObject(HandleProxy* handleProxy, Int32 objID, void* templateProxy);