/// <summary> /// Execute the function using the specified V8 context. |object| is the /// receiver ('this' object) of the function. If |object| is NULL the specified /// context's global object will be used. |arguments| is the list of arguments /// that will be passed to the function. Returns the function return value on /// success. Returns NULL if this function is called incorrectly or an /// exception is thrown. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public CfxV8Value ExecuteFunctionWithContext(CfxV8Context context, CfxV8Value @object, CfxV8Value[] arguments) { int arguments_length; IntPtr[] arguments_ptrs; if (arguments != null) { arguments_length = arguments.Length; arguments_ptrs = new IntPtr[arguments_length]; for (int i = 0; i < arguments_length; ++i) { arguments_ptrs[i] = CfxV8Value.Unwrap(arguments[i]); } } else { arguments_length = 0; arguments_ptrs = null; } PinnedObject arguments_pinned = new PinnedObject(arguments_ptrs); var __retval = CfxApi.cfx_v8value_execute_function_with_context(NativePtr, CfxV8Context.Unwrap(context), CfxV8Value.Unwrap(@object), arguments_length, arguments_pinned.PinnedPtr); arguments_pinned.Free(); return(CfxV8Value.Wrap(__retval)); }
/// <summary> /// Execute the function using the current V8 context. This function should /// only be called from within the scope of a CfxV8Handler or /// CfxV8Accessor callback, or in combination with calling enter() and /// exit() on a stored CfxV8Context reference. |object| is the receiver /// ('this' object) of the function. If |object| is NULL the current context's /// global object will be used. |arguments| is the list of arguments that will /// be passed to the function. Returns the function return value on success. /// Returns NULL if this function is called incorrectly or an exception is /// thrown. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public CfxV8Value ExecuteFunction(CfxV8Value @object, CfxV8Value[] arguments) { UIntPtr arguments_length; IntPtr[] arguments_ptrs; if (arguments != null) { arguments_length = (UIntPtr)arguments.Length; arguments_ptrs = new IntPtr[arguments.Length]; for (int i = 0; i < arguments.Length; ++i) { arguments_ptrs[i] = CfxV8Value.Unwrap(arguments[i]); } } else { arguments_length = UIntPtr.Zero; arguments_ptrs = null; } PinnedObject arguments_pinned = new PinnedObject(arguments_ptrs); var __retval = CfxApi.V8Value.cfx_v8value_execute_function(NativePtr, CfxV8Value.Unwrap(@object), arguments_length, arguments_pinned.PinnedPtr); arguments_pinned.Free(); return(CfxV8Value.Wrap(__retval)); }
internal static void get(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, out int object_release, out IntPtr retval, out IntPtr exception_str, out int exception_length, out IntPtr exception_gc_handle) { var self = (CfxV8Accessor)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null || self.CallbacksDisabled) { __retval = default(int); object_release = 1; retval = default(IntPtr); exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; return; } var e = new CfxV8AccessorGetEventArgs(name_str, name_length, @object); self.m_Get?.Invoke(self, e); e.m_isInvalid = true; object_release = e.m_object_wrapped == null? 1 : 0; retval = CfxV8Value.Unwrap(e.m_retval_wrapped); if (e.m_exception_wrapped != null && e.m_exception_wrapped.Length > 0) { var exception_pinned = new PinnedString(e.m_exception_wrapped); exception_str = exception_pinned.Obj.PinnedPtr; exception_length = exception_pinned.Length; exception_gc_handle = exception_pinned.Obj.GCHandlePtr(); } else { exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; } __retval = e.m_returnValue ? 1 : 0; }
internal static void get(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, out IntPtr retval, ref IntPtr exception_str, ref int exception_length) { var self = (CfxV8Accessor)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null || self.CallbacksDisabled) { __retval = default(int); retval = default(IntPtr); return; } var e = new CfxV8AccessorGetEventArgs(name_str, name_length, @object, exception_str, exception_length); var eventHandler = self.m_Get; if (eventHandler != null) { eventHandler(self, e); } e.m_isInvalid = true; if (e.m_object_wrapped == null) { CfxApi.cfx_release(e.m_object); } retval = CfxV8Value.Unwrap(e.m_retval_wrapped); if (e.m_exception_changed) { var exception_pinned = new PinnedString(e.m_exception_wrapped); exception_str = exception_pinned.Obj.PinnedPtr; exception_length = exception_pinned.Length; } __retval = e.m_returnValue ? 1 : 0; }
/// <summary> /// Create a new CfxV8Value object of type function. This function should only /// be called from within the scope of a CfxRenderProcessHandler, /// CfxV8Handler or CfxV8Accessor callback, or in combination with calling /// enter() and exit() on a stored CfxV8Context reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateFunction(string name, CfxV8Handler handler) { var name_pinned = new PinnedString(name); var __retval = CfxApi.cfx_v8value_create_function(name_pinned.Obj.PinnedPtr, name_pinned.Length, CfxV8Handler.Unwrap(handler)); name_pinned.Obj.Free(); return(CfxV8Value.Wrap(__retval)); }
/// <summary> /// Returns the value with the specified identifier on success. Returns NULL if /// this function is called incorrectly or an exception is thrown. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public CfxV8Value GetValue(string key) { var key_pinned = new PinnedString(key); var __retval = CfxApi.cfx_v8value_get_value_bykey(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length); key_pinned.Obj.Free(); return(CfxV8Value.Wrap(__retval)); }
/// <summary> /// Associates a value with the specified identifier and returns true (1) on /// success. Returns false (0) if this function is called incorrectly or an /// exception is thrown. For read-only values this function will return true /// (1) even though assignment failed. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public bool SetValue(string key, CfxV8Value value, CfxV8PropertyAttribute attribute) { var key_pinned = new PinnedString(key); var __retval = CfxApi.cfx_v8value_set_value_bykey(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length, CfxV8Value.Unwrap(value), (int)attribute); key_pinned.Obj.Free(); return(0 != __retval); }
/// <summary> /// Create a new CfxV8Value object of type string. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateString(string value) { var value_pinned = new PinnedString(value); var __retval = CfxApi.cfx_v8value_create_string(value_pinned.Obj.PinnedPtr, value_pinned.Length); value_pinned.Obj.Free(); return(CfxV8Value.Wrap(__retval)); }
/// <summary> /// Evaluates the specified JavaScript code using this context's global object. /// On success |retval| will be set to the return value, if any, and the /// function will return true (1). On failure |exception| will be set to the /// exception, if any, and the function will return false (0). /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public bool Eval(string code, out CfxV8Value retval, out CfxV8Exception exception) { var code_pinned = new PinnedString(code); IntPtr retval_ptr; IntPtr exception_ptr; var __retval = CfxApi.cfx_v8context_eval(NativePtr, code_pinned.Obj.PinnedPtr, code_pinned.Length, out retval_ptr, out exception_ptr); code_pinned.Obj.Free(); retval = CfxV8Value.Wrap(retval_ptr); exception = CfxV8Exception.Wrap(exception_ptr); return(0 != __retval); }
internal static void execute(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, int argumentsCount, IntPtr arguments, out IntPtr retval, out IntPtr exception_str, out int exception_length, out IntPtr exception_gc_handle) { var self = (CfxV8Handler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null) { __retval = default(int); retval = default(IntPtr); exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; return; } var e = new CfxV8HandlerExecuteEventArgs(name_str, name_length, @object, arguments, argumentsCount); var eventHandler = self.m_Execute; if (eventHandler != null) { eventHandler(self, e); } e.m_isInvalid = true; if (e.m_object_wrapped == null) { CfxApi.cfx_release(e.m_object); } if (e.m_arguments_managed == null) { for (int i = 0; i < argumentsCount; ++i) { CfxApi.cfx_release(e.m_arguments[i]); } } if (e.m_exception_wrapped != null && e.m_exception_wrapped.Length > 0) { var exception_pinned = new PinnedString(e.m_exception_wrapped); exception_str = exception_pinned.Obj.PinnedPtr; exception_length = exception_pinned.Length; exception_gc_handle = exception_pinned.Obj.ToIntPtr(); } else { exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; } retval = CfxV8Value.Unwrap(e.m_returnValue); __retval = e.m_returnValue != null || e.m_exception_wrapped != null ? 1 : 0; }
internal static void execute(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, out int object_release, UIntPtr argumentsCount, IntPtr arguments, out int arguments_release, out IntPtr retval, out IntPtr exception_str, out int exception_length, out IntPtr exception_gc_handle) { var self = (CfxV8Handler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null || self.CallbacksDisabled) { __retval = default(int); object_release = 1; arguments_release = 1; retval = default(IntPtr); exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; return; } var e = new CfxV8HandlerExecuteEventArgs(); e.m_name_str = name_str; e.m_name_length = name_length; e.m_object = @object; e.m_arguments = new IntPtr[(ulong)argumentsCount]; if (e.m_arguments.Length > 0) { System.Runtime.InteropServices.Marshal.Copy(arguments, e.m_arguments, 0, (int)argumentsCount); } self.m_Execute?.Invoke(self, e); e.m_isInvalid = true; object_release = e.m_object_wrapped == null? 1 : 0; arguments_release = e.m_arguments_managed == null? 1 : 0; if (e.m_exception_wrapped != null && e.m_exception_wrapped.Length > 0) { var exception_pinned = new PinnedString(e.m_exception_wrapped); exception_str = exception_pinned.Obj.PinnedPtr; exception_length = exception_pinned.Length; exception_gc_handle = exception_pinned.Obj.GCHandlePtr(); } else { exception_str = IntPtr.Zero; exception_length = 0; exception_gc_handle = IntPtr.Zero; } retval = CfxV8Value.Unwrap(e.m_returnValue); __retval = e.m_returnValue != null || e.m_exception_wrapped != null ? 1 : 0; }
internal static CfxV8Value Wrap(IntPtr nativePtr) { if (nativePtr == IntPtr.Zero) { return(null); } lock (weakCache) { var wrapper = (CfxV8Value)weakCache.Get(nativePtr); if (wrapper == null) { wrapper = new CfxV8Value(nativePtr); weakCache.Add(wrapper); } else { CfxApi.cfx_release(nativePtr); } return(wrapper); } }
/// <summary> /// Create a new CfxV8Value object of type array with the specified |length|. /// If |length| is negative the returned array will have length 0. This function /// should only be called from within the scope of a /// CfxRenderProcessHandler, CfxV8Handler or CfxV8Accessor callback, /// or in combination with calling enter() and exit() on a stored CfxV8Context /// reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateArray(int length) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_array(length))); }
/// <summary> /// Create a new CfxV8Value object of type ArrayBuffer which wraps the /// provided |buffer| of size |length| bytes. The ArrayBuffer is externalized, /// meaning that it does not own |buffer|. The caller is responsible for freeing /// |buffer| when requested via a call to CfxV8ArrayBufferReleaseCallback:: /// ReleaseBuffer. This function should only be called from within the scope of a /// CfxRenderProcessHandler, CfxV8Handler or CfxV8Accessor callback, /// or in combination with calling enter() and exit() on a stored CfxV8Context /// reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateArrayBuffer(IntPtr buffer, ulong length, CfxV8ArrayBufferReleaseCallback releaseCallback) { return(CfxV8Value.Wrap(CfxApi.V8Value.cfx_v8value_create_array_buffer(buffer, (UIntPtr)length, CfxV8ArrayBufferReleaseCallback.Unwrap(releaseCallback)))); }
/// <summary> /// Create a new CfxV8Value object of type object with optional accessor /// and/or interceptor. This function should only be called from within the scope /// of a CfxRenderProcessHandler, CfxV8Handler or CfxV8Accessor /// callback, or in combination with calling enter() and exit() on a stored /// CfxV8Context reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateObject(CfxV8Accessor accessor, CfxV8Interceptor interceptor) { return(CfxV8Value.Wrap(CfxApi.V8Value.cfx_v8value_create_object(CfxV8Accessor.Unwrap(accessor), CfxV8Interceptor.Unwrap(interceptor)))); }
/// <summary> /// Create a new CfxV8Value object of type int. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateInt(int value) { return(CfxV8Value.Wrap(CfxApi.V8Value.cfx_v8value_create_int(value))); }
/// <summary> /// Create a new CfxV8Value object of type undefined. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateUndefined() { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_undefined())); }
/// <summary> /// Associates a value with the specified identifier and returns true (1) on /// success. Returns false (0) if this function is called incorrectly or an /// exception is thrown. For read-only values this function will return true /// (1) even though assignment failed. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public bool SetValue(int index, CfxV8Value value) { return(0 != CfxApi.cfx_v8value_set_value_byindex(NativePtr, index, CfxV8Value.Unwrap(value))); }
/// <summary> /// Create a new CfxV8Value object of type null. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateNull() { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_null())); }
/// <summary> /// Returns the value with the specified identifier on success. Returns NULL if /// this function is called incorrectly or an exception is thrown. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public CfxV8Value GetValue(int index) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_get_value_byindex(NativePtr, index))); }
/// <summary> /// Create a new CfxV8Value object of type bool. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateBool(bool value) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_bool(value ? 1 : 0))); }
/// <summary> /// Returns true (1) if this object is pointing to the same handle as |that| /// object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public bool IsSame(CfxV8Value that) { return(0 != CfxApi.cfx_v8value_is_same(NativePtr, CfxV8Value.Unwrap(that))); }
/// <summary> /// Create a new CfxV8Value object of type unsigned int. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateUint(uint value) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_uint(value))); }
/// <summary> /// Create a new CfxV8Value object of type double. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateDouble(double value) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_double(value))); }
/// <summary> /// Create a new CfxV8Value object of type object with optional accessor. This /// function should only be called from within the scope of a /// CfxRenderProcessHandler, CfxV8Handler or CfxV8Accessor callback, /// or in combination with calling enter() and exit() on a stored CfxV8Context /// reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateObject(CfxV8Accessor accessor) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_object(CfxV8Accessor.Unwrap(accessor)))); }
/// <summary> /// Create a new CfxV8Value object of type Date. This function should only be /// called from within the scope of a CfxRenderProcessHandler, /// CfxV8Handler or CfxV8Accessor callback, or in combination with calling /// enter() and exit() on a stored CfxV8Context reference. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>. /// </remarks> public static CfxV8Value CreateDate(CfxTime date) { return(CfxV8Value.Wrap(CfxApi.cfx_v8value_create_date(CfxTime.Unwrap(date)))); }