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

View File

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