Seperated header and body

This commit is contained in:
Jesse van den Kieboom 2005-11-07 10:15:43 +00:00
parent a29f64288d
commit df2acf4cc4
1 changed files with 17 additions and 12 deletions

View File

@ -1,11 +1,6 @@
#!/usr/bin/ruby
begin
defs = File.readlines(ARGV[0])
defs.collect! {|elem| elem.chomp}
fout = File.open(ARGV[1] + '.c', 'w')
def print_body(defs)
includes = ['<glib-object.h>']
content = "GList *\ngm_mcp_classes_initialize() {\n\tGList *result = NULL;\n\n"
@ -21,13 +16,23 @@ begin
content += "\tresult = g_list_append(result, \n\t\t\tg_type_class_ref(GM_TYPE_MCP_" + ucase + "));\n"
end
includes.each {|inc| fout.write('#include ' + inc + "\n")}
fout.write("\n" + content + "\treturn result;\n}\n")
fout.close
includes.each {|inc| $stdout.write('#include ' + inc + "\n")}
$stdout.write("\n" + content + "\n\treturn result;\n}\n")
end
def print_header(defs)
$stdout.write("GList *gm_mcp_classes_initialize();\n")
end
begin
defs = File.readlines(ARGV[0])
defs.collect! {|elem| elem.chomp}
fout = File.open(ARGV[1] + '.h', 'w')
fout.write("GList *gm_mcp_classes_initialize();\n")
fout.close
if (ARGV[1] == "header")
print_header(defs)
elsif (ARGV[1] == "body")
print_body(defs)
end
rescue StandardError => boom
p boom
exit(1)