Пример #1
0
            /// <exception cref="VariantException"></exception>
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                Variant val = new Variant(string.Empty);

                if ((param.Length > 0) ? param[0].IsVoid() != true : false)
                {
                    val.CopyRef(param[0]);
                }
                string message_name = "message";

                objthis.PropSet(Interface.MEMBERENSURE, message_name, val, objthis);
                if ((param.Length > 1) ? param[1].IsVoid() != true : false)
                {
                    val.CopyRef(param[1]);
                }
                else
                {
                    val.Set(string.Empty);
                }
                string trace_name = "trace";

                objthis.PropSet(Interface.MEMBERENSURE, trace_name, val, objthis);
                return(Error.S_OK);
            }
Пример #2
0
            //private Callback mCallback;
            //private VariantClosure mCallbackClosure;
            // a class to receive member callback from class
            // destination object
            /// <exception cref="VariantException"></exception>
            /// <exception cref="TjsException"></exception>
            public override int FuncCall(int flag, string membername, Variant result, Variant
                                         [] param, Dispatch2 objthis)
            {
                // *param[0] = name   *param[1] = flags   *param[2] = value
                int flags = param[1].AsInteger();

                if ((flags & Interface.STATICMEMBER) == 0)
                {
                    Variant val = new Variant(param[2]);
                    if (val.IsObject())
                    {
                        // change object's objthis if the object's objthis is null
                        if (val.AsObjectThis() == null)
                        {
                            val.ChangeClosureObjThis(mDest);
                        }
                    }
                    mDest.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP | flags, param[0].AsString
                                      (), val, mDest);
                }
                if (result != null)
                {
                    result.Set(1);
                }
                // returns true
                return(Error.S_OK);
            }
Пример #3
0
 /// <exception cref="TjsException"></exception>
 /// <exception cref="VariantException"></exception>
 public virtual int PropSet(int flag, string mumberName, Variant param, Dispatch2
                            objThis)
 {
     if (mObject == null)
     {
         throw new TjsException(Error.NullAccess);
     }
     return(mObject.PropSet(flag, mumberName, param, mObjThis != null ? mObjThis : (objThis
                                                                                    != null ? objThis : mObject)));
 }
Пример #4
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public virtual int PropSet(int flag, string membername, Variant param, Dispatch2
                                   objthis)
        {
            Dispatch2 OBJ1 = ((objthis != null) ? (objthis) : (mDispatch1));
            int       hr   = mDispatch1.PropSet(flag, membername, param, OBJ1);

            if (hr == Error.E_MEMBERNOTFOUND && mDispatch1 != mDispatch2)
            {
                Dispatch2 OBJ2 = ((objthis != null) ? (objthis) : (mDispatch2));
                return(mDispatch2.PropSet(flag, membername, param, OBJ2));
            }
            return(hr);
        }
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public virtual Dispatch2 Serialize()
        {
            // create dictionary object which has reconstructible information
            // which can be passed into constructor or randomize method.
            if (mGenerator == null)
            {
                return(null);
            }
            Dispatch2 dic = null;
            Variant   val = new Variant();
            // retrive tTJSMersenneTwisterData
            MersenneTwisterData data = mGenerator.GetData();
            // create 'state' string
            string        state;
            StringBuilder p = new StringBuilder(MT_N * 8);

            for (int i = 0; i < MT_N; i++)
            {
                string hex = "0123456789abcdef";
                p.Append(hex[(int)((data.state.Get(i) >> 28) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 24) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 20) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 16) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 12) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 8) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 4) & unchecked ((int)(0x000f)))]);
                p.Append(hex[(int)((data.state.Get(i) >> 0) & unchecked ((int)(0x000f)))]);
            }
            state = p.ToString();
            // create dictionary and store information
            dic = Tjs.CreateDictionaryObject();
            val.Set(state);
            dic.PropSet(Interface.MEMBERENSURE, "state", val, dic);
            val.Set(data.left);
            dic.PropSet(Interface.MEMBERENSURE, "left", val, dic);
            val.Set(data.next);
            dic.PropSet(Interface.MEMBERENSURE, "next", val, dic);
            return(dic);
        }
Пример #6
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal override int Process(Variant result, Variant[] param, Dispatch2
     objthis)
 {
     Variant val = new Variant(string.Empty);
     if ((param.Length > 0) ? param[0].IsVoid() != true : false)
     {
         val.CopyRef(param[0]);
     }
     string message_name = "message";
     objthis.PropSet(Interface.MEMBERENSURE, message_name, val, objthis);
     if ((param.Length > 1) ? param[1].IsVoid() != true : false)
     {
         val.CopyRef(param[1]);
     }
     else
     {
         val.Set(string.Empty);
     }
     string trace_name = "trace";
     objthis.PropSet(Interface.MEMBERENSURE, trace_name, val, objthis);
     return Error.S_OK;
 }
Пример #7
0
        /// <summary>TJSGetExceptionObject : retrieves TJS 'Exception' object</summary>
        /// <exception cref="TjsException">TJSException</exception>
        /// <exception cref="VariantException">VariantException</exception>
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public static void GetExceptionObject(Tjs tjs, Variant res, Variant msg, Variant
                                              trace)
        {
            if (res == null)
            {
                return;
            }
            // not prcess
            // retrieve class "Exception" from global
            Dispatch2 global = tjs.GetGlobal();
            Variant   val    = new Variant();
            int       hr     = global.PropGet(0, EXCEPTION_NAME, val, global);

            if (hr < 0)
            {
                throw new TjsException(ExceptionNotFound);
            }
            // create an Exception object
            Holder <Dispatch2> excpobj = new Holder <Dispatch2>(null);
            VariantClosure     clo     = val.AsObjectClosure();

            Variant[] pmsg = new Variant[1];
            pmsg[0] = msg;
            hr      = clo.CreateNew(0, null, excpobj, pmsg, clo.mObjThis);
            if (hr < 0)
            {
                throw new TjsException(ExceptionNotFound);
            }
            Dispatch2 disp = excpobj.mValue;

            if (trace != null)
            {
                string trace_name = "trace";
                disp.PropSet(Interface.MEMBERENSURE, trace_name, trace, disp);
            }
            res.Set(disp, disp);
            excpobj = null;
        }
Пример #8
0
 /// <exception cref="VariantException"></exception>
 /// <exception cref="TjsException"></exception>
 public virtual bool Callback(string name, int flags, Variant value)
 {
     if ((flags & Interface.HIDDENMEMBER) != 0)
     {
         return(true);
     }
     if (value.IsObject())
     {
         // object
         Dispatch2 dsp = value.AsObject();
         // determin dsp's object type
         Variant val;
         if (dsp != null)
         {
             if (dsp.GetNativeInstance(DictionaryClass.ClassID) != null)
             {
                 // dictionary
                 bool objrec = false;
                 int  count  = mStack.Count;
                 for (int i = 0; i < count; i++)
                 {
                     Dispatch2 v = mStack[i];
                     if (v == dsp)
                     {
                         // object recursion detected
                         objrec = true;
                         break;
                     }
                 }
                 val = new Variant();
                 if (objrec)
                 {
                     val.SetObject(null);
                 }
                 else
                 {
                     // becomes null
                     Dispatch2 newobj = Tjs.CreateDictionaryObject();
                     val.SetObject(newobj, newobj);
                     DictionaryNI newni;
                     if ((newni = (DictionaryNI)newobj.GetNativeInstance(DictionaryClass.ClassID)) !=
                         null)
                     {
                         newni.AssignStructure(dsp, mStack);
                     }
                 }
             }
             else
             {
                 if (dsp.GetNativeInstance(ArrayClass.ClassID) != null)
                 {
                     // array
                     bool objrec = false;
                     int  count  = mStack.Count;
                     for (int i = 0; i < count; i++)
                     {
                         Dispatch2 v = mStack[i];
                         if (v == dsp)
                         {
                             // object recursion detected
                             objrec = true;
                             break;
                         }
                     }
                     val = new Variant();
                     if (objrec)
                     {
                         val.SetObject(null);
                     }
                     else
                     {
                         // becomes null
                         Dispatch2 newobj = Tjs.CreateArrayObject();
                         val.SetObject(newobj, newobj);
                         ArrayNI newni;
                         if ((newni = (ArrayNI)newobj.GetNativeInstance(ArrayClass.ClassID)) != null)
                         {
                             newni.AssignStructure(dsp, mStack);
                         }
                     }
                 }
                 else
                 {
                     val = value;
                 }
             }
         }
         else
         {
             // other object types
             val = value;
         }
         mDest.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, val, mDest);
     }
     else
     {
         // other types
         mDest.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, value, mDest);
     }
     return(true);
 }