diff --git a/Source/Libs/Shared/FuncLoader.cs b/Source/Libs/Shared/FuncLoader.cs index 4b384e8c6..d94c6710a 100644 --- a/Source/Libs/Shared/FuncLoader.cs +++ b/Source/Libs/Shared/FuncLoader.cs @@ -61,8 +61,16 @@ class FuncLoader ret = Linux.dlsym(library, function); if (ret == IntPtr.Zero) - throw new EntryPointNotFoundException(function); + Console.WriteLine("[WARNING] Function not found: " + function); return ret; } + + public static T LoadFunction(IntPtr procaddress) + { + if (procaddress == IntPtr.Zero) + return default(T); + + return Marshal.GetDelegateForFunctionPointer(procaddress); + } } diff --git a/Source/Tools/GapiCodegen/Ctor.cs b/Source/Tools/GapiCodegen/Ctor.cs index e2b13b146..ce8e9ada8 100755 --- a/Source/Tools/GapiCodegen/Ctor.cs +++ b/Source/Tools/GapiCodegen/Ctor.cs @@ -66,7 +66,7 @@ namespace GtkSharp.Generation { void GenerateImport (StreamWriter sw) { sw.WriteLine("\t\tdelegate IntPtr d_{0}({1});", CName, Parameters.ImportSignature); - sw.WriteLine("\t\tstatic d_{0} {0} = Marshal.GetDelegateForFunctionPointer(FuncLoader.GetProcAddress(GLibrary.Load(\"{1}\"), \"{0}\"));", CName, LibraryName); + sw.WriteLine("\t\tstatic d_{0} {0} = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(\"{1}\"), \"{0}\"));", CName, LibraryName); sw.WriteLine(); } diff --git a/Source/Tools/GapiCodegen/EnumGen.cs b/Source/Tools/GapiCodegen/EnumGen.cs index 154dea1c5..43f360fcd 100755 --- a/Source/Tools/GapiCodegen/EnumGen.cs +++ b/Source/Tools/GapiCodegen/EnumGen.cs @@ -119,7 +119,7 @@ namespace GtkSharp.Generation { sw.WriteLine ("\tinternal class " + Name + "GType {"); var funcname = Elem.GetAttribute("gtype"); sw.WriteLine ("\t\tdelegate IntPtr d_" + funcname + "();"); - sw.WriteLine ("\t\tstatic d_" + funcname + " " + funcname + " = Marshal.GetDelegateForFunctionPointer(FuncLoader.GetProcAddress(GLibrary.Load(\"" + LibraryName + "\"), \"" + funcname + "\"));"); + sw.WriteLine ("\t\tstatic d_" + funcname + " " + funcname + " = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(\"" + LibraryName + "\"), \"" + funcname + "\"));"); sw.WriteLine (); sw.WriteLine ("\t\tpublic static GLib.GType GType {"); sw.WriteLine ("\t\t\tget {"); diff --git a/Source/Tools/GapiCodegen/Method.cs b/Source/Tools/GapiCodegen/Method.cs index dd9071fe7..e2b8f8f9d 100755 --- a/Source/Tools/GapiCodegen/Method.cs +++ b/Source/Tools/GapiCodegen/Method.cs @@ -196,7 +196,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\tdelegate " + retval.CSType + " d_" + CName + "(" + import_sig + ");"); else sw.WriteLine("\t\tdelegate " + retval.MarshalType + " d_" + CName + "(" + import_sig + ");"); - sw.WriteLine("\t\tstatic d_" + CName + " " + CName + " = Marshal.GetDelegateForFunctionPointer(FuncLoader.GetProcAddress(GLibrary.Load(\"" + LibraryName + "\"), \"" + CName + "\"));"); + sw.WriteLine("\t\tstatic d_" + CName + " " + CName + " = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(\"" + LibraryName + "\"), \"" + CName + "\"));"); sw.WriteLine(); } diff --git a/Source/Tools/GapiCodegen/OpaqueGen.cs b/Source/Tools/GapiCodegen/OpaqueGen.cs index d9e0b3a84..288efd17d 100755 --- a/Source/Tools/GapiCodegen/OpaqueGen.cs +++ b/Source/Tools/GapiCodegen/OpaqueGen.cs @@ -186,7 +186,7 @@ namespace GtkSharp.Generation { #endif if (set_gvalue != null) { sw.WriteLine("\t\tdelegate IntPtr d_{0}(ref GLib.Value val, IntPtr obj);", set_gvalue.CName); - sw.WriteLine("\t\tstatic d_{0} {0} = Marshal.GetDelegateForFunctionPointer(FuncLoader.GetProcAddress(GLibrary.Load(\"{1}\"), \"{0}\"));", set_gvalue.CName, LibraryName); + sw.WriteLine("\t\tstatic d_{0} {0} = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(\"{1}\"), \"{0}\"));", set_gvalue.CName, LibraryName); sw.WriteLine (); sw.WriteLine ("\t\tpublic void SetGValue (ref GLib.Value val)"); sw.WriteLine ("\t\t{");