internal unsafe override int set(cef_v8accessor_t* self, cef_string_t* name, cef_v8value_t* @object, cef_v8value_t* value, cef_string_t* exception)
        {
            var prop = this.dispatchTable.GetOrDefault(name);
            if (prop == null) return 0;

            var method = prop.SetMethod;
            if (method == null) return 0;

            var instance = this.instance;
            if (instance == null)
            {
                // TODO: self must be got from obj's userdata
                throw new NotImplementedException();
            }

            try
            {
                method.Invoke(instance, 1, &value, null);
            }
            catch (Exception ex)
            {
                // TODO: how exceptions must be formatted ?
                cef_string_t.Copy(ex.ToString(), exception);
            }

            // TODO: this pointer must be typed
            cef_v8value_t.invoke_release((cef_base_t*)@object);
            cef_v8value_t.invoke_release((cef_base_t*)value);

            return 1;
        }
        /// <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>
        internal virtual int get(cef_v8accessor_t* self, /*const*/ cef_string_t* name, cef_v8value_t* @object, 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_returnValue;
            string mException;

            var handled = this.Get(m_name, m_obj, out m_returnValue, out mException);

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

            return handled ? 1 : 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>
        internal virtual int set(cef_v8accessor_t* self, /*const*/ cef_string_t* name, cef_v8value_t* @object, cef_v8value_t* value, cef_string_t* exception)
        {
            ThrowIfObjectDisposed();

            var m_name = cef_string_t.ToString(name);
            var m_obj = CefV8Value.From(@object);
            var m_value = CefV8Value.From(value);
            string mException;

            var handled = this.Set(m_name, m_obj, m_value, out mException);

            if (handled)
            {
                if (mException != null)
                {
                    cef_string_t.Copy(mException, exception);
                }
            }

            return handled ? 1 : 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;
        }
Example #5
0
        internal unsafe void Invoke(object instance, int argumentsCount, cef_v8value_t** arguments, cef_v8value_t** retval)
        {
            if (!this.Compiled)
            {
                this.Compile();
            }

            this.invoker(instance, argumentsCount, arguments, retval);
        }
Example #6
0
 internal static int? ToNullableInt32(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         return cef_v8value_t.invoke_get_int_value(value);
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #7
0
 internal static string ToString(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_string(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_string_value(value);
         return cef_string_userfree.GetStringAndFree(nResult);
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
              || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #8
0
 internal static ushort ToUInt16(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         checked
         {
             return (ushort)cef_v8value_t.invoke_get_int_value(value);
         }
     }
     else throw new InvalidCastException();
 }
Example #9
0
 internal static sbyte ToSByte(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         checked
         {
             return (sbyte)cef_v8value_t.invoke_get_int_value(value);
         }
     }
     else throw new InvalidCastException();
 }
Example #10
0
 internal static float ToSingle(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_double(value) != 0
         || cef_v8value_t.invoke_is_int(value) != 0)
     {
         return (float)cef_v8value_t.invoke_get_double_value(value);
     }
     else throw new InvalidCastException();
 }
Example #11
0
 internal static ushort? ToNullableUInt16(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         checked
         {
             return (ushort)cef_v8value_t.invoke_get_int_value(value);
         }
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #12
0
 internal static object ToObject(cef_v8value_t* value)
 {
     // TODO: CefConvert.ToObject - do test order from usage
     if (cef_v8value_t.invoke_is_bool(value) != 0)
     {
         return cef_v8value_t.invoke_get_bool_value(value) != 0;
     }
     else if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         return cef_v8value_t.invoke_get_int_value(value);
     }
     else if (cef_v8value_t.invoke_is_string(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_string_value(value);
         return cef_string_userfree.GetStringAndFree(nResult);
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0 || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else if (cef_v8value_t.invoke_is_double(value) != 0)
     {
         return cef_v8value_t.invoke_get_double_value(value);
     }
     else if (cef_v8value_t.invoke_is_date(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_date_value(value);
         return nResult.ToDateTime();
     }
     else throw new InvalidCastException();
 }
Example #13
0
 internal static bool ToBoolean(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_bool(value) != 0)
     {
         return cef_v8value_t.invoke_get_bool_value(value) != 0;
     }
     else throw new InvalidCastException();
 }
Example #14
0
 internal static float? ToNullableSingle(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_double(value) != 0
         || cef_v8value_t.invoke_is_int(value) != 0)
     {
         return (float)cef_v8value_t.invoke_get_double_value(value);
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #15
0
 internal static DateTime? ToNullableDateTime(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_date(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_date_value(value);
         return nResult.ToDateTime();
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #16
0
 internal static char? ToNullableChar(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         checked
         {
             return (char)cef_v8value_t.invoke_get_int_value(value);
         }
     }
     else if (cef_v8value_t.invoke_is_string(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_string_value(value);
         if (cef_string_userfree.GetLength(nResult) == 1)
         {
             var result = cef_string_userfree.GetFirstCharOrDefault(nResult);
             cef_string_userfree.Free(nResult);
             return result;
         }
         else
         {
             cef_string_userfree.Free(nResult);
             throw new InvalidCastException();
         }
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #17
0
 internal static bool? ToNullableBoolean(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_bool(value) != 0)
     {
         return cef_v8value_t.invoke_get_bool_value(value) != 0;
     }
     else if (cef_v8value_t.invoke_is_null(value) != 0
         || cef_v8value_t.invoke_is_undefined(value) != 0)
     {
         return null;
     }
     else throw new InvalidCastException();
 }
Example #18
0
 internal static int ToInt32(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_int(value) != 0)
     {
         return cef_v8value_t.invoke_get_int_value(value);
     }
     else throw new InvalidCastException();
 }
Example #19
0
 internal static DateTime ToDateTime(cef_v8value_t* value)
 {
     if (cef_v8value_t.invoke_is_date(value) != 0)
     {
         var nResult = cef_v8value_t.invoke_get_date_value(value);
         return nResult.ToDateTime();
     }
     else throw new InvalidCastException();
 }