本文整理汇总了C#中Kirikiri.Tjs2.Variant.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.Set方法的具体用法?C# Variant.Set怎么用?C# Variant.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kirikiri.Tjs2.Variant
的用法示例。
在下文中一共展示了Variant.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CharacterCodeOf
/// <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);
}
}
示例2: PropGet
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;
}
示例3: Process
/// <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;
}
示例4: Process
/// <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;
}
示例5: InstanceOf
/// <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);
}
示例6: GetStringProperty
/// <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);
}
示例7: Process
/// <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;
}
示例8: TypeOfMemberIndirect
/// <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);
}
}
}
}
示例9: GetOctetProperty
/// <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);
}
示例10: Get
public override int Get(Variant result, Dispatch2 objthis)
{
result.Set(2.30258509299404568402);
return Error.S_OK;
}
示例11: TypeOfMemberDirect
/// <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);
}
}
}
}
示例12: TypeOf
protected internal static void TypeOf(Variant val)
{
// processes TJS2's typeof operator.
string name = val.GetTypeName();
if (name != null)
{
val.Set(name);
}
}
示例13: CharacterCodeFrom
/// <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));
}
示例14: ReadObjects
/// <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];
//.........这里部分代码省略.........
示例15: Eval
/// <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);
}
}