コード例 #1
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public override int CreateNew(int flag, string membername, Holder <Dispatch2> result
                                      , Variant[] param, Dispatch2 objthis)
        {
            // CreateNew
            Dispatch2 dsp = CreateBaseTJSObject();

            // instance initialization
            //int hr = funcCall( 0, null, null, null, dsp); // add member to dsp
            // 生成を高速化するためにメンバコピーを特别处理する形で实装
            dsp.AddClassInstanveInfo(ClassName);
            NativeInstance nativeptr = CreateNativeInstance();

            dsp.SetNativeInstance(ClassId, nativeptr);
            int hr = CopyAllMembers((CustomObject)dsp);

            if (hr < 0)
            {
                return(hr);
            }
            hr = base.FuncCall(0, ClassName, null, param, dsp);
            // call constructor
            // call the constructor
            if (hr == Error.E_MEMBERNOTFOUND)
            {
                hr = Error.S_OK;
            }
            // missing constructor is OK ( is this ugly ? )
            if (hr >= 0)
            {
                result.Set(dsp);
            }
            return(hr);
        }
コード例 #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((NativeInstance.GetHashCode() * 397) ^ DisposedCounter);
     }
 }
コード例 #3
0
ファイル: Signal.cs プロジェクト: zorbathut/greact
            public override int GetHashCode()
            {
                int hashCode = -16276663;

                hashCode = hashCode * -1521134295 + NativeInstance.GetHashCode();
                hashCode = hashCode * -1521134295 + EqualityComparer <PropT> .Default.GetHashCode(props);

                hashCode = hashCode * -1521134295 + EqualityComparer <Action <Godot.Node, PropT> > .Default.GetHashCode(callback);

                return(hashCode);
            }
コード例 #4
0
 public bool Equals(NativeObject other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(NativeInstance.Equals(other.NativeInstance) && IsDisposed == other.IsDisposed);
 }
コード例 #5
0
        /// <summary>
        /// Converts a JavaScript object or value to a JSON string, optionally replacing values if
        /// a <paramref name="replacer"/> function is specified or optionally including only
        /// the specified properties if a <paramref name="replacer"/> array is specified.
        /// </summary>
        /// <param name="replacer">
        /// A function that alters the behavior of the stringification process, or an array of String
        /// and Number that serve as a whitelist for selecting/filtering the properties of the value
        /// object to be included in the JSON string.<para/>
        /// If this value is null or not provided, all properties of the object are included in the
        /// resulting JSON string.
        /// </param>
        /// <param name="space">
        /// The string (or the first 10 characters of the string, if it&apos;s longer than that)
        /// is used as white space. If this parameter is null, no white space is used.
        /// </param>
        /// <returns>The JSON string representing this <see cref="JSValue"/>.</returns>
        public string ToJSON(QuickJSValue replacer, string space)
        {
            if (replacer is null)
            {
                return(NativeInstance.ToJSON(Context.NativeInstance, JSValue.Undefined, space));
            }

            if (!Context.IsCompatibleWith(replacer.Context))
            {
                throw new ArgumentOutOfRangeException(nameof(replacer));
            }

            return(NativeInstance.ToJSON(Context.NativeInstance, replacer.NativeInstance, space));
        }
コード例 #6
0
        /// <summary>
        /// Converts a JavaScript object or value to a JSON string, optionally replacing values if
        /// a <paramref name="replacer"/> function is specified or optionally including only
        /// the specified properties if a <paramref name="replacer"/> array is specified.
        /// </summary>
        /// <param name="replacer">
        /// A function that alters the behavior of the stringification process, or an array of String
        /// and Number that serve as a whitelist for selecting/filtering the properties of the value
        /// object to be included in the JSON string.<para/>
        /// If this value is null or not provided, all properties of the object are included in the
        /// resulting JSON string.
        /// </param>
        /// <param name="space">
        /// Indicates the number of space characters to use as white space;
        /// this number is capped at 10 (if it is greater, the value is just 10).
        /// Values less than 1 indicate that no space should be used.
        /// </param>
        /// <param name="json">
        /// When the method returns, the JSON string representing this <see cref="JSValue"/>.
        /// </param>
        /// <returns>true if the operation is successful; otherwise, false.</returns>
        public bool TryGetJSON(QuickJSValue replacer, int space, out string json)
        {
            if (replacer is null)
            {
                return(NativeInstance.TryGetJSON(Context.NativeInstance, JSValue.Undefined, space, out json));
            }

            if (!Context.IsCompatibleWith(replacer.Context))
            {
                throw new ArgumentOutOfRangeException(nameof(replacer));
            }

            return(NativeInstance.TryGetJSON(Context.NativeInstance, replacer.NativeInstance, space, out json));
        }
コード例 #7
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public override int FuncCall(int flag, string membername, Variant result, Variant
                                     [] param, Dispatch2 objthis)
        {
            if (!GetValidity())
            {
                return(Error.E_INVALIDOBJECT);
            }
            if (membername != null)
            {
                return(base.FuncCall(flag, membername, result, param, objthis));
            }
            // 生成を高速化するためにメンバコピーを特别处理する形で实装
            objthis.AddClassInstanveInfo(ClassName);
            NativeInstance nativeptr = CreateNativeInstance();

            objthis.SetNativeInstance(ClassId, nativeptr);
            int hr = CopyAllMembers((CustomObject)objthis);

            if (hr < 0)
            {
                return(hr);
            }
            return(Error.S_OK);
        }
コード例 #8
0
 public bool Equals(NativeObject other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return NativeInstance.Equals(other.NativeInstance) && IsDisposed == other.IsDisposed;
 }
コード例 #9
0
 /// <summary>
 /// Converts a JavaScript object or value to a JSON string.
 /// </summary>
 /// <param name="json">
 /// When the method returns, the JSON string representing this <see cref="JSValue"/>.
 /// </param>
 /// <returns>true if the operation is successful; otherwise, false.</returns>
 public bool TryGetJSON(out string json)
 {
     return(NativeInstance.TryGetJSON(Context.NativeInstance, out json));
 }
コード例 #10
0
 /// <summary>
 /// Converts a JavaScript object or value to a JSON string.
 /// </summary>
 /// <returns>The JSON string representing this <see cref="JSValue"/>.</returns>
 public string ToJSON()
 {
     return(NativeInstance.ToJSON(Context.NativeInstance));
 }
コード例 #11
0
        public virtual int SetNativeInstance(int classid, NativeInstance ni)
        {
            Holder <NativeInstance> holder = new Holder <NativeInstance>(ni);

            return(NativeInstanceSupport(Interface.NIS_REGISTER, classid, holder));
        }
コード例 #12
0
 public virtual int SetNativeInstance(int classid, NativeInstance ni)
 {
     return(Error.E_NOTIMPL);
 }
コード例 #13
0
ファイル: ObjectProxy.cs プロジェクト: fantasydr/krkr-cs
 public virtual int SetNativeInstance(int classid, NativeInstance ni)
 {
     return Error.E_NOTIMPL;
 }
コード例 #14
0
ファイル: Dispatch.cs プロジェクト: fantasydr/krkr-cs
 public virtual int SetNativeInstance(int classid, NativeInstance ni)
 {
     Holder<NativeInstance> holder = new Holder<NativeInstance>(ni);
     return NativeInstanceSupport(Interface.NIS_REGISTER, classid, holder);
 }
コード例 #15
0
ファイル: CustomObject.cs プロジェクト: fantasydr/krkr-cs
 //if(TJSObjectHashMapEnabled()) TJSRemoveObjectHashRecord(this);
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal virtual void FinalizeObject()
 {
     // call this object's "finalize"
     if (mCallFinalize && TJS.IsTarminating == false)
     {
         //funcCall( 0, mfinalize_name, mfinalize_name.hashCode(), null, 0, null, this );
         FuncCall(0, mfinalize_name, null, TJS.NULL_ARG, this);
     }
     for (int i = MAX_NATIVE_CLASS - 1; i >= 0; i--)
     {
         if (mClassIDs[i] != -1)
         {
             if (mClassInstances[i] != null)
             {
                 mClassInstances[i].Invalidate();
             }
         }
     }
     mPrimaryClassInstances = null;
     DeleteAllMembers();
 }
コード例 #16
0
ファイル: CustomObject.cs プロジェクト: fantasydr/krkr-cs
 public override int NativeInstanceSupport(int flag, int classid, Holder<NativeInstance
     > pointer)
 {
     if (flag == Interface.NIS_GETINSTANCE)
     {
         // search "classid"
         for (int i = 0; i < MAX_NATIVE_CLASS; i++)
         {
             if (mClassIDs[i] == classid)
             {
                 pointer.mValue = mClassInstances[i];
                 return Error.S_OK;
             }
         }
         return Error.E_FAIL;
     }
     else
     {
         if (flag == Interface.NIS_REGISTER)
         {
             // search for the empty place
             if (mPrimaryClassID == -1)
             {
                 mPrimaryClassID = classid;
                 mPrimaryClassInstances = pointer.mValue;
             }
             for (int i = 0; i < MAX_NATIVE_CLASS; i++)
             {
                 if (mClassIDs[i] == -1)
                 {
                     // found... writes there
                     mClassIDs[i] = classid;
                     mClassInstances[i] = pointer.mValue;
                     return Error.S_OK;
                 }
             }
             return Error.E_FAIL;
         }
     }
     return Error.E_NOTIMPL;
 }
コード例 #17
0
 public override int GetHashCode()
 {
     return(NativeInstance.GetHashCode() * 397);
 }
コード例 #18
0
ファイル: CustomObject.cs プロジェクト: fantasydr/krkr-cs
 public override int SetNativeInstance(int classid, NativeInstance ni)
 {
     // search for the empty place
     if (mPrimaryClassID == -1)
     {
         mPrimaryClassID = classid;
         mPrimaryClassInstances = ni;
     }
     for (int i = 0; i < MAX_NATIVE_CLASS; i++)
     {
         if (mClassIDs[i] == -1)
         {
             // found... writes there
             mClassIDs[i] = classid;
             mClassInstances[i] = ni;
             return Error.S_OK;
         }
     }
     return Error.E_FAIL;
 }