public static bool IsMethodDelegate(IntPtr className, IntPtr methodName) { string _className = Marshal.PtrToStringAnsi(className); string _methodName = Marshal.PtrToStringAnsi(methodName); return(EngineCallbacks.IsMethod(_className, _methodName)); }
public static string CallFunctionDelegate(IntPtr name, IntPtr argv, int argc, out bool result) { string _name = Marshal.PtrToStringAnsi(name); string[] strings = null; if (argv != IntPtr.Zero) { strings = CustomMarshalling.IntPtrToStringArray(argv, argc); } return(EngineCallbacks.CallScriptFunction(_name, strings, out result)); }
public static string CallMethodDelegate(IntPtr className, uint obj, IntPtr name, IntPtr argv, int argc, out bool result) { string _className = Marshal.PtrToStringAnsi(className); string _name = Marshal.PtrToStringAnsi(name); SimObject objectWrapper = new SimObject(obj); string[] strings = {}; if (argv != IntPtr.Zero) { strings = CustomMarshalling.IntPtrToStringArray(argv, argc); } string strRes = EngineCallbacks.CallScriptMethod(_className, objectWrapper, _name, strings, out result); if (!result) { strRes = EngineCallbacks.CallScriptMethod(_className, objectWrapper, _name, strings, out result); } return(strRes); }
public static void InitializeTypeDictionaries(IEnumerable <Type> types) { EngineCallbacks.Clear(); foreach (Type type in types) { IEnumerable <ConsoleClassAttribute> attributes = type.GetCustomAttributes <ConsoleClassAttribute>(false); if (attributes.Any()) { EngineCallbacks.RegisterType(attributes.First().ConsoleName ?? type.Name, type); } foreach (MethodInfo methodInfo in type.GetMethods()) { IEnumerable <ConsoleFunctionAttribute> functionAttributes = methodInfo.GetCustomAttributes <ConsoleFunctionAttribute>(false); if (functionAttributes.Any()) { EngineCallbacks.RegisterFunction(functionAttributes.First().FunctionName ?? methodInfo.Name, methodInfo); } IEnumerable <ScriptEntryPointAttribute> entryAttribute = methodInfo.GetCustomAttributes <ScriptEntryPointAttribute>(false); if (entryAttribute.Any()) { if (methodInfo.IsStatic && !methodInfo.GetParameters().Any() && methodInfo.ReturnType == typeof(void)) { mScriptEntryPointMethodInfo = methodInfo; } else { Console.WriteLine("ScriptEntry method: " + methodInfo.Name + " did not match the necessary signature."); } } } } }