/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void SetOctetProperty(Variant param, Variant octet, Variant member ) { // processes properties toward octets. if (member.IsNumber() != true) { string name = member.GetString(); if (name == null) { ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty); } if (name.Equals("length")) { ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty); } else { if (name[0] >= '0' && name[0] <= '9') { ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty); } } ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name); } else { // member.Type() == tvtInteger || member.Type() == tvtReal ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty); } }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetOctetProperty(Variant result, Variant octet, Variant member ) { // processes properties toward octets. if (member.IsNumber() != true) { string name = member.GetString(); 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); } else { // member.Type() == tvtInteger || member.Type() == tvtReal ByteBuffer o = octet.AsOctet(); int n = member.AsInteger(); int len = o != null ? o.Capacity() : 0; if (n < 0 || n >= len) { throw new TJSException(Error.RangeError); } result.Set(o.Get(n)); return; } }
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception> /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> private static void GetStringProperty(Variant result, Variant str, Variant member ) { // processes properties toward strings. if (member.IsNumber() != true) { string name = member.GetString(); 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); } else { // member.Type() == tvtInteger || member.Type() == tvtReal string s = str.AsString(); int n = member.AsInteger(); 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; } }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public static int DefaultIsInstanceOf(int flag, Variant targ, string name, Dispatch2 objthis) { if (targ.IsVoid()) { return Error.S_FALSE; } if ("Object".Equals(name)) { return Error.S_TRUE; } if (targ.IsNumber()) { if ("Number".Equals(name)) { return Error.S_TRUE; } else { return Error.S_FALSE; } } else { if (targ.IsString()) { if ("String".Equals(name)) { return Error.S_TRUE; } else { return Error.S_FALSE; } } else { if (targ.IsOctet()) { if ("Octet".Equals(name)) { return Error.S_TRUE; } else { return Error.S_FALSE; } } else { if (targ.IsObject()) { VariantClosure tvclosure = targ.AsObjectClosure(); if (tvclosure.mObject != null) { // bypass Dispatch2 disp = tvclosure.mObjThis != null ? tvclosure.mObjThis : objthis; return tvclosure.mObject.IsInstanceOf(flag, null, name, disp); } return Error.S_FALSE; } } } } return Error.S_FALSE; }