-
Notifications
You must be signed in to change notification settings - Fork 0
API Host ClrType
已注册 CLR 类型的脚本可见包装对象。
Script-visible wrapper for a registered CLR type.
命名空间:AuroraScript.Runtime.Interop。类型:class。
Namespace:
AuroraScript.Runtime.Interop. Kind: class.
ClrType 是公开宿主类型。通过下方签名选择调用方式;对运行时对象、生命周期和异常,应由宿主在边界处明确处理。
Script-visible wrapper for a registered CLR type.
注意
宿主通常通过 AuroraEngine.RegisterType 或 ClrTypeRegistry.TryGetClrType 获得该对象。
Hosts normally obtain this through AuroraEngine.RegisterType or ClrTypeRegistry.TryGetClrType.
下面是 ClrType 的最小使用方式。
A minimal use of
ClrType.
engine.RegisterType<DateTime>("HostDate", TypeAccess.Constructor);
if (engine.ClrRegistry.TryGetClrType("HostDate", out var type))
{
Console.WriteLine(type);
}调用 Construct 完成其公开操作。
Constructs a CLR instance when constructor access is allowed.
Parameters:
-
ctx
当前脚本执行上下文。Current script execution context.
-
args
传给脚本或回调的实参数组。Argument array passed to a script or callback.
-
result
接收调用结果的变量。Variable receiving the call result.
Returns
无。
None.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ClrType value = /* 从宿主 API 获取实例 */;
value.Construct(/* ctx */, /* args */, /* result */);AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License