Ejemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (_self != null)
     {
         cef_v8accessor_t.Free(_self);
         _self = null;
     }
 }
Ejemplo n.º 2
0
 protected CefV8Accessor()
 {
     _self = cef_v8accessor_t.Alloc();
 
     _ds0 = new cef_v8accessor_t.add_ref_delegate(add_ref);
     _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
     _ds1 = new cef_v8accessor_t.release_delegate(release);
     _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
     _ds2 = new cef_v8accessor_t.has_one_ref_delegate(has_one_ref);
     _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
     _ds3 = new cef_v8accessor_t.get_delegate(get);
     _self->_get = Marshal.GetFunctionPointerForDelegate(_ds3);
     _ds4 = new cef_v8accessor_t.set_delegate(set);
     _self->_set = Marshal.GetFunctionPointerForDelegate(_ds4);
 }
Ejemplo n.º 3
0
        protected CefV8Accessor()
        {
            _self = cef_v8accessor_t.Alloc();

            _ds0 = new cef_v8accessor_t.add_ref_delegate(add_ref);
            _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
            _ds1 = new cef_v8accessor_t.release_delegate(release);
            _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
            _ds2 = new cef_v8accessor_t.has_one_ref_delegate(has_one_ref);
            _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
            _ds3 = new cef_v8accessor_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
            _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
            _ds4        = new cef_v8accessor_t.get_delegate(get);
            _self->_get = Marshal.GetFunctionPointerForDelegate(_ds4);
            _ds5        = new cef_v8accessor_t.set_delegate(set);
            _self->_set = Marshal.GetFunctionPointerForDelegate(_ds5);
        }
        private int set(cef_v8accessor_t *self, cef_string_t *name, cef_v8value_t * @object, cef_v8value_t *value, cef_string_t *exception)
        {
            CheckSelf(self);

            var    m_name  = cef_string_t.ToString(name);
            var    m_obj   = CefV8Value.FromNative(@object);
            var    m_value = CefV8Value.FromNative(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);
        }
Ejemplo n.º 5
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);
        }
        internal override unsafe 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);
        }
Ejemplo n.º 7
0
 private int get_refct(cef_v8accessor_t *self)
 {
     return(_refct);
 }
Ejemplo n.º 8
0
 private int has_one_ref(cef_v8accessor_t *self)
 {
     lock (SyncRoot) { return(_refct == 1 ? 1 : 0); }
 }
Ejemplo n.º 9
0
 public static extern cef_v8value_t *create_object(cef_v8accessor_t *accessor);
Ejemplo n.º 10
0
 public CefV8Accessor(cef_v8accessor_t *instance)
     : base((cef_base_ref_counted_t *)instance)
 {
 }
Ejemplo n.º 11
0
 internal static void Free(cef_v8accessor_t *ptr)
 {
     Marshal.FreeHGlobal((IntPtr)ptr);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Handle retrieval the accessor value identified by |name|. |object| is the
        /// receiver ('this' object) of the accessor. If retrieval succeeds set
        /// |retval| to the return value. If retrieval fails set |exception| to the
        /// exception that will be thrown. Return true if accessor retrieval was
        /// handled.
        /// </summary>
        // protected abstract int Get(cef_string_t* name, cef_v8value_t* @object, cef_v8value_t** retval, cef_string_t* exception);

        private int set(cef_v8accessor_t *self, cef_string_t *name, cef_v8value_t * @object, cef_v8value_t *value, cef_string_t *exception)
        {
            CheckSelf(self);
            throw new NotImplementedException(); // TODO: CefV8Accessor.Set
        }
 /// <summary>
 /// Create a new CefV8Value object of type object with optional accessor. This
 /// method should only be called from within the scope of a
 /// CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
 /// combination with calling Enter() and Exit() on a stored CefV8Context
 /// reference.
 /// </summary>
 public static cef_v8value_t *CreateObject(cef_v8accessor_t *accessor)
 {
     throw new NotImplementedException(); // TODO: CefV8Value.CreateObject
 }
Ejemplo n.º 14
0
 private int has_at_least_one_ref(cef_v8accessor_t *self)
 {
     lock (SyncRoot) { return(_refct != 0 ? 1 : 0); }
 }