本文整理汇总了C#中Kirikiri.Tjs2.Variant.AsObjectClosure方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.AsObjectClosure方法的具体用法?C# Variant.AsObjectClosure怎么用?C# Variant.AsObjectClosure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kirikiri.Tjs2.Variant
的用法示例。
在下文中一共展示了Variant.AsObjectClosure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryFuncCallViaPropGet
// オリジナルでは、强制的に int で返す(アドレスになるかもしれない)もののようだが……
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
private static int TryFuncCallViaPropGet(VariantClosure tvclosure, int flag, Variant
result, Variant[] param, Dispatch2 objthis)
{
// retry using PropGet
Variant tmp = new Variant();
Dispatch2 disp = tvclosure.mObjThis != null ? tvclosure.mObjThis : objthis;
int er = tvclosure.mObject.PropGet(0, null, tmp, disp);
if (er >= 0)
{
tvclosure = tmp.AsObjectClosure();
disp = tvclosure.mObjThis != null ? tvclosure.mObjThis : objthis;
er = tvclosure.mObject.FuncCall(flag, null, result, param, disp);
}
return er;
}
示例2: IsInstanceOf
// class instance matching returns false or true
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public override int IsInstanceOf(int flag, string membername, string classname, Dispatch2
objthis)
{
if (!GetValidity())
{
return Error.E_INVALIDOBJECT;
}
if (membername == null)
{
switch (mContextType)
{
case ContextType.TOP_LEVEL:
case ContextType.PROPERTY_SETTER:
case ContextType.PROPERTY_GETTER:
case ContextType.SUPER_CLASS_GETTER:
{
break;
}
case ContextType.FUNCTION:
case ContextType.EXPR_FUNCTION:
{
if ("Function".Equals(classname))
{
return Error.S_TRUE;
}
break;
}
case ContextType.PROPERTY:
{
if ("Property".Equals(classname))
{
return Error.S_TRUE;
}
break;
}
case ContextType.CLASS:
{
if ("Class".Equals(classname))
{
return Error.S_TRUE;
}
break;
}
}
}
int hr = base.IsInstanceOf(flag, membername, classname, objthis);
if (membername != null && hr == Error.E_MEMBERNOTFOUND && mContextType == ContextType
.CLASS && mSuperClassGetter != null)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.IsInstanceOf(flag, membername, classname, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
return hr;
}
示例3: DefaultPropSet
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
protected internal static int DefaultPropSet(int flag, Variant targ, Variant param
, Dispatch2 objthis)
{
if ((flag & Interface.IGNOREPROP) == 0)
{
if (targ.IsObject())
{
// roughly the same as TJSDefaultPropGet
VariantClosure tvclosure = targ.AsObjectClosure();
int hr = Error.E_NOTIMPL;
if (tvclosure.mObject != null)
{
Dispatch2 disp = tvclosure.mObjThis != null ? tvclosure.mObjThis : objthis;
hr = tvclosure.mObject.PropSet(0, null, param, disp);
}
if (hr >= 0)
{
return hr;
}
if (hr != Error.E_NOTIMPL && hr != Error.E_INVALIDTYPE && hr != Error.E_INVALIDOBJECT)
{
return hr;
}
}
}
// normal substitution
if (param == null)
{
return Error.E_INVALIDPARAM;
}
targ.CopyRef(param);
return Error.S_OK;
}
示例4: SetPropertyIndirect
/// <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);
}
}
}
}
示例5: 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);
}
}
}
}
示例6: GetExceptionObject
/// <summary>TJSGetExceptionObject : retrieves TJS 'Exception' object</summary>
/// <exception cref="TJSException">TJSException</exception>
/// <exception cref="VariantException">VariantException</exception>
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public static void GetExceptionObject(TJS tjs, Variant res, Variant msg, Variant
trace)
{
if (res == null)
{
return;
}
// not prcess
// retrieve class "Exception" from global
Dispatch2 global = tjs.GetGlobal();
Variant val = new Variant();
int hr = global.PropGet(0, EXCEPTION_NAME, val, global);
if (hr < 0)
{
throw new TJSException(ExceptionNotFound);
}
// create an Exception object
Holder<Dispatch2> excpobj = new Holder<Dispatch2>(null);
VariantClosure clo = val.AsObjectClosure();
Variant[] pmsg = new Variant[1];
pmsg[0] = msg;
hr = clo.CreateNew(0, null, excpobj, pmsg, clo.mObjThis);
if (hr < 0)
{
throw new TJSException(ExceptionNotFound);
}
Dispatch2 disp = excpobj.mValue;
if (trace != null)
{
string trace_name = "trace";
disp.PropSet(Interface.MEMBERENSURE, trace_name, trace, disp);
}
res.Set(disp, disp);
excpobj = null;
}
示例7: GetPropertyDirect
//getPropertyDirect( ra[ra_offset+ca[code+1]], ra[ra_offset+ca[code+2]], da[ca[code+3]], objthis, flags );
// member は、固定值なので、事前に条件分岐できる、文字か数值で割り分け
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
protected internal static void GetPropertyDirect(Variant result, Variant target,
string member, Dispatch2 objthis, int flags)
{
if (target.IsObject())
{
VariantClosure clo = target.AsObjectClosure();
int hr = clo.PropGet(flags, member, result, clo.mObjThis != null ? clo.mObjThis :
objthis);
if (hr < 0)
{
ThrowFrom_tjs_error(hr, member);
}
}
else
{
if (target.IsString())
{
GetStringProperty(result, target, member);
}
else
{
if (target.IsOctet())
{
GetOctetProperty(result, target, member);
}
else
{
string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString
(target));
throw new VariantException(mes);
}
}
}
}
示例8: GetCount
// get member count
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public override int GetCount(IntWrapper result, string membername, Dispatch2 objthis
)
{
int hr = base.GetCount(result, membername, objthis);
if (membername != null && hr == Error.E_MEMBERNOTFOUND && mContextType == ContextType
.CLASS && mSuperClassGetter != null)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.GetCount(result, membername, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
return hr;
}
示例9: DefaultCreateNew
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
protected internal static int DefaultCreateNew(int flag, Variant targ, Holder<Dispatch2
> result, Variant[] param, Dispatch2 objthis)
{
if (targ.IsObject())
{
VariantClosure tvclosure = targ.AsObjectClosure();
if (tvclosure.mObject != null)
{
// bypass
Dispatch2 disp = tvclosure.mObjThis != null ? tvclosure.mObjThis : objthis;
return tvclosure.mObject.CreateNew(flag, null, result, param, disp);
}
}
return Error.E_INVALIDTYPE;
}
示例10: CreateNew
// create new object
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public override int CreateNew(int flag, string membername, Holder<Dispatch2> result
, Variant[] param, Dispatch2 objthis)
{
if (!GetValidity())
{
return Error.E_INVALIDOBJECT;
}
if (membername == null)
{
if (mContextType != ContextType.CLASS)
{
return Error.E_INVALIDTYPE;
}
Dispatch2 dsp = new CustomObject();
ExecuteAsFunction(dsp, null, null, 0);
FuncCall(0, mName, null, param, dsp);
result.Set(dsp);
return Error.S_OK;
}
int hr = base.CreateNew(flag, membername, result, param, objthis);
if (membername != null && hr == Error.E_MEMBERNOTFOUND && mContextType == ContextType
.CLASS && mSuperClassGetter != null)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.CreateNew(flag, membername, result, param, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
return hr;
}
示例11: FuncCall
// Dispatch2 implementation
// function invocation
/// <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 (!GetValidity())
{
return Error.E_INVALIDOBJECT;
}
if (membername == null)
{
switch (mContextType)
{
case ContextType.TOP_LEVEL:
{
ExecuteAsFunction(objthis != null ? objthis : mBlock.GetTJS().GetGlobal(), null,
result, 0);
break;
}
case ContextType.FUNCTION:
case ContextType.EXPR_FUNCTION:
case ContextType.PROPERTY_GETTER:
case ContextType.PROPERTY_SETTER:
{
ExecuteAsFunction(objthis, param, result, 0);
break;
}
case ContextType.CLASS:
{
// on super class' initialization
ExecuteAsFunction(objthis, param, result, 0);
break;
}
case ContextType.PROPERTY:
{
return Error.E_INVALIDTYPE;
}
}
return Error.S_OK;
}
int hr = base.FuncCall(flag, membername, result, param, objthis);
if (membername != null && hr == Error.E_MEMBERNOTFOUND && mContextType == ContextType
.CLASS && mSuperClassGetter != null)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count > 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
int v = pointer[i];
mSuperClassGetter.ExecuteAsFunction(null, null, res, v);
VariantClosure clo = res.AsObjectClosure();
hr = clo.FuncCall(flag, membername, result, param, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
return hr;
}
示例12: PropSet
// property set
/// <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 (!GetValidity())
{
return Error.E_INVALIDOBJECT;
}
if (membername == null)
{
if (mContextType == ContextType.PROPERTY)
{
// executed as a property setter
if (mPropSetter != null)
{
Variant[] @params = new Variant[1];
@params[0] = param;
return mPropSetter.FuncCall(0, null, null, @params, objthis);
}
else
{
return Error.E_ACCESSDENYED;
}
}
}
// WARNING!! const tTJSVariant ** -> tTJSVariant** force casting
int hr;
if (membername != null && mContextType == ContextType.CLASS && mSuperClassGetter
!= null)
{
int pseudo_flag = (flag & Interface.IGNOREPROP) != 0 ? flag : (flag & ~Interface.
MEMBERENSURE);
// member ensuring is temporarily disabled unless Interface.IGNOREPROP
hr = base.PropSet(pseudo_flag, membername, param, objthis);
if (hr == Error.E_MEMBERNOTFOUND)
{
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.PropSet(pseudo_flag, membername, param, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
if (hr == Error.E_MEMBERNOTFOUND && (flag & Interface.MEMBERENSURE) != 0)
{
// re-ensure the member for "this" object
hr = base.PropSet(flag, membername, param, objthis);
}
}
else
{
hr = base.PropSet(flag, membername, param, objthis);
}
return hr;
}
示例13: PropGet
// property get
/// <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 (!GetValidity())
{
return Error.E_INVALIDOBJECT;
}
if (membername == null)
{
if (mContextType == ContextType.PROPERTY)
{
// executed as a property getter
if (mPropGetter != null)
{
return mPropGetter.FuncCall(0, null, result, null, objthis);
}
else
{
return Error.E_ACCESSDENYED;
}
}
}
int hr = base.PropGet(flag, membername, result, objthis);
if (membername != null && hr == Error.E_MEMBERNOTFOUND && mContextType == ContextType
.CLASS && mSuperClassGetter != null)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.PropGet(flag, membername, result, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
return hr;
}
示例14: Operation
// operation with member
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public override int Operation(int flag, string membername, Variant result, Variant
param, Dispatch2 objthis)
{
if (membername == null)
{
if (mContextType == ContextType.PROPERTY)
{
// operation for property object
return base.DispatchOperation(flag, membername, result, param, objthis);
}
else
{
return base.Operation(flag, membername, result, param, objthis);
}
}
int hr;
if (membername != null && mContextType == ContextType.CLASS && mSuperClassGetter
!= null)
{
int pseudo_flag = (flag & Interface.IGNOREPROP) != 0 ? flag : (flag & ~Interface.
MEMBERENSURE);
hr = base.Operation(pseudo_flag, membername, result, param, objthis);
if (hr == Error.E_MEMBERNOTFOUND)
{
// look up super class
int[] pointer = mSuperClassGetter.mSuperClassGetterPointer;
int count = pointer.Length;
if (count != 0)
{
Variant res = new Variant();
for (int i = count - 1; i >= 0; i--)
{
mSuperClassGetter.ExecuteAsFunction(null, null, res, pointer[i]);
VariantClosure clo = res.AsObjectClosure();
hr = clo.Operation(pseudo_flag, membername, result, param, objthis);
if (hr != Error.E_MEMBERNOTFOUND)
{
break;
}
}
}
}
if (hr == Error.E_MEMBERNOTFOUND)
{
hr = base.Operation(flag, membername, result, param, objthis);
}
return hr;
}
else
{
return base.Operation(flag, membername, result, param, objthis);
}
}
示例15: DefaultIsInstanceOf
/// <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;
}