Ejemplo n.º 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(name_str, name_length, @object, arguments, 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;
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
 /// <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)));
 }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
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)));
 }
Ejemplo n.º 6
0
        /// <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));
        }