mirror of
				https://github.com/Ryujinx/GtkSharp.git
				synced 2025-11-04 14:44:56 +00:00 
			
		
		
		
	* gapi-cdecl-insert : a little perl script to insert modopts * Makefile.am : dist the new script. for cdecl callback delegates on win32. * glade/makefile.win32 : use gapi-cdecl-insert * glade/XML.custom : add [GLib.CDeclCallback] to RawXMLConnectFunc. * glib/makefile.win32 : use gapi-cdecl-insert * glib/CDeclCallbackAttribute.cs : new attr to tag delegates with that will be invoked from native code. We have to mangle the il with a modopt otherwise they are stdcall'd. * glib/ManagedValue.cs : add [GLib.CDeclCallback] to Copy/Free. switch to using GCHandles instead of the current IntPtr hack. svn path=/trunk/gtk-sharp/; revision=42168
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable file
		
	
	
	
	
#!/usr/bin/perl
 | 
						|
#
 | 
						|
# gapi-cdecl-insert : Inserts il into an assembly for CDecl callback delegates.
 | 
						|
#
 | 
						|
# Authors: Mike Kestner <mkestner@novell.com>
 | 
						|
#
 | 
						|
# Copyright (c) 2005 Novell, Inc.
 | 
						|
#
 | 
						|
# This program is free software; you can redistribute it and/or
 | 
						|
# modify it under the terms of version 2 of the GNU General Public
 | 
						|
# License as published by the Free Software Foundation.
 | 
						|
#
 | 
						|
# This program is distributed in the hope that it will be useful,
 | 
						|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
						|
# General Public License for more details.
 | 
						|
#
 | 
						|
# You should have received a copy of the GNU General Public
 | 
						|
# License along with this program; if not, write to the
 | 
						|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 | 
						|
# Boston, MA 02111-1307, USA.
 | 
						|
 | 
						|
die "Usage: gapi-cdecl-insert [--keyfile=<file>] <assembly_path>\n" if ($ARGV > 2);
 | 
						|
foreach $arg (@ARGV) {
 | 
						|
	if ($arg =~ /--keyfile=(.*)/) {
 | 
						|
		$key = $1;
 | 
						|
	} elsif (-e $arg) {
 | 
						|
		$assembly = $arg;
 | 
						|
	} else {
 | 
						|
		die "Usage: gapi-cdecl-insert [--keyfile=<file>] <assembly_path>\n";
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
if ($assembly =~ /(.*)\.dll/) {
 | 
						|
	$basename = $1;
 | 
						|
	`ildasm $assembly /out:$basename.raw`;
 | 
						|
	open(INFILE, $basename . ".raw") || die "Couldn't open $basename.raw\n";
 | 
						|
	open(OUTFILE, "> $basename.il") || die "Couldn't open $basename.il\n";
 | 
						|
	while ($line = <INFILE>) {
 | 
						|
		$insert = 1 if ($line =~ /\.custom instance void .*GLib\.CDeclCallbackAttribute/);
 | 
						|
 | 
						|
		if ($insert && $line =~ /(.*)\s+(Invoke\(.*)/) {
 | 
						|
			print OUTFILE "$1 modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) $2";
 | 
						|
			$insert = 0;
 | 
						|
			next;
 | 
						|
		}
 | 
						|
		print OUTFILE $line;
 | 
						|
	}
 | 
						|
	`ilasm /DLL /QUIET $basename.il`;
 | 
						|
	`sn -R $assembly gtk-sharp.snk` if ($key);
 | 
						|
	unlink "$basename.raw";
 | 
						|
	unlink "$basename.il";
 | 
						|
	unlink "$basename.res";
 | 
						|
} else {
 | 
						|
	print "This script only works for dlls.\nUsage: gapi-cdecl-insert [--keyfile=<file>] <dll_path>\n";
 | 
						|
}
 | 
						|
 | 
						|
 |