Generator now creating imported api delegates with UnamangedFunctionPointer calling convention cdecl by default.

This commit is contained in:
Mikhail Kanygin 2019-10-03 11:19:23 +03:00 committed by cra0zy
parent 42a0e01775
commit f43292c19c
5 changed files with 35 additions and 28 deletions

View file

@ -208,7 +208,7 @@ namespace GtkSharp.Generation {
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine ("#region Autogenerated code");
sw.WriteLine ("\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
//sw.WriteLine ("\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
sw.WriteLine ("\tinternal delegate " + retval.MarshalType + " " + wrapper + "(" + parms.ImportSignature + ");");
sw.WriteLine ();
GenInvoker (gen_info, sw);

View file

@ -65,6 +65,7 @@ namespace GtkSharp.Generation {
void GenerateImport (StreamWriter sw)
{
sw.WriteLine("\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
sw.WriteLine("\t\tdelegate IntPtr d_{0}({1});", CName, Parameters.ImportSignature);
sw.WriteLine("\t\tstatic d_{0} {0} = FuncLoader.LoadFunction<d_{0}>(FuncLoader.GetProcAddress(GLibrary.Load(\"{1}\"), \"{0}\"));", CName, LibraryName);
sw.WriteLine();

View file

@ -19,6 +19,8 @@
// Boston, MA 02111-1307, USA.
using System.Runtime.InteropServices;
namespace GtkSharp.Generation {
using System;
@ -113,11 +115,11 @@ namespace GtkSharp.Generation {
sw.WriteLine (member);
sw.WriteLine ("\t}");
if (Elem.HasAttribute ("gtype")) {
sw.WriteLine ();
sw.WriteLine ("\tinternal class " + Name + "GType {");
var funcname = Elem.GetAttribute("gtype");
sw.WriteLine ("\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
sw.WriteLine ("\t\tdelegate IntPtr d_" + funcname + "();");
sw.WriteLine ("\t\tstatic d_" + funcname + " " + funcname + " = FuncLoader.LoadFunction<d_" + funcname + ">(FuncLoader.GetProcAddress(GLibrary.Load(\"" + LibraryName + "\"), \"" + funcname + "\"));");
sw.WriteLine ();

View file

@ -192,6 +192,8 @@ namespace GtkSharp.Generation {
import_sig += !IsStatic && Parameters.Count > 0 ? ", " : "";
import_sig += Parameters.ImportSignature.ToString();
sw.WriteLine("\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
if (retval.MarshalType.StartsWith("[return:"))
sw.WriteLine("\t\tdelegate " + retval.CSType + " d_" + CName + "(" + import_sig + ");");
else

View file

@ -1,11 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.29306.81
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GapiCodegen", "GapiCodegen\GapiCodegen.csproj", "{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GapiCodegen", "GapiCodegen\GapiCodegen.csproj", "{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GapiFixup", "GapiFixup\GapiFixup.csproj", "{DC7A0B5F-448F-4978-849B-3038D9B9C285}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GapiFixup", "GapiFixup\GapiFixup.csproj", "{DC7A0B5F-448F-4978-849B-3038D9B9C285}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -16,33 +15,36 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x64.ActiveCfg = Debug|x64
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x64.Build.0 = Debug|x64
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x86.ActiveCfg = Debug|x86
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x86.Build.0 = Debug|x86
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x64.ActiveCfg = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x64.Build.0 = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x86.ActiveCfg = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Debug|x86.Build.0 = Debug|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|Any CPU.Build.0 = Release|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x64.ActiveCfg = Release|x64
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x64.Build.0 = Release|x64
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x86.ActiveCfg = Release|x86
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x86.Build.0 = Release|x86
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x64.ActiveCfg = Release|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x64.Build.0 = Release|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x86.ActiveCfg = Release|Any CPU
{2CA6614A-F064-4136-ABDE-2DFB37E0F12B}.Release|x86.Build.0 = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x64.ActiveCfg = Debug|x64
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x64.Build.0 = Debug|x64
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x86.ActiveCfg = Debug|x86
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x86.Build.0 = Debug|x86
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x64.ActiveCfg = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x64.Build.0 = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x86.ActiveCfg = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Debug|x86.Build.0 = Debug|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|Any CPU.Build.0 = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x64.ActiveCfg = Release|x64
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x64.Build.0 = Release|x64
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x86.ActiveCfg = Release|x86
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x86.Build.0 = Release|x86
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x64.ActiveCfg = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x64.Build.0 = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x86.ActiveCfg = Release|Any CPU
{DC7A0B5F-448F-4978-849B-3038D9B9C285}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {35C3162B-E475-42D4-8ACE-5A81617CDDA9}
EndGlobalSection
EndGlobal