//internal static MetaUtilityFunctions muf; internal static void handlerMeta_Query(PluginLoadTime now, IntPtr PluginInfo, IntPtr MetaUtilFuncs) // unsafe internal static void handlerMeta_Query(PluginLoadTime now, IntPtr PluginInfo, ref MetaUtilityFunctions MetaUtilFuncs) { #if DEBUG Console.WriteLine(" -- MONO: handlerMeta_Query"); #endif // TODO: fix that // The following code doesn't work because C# treats char * as a pointer to a char, while // in C the offsets are really as long as the text itself, or something like that /* * PluginInfo* pluginInfo = (PluginInfo *)Marshal.AllocHGlobal(sizeof(PluginInfo)).ToPointer(); * pluginInfo->ifvers = (char *)UnixMarshal.StringToHeap("5:13").ToPointer(); * pluginInfo->name = (char *)UnixMarshal.StringToHeap("sharpmod").ToPointer(); * pluginInfo->version = (char *)UnixMarshal.StringToHeap("0.1").ToPointer(); * pluginInfo->date = (char *)UnixMarshal.StringToHeap("2008/01/01").ToPointer(); * pluginInfo->author = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); * pluginInfo->url = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); * pluginInfo->logtag = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); * pluginInfo->loadable = PluginLoadTime.Anytime; * pluginInfo->unloadable = PluginLoadTime.Anytime; * pPlugInfo = pluginInfo; */ //muf = (MetaUtilityFunctions)Marshal.PtrToStructure(MetaUtilFuncs, typeof(MetaUtilityFunctions)); metaUtilityFunctions = (MetaUtilityFunctions)Marshal.PtrToStructure(MetaUtilFuncs, typeof(MetaUtilityFunctions)); PLID = PluginInfo; }
public static IntPtr AllocPluginInfo(string ifvers, string name, string version, string date, string author, string url, string logtag, PluginLoadTime load, PluginLoadTime unload) { PluginInfo *pl = (PluginInfo *)UnixMarshal.AllocHeap(sizeof(PluginInfo)).ToPointer(); pl->ifvers = (sbyte *)UnixMarshal.StringToHeap(ifvers).ToPointer(); pl->name = (sbyte *)UnixMarshal.StringToHeap(name).ToPointer(); pl->version = (sbyte *)UnixMarshal.StringToHeap(version).ToPointer(); pl->date = (sbyte *)UnixMarshal.StringToHeap(date).ToPointer(); pl->author = (sbyte *)UnixMarshal.StringToHeap(author).ToPointer(); pl->url = (sbyte *)UnixMarshal.StringToHeap(url).ToPointer(); pl->logtag = (sbyte *)UnixMarshal.StringToHeap(logtag).ToPointer(); pl->loadable = load; pl->unloadable = unload; return(new IntPtr((void *)pl)); }
//internal static MetaUtilityFunctions muf; internal static void handlerMeta_Query(PluginLoadTime now, IntPtr PluginInfo, IntPtr MetaUtilFuncs) // unsafe internal static void handlerMeta_Query(PluginLoadTime now, IntPtr PluginInfo, ref MetaUtilityFunctions MetaUtilFuncs) { #if DEBUG Console.WriteLine(" -- MONO: handlerMeta_Query"); #endif // TODO: fix that // The following code doesn't work because C# treats char * as a pointer to a char, while // in C the offsets are really as long as the text itself, or something like that /* PluginInfo* pluginInfo = (PluginInfo *)Marshal.AllocHGlobal(sizeof(PluginInfo)).ToPointer(); pluginInfo->ifvers = (char *)UnixMarshal.StringToHeap("5:13").ToPointer(); pluginInfo->name = (char *)UnixMarshal.StringToHeap("sharpmod").ToPointer(); pluginInfo->version = (char *)UnixMarshal.StringToHeap("0.1").ToPointer(); pluginInfo->date = (char *)UnixMarshal.StringToHeap("2008/01/01").ToPointer(); pluginInfo->author = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); pluginInfo->url = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); pluginInfo->logtag = (char *)UnixMarshal.StringToHeap("Andrius Bentkus").ToPointer(); pluginInfo->loadable = PluginLoadTime.Anytime; pluginInfo->unloadable = PluginLoadTime.Anytime; *pPlugInfo = pluginInfo; */ //muf = (MetaUtilityFunctions)Marshal.PtrToStructure(MetaUtilFuncs, typeof(MetaUtilityFunctions)); metaUtilityFunctions = (MetaUtilityFunctions)Marshal.PtrToStructure(MetaUtilFuncs, typeof(MetaUtilityFunctions)); PLID = PluginInfo; }