[cairo-commit] rcairo/gen gen.rb,1.1,1.2

Evan Martin commit at pdx.freedesktop.org
Tue Oct 28 15:31:09 PST 2003


Committed by: martine

Update of /cvs/cairo/rcairo/gen
In directory pdx:/tmp/cvs-serv1318/gen

Modified Files:
	gen.rb 
Log Message:
Those last-minute changes in my first commit caused it not to compile.
I fixed those, and added generation code for all the enums while I was at it.

Also: copyrights everywhere (not sure how useful that is, really, because
I haven't specified a license yet), and updated the spline demo to use round
caps (which is what I needed the enums for).



Index: gen.rb
===================================================================
RCS file: /cvs/cairo/rcairo/gen/gen.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** gen.rb	28 Oct 2003 18:27:22 -0000	1.1
--- gen.rb	28 Oct 2003 23:31:06 -0000	1.2
***************
*** 3,10 ****
  # Copyright (C) 2003 Evan Martin <martine at danga.com>
  # 
! # vim: tabstop=4 shiftwidth=4 noexpandtab :
  
  require 'load_api'
  
  $funcs, $structs, enums = load_api(ARGV[0])
  $enums = {}
--- 3,22 ----
  # Copyright (C) 2003 Evan Martin <martine at danga.com>
  # 
! # vim: tabstop=2 shiftwidth=2 expandtab :
  
  require 'load_api'
  
+ $FILE_HEADER = '/* ruby-cairo - Ruby bindings for Cairo.
+  * Copyright (C) 2003 Evan Martin <martine at danga.com>
+  *
+  * vim: tabstop=4 shiftwidth=4 noexpandtab :
+  */
+ 
+ /* this file was autogenerated by gen.rb, available in the ruby-cairo cvs. */
+ 
+ #include "shared.h"
+ 
+ '
+ 
  $funcs, $structs, enums = load_api(ARGV[0])
  $enums = {}
***************
*** 192,206 ****
  
    def write(out)
- 	p out
-     out << '/* ruby-cairo - Ruby bindings for Cairo.
-  * Copyright (C) 2003 Evan Martin <martine at danga.com>
-  *
-  * vim: tabstop=4 shiftwidth=4 noexpandtab :
-  */
- 
- /* this file was autogenerated by gen.rb, available in the ruby-cairo cvs. */
- 
- #include "shared.h"'
- EOT
      out_setters(out)
      out << "\n"
--- 204,207 ----
***************
*** 252,256 ****
--- 253,284 ----
  $classes.each_value { |c|
    File.open("../src/gen-#{c.name}.c", "w") { |f|
+   puts "Generating #{c.name}..."
+     f << $FILE_HEADER
      c.write(f)
    }
  }
+ 
+ File.open("../src/gen-constants.c", "w") { |f|
+   puts "Generating constants..."
+   f << $FILE_HEADER
+   $enums.each { |type, defs|
+     type = type[0..-3]
+     rtype = type.split(/_/).map{|x| x.capitalize}.join('')
+     f << "static void\ninit_#{type}(void) {\n"
+     shortrtype = rtype.sub(/^Cairo/, '')
+     f << "\tVALUE m#{rtype} = rb_define_module_under(mCairo, \"#{shortrtype}\");\n"
+     defs.each { |d|
+       shortdef = d[(type.length+1)..-1]
+       f << "\trb_define_const(m#{rtype}, \"#{shortdef}\", INT2NUM(#{d}));\n"
+     }
+     f << "}\n\n"
+   }
+ 
+   f << "\n"
+   f << "void\nconstants_init(void) {\n"
+   $enums.each { |type, defs|
+     type = type[0..-3]
+     f << "\tinit_#{type}();\n"
+   }
+   f << "}\n"
+ }





More information about the cairo-commit mailing list