Beispiel #1
0
        /// <summary>
        /// Execute a string of JavaScript code in this V8 context. The |script_url|
        /// parameter is the URL where the script in question can be found, if any. The
        /// |start_line| parameter is the base line number to use for error reporting.
        /// 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>
        public unsafe virtual bool Eval(string code, string scriptUrl, int startLine, ref CefV8Value retval, ref CefV8Exception exception)
        {
            fixed(char *s0 = code)
            fixed(char *s1 = scriptUrl)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = code != null ? code.Length : 0
                };
                var cstr1 = new cef_string_t {
                    Str = s1, Length = scriptUrl != null ? scriptUrl.Length : 0
                };
                cef_v8value_t *     p3  = (retval != null) ? retval.GetNativeInstance() : null;
                cef_v8value_t **    pp3 = &p3;
                cef_v8exception_t * p4  = (exception != null) ? exception.GetNativeInstance() : null;
                cef_v8exception_t **pp4 = &p4;
                var rv = NativeInstance->Eval(&cstr0, &cstr1, startLine, pp3, pp4) != 0;

                retval    = CefV8Value.Wrap(CefV8Value.Create, p3);
                exception = CefV8Exception.Wrap(CefV8Exception.Create, p4);
                GC.KeepAlive(this);
                return(rv);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Execute the function without arguments using the current V8 context.<para/>
 /// This function should only be called from within the scope of a <see cref="CefV8Handler"/>
 /// or <see cref="CefV8Accessor"/> callback, or in combination with calling
 /// <see cref="CefV8Context.Enter"/> and <see cref="CefV8Context.Enter"/>
 /// on a stored <see cref="CefV8Context"/> reference.
 /// </summary>
 /// <param name="thisArg">
 /// The receiver (&apos;this&apos; object) of the function. If <paramref name="thisArg"/>
 /// is null the current context&apos;s global objectwill be used.
 /// </param>
 /// <returns>
 /// Returns the function return value on success, or null if this function
 /// is called incorrectly or an exception is thrown.
 /// </returns>
 public unsafe virtual CefV8Value ExecuteFunction(CefV8Value thisArg)
 {
     return(SafeCall(CefV8Value.Wrap(CefV8Value.Create, NativeInstance->ExecuteFunction(thisArg != null ? thisArg.GetNativeInstance() : null, new UIntPtr(), null))));
 }
Beispiel #3
0
        /// <summary>
        /// Execute the function using the specified V8 context. |object| is the
        /// receiver (&apos;this&apos; object) of the function. If |object| is NULL the specified
        /// context&apos;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>
        public unsafe virtual CefV8Value ExecuteFunctionWithContext(CefV8Context context, CefV8Value @object, CefV8Value[] arguments)
        {
            cef_v8value_t **arr3 = (cef_v8value_t **)Marshal.AllocHGlobal(sizeof(cef_v8value_t *) * arguments.Length);

            for (int i = 0; i < arguments.Length; i++)
            {
                var e3 = arguments[i];
                *(arr3 + i) = e3 != null?e3.GetNativeInstance() : null;
            }
            var rv = CefV8Value.Wrap(CefV8Value.Create, NativeInstance->ExecuteFunctionWithContext((context != null) ? context.GetNativeInstance() : null, (@object != null) ? @object.GetNativeInstance() : null, new UIntPtr((uint)arguments.Length), arr3));

            Marshal.FreeHGlobal((IntPtr)arr3);
            GC.KeepAlive(this);
            return(rv);
        }
Beispiel #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>
 public unsafe virtual bool SetValueByIndex(int index, CefV8Value value)
 {
     return(SafeCall(NativeInstance->SetValueByIndex(index, (value != null) ? value.GetNativeInstance() : null) != 0));
 }
Beispiel #5
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>
        public unsafe virtual bool SetValueByKey(string key, CefV8Value value, CefV8PropertyAttribute attribute)
        {
            fixed(char *s0 = key)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = key != null ? key.Length : 0
                };

                return(SafeCall(NativeInstance->SetValueByKey(&cstr0, (value != null) ? value.GetNativeInstance() : null, attribute) != 0));
            }
        }
Beispiel #6
0
 /// <summary>
 /// Returns true (1) if this object is pointing to the same handle as |that|
 /// object.
 /// </summary>
 public unsafe virtual bool IsSame(CefV8Value that)
 {
     return(SafeCall(NativeInstance->IsSame((that != null) ? that.GetNativeInstance() : null) != 0));
 }