Seperated header and body
This commit is contained in:
parent
a29f64288d
commit
df2acf4cc4
1 changed files with 17 additions and 12 deletions
|
@ -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
|
||||||
|
|
||||||
fout = File.open(ARGV[1] + '.h', 'w')
|
def print_header(defs)
|
||||||
fout.write("GList *gm_mcp_classes_initialize();\n")
|
$stdout.write("GList *gm_mcp_classes_initialize();\n")
|
||||||
fout.close
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
defs = File.readlines(ARGV[0])
|
||||||
|
defs.collect! {|elem| elem.chomp}
|
||||||
|
|
||||||
|
if (ARGV[1] == "header")
|
||||||
|
print_header(defs)
|
||||||
|
elsif (ARGV[1] == "body")
|
||||||
|
print_body(defs)
|
||||||
|
end
|
||||||
rescue StandardError => boom
|
rescue StandardError => boom
|
||||||
p boom
|
p boom
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Reference in a new issue