[Gridflow-cvs] [svn] commit: r4861 - /trunk/src/source_filter.rb

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Nov 20 15:18:11 EST 2009


Author: matju
Date: Fri Nov 20 15:18:10 2009
New Revision: 4861

Log:
define the _wrap at \decl time instead of \def time

Modified:
    trunk/src/source_filter.rb

Modified: trunk/src/source_filter.rb
==============================================================================
--- trunk/src/source_filter.rb (original)
+++ trunk/src/source_filter.rb Fri Nov 20 15:18:10 2009
@@ -134,14 +134,29 @@
 end
 
 def handle_decl(line)
-	frame = $stack[-1]
-	raise "missing \\class #{where}" if not frame or not ClassDecl===frame
-	classname = frame.name
+	qlass = $stack[-1]
+	raise "missing \\class #{where}" if not qlass or not ClassDecl===qlass
+	classname = qlass.name
 	m = parse_methoddecl(line,";\s*$")
-	frame.methods[m.selector] = m
+	qlass.methods[m.selector] = m
 	Out.print "#{m.rettype} #{m.selector}(VA"
 	Out.print ", #{unparse_arglist m.arglist}" if m.arglist.length>0
-	Out.print "); static void #{m.selector}_wrap(#{classname} *self, VA); "
+	Out.print "); static void #{m.selector}_wrap(#{classname} *self, VA) {"
+	Out.print "static const char *methodspec = \"#{qlass.name}::#{m.selector}(#{unparse_arglist m.arglist,false})\";"
+	Out.print "#{m.rettype} foo;" if m.rettype!="void"
+	Out.print "if (argc<#{m.minargs}"
+	Out.print "||argc>#{m.maxargs}" if m.maxargs!=-1
+	Out.print ") RAISE(\"got %d args instead of %d..%d in %s\",argc,#{m.minargs},#{m.maxargs},methodspec);"
+	Out.print "foo = " if m.rettype!="void"
+	Out.print " self->#{m.selector}(argc,argv"
+	m.arglist.each_with_index{|arg,i|
+		if arg.default then
+			Out.print ",argc<#{i+1}?#{arg.default}:convert(argv[#{i}],(#{arg.type}*)0)"
+		else
+			Out.print ",convert(argv[#{i}],(#{arg.type}*)0)"
+		end
+	}
+	Out.print ");}"
 end
 
 def handle_def(line)
@@ -162,22 +177,7 @@
 	else
 		qlass.methods[m.selector] = m
 	end
-	Out.print "void #{classname}::#{m.selector}_wrap(#{classname} *self, VA) {"
-	Out.print "static const char *methodspec = \"#{qlass.name}::#{m.selector}(#{unparse_arglist m.arglist,false})\";"
-	Out.print "#{m.rettype} foo;" if m.rettype!="void"
-	Out.print "if (argc<#{m.minargs}"
-	Out.print "||argc>#{m.maxargs}" if m.maxargs!=-1
-	Out.print ") RAISE(\"got %d args instead of %d..%d in %s\",argc,#{m.minargs},#{m.maxargs},methodspec);"
-	Out.print "foo = " if m.rettype!="void"
-	Out.print " self->#{m.selector}(argc,argv"
-	m.arglist.each_with_index{|arg,i|
-		if arg.default then
-			Out.print ",argc<#{i+1}?#{arg.default}:convert(argv[#{i}],(#{arg.type}*)0)"
-		else
-			Out.print ",convert(argv[#{i}],(#{arg.type}*)0)"
-		end
-	}
-	Out.print ");} #{m.rettype} #{classname}::#{m.selector}(VA"
+	Out.print "#{m.rettype} #{classname}::#{m.selector}(VA"
 	#puts "m=#{m} n=#{n}"
 	Out.print ","+unparse_arglist(n.arglist,false) if m.arglist.length>0
 	Out.print ")#{term} "



More information about the Gridflow-cvs mailing list