[uim-commit] r3066 - in branches/r5rs/sigscheme/src: . script
yamaken at freedesktop.org
yamaken at freedesktop.org
Wed Feb 1 21:00:00 PST 2006
Author: yamaken
Date: 2006-02-01 20:59:55 -0800 (Wed, 01 Feb 2006)
New Revision: 3066
Modified:
branches/r5rs/sigscheme/src/Makefile.am
branches/r5rs/sigscheme/src/script/build_func_table.rb
branches/r5rs/sigscheme/src/script/functable-header.txt
Log:
* sigscheme/src/script/build_func_table.rb
- Simplify
- Add @filename@ substitution feature to file header and footer
- Generate the file directly instead of printing to stdout. This
resolve the collupted file problem
- (DATA_DIR, FILE_HEADER, FILE_FOOTER): New constant
- (search_declare_function, build_table, null_entry,
print_tableheader, print_tablefooter, build_functable,
print_header, print_footer): Removed
- (table_header, table_footer, build_table_body, terminal_entry,
build_table, file_header, file_footer): New function reformed from
above functions. The 'build_table' is pointing different function
between the new and previous
* sigscheme/src/script/functable-header.txt
- Replace 'sigschemefunctable.c' with @filename@
* sigscheme/src/Makefile.am
- Follow the change of build_func_table.rb
Modified: branches/r5rs/sigscheme/src/Makefile.am
===================================================================
--- branches/r5rs/sigscheme/src/Makefile.am 2006-02-02 03:51:06 UTC (rev 3065)
+++ branches/r5rs/sigscheme/src/Makefile.am 2006-02-02 04:59:55 UTC (rev 3066)
@@ -31,35 +31,34 @@
.PHONY: func-tables
func-tables: $(FUNC_TABLES)
sigschemefunctable-r5rs-syntax.c: syntax.c module.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_r5rs_syntax_func_info_table" \
- syntax.c module.c > $@
+ $(BUILD_FUNCTBL) $@ "scm_r5rs_syntax_func_info_table" syntax.c module.c
sigschemefunctable-r5rs-procedure.c: $(R5RS_PROC_SRCS) $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_r5rs_procedure_func_info_table" \
- $(R5RS_PROC_SRCS) > $@
+ $(BUILD_FUNCTBL) $@ "scm_r5rs_procedure_func_info_table" \
+ $(R5RS_PROC_SRCS)
sigschemefunctable-r5rs-deepcadrs.c: module-r5rs-deepcadrs.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_r5rs_deepcadrs_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_r5rs_deepcadrs_func_info_table" $<
sigschemefunctable-error.c: error.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_error_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_error_func_info_table" $<
sigschemefunctable-nonstd.c: module-nonstd.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_nonstd_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_nonstd_func_info_table" $<
sigschemefunctable-srfi1.c: module-srfi1.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi1_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi1_func_info_table" $<
sigschemefunctable-srfi2.c: module-srfi2.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi2_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi2_func_info_table" $<
sigschemefunctable-srfi6.c: module-srfi6.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi6_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi6_func_info_table" $<
sigschemefunctable-srfi8.c: module-srfi8.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi8_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi8_func_info_table" $<
sigschemefunctable-srfi23.c: module-srfi23.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi23_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi23_func_info_table" $<
sigschemefunctable-srfi34.c: module-srfi34.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi34_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi34_func_info_table" $<
sigschemefunctable-srfi38.c: module-srfi38.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi38_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi38_func_info_table" $<
sigschemefunctable-srfi60.c: module-srfi60.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_srfi60_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_srfi60_func_info_table" $<
sigschemefunctable-siod.c: module-siod.c $(BUILD_FUNCTBL_SOURCES)
- $(BUILD_FUNCTBL) "scm_siod_func_info_table" $< > $@
+ $(BUILD_FUNCTBL) $@ "scm_siod_func_info_table" $<
EXTRA_DIST = $(FUNC_TABLES) $(BUILD_FUNCTBL_SOURCES) \
test-compact.c
Modified: branches/r5rs/sigscheme/src/script/build_func_table.rb
===================================================================
--- branches/r5rs/sigscheme/src/script/build_func_table.rb 2006-02-02 03:51:06 UTC (rev 3065)
+++ branches/r5rs/sigscheme/src/script/build_func_table.rb 2006-02-02 04:59:55 UTC (rev 3066)
@@ -32,63 +32,58 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#===========================================================================
+
require 'script/scm_decl.rb'
-def search_declare_function(filename)
- puts " /* #{filename} */"
- f = File.new(filename)
+DATA_DIR = "./script"
+FILE_HEADER = "#{DATA_DIR}/functable-header.txt"
+FILE_FOOTER = "#{DATA_DIR}/functable-footer.txt"
- print (scm_generate_func_table_body f.read)
-
- f.close
+def table_header(table_name)
+ "static struct scm_func_registration_info #{table_name}[] = {"
end
-def build_table(filename)
- search_declare_function(filename)
+def table_footer
+ "};"
end
-def null_entry()
- puts " { NULL, NULL, NULL }"
+def build_table_body(filename)
+ src = File.new(filename).read
+ " /* #{filename} */\n" + scm_generate_func_table_body(src)
end
-def print_tableheader(tablename)
- puts "static struct scm_func_registration_info #{tablename}[] = {"
+def terminal_entry
+ " { NULL, NULL, NULL }"
end
-def print_tablefooter()
- puts "};"
- puts ""
+def build_table(table_name, src_files)
+ [
+ table_header(table_name),
+ src_files.collect { |src|
+ build_table_body(src)
+ },
+ terminal_entry,
+ table_footer,
+ "\n"
+ ].flatten.join("\n")
end
-def build_functable(tablename, filelist)
- print_tableheader(tablename)
- filelist.each { |filename|
- build_table(filename)
- }
- null_entry()
- print_tablefooter
+def file_header(table_filename)
+ File.new(FILE_HEADER).read.gsub("@filename@", table_filename)
end
-def print_header()
- IO.readlines("./script/functable-header.txt").each { |line|
- puts line
- }
+def file_footer(table_filename)
+ File.new(FILE_FOOTER).read.gsub("@filename@", table_filename)
end
-def print_footer()
- IO.readlines("script/functable-footer.txt").each { |line|
- puts line
- }
-end
-
######################################################################
-# Header
-print_header
+table_filename, table_name, *srcs = ARGV
+table = build_table(table_name, srcs)
+header = file_header(table_filename)
+footer = file_footer(table_filename)
-# Print Table
-build_functable(ARGV[0],
- ARGV[1..-1])
-
-# Footer
-print_footer
+# The generated file should explicitly be opened by the script instead of
+# printing to stdout redirected by shell, to avoid the accidencial file
+# colluption problem that makes 'make' failed.
+File.new(table_filename, "w").print(header, table, footer)
Modified: branches/r5rs/sigscheme/src/script/functable-header.txt
===================================================================
--- branches/r5rs/sigscheme/src/script/functable-header.txt 2006-02-02 03:51:06 UTC (rev 3065)
+++ branches/r5rs/sigscheme/src/script/functable-header.txt 2006-02-02 04:59:55 UTC (rev 3066)
@@ -1,5 +1,5 @@
/*===========================================================================
- * FileName : sigschemefunctable.c
+ * FileName : @filename@
* About : Built-in function table
* This file is auto-generated by build_func_table.rb
*
More information about the uim-commit
mailing list