[uim-commit] r1948 - branches/r5rs/sigscheme/script
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Nov 1 17:56:58 PST 2005
Author: yamaken
Date: 2005-11-01 17:56:55 -0800 (Tue, 01 Nov 2005)
New Revision: 1948
Modified:
branches/r5rs/sigscheme/script/build_func_table.rb
Log:
* This commit simplifies the codes based on my style. Feel free
to revert if not favor
* sigscheme/script/build_func_table.rb
- (TYPE2PREFIX): New constant
- ($FUNC_TYPE_INVALID, $FUNC_TYPE_SYNTAX, $FUNC_TYPE_PROCEDURE,
$FUNC_TYPE_REDUCTION, $SCM2C_FUNCNAME_RULE): Rename to constant
- (FUNC_TYPE_INVALID, FUNC_TYPE_SYNTAX, FUNC_TYPE_PROCEDURE,
FUNC_TYPE_REDUCTION, SCM2C_FUNCNAME_RULE): Renamed from global
variable
- (guess_c_funcname, search_declare_function):
* Simplify
* Follow the renamings
Modified: branches/r5rs/sigscheme/script/build_func_table.rb
===================================================================
--- branches/r5rs/sigscheme/script/build_func_table.rb 2005-11-02 01:51:02 UTC (rev 1947)
+++ branches/r5rs/sigscheme/script/build_func_table.rb 2005-11-02 01:56:55 UTC (rev 1948)
@@ -33,12 +33,18 @@
# SUCH DAMAGE.
#===========================================================================
-$FUNC_TYPE_INVALID = 0
-$FUNC_TYPE_SYNTAX = 1
-$FUNC_TYPE_PROCEDURE = 2
-$FUNC_TYPE_REDUCTION = 3
+FUNC_TYPE_INVALID = 0
+FUNC_TYPE_SYNTAX = 1
+FUNC_TYPE_PROCEDURE = 2
+FUNC_TYPE_REDUCTION = 3
-$SCM2C_FUNCNAME_RULE = [
+TYPE2PREFIX = {
+ FUNC_TYPE_SYNTAX => "ScmExp_",
+ FUNC_TYPE_PROCEDURE => "ScmOp_",
+ FUNC_TYPE_REDUCTION => "ScmOp_",
+}
+
+SCM2C_FUNCNAME_RULE = [
# prefix
[/^\+/, "add"],
[/^\*/, "multiply"],
@@ -67,18 +73,11 @@
def guess_c_funcname(scm_funcname, type)
# guess prefix
- prefix = ""
- if type == $FUNC_TYPE_SYNTAX
- prefix = "ScmExp_"
- elsif type == $FUNC_TYPE_PROCEDURE
- prefix = "ScmOp_"
- elsif type == $FUNC_TYPE_REDUCTION
- prefix = "ScmOp_"
- end
+ prefix = TYPE2PREFIX[type] || "";
# apply replace rule
c_funcname = scm_funcname
- $SCM2C_FUNCNAME_RULE.each { |rule|
+ SCM2C_FUNCNAME_RULE.each { |rule|
c_funcname = c_funcname.gsub(rule[0], rule[1])
}
@@ -91,14 +90,15 @@
scm_func = $1
reg_func = "Scm_Register" + $2
- type = $FUNC_TYPE_INVALID
- if reg_func.index("Syntax")
- type = $FUNC_TYPE_SYNTAX
- elsif reg_func.index("Procedure")
- type = $FUNC_TYPE_PROCEDURE
- elsif reg_func.index("Reduction")
- type = $FUNC_TYPE_REDUCTION
- end
+ type = if reg_func.index("Syntax")
+ FUNC_TYPE_SYNTAX
+ elsif reg_func.index("Procedure")
+ FUNC_TYPE_PROCEDURE
+ elsif reg_func.index("Reduction")
+ FUNC_TYPE_REDUCTION
+ else
+ FUNC_TYPE_INVALID
+ end
c_func = guess_c_funcname(scm_func, type)
More information about the uim-commit
mailing list