本文整理汇总了C#中Kirikiri.Tjs2.Variant.ToJavaObject方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.ToJavaObject方法的具体用法?C# Variant.ToJavaObject怎么用?C# Variant.ToJavaObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kirikiri.Tjs2.Variant
的用法示例。
在下文中一共展示了Variant.ToJavaObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutData
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
private int PutData(Variant val)
{
// 直近の20个の中で同じものがあるか调べる TODO 别コンパイルにするのなら、全データでチェックするようにした方がいいか
int size = mDataArea.Count;
int count = size > SEARCH_CONST_VAL_SIZE ? SEARCH_CONST_VAL_SIZE : size;
int offset = size - 1;
for (int i = 0; i < count; i++)
{
int pos = offset - i;
if (mDataArea[pos].DiscernCompareStrictReal(val))
{
return pos;
}
}
Variant v;
if (val.IsString())
{
v = new Variant(TJS.MapGlobalStringMap(val.AsString()));
}
else
{
v = new Variant(val);
object o = v.ToJavaObject();
if (o is InterCodeGenerator)
{
mInterCodeDataArea.AddItem(v);
}
}
mDataArea.AddItem(v);
return mDataArea.Count - 1;
}
示例2: VariantToJavaObject
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
public static object VariantToJavaObject(Variant param, Type type)
{
if (type.IsPrimitive)
{
// プリミティブタイプの场合
if (type.Equals(typeof(int)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger());
}
else
{
if (type.Equals(typeof(double)))
{
return (param.AsDouble());
}
else
{
if (type.Equals(typeof(bool)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger() != 0 ? true : false);
}
else
{
if (type.Equals(typeof(float)))
{
return ((float)param.AsDouble());
}
else
{
if (type.Equals(typeof(long)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger());
}
else
{
if (type.Equals(typeof(char)))
{
return ((char)param.AsInteger());
}
else
{
if (type.Equals(typeof(byte)))
{
return (unchecked((byte)param.AsInteger()));
}
else
{
if (type.Equals(typeof(short)))
{
return ((short)param.AsInteger());
}
else
{
// may be Void.TYPE
return null;
}
}
}
}
}
}
}
}
}
else
{
if (type.Equals(typeof(string)))
{
return param.AsString();
}
else
{
if (type.Equals(typeof(ByteBuffer)))
{
return param.AsOctet();
}
else
{
if (type.Equals(typeof(Variant)))
{
return param;
}
else
{
if (type.Equals(typeof(VariantClosure)))
{
return param.AsObjectClosure();
}
else
{
if (type.Equals(typeof(Dispatch2)))
{
return param.AsObject();
}
else
{
if (type.Equals(param.ToJavaObject().GetType()))
{
return param.ToJavaObject();
//.........这里部分代码省略.........
示例3: PutVariant
public int PutVariant(Variant v, Compiler block)
{
object o = v.ToJavaObject();
int type = GetType(v);
switch (type)
{
case TYPE_VOID:
{
return 0;
}
case TYPE_OBJECT:
{
// 常に0
VariantClosure clo = (VariantClosure)o;
if (clo.mObject == null && clo.mObjThis == null)
{
return 0;
}
else
{
// null の VariantClosure は受け入れる
return -1;
}
goto case TYPE_INTER_OBJECT;
}
case TYPE_INTER_OBJECT:
{
// その他は入れない。Dictionary と Array は保存できるようにした方がいいが……
VariantClosure clo = (VariantClosure)o;
Dispatch2 dsp = clo.mObject;
return block.GetObjectIndex((InterCodeObject)dsp);
}
case TYPE_STRING:
{
return PutString(((string)o));
}
case TYPE_OCTET:
{
return PutByteBuffer((ByteBuffer)o);
}
case TYPE_REAL:
{
return PutDouble(((Number)o));
}
case TYPE_BYTE:
{
return PutByte(((Number)o));
}
case TYPE_SHORT:
{
return PutShort(((Number)o));
}
case TYPE_INTEGER:
{
return PutInteger(((Number)o));
}
case TYPE_LONG:
{
return PutLong(((Number)o));
}
case TYPE_INTER_GENERATOR:
{
return block.GetCodeIndex((InterCodeGenerator)o);
}
case TYPE_UNKNOWN:
{
return -1;
}
}
return -1;
}
示例4: GetType
public byte GetType(Variant v)
{
object o = v.ToJavaObject();
if (o == null)
{
return TYPE_VOID;
}
else
{
if (o is string)
{
return TYPE_STRING;
}
else
{
if (o is int)
{
int val = ((int)o);
if (val >= byte.MinValue && val <= byte.MaxValue)
{
return TYPE_BYTE;
}
else
{
if (val >= short.MinValue && val <= short.MaxValue)
{
return TYPE_SHORT;
}
else
{
return TYPE_INTEGER;
}
}
}
else
{
if (o is double)
{
return TYPE_REAL;
}
else
{
if (o is VariantClosure)
{
VariantClosure clo = (VariantClosure)o;
Dispatch2 dsp = clo.mObject;
if (dsp is InterCodeObject)
{
return TYPE_INTER_OBJECT;
}
else
{
return TYPE_OBJECT;
}
}
else
{
if (o is InterCodeGenerator)
{
return TYPE_INTER_GENERATOR;
}
else
{
if (o is ByteBuffer)
{
return TYPE_OCTET;
}
else
{
if (o is long)
{
long val = ((long)o);
if (val >= byte.MinValue && val <= byte.MaxValue)
{
return TYPE_BYTE;
}
else
{
if (val >= short.MinValue && val <= short.MaxValue)
{
return TYPE_SHORT;
}
else
{
if (val >= int.MinValue && val <= int.MaxValue)
{
return TYPE_INTEGER;
}
else
{
return TYPE_LONG;
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例5: GetType
private byte GetType(Variant v)
{
object o = v.ToJavaObject();
if (o == null)
{
return TYPE_VOID;
}
else
{
if (o is string)
{
return TYPE_STRING;
}
else
{
if (o is int)
{
return TYPE_INTEGER;
}
else
{
if (o is double)
{
return TYPE_REAL;
}
else
{
if (o is VariantClosure)
{
VariantClosure clo = (VariantClosure)o;
Dispatch2 dsp = clo.mObject;
if (dsp is InterCodeObject)
{
return TYPE_INTER_OBJECT;
}
else
{
if (dsp == null)
{
return TYPE_NULL_CLOSURE;
}
return TYPE_OBJECT;
}
}
else
{
if (o is InterCodeGenerator)
{
return TYPE_INTER_GENERATOR;
}
else
{
if (o is ByteBuffer)
{
return TYPE_OCTET;
}
else
{
if (o is long)
{
return TYPE_INTEGER;
}
}
}
}
}
}
}
}
return TYPE_UNKNOWN;
}
示例6: GetDataToStrOrNum
/// <exception cref="Kirikiri.Tjs2.CompileException"></exception>
private string GetDataToStrOrNum(Variant v)
{
object o = v.ToJavaObject();
if (o == null)
{
return "null";
}
else
{
if (o is string)
{
return "\"" + (string)o + "\"";
}
else
{
if (o is int)
{
return ((int)o).ToString();
}
else
{
if (o is double)
{
return ((double)o).ToString();
}
else
{
if (o is VariantClosure)
{
throw new CompileException("非サポートの定数形式");
}
else
{
if (o is InterCodeGenerator)
{
throw new CompileException("非サポートの定数形式");
}
else
{
if (o is ByteBuffer)
{
throw new CompileException("非サポートの定数形式");
}
else
{
if (o is long)
{
return ((long)o).ToString();
}
}
}
}
}
}
}
}
throw new CompileException("非サポートの定数形式");
}