From df2acf4cc4bb0e1814f354fd24b0cc8f67b986a4 Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Mon, 7 Nov 2005 10:15:43 +0000 Subject: [PATCH] Seperated header and body --- gnoemoe/mcp/mcpinit.rb | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gnoemoe/mcp/mcpinit.rb b/gnoemoe/mcp/mcpinit.rb index 1787e09..f8eb2f0 100755 --- a/gnoemoe/mcp/mcpinit.rb +++ b/gnoemoe/mcp/mcpinit.rb @@ -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 = [''] 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)