PorygonSharp/PorygonSharp/StaticScope.cs

22 lines
798 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);
RegisterStaticVariable(hash, scriptType, value.GetPointer());
}
[DllImport("libPorygonLang", EntryPoint = "RegisterStaticVariable", CallingConvention = CallingConvention.Cdecl)]
private static extern void RegisterStaticVariable(uint hashId, IntPtr scriptType, IntPtr value);
}
}