IsInteger() public method

public IsInteger ( ) : bool
return bool
示例#1
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static string VariantToExpressionString(Variant val)
 {
     // convert given variant to string which can be interpret as an expression.
     // this function does not convert objects ( returns empty string )
     if (val.IsVoid())
     {
         return "void";
     }
     else
     {
         if (val.IsInteger())
         {
             return val.AsString();
         }
         else
         {
             if (val.IsReal())
             {
                 string s = Variant.RealToHexString(val.AsDouble());
                 return s + " /* " + val.AsString() + " */";
             }
             else
             {
                 if (val.IsString())
                 {
                     string s = LexBase.EscapeC(val.AsString());
                     return "\"" + s + "\"";
                 }
                 else
                 {
                     if (val.IsOctet())
                     {
                         string s = Variant.OctetToListString(val.AsOctet());
                         return "<%" + s + "%>";
                     }
                     else
                     {
                         return string.Empty;
                     }
                 }
             }
         }
     }
 }
 /// <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>
 protected internal static void SetPropertyIndirect(Variant target, Variant member
     , Variant param, Dispatch2 objthis, int flags)
 {
     if (target.IsObject())
     {
         VariantClosure clo = target.AsObjectClosure();
         if (member.IsInteger() != true)
         {
             string str = member.AsString();
             int hr = clo.PropSet(flags, str, param, clo.mObjThis != null ? clo.mObjThis : objthis
                 );
             if (hr < 0)
             {
                 ThrowFrom_tjs_error(hr, str);
             }
         }
         else
         {
             int hr = clo.PropSetByNum(flags, member.AsInteger(), param, clo.mObjThis != null ?
                 clo.mObjThis : objthis);
             if (hr < 0)
             {
                 ThrowFrom_tjs_error_num(hr, member.AsInteger());
             }
         }
     }
     else
     {
         if (target.IsString())
         {
             SetStringProperty(param, target, member);
         }
         else
         {
             if (target.IsOctet())
             {
                 SetOctetProperty(param, target, member);
             }
             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>
 protected internal static void OperatePropertyIndirect0(VariantClosure clo, Variant
     name, Variant result, Dispatch2 objthis, int ope)
 {
     if (name.IsInteger() != true)
     {
         string str = name.AsString();
         int hr = clo.Operation(ope, str, result, null, clo.mObjThis != null ? clo.mObjThis
              : objthis);
         if (hr < 0)
         {
             ThrowFrom_tjs_error(hr, str);
         }
     }
     else
     {
         int hr = clo.OperationByNum(ope, name.AsInteger(), result, null, clo.mObjThis !=
             null ? clo.mObjThis : objthis);
         if (hr < 0)
         {
             ThrowFrom_tjs_error_num(hr, name.AsInteger());
         }
     }
 }
示例#5
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static string VariantToReadableString(Variant val, int maxlen)
 {
     string ret = null;
     if (val == null || val.IsVoid())
     {
         ret = "(void)";
     }
     else
     {
         if (val.IsInteger())
         {
             ret = "(int)" + val.AsString();
         }
         else
         {
             if (val.IsReal())
             {
                 ret = "(real)" + val.AsString();
             }
             else
             {
                 if (val.IsString())
                 {
                     ret = "(string)\"" + LexBase.EscapeC(val.AsString()) + "\"";
                 }
                 else
                 {
                     if (val.IsOctet())
                     {
                         ret = "(octet)<% " + Variant.OctetToListString(val.AsOctet()) + " %>";
                     }
                     else
                     {
                         if (val.IsObject())
                         {
                             VariantClosure c = (VariantClosure)val.AsObjectClosure();
                             StringBuilder str = new StringBuilder(128);
                             str.Append("(object)");
                             str.Append('(');
                             if (c.mObject != null)
                             {
                                 str.Append('[');
                                 if (c.mObject is NativeClass)
                                 {
                                     str.Append(((NativeClass)c.mObject).GetClassName());
                                 }
                                 else
                                 {
                                     if (c.mObject is InterCodeObject)
                                     {
                                         str.Append(((InterCodeObject)c.mObject).GetName());
                                     }
                                     else
                                     {
                                         if (c.mObject is CustomObject)
                                         {
                                             string name = ((CustomObject)c.mObject).GetClassNames();
                                             if (name != null)
                                             {
                                                 str.Append(name);
                                             }
                                             else
                                             {
                                                 str.Append(c.mObject.GetType().FullName);
                                             }
                                         }
                                         else
                                         {
                                             str.Append(c.mObject.GetType().FullName);
                                         }
                                     }
                                 }
                                 str.Append(']');
                             }
                             else
                             {
                                 str.Append("0x00000000");
                             }
                             if (c.mObjThis != null)
                             {
                                 str.Append('[');
                                 if (c.mObjThis is NativeClass)
                                 {
                                     str.Append(((NativeClass)c.mObjThis).GetClassName());
                                 }
                                 else
                                 {
                                     if (c.mObjThis is InterCodeObject)
                                     {
                                         str.Append(((InterCodeObject)c.mObjThis).GetName());
                                     }
                                     else
                                     {
                                         if (c.mObjThis is CustomObject)
                                         {
                                             string name = ((CustomObject)c.mObjThis).GetClassNames();
                                             if (name != null)
                                             {
                                                 str.Append(name);
                                             }
                                             else
                                             {
                                                 str.Append(c.mObjThis.GetType().FullName);
                                             }
                                         }
                                         else
                                         {
                                             str.Append(c.mObjThis.GetType().FullName);
                                         }
                                     }
                                 }
                                 str.Append(']');
                             }
                             else
                             {
                                 str.Append(":0x00000000");
                             }
                             str.Append(')');
                             ret = str.ToString();
                         }
                         else
                         {
                             // native object ?
                             ret = "(octet) [" + val.GetType().FullName + "]";
                         }
                     }
                 }
             }
         }
     }
     if (ret != null)
     {
         if (ret.Length > maxlen)
         {
             return Sharpen.Runtime.Substring(ret, 0, maxlen);
         }
         else
         {
             return ret;
         }
     }
     return string.Empty;
 }