Пример #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.AddClassInstanceInfo(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
 /// <exception cref="VariantException"></exception>
 protected internal static void AddClassInstanceInfo(Dispatch2 dsp, string className
                                                     )
 {
     if (dsp != null)
     {
         dsp.AddClassInstanceInfo(className);
     }
 }
Пример #3
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.AddClassInstanceInfo(ClassName);
            NativeInstance nativeptr = CreateNativeInstance();

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

            if (hr < 0)
            {
                return(hr);
            }
            return(Error.S_OK);
        }