コード例 #1
0
        /// <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. On failure |exception| will be set to the
        /// exception, if any, and the function will return false.
        /// </summary>
        public bool Eval(string code, out CefV8Value retval, out CefV8Exception exception)
        {
            cef_v8value_t* n_retval = null;
            cef_v8exception_t* n_exception = null;
            fixed (char* code_str = code)
            {
                var n_code = new cef_string_t(code_str, code != null ? code.Length : 0);

                var n_result = cef_v8context_t.invoke_eval(this.ptr, &n_code, &n_retval, &n_exception);
                if (n_result != 0)
                {
                    retval = CefV8Value.From(n_retval);
                    exception = null;
                    return true;
                }
                else
                {
                    retval = null;
                    exception = CefV8Exception.From(n_exception);
                    return false;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Execute with the specified argument list and return value. Return
        /// true if the method was handled. To invoke V8 callback functions
        /// outside the scope of this method you need to keep references to the
        /// current V8 context (CefV8Context) along with any necessary callback
        /// objects.
        /// </summary>
        internal virtual int execute(cef_v8handler_t* self, /*const*/ cef_string_t* name, cef_v8value_t* @object, int argumentCount, cef_v8value_t* /*const*/ * arguments, cef_v8value_t** retval, cef_string_t* exception)
        {
            ThrowIfObjectDisposed();

            var m_name = cef_string_t.ToString(name);
            var m_obj = CefV8Value.From(@object);
            CefV8Value[] m_arguments;
            if (argumentCount == 0) { m_arguments = null; }
            else
            {
                m_arguments = new CefV8Value[argumentCount];
                for (var i = 0; i < argumentCount; i++)
                {
                    m_arguments[i] = CefV8Value.From(arguments[i]);
                }
            }

            CefV8Value m_returnValue;
            string m_exception;

            var handled = this.Execute(m_name, m_obj, m_arguments, out m_returnValue, out m_exception);

            if (handled)
            {
                if (m_exception != null)
                {
                    cef_string_t.Copy(m_exception, exception);
                }
                else if (m_returnValue != null)
                {
                    *retval = m_returnValue.GetNativePointerAndAddRef();
                }
            }

            return handled ? 1 : 0;
        }
コード例 #3
0
 /// <summary>
 /// Create a new CefV8Value object of type double.
 /// </summary>
 public static CefV8Value CreateDouble(double value)
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_double(value)
                ));
 }
コード例 #4
0
 /// <summary>
 /// Associates a value with the specified identifier and returns true on
 /// success. Returns false if this method is called incorrectly or an exception
 /// is thrown. For read-only values this method will return true even though
 /// assignment failed.
 /// </summary>
 public bool SetValue(int index, CefV8Value value)
 {
     ThrowIfObjectIsInvalid();
     return cef_v8value_t.invoke_set_value_byindex(this.ptr, index, value.GetNativePointerAndAddRef()) != 0;
 }
コード例 #5
0
 /// <summary>
 /// Create a new CefV8Value object of type unsigned int.
 /// </summary>
 public static CefV8Value CreateUInt(uint value)
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_uint(value)
                ));
 }
コード例 #6
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static sbyte ToSByte(CefV8Value value)
 {
     return(ToSByte(value.NativePointer));
 }
コード例 #7
0
 /// <summary>
 /// Called to set an accessor value.
 /// |name| is the name of the property being accessed.
 /// |value| is the new value being assigned to this property.
 /// |object| is the This() object from V8's AccessorInfo structure.
 /// Return true if handled.
 /// </summary>
 protected virtual bool Set(string name, CefV8Value obj, CefV8Value value, out string exception)
 {
     exception = null;
     return false;
 }
コード例 #8
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static float? ToNullableSingle(CefV8Value value)
 {
     return ToNullableSingle(value.NativePointer);
 }
コード例 #9
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static string ToString(CefV8Value value)
 {
     return ToString(value.NativePointer);
 }
コード例 #10
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static bool?ToNullableBoolean(CefV8Value value)
 {
     return(ToNullableBoolean(value.NativePointer));
 }
コード例 #11
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static int?ToNullableInt32(CefV8Value value)
 {
     return(ToNullableInt32(value.NativePointer));
 }
コード例 #12
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static char ToChar(CefV8Value value)
 {
     return(ToChar(value.NativePointer));
 }
コード例 #13
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static float ToSingle(CefV8Value value)
 {
     return(ToSingle(value.NativePointer));
 }
コード例 #14
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static CefV8Value ToV8Value(ushort value)
 {
     return(CefV8Value.From(ToNativeV8Value(value)));
 }
コード例 #15
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static ushort ToUInt16(CefV8Value value)
 {
     return(ToUInt16(value.NativePointer));
 }
コード例 #16
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static CefV8Value ToV8Value(sbyte value)
 {
     return(CefV8Value.From(ToNativeV8Value(value)));
 }
コード例 #17
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static DateTime? ToNullableDateTime(CefV8Value value)
 {
     return ToNullableDateTime(value.NativePointer);
 }
コード例 #18
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static int ToInt32(CefV8Value value)
 {
     return(ToInt32(value.NativePointer));
 }
コード例 #19
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static int? ToNullableInt32(CefV8Value value)
 {
     return ToNullableInt32(value.NativePointer);
 }
コード例 #20
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static double?ToNullableDouble(CefV8Value value)
 {
     return(ToNullableDouble(value.NativePointer));
 }
コード例 #21
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static object ToObject(CefV8Value value)
 {
     return ToObject(value.NativePointer);
 }
コード例 #22
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static DateTime?ToNullableDateTime(CefV8Value value)
 {
     return(ToNullableDateTime(value.NativePointer));
 }
コード例 #23
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static byte ToByte(CefV8Value value)
 {
     return ToByte(value.NativePointer);
 }
コード例 #24
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static CefV8Value ToV8Value(DateTime?value)
 {
     return(CefV8Value.From(ToNativeV8Value(value)));
 }
コード例 #25
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static bool? ToNullableBoolean(CefV8Value value)
 {
     return ToNullableBoolean(value.NativePointer);
 }
コード例 #26
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static sbyte?ToNullableSByte(CefV8Value value)
 {
     return(ToNullableSByte(value.NativePointer));
 }
コード例 #27
0
 /// <summary>
 /// Returns true if this object is pointing to the same handle as |that| object.
 /// </summary>
 public bool IsSame(CefV8Value that)
 {
     ThrowIfObjectIsInvalid();
     return cef_v8value_t.invoke_is_same(this.ptr, that.GetNativePointerAndAddRef()) != 0;
 }
コード例 #28
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static ushort?ToNullableUInt16(CefV8Value value)
 {
     return(ToNullableUInt16(value.NativePointer));
 }
コード例 #29
0
 /// <summary>
 /// Execute with the specified argument list and return value.
 /// Return true if the method was handled.
 /// To invoke V8 callback functions outside the scope of this method you need to keep references to the current V8 context (CefV8Context) along with any necessary callback objects.
 /// </summary>
 protected virtual bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
 {
     returnValue = null;
     exception = null;
     return false;
 }
コード例 #30
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static char?ToNullableChar(CefV8Value value)
 {
     return(ToNullableChar(value.NativePointer));
 }
コード例 #31
0
 /// <summary>
 /// Associates a value with the specified identifier and returns true on
 /// success. Returns false if this method is called incorrectly or an exception
 /// is thrown. For read-only values this method will return true even though
 /// assignment failed.
 /// </summary>
 public bool SetValue(int index, CefV8Value value)
 {
     ThrowIfObjectIsInvalid();
     return(cef_v8value_t.invoke_set_value_byindex(this.ptr, index, value.GetNativePointerAndAddRef()) != 0);
 }
コード例 #32
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static double ToDouble(CefV8Value value)
 {
     return(ToDouble(value.NativePointer));
 }
コード例 #33
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static char? ToNullableChar(CefV8Value value)
 {
     return ToNullableChar(value.NativePointer);
 }
コード例 #34
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static float?ToNullableSingle(CefV8Value value)
 {
     return(ToNullableSingle(value.NativePointer));
 }
コード例 #35
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static double? ToNullableDouble(CefV8Value value)
 {
     return ToNullableDouble(value.NativePointer);
 }
コード例 #36
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static CefV8Value ToV8Value(float?value)
 {
     return(CefV8Value.From(ToNativeV8Value(value)));
 }
コード例 #37
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static sbyte? ToNullableSByte(CefV8Value value)
 {
     return ToNullableSByte(value.NativePointer);
 }
コード例 #38
0
 /// <summary>
 /// Returns the global object for this context. The context must be entered
 /// before calling this method.
 /// </summary>
 public CefV8Value GetGlobal()
 {
     return(CefV8Value.From(
                cef_v8context_t.invoke_get_global(this.ptr)
                ));
 }
コード例 #39
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static ushort? ToNullableUInt16(CefV8Value value)
 {
     return ToNullableUInt16(value.NativePointer);
 }
コード例 #40
0
 /// <summary>
 /// Execute with the specified argument list and return value.
 /// Return true if the method was handled.
 /// To invoke V8 callback functions outside the scope of this method you need to keep references to the current V8 context (CefV8Context) along with any necessary callback objects.
 /// </summary>
 protected virtual bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
 {
     returnValue = null;
     exception   = null;
     return(false);
 }
コード例 #41
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static float ToSingle(CefV8Value value)
 {
     return ToSingle(value.NativePointer);
 }
コード例 #42
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static DateTime ToDateTime(CefV8Value value)
 {
     return ToDateTime(value.NativePointer);
 }
コード例 #43
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static bool ToBoolean(CefV8Value value)
 {
     return ToBoolean(value.NativePointer);
 }
コード例 #44
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static short ToInt16(CefV8Value value)
 {
     return ToInt16(value.NativePointer);
 }
コード例 #45
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static char ToChar(CefV8Value value)
 {
     return ToChar(value.NativePointer);
 }
コード例 #46
0
ファイル: CefConvert.cs プロジェクト: PlumpMath/cefglue-5
 public static DateTime ToDateTime(CefV8Value value)
 {
     return(ToDateTime(value.NativePointer));
 }
コード例 #47
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static double ToDouble(CefV8Value value)
 {
     return ToDouble(value.NativePointer);
 }
コード例 #48
0
 /// <summary>
 /// Create a new CefV8Value object of type undefined.
 /// </summary>
 public static CefV8Value CreateUndefined()
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_undefined()
                ));
 }
コード例 #49
0
ファイル: CefConvert.cs プロジェクト: yasoonOfficial/cefglue
 public static int ToInt32(CefV8Value value)
 {
     return ToInt32(value.NativePointer);
 }
コード例 #50
0
 /// <summary>
 /// Create a new CefV8Value object of type object with accessors.
 /// </summary>
 public static CefV8Value CreateObject(CefV8Accessor accessor)
 {
     return(CefV8Value.From(NativeMethods.cef_v8value_create_object(
                                accessor != null ? accessor.GetNativePointerAndAddRef() : null
                                )));
 }
コード例 #51
0
 /// <summary>
 /// Called to get an accessor value.
 /// |name| is the name of the property being accessed.
 /// |object| is the This() object from V8's AccessorInfo structure.
 /// |retval| is the value to return for this property.
 /// Return true if handled.
 /// </summary>
 protected virtual bool Get(string name, CefV8Value obj, out CefV8Value returnValue, out string exception)
 {
     returnValue = null;
     exception = null;
     return false;
 }
コード例 #52
0
 /// <summary>
 /// Create a new CefV8Value object of type array.
 /// </summary>
 public static CefV8Value CreateArray(int length)
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_array(length)
                ));
 }
コード例 #53
0
        /// <summary>
        /// Execute the function using the specified V8 context. |object| is the
        /// receiver ('this' object) of the function. If |object| is empty 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 method is called incorrectly or an
        /// exception is thrown.
        /// </summary>
        public CefV8Value ExecuteFunctionWithContext(CefV8Context context, CefV8Value obj, CefV8Value[] arguments)
        {
            ThrowIfObjectIsInvalid();
            var n_arguments = CreateArgumentsArray(arguments);

            fixed (cef_v8value_t** n_arguments_ptr = n_arguments)
            {
                return CefV8Value.FromOrDefault(
                    cef_v8value_t.invoke_execute_function_with_context(
                        this.ptr,
                        context.GetNativePointerAndAddRef(),
                        obj.GetNativePointerAndAddRef(),
                        n_arguments != null ? n_arguments.Length : 0,
                        n_arguments_ptr
                    )
                );
            }
        }
コード例 #54
0
 /// <summary>
 /// Create a new CefV8Value object of type null.
 /// </summary>
 public static CefV8Value CreateNull()
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_null()
                ));
 }
コード例 #55
0
        /// <summary>
        /// Associates a value with the specified identifier and returns true on
        /// success. Returns false if this method is called incorrectly or an exception
        /// is thrown. For read-only values this method will return true even though
        /// assignment failed.
        /// </summary>
        public bool SetValue(string key, CefV8Value value, CefV8PropertyAttribute attribute = CefV8PropertyAttribute.None)
        {
            ThrowIfObjectIsInvalid();
            fixed (char* key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return cef_v8value_t.invoke_set_value_bykey(this.ptr, &n_key, value.GetNativePointerAndAddRef(), (cef_v8_propertyattribute_t)attribute) != 0;
            }
        }
コード例 #56
0
 /// <summary>
 /// Create a new CefV8Value object of type bool.
 /// </summary>
 public static CefV8Value CreateBool(bool value)
 {
     return(CefV8Value.From(
                NativeMethods.cef_v8value_create_bool(value ? 1 : 0)
                ));
 }
コード例 #57
0
        private static cef_v8value_t*[] CreateArgumentsArray(CefV8Value[] arguments)
        {
            if (arguments == null) return null;

            var length = arguments.Length;
            if (length == 0) return null;

            var result = new cef_v8value_t*[arguments.Length];

            for (var i = 0; i < length; i++)
            {
                result[i] = arguments[i].GetNativePointerAndAddRef();
            }

            return result;
        }
コード例 #58
0
 /// <summary>
 /// Returns true if this object is pointing to the same handle as |that| object.
 /// </summary>
 public bool IsSame(CefV8Value that)
 {
     ThrowIfObjectIsInvalid();
     return(cef_v8value_t.invoke_is_same(this.ptr, that.GetNativePointerAndAddRef()) != 0);
 }