/// <exception cref="VariantException"></exception> /// <exception cref="TjsException"></exception> public static void SaveStructuredDataForObject(Dispatch2 dsp, AList <Dispatch2> stack , TextWriteStreamInterface stream, string indentstr) { // check object recursion int count = stack.Count; for (int i = 0; i < count; i++) { Dispatch2 d = stack[i]; if (d == dsp) { // object recursion detected stream.Write("null /* object recursion detected */"); return; } } // determin dsp's object type DictionaryNI dicni; ArrayNI arrayni; if (dsp != null) { dicni = (DictionaryNI)dsp.GetNativeInstance(DictionaryClass.ClassID); if (dicni != null) { // dictionary stack.AddItem(dsp); dicni.SaveStructuredData(stack, stream, indentstr); stack.Remove(stack.Count - 1); return; } else { arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID); if (arrayni != null) { // array stack.AddItem(dsp); arrayni.SaveStructuredData(stack, stream, indentstr); stack.Remove(stack.Count - 1); return; } else { // other objects stream.Write("null /* (object) \""); // stored as a null Variant val = new Variant(dsp, dsp); stream.Write(LexBase.EscapeC(val.AsString())); stream.Write("\" */"); return; } } } stream.Write("null"); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public static void SaveStructuredDataForObject(Dispatch2 dsp, AList<Dispatch2> stack , TextWriteStreamInterface stream, string indentstr) { // check object recursion int count = stack.Count; for (int i = 0; i < count; i++) { Dispatch2 d = stack[i]; if (d == dsp) { // object recursion detected stream.Write("null /* object recursion detected */"); return; } } // determin dsp's object type DictionaryNI dicni; ArrayNI arrayni; if (dsp != null) { dicni = (DictionaryNI)dsp.GetNativeInstance(DictionaryClass.ClassID); if (dicni != null) { // dictionary stack.AddItem(dsp); dicni.SaveStructuredData(stack, stream, indentstr); stack.Remove(stack.Count - 1); return; } else { arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID); if (arrayni != null) { // array stack.AddItem(dsp); arrayni.SaveStructuredData(stack, stream, indentstr); stack.Remove(stack.Count - 1); return; } else { // other objects stream.Write("null /* (object) \""); // stored as a null Variant val = new Variant(dsp, dsp); stream.Write(LexBase.EscapeC(val.AsString())); stream.Write("\" */"); return; } } } stream.Write("null"); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } ((ArrayObject)objthis).Clear(ni); AList <Dispatch2> stack = new AList <Dispatch2>(); VariantClosure clo = param[0].AsObjectClosure(); if (clo.mObjThis != null) { ni.AssignStructure(clo.mObjThis, stack); } else { if (clo.mObject != null) { ni.AssignStructure(clo.mObject, stack); } else { throw new TjsException(Error.NullAccess); } } return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (ni.mItems.IsEmpty()) { if (result != null) { result.Clear(); } } else { if (result != null) { result.Set(ni.mItems[0]); } ((ArrayObject)objthis).Erase(ni, 0); } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> /// <exception cref="TjsException"></exception> public virtual void Assign(Dispatch2 dsp) { // copy members from "dsp" to "Owner" // determin dsp's object type //Holder<ArrayNI> arrayni = new Holder<ArrayNI>(null); ArrayNI array = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID); if (array != null) { // copy from array mItems.Clear(); int count = array.mItems.Count; for (int i = 0; i < count; i++) { mItems.AddItem(new Variant(array.mItems[i])); } } else { //mItems.addAll( array.mItems ); // convert from dictionary or others mItems.Clear(); ArrayNI.DictionaryEnumCallback callback = new ArrayNI.DictionaryEnumCallback(mItems ); dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp); } }
/// <exception cref="VariantException"></exception> /// <exception cref="TjsException"></exception> public virtual void AssignStructure(Dispatch2 dsp, AList <Dispatch2> stack) { // assign structured data from dsp //ArrayNI dicni = null; if (dsp.GetNativeInstance(DictionaryClass.ClassID) != null) { // copy from dictionary stack.AddItem(dsp); try { CustomObject owner = mOwner.Get(); owner.Clear(); DictionaryNI.AssignStructCallback callback = new DictionaryNI.AssignStructCallback (stack, owner); dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp); } finally { stack.Remove(stack.Count - 1); } } else { throw new TjsException(Error.SpecifyDicOrArray); } }
/// <exception cref="VariantException"></exception> public override int Set(Variant param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); // インスタンス所得 if (ni == null) { return(Error.E_NATIVECLASSCRASH); } int resize = param.AsInteger(); int count = ni.mItems.Count; if (count < resize) { int addcount = resize - count; ni.mItems.EnsureCapacity(count); for (int i = 0; i < addcount; i++) { ni.mItems.AddItem(new Variant()); } } else { if (count > resize) { for (int i = count - 1; i >= resize; i--) { ni.mItems.Remove(i); } } } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } bool eraseall; if (param.Length >= 2) { eraseall = param[1].AsBoolean(); } else { eraseall = true; } Variant val = param[0]; int count = ((ArrayObject)objthis).Remove(ni, val, eraseall); if (result != null) { result.Set(count); } return(Error.S_OK); }
// class instance matching by index number /// <exception cref="VariantException"></exception> /// <exception cref="TjsException"></exception> public override int IsInstanceOfByNum(int flag, int num, string className, Dispatch2 objthis) { if (!GetValidity()) { return(Error.E_INVALIDOBJECT); } ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } int membercount = ni.mItems.Count; if (num < 0) { num = membercount + num; } if ((flag & Interface.MEMBERMUSTEXIST) != 0 && (num < 0 || membercount <= num)) { return(Error.E_MEMBERNOTFOUND); } Variant val = new Variant((membercount <= num || num < 0) ? VoidValue : ni.mItems [num]); return(DefaultIsInstanceOf(flag, val, className, objthis)); }
/// <exception cref="TjsException"></exception> public static int CopyArrayElementTo(Dispatch2 dsp, Variant[] dest, int dest_offset , int start, int count) { // copy array elements to specified variant array. // returns copied element count. ArrayNI ni = (ArrayNI)dsp.GetNativeInstance(ClassID); if (ni == null) { throw new TjsException(Error.SpecifyArray); } if (count < 0) { count = ni.mItems.Count; } if (start >= ni.mItems.Count) { return(0); } int limit = start + count; int d = dest_offset; for (int i = start; i < limit; i++) { dest[d] = ni.mItems[i]; d++; } return(limit - start); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } string target = param[0].AsString(); bool purgeempty = false; if (param.Length >= 3) { purgeempty = param[2].AsBoolean(); } Holder <Dispatch2> array = new Holder <Dispatch2>(null); _this.Split(array, target, purgeempty); if (result != null) { result.Set(array.mValue, array.mValue); } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); ((ArrayObject)objthis).Clear(ni); return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length != 1) { return(Error.E_BADPARAMCOUNT); } string expr = param[0].GetString(); if (expr == null || expr[0] == 0) { return(Error.E_FAIL); } if (expr[0] != '/' || expr[1] != '/') { return(Error.E_FAIL); } int exprstart = expr.IndexOf('/', 2); if (exprstart < 0) { return(Error.E_FAIL); } int flags = RegExpNI.GetRegExpFlagsFromString(Sharpen.Runtime.Substring(expr, 2)); int pflag = (flags & ~RegExpClass.tjsflagsmask); try { if (pflag != 0) { _this.RegEx = Sharpen.Pattern.Compile(Sharpen.Runtime.Substring(expr, exprstart + 1), pflag); } else { _this.RegEx = Sharpen.Pattern.Compile(Sharpen.Runtime.Substring(expr, exprstart + 1)); } } //catch (PatternSyntaxException e) //{ // throw new TJSException(e.Message); //} catch (ArgumentException e) { throw new TjsException(e.Message); } _this.mFlags = flags; return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } if (result != null) { Variant val = param[0]; int start = 0; if (param.Length >= 2) { start = param[1].AsInteger(); } if (start < 0) { start += ni.mItems.Count; } if (start < 0) { start = 0; } if (start >= ni.mItems.Count) { result.Set(-1); return(Error.S_OK); } int count = ni.mItems.Count; int i; for (i = start; i < count; i++) { Variant v = ni.mItems[i]; if (val.DiscernCompareInternal(v)) { break; } } if (i == count) { result.Set(-1); } else { result.Set(i); } } return(Error.S_OK); }
/// <exception cref="TjsException"></exception> public static int GetArrayElementCount(Dispatch2 dsp) { // returns array element count ArrayNI ni = (ArrayNI)dsp.GetNativeInstance(ClassID); if (ni == null) { throw new TjsException(Error.SpecifyArray); } return(ni.mItems.Count); }
/// <exception cref="VariantException"></exception> public override int Set(Variant param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } _this.mStart = param.AsInteger(); return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } Collections.Reverse(ni.mItems); return(Error.S_OK); }
public override int Get(Variant result, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } result.Set(_this.mRightContext); return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RandomGeneratorNI _this = (RandomGeneratorNI)objthis.GetNativeInstance(RandomGeneratorClass .mClassID); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } _this.Randomize(param); return(Error.S_OK); }
/// <exception cref="TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DateNI _this = (DateNI)objthis.GetNativeInstance(DateClass.mClassID ); // インスタンス所得 if (_this == null) { return(Error.E_NATIVECLASSCRASH); } _this.mDateTime = DateClass.ParseDateString(param[0].GetString()); return(Error.S_OK); }
public override int Get(Variant result, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (result != null) { result.Set(ni.mItems.Count); } return(Error.S_OK); }
protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(DictionaryClass .ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (!ni.IsValid()) { return(Error.E_INVALIDOBJECT); } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DateNI _this = (DateNI)objthis.GetNativeInstance(DateClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (result != null) { result.Set((int)_this.mDateTime.Get(Calendar.YEAR)); } return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } ((ArrayObject)objthis).Insert(ni, param, 0); if (result != null) { result.Set(ni.mItems.Count); } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DateNI _this = (DateNI)objthis.GetNativeInstance(DateClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (result != null) { long num = _this.mDateTime.GetTimeInMillis(); result.Set(num); } return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } RegExpClass.Compile(param, _this); return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } string delimiter = param[0].AsString(); bool purgeempty = false; if (param.Length >= 3 && param[2].IsVoid() != true) { purgeempty = param[2].AsBoolean(); } bool first = true; StringBuilder builer = new StringBuilder(1024); int count = ni.mItems.Count; for (int i = 0; i < count; i++) { Variant v = ni.mItems[i]; if (purgeempty && v.IsVoid()) { } else { if (!first) { builer.Append(delimiter); } first = false; builer.Append(v.AsString()); } } if (result != null) { result.Set(builer.ToString()); } return(Error.S_OK); }
/// <exception cref="VariantException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DateNI _this = (DateNI)objthis.GetNativeInstance(DateClass.mClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } _this.mDateTime.Set(Calendar.SECOND, param[0].AsInteger()); return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 1) { return(Error.E_BADPARAMCOUNT); } string name = param[0].AsString(); string mode = null; if (param.Length >= 2 && param[1].IsVoid() == false) { mode = param[1].AsString(); } TextWriteStreamInterface stream = Tjs.mStorage.CreateTextWriteStream(name, mode); try { Iterator <Variant> i = ni.mItems.Iterator(); while (i.HasNext()) { Variant o = i.Next(); if (o != null && (o.IsString() || o.IsNumber())) { stream.Write(o.AsString()); } stream.Write("\n"); } } finally { stream.Destruct(); } if (result != null) { result.Set(new Variant(objthis, objthis)); } return(Error.S_OK); }
protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI _this = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID ); if (_this == null) { return(Error.E_NATIVECLASSCRASH); } int hr = _this.Construct(param, objthis); if (hr < 0) { return(hr); } return(Error.S_OK); }
/// <exception cref="TjsException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return(Error.E_NATIVECLASSCRASH); } if (param.Length < 2) { return(Error.E_BADPARAMCOUNT); } int num = param[0].AsInteger(); ((ArrayObject)objthis).Insert(ni, param[1], num); return(Error.S_OK); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public virtual void Assign(Dispatch2 dsp, bool clear) { // copy members from "dsp" to "Owner" // determin dsp's object type ArrayNI arrayni = null; CustomObject owner = mOwner.Get(); if (dsp != null && (arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID)) != null) { // convert from array if (clear) { owner.Clear(); } int count = arrayni.mItems.Count; for (int i = 0; i < count; i++) { Variant v = arrayni.mItems[i]; string name = v.AsString(); i++; if (i >= count) { break; } Variant v2 = arrayni.mItems[i]; owner.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, v2, owner); } } else { // otherwise if (clear) { owner.Clear(); } DictionaryNI.AssignCallback callback = new DictionaryNI.AssignCallback(owner); dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp); } }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } Kirikiri.Tjs2.RegExpClass.Compile(param, _this); 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) { RandomGeneratorNI _this = (RandomGeneratorNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RandomGeneratorClass .mClassID); if (_this == null) { return Error.E_NATIVECLASSCRASH; } int hr = _this.Construct(param, objthis); if (hr < 0) { return hr; } _this.Randomize(param); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public override int PropSet(int flag, string membername, Variant param, Dispatch2 objthis) { if (membername != null) { return base.PropSet(flag, membername, param, objthis); } if (objthis == null) { return Error.E_NATIVECLASSCRASH; } if (param == null) { return Error.E_FAIL; } if (mSet == null) { return Error.E_ACCESSDENYED; } object self; if (mIsStaticSet) { self = null; } else { // static 时は null NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID); if (ni == null) { return Error.E_FAIL; } self = ni.GetNativeObject(); if (self == null) { return Error.E_NATIVECLASSCRASH; } } int er = Error.S_OK; object arg = NativeJavaClass.VariantToJavaObject(param, mParamType); if (arg == null) { return Error.E_INVALIDPARAM; } object[] args = new object[1]; args[0] = arg; try { mSet.Invoke(self, args); } catch (ArgumentException) { er = Error.E_INVALIDPARAM; } catch (MemberAccessException) { er = Error.E_ACCESSDENYED; } catch (TargetInvocationException e) { Exception t = e.InnerException; if (t is VariantException) { throw (VariantException)t; } else { if (t is TJSException) { throw (TJSException)t; } else { throw new TJSException(t.ToString()); } } } return er; }
/// <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; }
/// <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 (param.Length < 1) { return Error.E_BADPARAMCOUNT; } _this.mDateTime.Set(Calendar.DAY_OF_MONTH, param[0].AsInteger()); return Error.S_OK; }
// property set by index number /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public override int PropSetByNum(int flag, int num, Variant param, Dispatch2 objthis ) { if (!GetValidity()) { return Error.E_INVALIDOBJECT; } ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (num < 0) { num += ni.mItems.Count; } if (num >= ni.mItems.Count) { if ((flag & Interface.MEMBERMUSTEXIST) != 0) { return Error.E_MEMBERNOTFOUND; } //ni.mItems.resize(num+1); for (int i = ni.mItems.Count; i <= num; i++) { ni.mItems.AddItem(new Variant()); } } if (num < 0) { return Error.E_MEMBERNOTFOUND; } Variant val = ni.mItems[num]; return DefaultPropSet(flag, val, param, objthis); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></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; } int hr = _this.Construct(param, objthis); if (hr < 0) { return hr; } if (param.Length == 0) { _this.mDateTime = Calendar.GetInstance(); } else { if (param.Length >= 1) { if (param[0].IsString()) { _this.mDateTime = Kirikiri.Tjs2.DateClass.ParseDateString(param[0].GetString()); } else { int y; int mon = 0; int day = 1; int h = 0; int m = 0; int s = 0; y = param[0].AsInteger(); if (param.Length > 1 && param[1].IsVoid() != true) { mon = param[1].AsInteger(); } if (param.Length > 2 && param[2].IsVoid() != true) { day = param[2].AsInteger(); } if (param.Length > 3 && param[3].IsVoid() != true) { h = param[3].AsInteger(); } if (param.Length > 4 && param[4].IsVoid() != true) { m = param[4].AsInteger(); } if (param.Length > 5 && param[5].IsVoid() != true) { s = param[5].AsInteger(); } Calendar cal = Calendar.GetInstance(); cal.Set(y, mon, day, h, m, s); _this.mDateTime = cal; } } } return Error.S_OK; }
public override int Get(Variant result, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } result.Set(_this.mRightContext); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public override int Set(Variant param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } _this.mStart = param.AsInteger(); return Error.S_OK; }
protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass .ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (!ni.IsValid()) { return Error.E_INVALIDOBJECT; } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass .ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (!ni.IsValid()) { return Error.E_INVALIDOBJECT; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } AList<Dispatch2> stack = new AList<Dispatch2>(); VariantClosure clo = param[0].AsObjectClosure(); if (clo.mObjThis != null) { ni.AssignStructure(clo.mObjThis, stack); } else { if (clo.mObject != null) { ni.AssignStructure(clo.mObject, stack); } else { throw new TJSException(Error.NullAccess); } } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass .ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (!ni.IsValid()) { return Error.E_INVALIDOBJECT; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } string name = param[0].AsString(); string mode = null; if (param.Length >= 2 && param[1].IsVoid() != true) { mode = param[1].AsString(); } TextWriteStreamInterface stream = TJS.mStorage.CreateTextWriteStream(name, mode); try { AList<Dispatch2> stack = new AList<Dispatch2>(); stack.AddItem(objthis); ni.SaveStructuredData(stack, stream, string.Empty); } finally { stream.Destruct(); } if (result != null) { result.Set(new Variant(objthis, objthis)); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass .ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (!ni.IsValid()) { return Error.E_INVALIDOBJECT; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } bool clear = true; if (param.Length >= 2 && param[1].IsVoid() != true) { clear = param[1].AsBoolean(); } VariantClosure clo = param[0].AsObjectClosure(); if (clo.mObjThis != null) { ni.Assign(clo.mObjThis, clear); } else { if (clo.mObject != null) { ni.Assign(clo.mObject, clear); } else { throw new TJSException(Error.NullAccess); } } return Error.S_OK; }
protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { DictionaryNI _this = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass .ClassID); if (_this == null) { return Error.E_NATIVECLASSCRASH; } int hr = _this.Construct(param, objthis); if (hr < 0) { return hr; } 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) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } int hr = _this.Construct(param, objthis); if (hr < 0) { return hr; } if (param.Length >= 1) { Kirikiri.Tjs2.RegExpClass.Compile(param, _this); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } string target = param[0].AsString(); bool purgeempty = false; if (param.Length >= 3) { purgeempty = param[2].AsBoolean(); } Holder<Dispatch2> array = new Holder<Dispatch2>(null); _this.Split(array, target, purgeempty); if (result != null) { result.Set(array.mValue, array.mValue); } return Error.S_OK; }
// delete member by index number /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public override int DeleteMemberByNum(int flag, int num, Dispatch2 objthis) { if (!GetValidity()) { return Error.E_INVALIDOBJECT; } ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } if (num < 0) { num += ni.mItems.Count; } if (num < 0 || num >= ni.mItems.Count) { return Error.E_MEMBERNOTFOUND; } ni.mItems.Remove(num); return Error.S_OK; }
/// <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) { if (membername != null) { return base.FuncCall(flag, membername, result, param, objthis); } if (param.Length < mParamTypes.Length) { return Error.E_INVALIDPARAM; } // パラメータが少ない if (result != null) { result.Clear(); } object self; if (mIsStatic) { self = null; } else { // static 时は null if (objthis == null) { return Error.E_NATIVECLASSCRASH; } NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID); if (ni == null) { return Error.E_FAIL; } self = ni.GetNativeObject(); if (self == null) { return Error.E_NATIVECLASSCRASH; } } int er = Error.S_OK; object[] args = NativeJavaClass.VariantArrayToJavaObjectArray(param, mParamTypes); try { object ret = mProcess.Invoke(self, args); if (result != null) { NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret); } } catch (ArgumentException) { er = Error.E_INVALIDPARAM; } catch (MemberAccessException) { er = Error.E_ACCESSDENYED; } catch (TargetInvocationException e) { Exception t = e.InnerException; if (t is VariantException) { throw (VariantException)t; } else { if (t is TJSException) { throw (TJSException)t; } else { throw new TJSException(t.ToString()); } } } return er; }
// create new object by index number /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public override int CreateNewByNum(int flag, int num, Holder<Dispatch2> result, Variant [] param, Dispatch2 objthis) { if (!GetValidity()) { return Error.E_INVALIDOBJECT; } ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID); if (ni == null) { return Error.E_NATIVECLASSCRASH; } int membercount = ni.mItems.Count; if (num < 0) { num = membercount + num; } if ((flag & Interface.MEMBERMUSTEXIST) != 0 && (num < 0 || membercount <= num)) { return Error.E_MEMBERNOTFOUND; } Variant val = new Variant((membercount <= num || num < 0) ? VoidValue : ni.mItems [num]); return DefaultCreateNew(flag, val, result, param, objthis); }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length < 2) { return Error.E_BADPARAMCOUNT; } string target = param[0].AsString(); string to = null; bool func; VariantClosure funcval = null; if (param[1].IsObject() != true) { to = param[1].AsString(); func = false; } else { funcval = param[1].AsObjectClosure(); if (funcval.mObjThis == null) { funcval.mObjThis = objthis; } func = true; } string ret = null; Matcher m = _this.RegEx.Matcher(target); if (func == false) { ret = m.ReplaceAll(to); } else { int hr; VariantClosure clo = new VariantClosure(null, null); Variant funcret = new Variant(); Variant arrayval = new Variant(clo); Variant[] args = new Variant[1]; args[0] = arrayval; int size = target.Length; ret = string.Empty; for (int i = 0; i < size; ) { if (m.Find(i)) { ret += Sharpen.Runtime.Substring(target, i, m.Start()); Dispatch2 array = Kirikiri.Tjs2.RegExpClass.GetResultArray(true, _this, m); clo.Set(array, array); hr = funcval.FuncCall(0, null, funcret, args, null); if (hr >= 0) { ret += funcret.AsString(); } i = m.End(); } else { break; } } } if (result != null) { result.Set(ret); } return Error.S_OK; }
/// <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 (param.Length < 1) { return Error.E_BADPARAMCOUNT; } double num = param[0].AsDouble(); _this.mDateTime.SetTimeInMillis((long)num); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } string target = param[0].AsString(); Kirikiri.Tjs2.RegExpClass.Exec(target, _this); Kirikiri.Tjs2.RegExpClass.mLastRegExp = new Variant(objthis, objthis); if (result != null) { result.Set(_this.mArray); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></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; } _this.mDateTime = Kirikiri.Tjs2.DateClass.ParseDateString(param[0].GetString()); return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length < 1) { return Error.E_BADPARAMCOUNT; } if (result != null) { string target = param[0].AsString(); bool matched = Kirikiri.Tjs2.RegExpClass.Match(target, _this); Dispatch2 array = Kirikiri.Tjs2.RegExpClass.GetResultArray(matched, _this, _this. mMatch); result.Set(array, array); } return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public virtual void AssignStructure(Dispatch2 dsp, AList<Dispatch2> stack) { // assign structured data from dsp ArrayNI arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID); if (arrayni != null) { // copy from array stack.AddItem(dsp); try { mItems.Clear(); int count = arrayni.mItems.Count; for (int i = 0; i < count; i++) { Variant v = arrayni.mItems[i]; if (v.IsObject()) { // object Dispatch2 dsp1 = v.AsObject(); // determin dsp's object type //DictionaryNI dicni = null; //ArrayNI arrayni1 = null; if (dsp1 != null && dsp1.GetNativeInstance(DictionaryClass.ClassID) != null) { //dicni = (DictionaryNI)ni.mValue; // dictionary bool objrec = false; int scount = stack.Count; for (int j = 0; j < scount; j++) { Dispatch2 d = stack[j]; if (d == dsp1) { // object recursion detected objrec = true; break; } } if (objrec) { mItems.AddItem(new Variant()); } else { // becomes null Dispatch2 newobj = TJS.CreateDictionaryObject(); mItems.AddItem(new Variant(newobj, newobj)); DictionaryNI newni; if ((newni = (DictionaryNI)newobj.GetNativeInstance(DictionaryClass.ClassID)) != null) { newni.AssignStructure(dsp1, stack); } } } else { if (dsp1 != null && dsp1.GetNativeInstance(ArrayClass.ClassID) != null) { // array bool objrec = false; int scount = stack.Count; for (int j = 0; j < scount; j++) { Dispatch2 d = stack[j]; if (d == dsp1) { // object recursion detected objrec = true; break; } } if (objrec) { mItems.AddItem(new Variant()); } else { // becomes null Dispatch2 newobj = TJS.CreateArrayObject(); mItems.AddItem(new Variant(newobj, newobj)); ArrayNI newni; if ((newni = (ArrayNI)newobj.GetNativeInstance(ArrayClass.ClassID)) != null) { newni.AssignStructure(dsp1, stack); } } } else { // other object types mItems.AddItem(v); } } } else { // others mItems.AddItem(v); } } } finally { stack.Remove(stack.Count - 1); } } else { throw new TJSException(Error.SpecifyDicOrArray); } }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> protected internal override int Process(Variant result, Variant[] param, Dispatch2 objthis) { RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID ); if (_this == null) { return Error.E_NATIVECLASSCRASH; } if (param.Length != 1) { return Error.E_BADPARAMCOUNT; } string expr = param[0].GetString(); if (expr == null || expr[0] == 0) { return Error.E_FAIL; } if (expr[0] != '/' || expr[1] != '/') { return Error.E_FAIL; } int exprstart = expr.IndexOf('/', 2); if (exprstart < 0) { return Error.E_FAIL; } int flags = RegExpNI.GetRegExpFlagsFromString(Sharpen.Runtime.Substring(expr, 2)); int pflag = (flags & ~Kirikiri.Tjs2.RegExpClass.tjsflagsmask); try { if (pflag != 0) { _this.RegEx = Sharpen.Pattern.Compile(Sharpen.Runtime.Substring(expr, exprstart + 1), pflag); } else { _this.RegEx = Sharpen.Pattern.Compile(Sharpen.Runtime.Substring(expr, exprstart + 1)); } } //catch (PatternSyntaxException e) //{ // throw new TJSException(e.Message); //} catch (ArgumentException e) { throw new TJSException(e.Message); } _this.mFlags = flags; return Error.S_OK; }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public virtual void Assign(Dispatch2 dsp) { // copy members from "dsp" to "Owner" // determin dsp's object type //Holder<ArrayNI> arrayni = new Holder<ArrayNI>(null); ArrayNI array = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID); if (array != null) { // copy from array mItems.Clear(); int count = array.mItems.Count; for (int i = 0; i < count; i++) { mItems.AddItem(new Variant(array.mItems[i])); } } else { //mItems.addAll( array.mItems ); // convert from dictionary or others mItems.Clear(); ArrayNI.DictionaryEnumCallback callback = new ArrayNI.DictionaryEnumCallback(mItems ); dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp); } }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public override int PropGet(int flag, string membername, Variant result, Dispatch2 objthis) { if (membername != null) { return base.PropGet(flag, membername, result, objthis); } if (result == null) { return Error.E_FAIL; } if (mGet == null) { return Error.E_ACCESSDENYED; } object self; if (mIsStaticGet) { self = null; } else { // static 时は null if (objthis == null) { return Error.E_NATIVECLASSCRASH; } NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID); if (ni == null) { return Error.E_FAIL; } self = ni.GetNativeObject(); if (self == null) { return Error.E_NATIVECLASSCRASH; } } int er = Error.S_OK; try { object ret = mGet.Invoke(self, new object[]{}); NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret); } catch (ArgumentException) { er = Error.E_INVALIDPARAM; } catch (MemberAccessException) { er = Error.E_ACCESSDENYED; } catch (TargetInvocationException e) { Exception t = e.InnerException; if (t is VariantException) { throw (VariantException)t; } else { if (t is TJSException) { throw (TJSException)t; } else { throw new TJSException(t.ToString()); } } } return er; }