/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public static void CharacterCodeOf(Variant val) { string str = val.AsString(); if (str != null) { int v = str[0]; val.Set(v); } else { val.Set(0); } }
public override int PropGet(int flag, string membername, Variant result, Dispatch2 objthis) { if (membername != null) { return Error.E_MEMBERNOTFOUND; } if (result != null) { result.Set(mValue); } return Error.S_OK; }
/// <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; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { if (result != null) { double r = double.PositiveInfinity; int count = param.Length; for (int i = 0; i < count; i++) { double v = param[i].AsDouble(); if (double.IsNaN(v)) { result.Set(double.NaN); return Error.S_OK; } else { if (Double.Compare(v, r) < 0) { r = v; } } } result.Set(r); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal static void InstanceOf(Variant name, Variant targ) { // checks instance inheritance. string str = name.AsString(); if (str != null) { int hr = CustomObject.DefaultIsInstanceOf(0, targ, str, null); if (hr < 0) { ThrowFrom_tjs_error(hr, null); } targ.Set((hr == Error.S_TRUE) ? 1 : 0); return; } targ.Set(0); }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetStringProperty(Variant result, Variant str, string name) { // processes properties toward strings. if (name == null) { ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty); } if (name.Equals("length")) { // get string length string s = str.AsString(); if (s == null) { result.Set(0); } else { // tTJSVariantString::GetLength can return zero if 'this' is NULL result.Set(s.Length); } return; } else { if (name[0] >= '0' && name[0] <= '9') { string s = str.AsString(); int n = int.Parse(name); int len = s.Length; if (n == len) { result.Set(string.Empty); return; } if (n < 0 || n > len) { throw new TJSException(Error.RangeError); } result.Set(Sharpen.Runtime.Substring(s, n, n + 1)); return; } } ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { if (result != null) { result.Set(System.TimeZoneInfo.Local.GetRawOffset() / (60 * 1000)); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal static void TypeOfMemberIndirect(Variant result, Variant target , Variant member, Dispatch2 objthis, int flags) { if (target.IsObject()) { VariantClosure clo = target.AsObjectClosure(); if (member.IsInteger() != true) { string str = member.AsString(); int hr = clo.PropGet(flags, str, result, clo.mObjThis != null ? clo.mObjThis : objthis ); if (hr == Error.S_OK) { TypeOf(result); } else { if (hr == Error.E_MEMBERNOTFOUND) { result.Set("undefined"); } else { if (hr < 0) { ThrowFrom_tjs_error(hr, str); } } } } else { int hr = clo.PropGetByNum(flags, member.AsInteger(), result, clo.mObjThis != null ? clo.mObjThis : objthis); if (hr == Error.S_OK) { TypeOf(result); } else { if (hr == Error.E_MEMBERNOTFOUND) { result.Set("undefined"); } else { if (hr < 0) { ThrowFrom_tjs_error_num(hr, member.AsInteger()); } } } } } else { if (target.IsString()) { GetStringProperty(result, target, member); TypeOf(result); } else { if (target.IsOctet()) { GetOctetProperty(result, target, member); TypeOf(result); } else { string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString (target)); throw new VariantException(mes); } } } }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetOctetProperty(Variant result, Variant octet, string name) { // processes properties toward octets. if (name == null) { ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty); } if (name.Equals("length")) { // get string length ByteBuffer o = octet.AsOctet(); if (o != null) { result.Set(o.Capacity()); } else { result.Set(0); } return; } else { if (name[0] >= '0' && name[0] <= '9') { ByteBuffer o = octet.AsOctet(); int n = int.Parse(name); int len = o != null ? o.Capacity() : 0; if (n < 0 || n >= len) { throw new TJSException(Error.RangeError); } result.Set(o.Get(n)); return; } } ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name); }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(2.30258509299404568402); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal static void TypeOfMemberDirect(Variant result, Variant target, int member, Dispatch2 objthis, int flags) { if (target.IsObject()) { int hr; VariantClosure clo = target.AsObjectClosure(); string name = Sharpen.Extensions.ToString(member); hr = clo.PropGet(flags, name, result, clo.mObjThis != null ? clo.mObjThis : objthis ); if (hr == Error.S_OK) { TypeOf(result); } else { if (hr == Error.E_MEMBERNOTFOUND) { result.Set("undefined"); } else { if (hr < 0) { ThrowFrom_tjs_error(hr, name); } } } } else { if (target.IsString()) { GetStringProperty(result, target, member); TypeOf(result); } else { if (target.IsOctet()) { GetOctetProperty(result, target, member); TypeOf(result); } else { string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString (target)); throw new VariantException(mes); } } } }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(1.4426950408889634074); return Error.S_OK; }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(0.4342944819032518276); return Error.S_OK; }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(2.7182818284590452354); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } if (result != null) { result.Set(Math.Exp(param[0].AsDouble())); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { if (result != null) { result.Set(Kirikiri.Tjs2.MathClass.mRandomGenerator.NextDouble()); } return Error.S_OK; }
protected internal static void TypeOf(Variant val) { // processes TJS2's typeof operator. string name = val.GetTypeName(); if (name != null) { val.Set(name); } }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(0.69314718055994530942); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public static void CharacterCodeFrom(Variant val) { char[] ch = new char[1]; ch[0] = (char)val.AsInteger(); val.Set(new string(ch)); }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(3.14159265358979323846); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> private void ReadObjects(ScriptBlock block, byte[] buff, int offset, int size) { string[] strarray = mStringArray; ByteBuffer[] bbarray = mByteBufferArray; double[] dblarray = mDoubleArray; byte[] barray = mByteArray; short[] sarray = mShortArray; int[] iarray = mIntArray; long[] larray = mLongArray; int toplevel = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int objcount = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; //Log.v("test","count:"+objcount); mObjectsCache.Create(objcount); InterCodeObject[] objs = mObjectsCache.mObjs; AList<ByteCodeLoader.VariantRepalace> work = mObjectsCache.mWork; int[] parent = mObjectsCache.mParent; int[] propSetter = mObjectsCache.mPropSetter; int[] propGetter = mObjectsCache.mPropGetter; int[] superClassGetter = mObjectsCache.mSuperClassGetter; int[][] properties = mObjectsCache.mProperties; for (int o = 0; o < objcount; o++) { int tag = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; if (tag != FILE_TAG_LE) { throw new TJSException(Error.ByteCodeBroken); } //int objsize = (buff[offset]&0xff) | (buff[offset+1]&0xff) << 8 | (buff[offset+2]&0xff) << 16 | (buff[offset+3]&0xff) << 24; offset += 4; parent[o] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int name = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int contextType = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int maxVariableCount = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1 ] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int variableReserveCount = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff) )) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int maxFrameCount = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int funcDeclArgCount = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1 ] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int funcDeclUnnamedArgArrayBase = (buff[offset] & unchecked((int)(0xff))) | (buff [offset + 1] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int )(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int funcDeclCollapseBase = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff) )) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; propSetter[o] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; propGetter[o] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; superClassGetter[o] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked((int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int count = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; LongBuffer srcpos; // codePos/srcPos は今のところ使ってない、ソート济みなので、longにする必要はないが…… offset += count << 3; srcpos = null; count = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked(( int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; short[] code = new short[count]; for (int i = 0; i < count; i++) { code[i] = (short)((buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8); offset += 2; } offset += (count & 1) << 1; count = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked(( int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int vcount = count << 1; if (mVariantTypeData == null || mVariantTypeData.Length < vcount) { mVariantTypeData = new short[vcount]; } short[] data = mVariantTypeData; for (int i_1 = 0; i_1 < vcount; i_1++) { data[i_1] = (short)((buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked((int)(0xff))) << 8); offset += 2; } Variant[] vdata = new Variant[count]; int datacount = count; Variant tmp; for (int i_2 = 0; i_2 < datacount; i_2++) { int pos = i_2 << 1; int type = data[pos]; int index = data[pos + 1]; switch (type) { case TYPE_VOID: { vdata[i_2] = new Variant(); // null break; } case TYPE_OBJECT: { vdata[i_2] = new Variant(null, null); // null Array Dictionary はまだサポートしていない TODO break; } case TYPE_INTER_OBJECT: { tmp = new Variant(); work.AddItem(new ByteCodeLoader.VariantRepalace(tmp, index)); vdata[i_2] = tmp; break; } case TYPE_INTER_GENERATOR: { tmp = new Variant(); work.AddItem(new ByteCodeLoader.VariantRepalace(tmp, index)); vdata[i_2] = tmp; break; } case TYPE_STRING: { vdata[i_2] = new Variant(strarray[index]); break; } case TYPE_OCTET: { vdata[i_2] = new Variant(bbarray[index]); break; } case TYPE_REAL: { vdata[i_2] = new Variant(dblarray[index]); break; } case TYPE_BYTE: { vdata[i_2] = new Variant(barray[index]); break; } case TYPE_SHORT: { vdata[i_2] = new Variant(sarray[index]); break; } case TYPE_INTEGER: { vdata[i_2] = new Variant(iarray[index]); break; } case TYPE_LONG: { vdata[i_2] = new Variant(larray[index]); break; } case TYPE_UNKNOWN: default: { vdata[i_2] = new Variant(); // null; break; break; } } } count = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked(( int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; int[] scgetterps = new int[count]; for (int i_3 = 0; i_3 < count; i_3++) { scgetterps[i_3] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; } // properties count = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked(( int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; if (count > 0) { int pcount = count << 1; int[] props = new int[pcount]; for (int i_4 = 0; i_4 < pcount; i_4++) { props[i_4] = (buff[offset] & unchecked((int)(0xff))) | (buff[offset + 1] & unchecked( (int)(0xff))) << 8 | (buff[offset + 2] & unchecked((int)(0xff))) << 16 | (buff[offset + 3] & unchecked((int)(0xff))) << 24; offset += 4; } properties[o] = props; } //IntVector superpointer = IntVector.wrap( scgetterps ); InterCodeObject obj = new InterCodeObject(block, mStringArray[name], contextType, code, vdata, maxVariableCount, variableReserveCount, maxFrameCount, funcDeclArgCount , funcDeclUnnamedArgArrayBase, funcDeclCollapseBase, true, srcpos, scgetterps); //objs.add(obj); objs[o] = obj; } Variant val = new Variant(); for (int o_1 = 0; o_1 < objcount; o_1++) { InterCodeObject parentObj = null; InterCodeObject propSetterObj = null; InterCodeObject propGetterObj = null; InterCodeObject superClassGetterObj = null; if (parent[o_1] >= 0) { parentObj = objs[parent[o_1]]; } if (propSetter[o_1] >= 0) { propSetterObj = objs[propSetter[o_1]]; } if (propGetter[o_1] >= 0) { propGetterObj = objs[propGetter[o_1]]; } if (superClassGetter[o_1] >= 0) { superClassGetterObj = objs[superClassGetter[o_1]]; } objs[o_1].SetCodeObject(parentObj, propSetterObj, propGetterObj, superClassGetterObj ); if (properties[o_1] != null) { InterCodeObject obj = parentObj; // objs.get(o).mParent; int[] prop = properties[o_1]; int length = (int)(((uint)prop.Length) >> 1); for (int i = 0; i < length; i++) { int pos = i << 1; int pname = prop[pos]; int pobj = prop[pos + 1]; val.Set(objs[pobj]); obj.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, mStringArray[pname], val , obj); } properties[o_1] = null; } } int count_1 = work.Count; for (int i_5 = 0; i_5 < count_1; i_5++) { ByteCodeLoader.VariantRepalace w = work[i_5]; w.Work.Set(objs[w.Index]); } work.Clear(); InterCodeObject top = null; if (toplevel >= 0) { top = objs[toplevel]; } block.SetObjects(top, objs, objcount); }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(0.70710678118654752440); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.CompileException"></exception> protected internal virtual void Eval(Variant val, Dispatch2 objthis, bool resneed ) { Variant res = new Variant(); string str = val.AsString(); if (str.Length > 0) { if (resneed) { GetOwner().EvalExpression(str, res, objthis, null, 0); } else { GetOwner().EvalExpression(str, null, objthis, null, 0); } } if (resneed) { val.Set(res); } }
public override int Get(Variant result, Dispatch2 objthis) { result.Set(1.41421356237309504880); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetOctetProperty(Variant result, Variant octet, int n) { // processes properties toward octets. ByteBuffer o = octet.AsOctet(); int len = o != null ? o.Capacity() : 0; if (n < 0 || n >= len) { throw new TJSException(Error.RangeError); } result.Set(o.Get(n)); return; }
//private Callback mCallback; //private VariantClosure mCallbackClosure; // a class to receive member callback from class // destination object /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.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; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetStringProperty(Variant result, Variant str, int n) { // processes properties toward strings. string s = str.AsString(); int len = s.Length; if (n == len) { result.Set(string.Empty); return; } if (n < 0 || n > len) { throw new TJSException(Error.RangeError); } result.Set(Sharpen.Runtime.Substring(s, n, n + 1)); return; }
// create a member if not exists // ignore property invoking /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> private ScriptBlock GenerateInterCodeObjects() { // dumpClassStructure(); ScriptBlock block = new ScriptBlock(mOwner, mName, mLineOffset, mScript, mLineData ); mInterCodeObjectList.Clear(); // 1st. pass, まずはInterCodeObjectを作る int count = mInterCodeGeneratorList.Count; for (int i = 0; i < count; i++) { InterCodeGenerator gen = mInterCodeGeneratorList[i]; mInterCodeObjectList.AddItem(gen.CreteCodeObject(block)); } Variant val = new Variant(); // 2nd. pass, 次にInterCodeObject内のリンクを解决する for (int i_1 = 0; i_1 < count; i_1++) { InterCodeGenerator gen = mInterCodeGeneratorList[i_1]; InterCodeObject obj = mInterCodeObjectList[i_1]; gen.CreateSecond(obj); gen.DateReplace(this); // DaraArray の中の InterCodeGenerator を InterCodeObject に差し替える //obj.dateReplace( this ); // DaraArray の中の InterCodeGenerator を InterCodeObject に差し替える AList<InterCodeGenerator.Property> p = gen.GetProp(); if (p != null) { int pcount = p.Count; for (int j = 0; j < pcount; j++) { InterCodeGenerator.Property prop = p[j]; val.Set(GetCodeObject(GetCodeIndex(prop.Value))); obj.mParent.PropSet(MEMBERENSURE | IGNOREPROP, prop.Name, val, obj.mParent); } p.Clear(); } } mTopLevelObject = GetCodeObject(GetCodeIndex(mTopLevelGenerator)); block.SetObjects(mTopLevelObject, mInterCodeObjectList); // 解放してしまう mInterCodeGenerator = null; mTopLevelGenerator = null; mGeneratorStack = null; mInterCodeGeneratorList.Clear(); mInterCodeGeneratorList = null; mInterCodeObjectList.Clear(); mInterCodeObjectList = null; return block; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DateNI _this = (DateNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DateClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (result != null) { result.Set((int)_this.mDateTime.Get(Calendar.YEAR)); } return Error.S_OK; }
public static void JavaObjectToVariant(Variant result, Type type, object src) { if (result == null) { return; } if (type.IsPrimitive) { // プリミティブタイプの场合 if (type.Equals(typeof(int))) { result.Set(((int)src)); } else { if (type.Equals(typeof(double))) { result.Set(((double)src)); } else { if (type.Equals(typeof(bool))) { result.Set(((bool)src) ? 1 : 0); } else { if (type.Equals(typeof(float))) { result.Set(((float)src)); } else { if (type.Equals(typeof(long))) { result.Set(((long)src)); } else { if (type.Equals(typeof(char))) { result.Set((int)((char)src)); } else { if (type.Equals(typeof(byte))) { result.Set(((byte)src)); } else { if (type.Equals(typeof(short))) { result.Set(((short)src)); } else { // may be Void.TYPE result.Clear(); } } } } } } } } } else { if (type.Equals(typeof(string))) { result.Set((string)src); } else { if (type.Equals(typeof(ByteBuffer))) { result.Set((ByteBuffer)src); } else { if (type.Equals(typeof(Variant))) { result.Set((Variant)src); } else { if (type.Equals(typeof(VariantClosure))) { result.Set(((VariantClosure)src).mObject, ((VariantClosure)src).mObjThis); } else { if (type.Equals(typeof(Dispatch2))) { result.Set((Dispatch2)src); } else { // その他 のクラス, 直接入れてしまう result.SetJavaObject(src); } } } } } } }