24 lines
866 B
C#
24 lines
866 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using PorygonSharp.EvalValues;
|
|
using PorygonSharp.Utilities;
|
|
|
|
namespace PorygonSharp
|
|
{
|
|
public static class StaticScope
|
|
{
|
|
public static void RegisterStaticVariable(string name, object o)
|
|
{
|
|
var type = o.GetType();
|
|
var scriptType = ScriptType.ScriptType.GetScriptType(type);
|
|
var hash = name.ScriptHash();
|
|
var value = EvalValueCreator.CreateValue(o);
|
|
if (!scriptType.HasValue)
|
|
return;
|
|
RegisterStaticVariable(hash, scriptType.Value, value.GetPointer());
|
|
}
|
|
|
|
[DllImport("libPorygonLang", EntryPoint = "RegisterStaticVariable", CallingConvention = CallingConvention.Cdecl)]
|
|
private static extern void RegisterStaticVariable(uint hashId, IntPtr scriptType, IntPtr value);
|
|
}
|
|
} |