--- a/generate_IEC_std.py Tue Jul 10 19:22:42 2007 +0200
+++ b/generate_IEC_std.py Thu Jul 12 11:27:43 2007 +0200
@@ -1,3 +1,19 @@
+"""
+
+ THIS CODE GENARATES C++ CODE FOR IEC2CC COMPILER
+ GENERATED CODE IS :
+
+function_type_decl.h - the long enumeration of std function types
+get_function_type_decl.c - the funct that return enumerated according function name
+st_code_gen.c - part of generate_cc_st_c::visit(function_invocation)
+ responsible to generate C code for std lib calls
+il_code_gen.c - part of generate_cc_il_c::visit(il_function_call)
+ responsible to generate C code for std lib calls
+search_type_code.c - called by search_expression_type_c::visit(function_invocation)
+ return type symbol for std function invocation
+
+"""
+
# Get definitions
from plcopen.structures import *
@@ -373,6 +389,29 @@
###################################################################
###################################################################
"""
+Generate the standard_function_names[] for inclusion in bizon generated code
+"""
+standard_function_names = """
+/****
+ * IEC 61131-3 standard function lib
+ * generated code, do not edit by hand
+ */
+
+const char *standard_function_names[] = {
+"""
+for fname, fdecls in [ (fname,std_fdecls[fname]) for fname in official_order ]:
+ standard_function_names += "\""+fname+"\",\n"
+standard_function_names += """
+/* end of array marker! Do not remove! */
+NULL
+};
+
+"""
+
+###################################################################
+###################################################################
+###################################################################
+"""
Generate the C implementation of the IEC standard function library.
"""
iec_std_lib_generated = """
@@ -401,14 +440,19 @@
sys.exit(0)
# Now, print that out, or write to files from sys.argv
-for name, ext in [
- ('function_type_decl','h'),
- ('get_function_type_decl','c'),
- ('st_code_gen','c'),
- ('il_code_gen','c'),
- ('search_type_code','c')#,
- #('iec_std_lib_generated','h')
+for path, name, ext in [
+ ('stage4/generate_cc','function_type_decl','h'),
+ ('stage4/generate_cc','get_function_type_decl','c'),
+ ('stage4/generate_cc','st_code_gen','c'),
+ ('stage4/generate_cc','il_code_gen','c'),
+ ('stage4/generate_cc','search_type_code','c'),
+ ('stage1_2','standard_function_names','c'),
+ ('lib', 'iec_std_lib_generated','h')
]:
- fd = open(os.path.join(sys.argv[1],name+'.'+ext),'w')
+ fd = open(os.path.join(sys.argv[1], path, name+'.'+ext),'w')
fd.write(eval(name))
fd.close()
+
+#print "/* Code to eventually paste in iec_std_lib.h if type hierarchy changed */"
+#print "/* you also have to change iec_std_lib.h according to new types */\n\n"
+#print iec_std_lib_generated