# HG changeset patch # User lbessard # Date 1224859172 -7200 # Node ID 6cf858411d3a205a91b7e7ae812632e66e655533 # Parent c4199b88cf60b161d40c0f23f779f6fc4e07ab8e Adding support for EN/ENO in standard functions diff -r c4199b88cf60 -r 6cf858411d3a generate_IEC_std.py --- a/generate_IEC_std.py Fri Oct 17 16:22:15 2008 +0200 +++ b/generate_IEC_std.py Fri Oct 24 16:39:32 2008 +0200 @@ -41,6 +41,10 @@ # Get definitions from plcopen.structures import * +if len(sys.argv) != 2 : + print "Usage: " + sys.argv[0] + " path_name\n -> create files in path_name" + sys.exit(0) + #import pprint #pp = pprint.PrettyPrinter(indent=4) @@ -154,7 +158,7 @@ symbol_c *%(input_name)s_type_symbol = search_expression_type->get_type(%(input_name)s_param_value); last_type_symbol = last_type_symbol && search_expression_type->is_same_type(%(input_name)s_type_symbol, last_type_symbol) ? search_expression_type->common_type(%(input_name)s_type_symbol, last_type_symbol) : %(input_name)s_type_symbol ; """%{"input_name":Paramname} - + for ParamType,NextParamDecl in ParamTypes.iteritems(): res += """ @@ -167,6 +171,7 @@ "if_good_type_code":recurse_and_indent(NextParamDecl,indent,do_type_search_only).replace('\n','\n ')} res += """ + ERROR; } """ @@ -176,6 +181,46 @@ res = "\n" fdecl=fdecls[0] + if not do_type_search_only: + code_gen = eval(fdecl["python_eval_c_code_format"]) + + if code_gen[1] is not None: + res += "function_name = (symbol_c*)(new pragma_c(\"%s\"));\n"%code_gen[1] + if fdecl["extensible"]: + res += """ +char nb_param_str[10]; +sprintf(nb_param_str, "%d", nb_param); +ADD_PARAM_LIST((symbol_c*)(new integer_c(nb_param_str)), (symbol_c*)(new int_type_name_c()), function_param_iterator_c::direction_in) +""" + for paramname,paramtype,unused in fdecl["inputs"]: + res += "ADD_PARAM_LIST(%(input_name)s_param_value, %(input_name)s_type_symbol, function_param_iterator_c::direction_in)\n"%{"input_name" : paramname} + + if fdecl["extensible"]: + res += """ +int base_num = %d; +symbol_c *param_value = NULL; +do{ + char my_name[10]; + sprintf(my_name, "IN%%d", base_num++); + identifier_c param_name(my_name); + + /* Get the value from a foo( = ) style call */ + param_value = function_call_param_iterator.search(¶m_name); + + /* Get the value from a foo() style call */ + if (param_value == NULL) + param_value = function_call_param_iterator.next(); + if (param_value != NULL){ + symbol_c *current_type_symbol = search_expression_type->get_type(param_value); + last_type_symbol = last_type_symbol && search_expression_type->is_same_type(current_type_symbol, last_type_symbol) ? search_expression_type->common_type(current_type_symbol, last_type_symbol) : current_type_symbol ; + + /*Function specific CODE */ + ADD_PARAM_LIST(param_value, current_type_symbol, function_param_iterator_c::direction_in) + } + +}while(param_value != NULL); +"""%(fdecl["baseinputnumber"] + 2) + result_type_rule = fdecl["return_type_rule"] res += { "copy_input" : "symbol_c * return_type_symbol = last_type_symbol;\n", @@ -183,64 +228,14 @@ }.get(result_type_rule, "symbol_c * return_type_symbol = %s;\n"%result_type_rule) if not do_type_search_only: - code_gen = eval(fdecl["python_eval_c_code_format"]) - - code_gen_dic_decl = {} - for paramname,paramtype,unused in fdecl["inputs"]: - code_gen_dic_decl[paramname+"_value"] = '");\n%s_param_value->accept(*this);\ns4o.print("'%(paramname) - code_gen_dic_decl[paramname+"_type"] = '");\n%s_type_symbol->accept(*this);\ns4o.print("'%(paramname) - code_gen_dic_decl["return_type"] = '");\nreturn_type_symbol->accept(*this);\ns4o.print("' - code_gen_dic_decl["param_count"] = '");\ns4o.print_integer(nb_param);\ns4o.print("' - code_gen_dic_decl["common_type"] = '");\nlast_type_symbol->accept(*this);\ns4o.print("' - code_gen_dic_decl["start_bool_filter"] = '");\nif (search_expression_type->is_bool_type(last_type_symbol))\n s4o.print("(' - code_gen_dic_decl["end_bool_filter"] = '");\nif (search_expression_type->is_bool_type(last_type_symbol)) {\n s4o.print("&1");\n s4o.print(")");\n}\ns4o.print("' - - if type(code_gen) == type(tuple()): - res += 's4o.indent_right();\n' - res += 's4o.print("%s\\n" + s4o.indent_spaces);\n'%(code_gen[0]%code_gen_dic_decl) - static_param_accept_list = [] - for paramname,paramtype,unused in fdecl["inputs"]: - static_param_accept_list.append("%s_param_value->accept(*this);\n"%(paramname)) - res += ('s4o.print("%s\\n" + s4o.indent_spaces);\n'%(code_gen[1])).join(static_param_accept_list) - code = 's4o.print("%s\\n" + s4o.indent_spaces);\nparam_value->accept(*this);\n'%(code_gen[1]) - end_code = 's4o.print("%s");\ns4o.indent_left();\nreturn NULL;\n'%(code_gen[2]%code_gen_dic_decl) - else: - code = '' - end_code = ('s4o.print("' + code_gen%code_gen_dic_decl + '");\nreturn NULL;\n').replace('s4o.print("");\n','') - - if fdecl["extensible"]: - res += (""" -int base_num = %d; -symbol_c *param_value = NULL; -do{ - char my_name[10]; - sprintf(my_name, "IN%%d", base_num++); - identifier_c param_name(my_name); - - /* Get the value from a foo( = ) style call */ - param_value = function_call_param_iterator.search(¶m_name); - - /* Get the value from a foo() style call */ - if (param_value == NULL) - param_value = function_call_param_iterator.next(); - if (param_value != NULL){ - symbol_c *current_type_symbol = search_expression_type->get_type(param_value); - last_type_symbol = last_type_symbol && search_expression_type->is_same_type(current_type_symbol, last_type_symbol) ? search_expression_type->common_type(current_type_symbol, last_type_symbol) : current_type_symbol ; - - /*Function specific CODE */ - %s - } - -}while(param_value != NULL); -%s -"""%(fdecl["baseinputnumber"]+2, code.replace('\n','\n '), end_code)) - else: - #res += code + end_code - res += end_code + if code_gen[0] is not None: + res += "function_type_prefix = %s;\n"%{"return_type" : "return_type_symbol"}.get(code_gen[0], "(symbol_c*)(new pragma_c(\"%s\"))"%code_gen[0]) + if code_gen[2] is not None: + res += "function_type_suffix = %s_symbol;\n"%{"common_type" : "last_type"}.get(code_gen[2], code_gen[2]) + res += "break;\n" else: res += "return return_type_symbol;\n" - return res.replace('\n','\n'+indent) ################################################################### @@ -336,7 +331,6 @@ case function_none : ERROR; } -return NULL; """ ################################################################### @@ -369,7 +363,6 @@ case function_none : ERROR; } -return NULL; """ ################################################################### @@ -379,10 +372,20 @@ """ search_type_code = matiec_header + """ -void *compute_standard_function_st(function_invocation_c *symbol) { - - function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); - function_call_param_iterator_c function_call_param_iterator(symbol); +void *compute_standard_function_default(function_invocation_c *st_symbol = NULL, il_formal_funct_call_c *il_symbol = NULL) { + function_type_t current_function_type; + function_call_param_iterator_c *tmp_function_call_param_iterator; + if (st_symbol != NULL && il_symbol == NULL) { + current_function_type = get_function_type((identifier_c *)st_symbol->function_name); + tmp_function_call_param_iterator = new function_call_param_iterator_c(st_symbol); + } + else if (st_symbol == NULL && il_symbol != NULL) { + current_function_type = get_function_type((identifier_c *)il_symbol->function_name); + tmp_function_call_param_iterator = new function_call_param_iterator_c(il_symbol); + } + else + ERROR; + function_call_param_iterator_c function_call_param_iterator(*tmp_function_call_param_iterator); search_expression_type_c* search_expression_type = this; switch(current_function_type){ @@ -487,10 +490,6 @@ else: break -if len(sys.argv) != 2 : - print "Usage: " + sys.argv[0] + "path_name\n -> create files in path_name" - sys.exit(0) - # Now, print that out, or write to files from sys.argv for path, name, ext in [ ('stage4/generate_c','function_type_decl','h'), diff -r c4199b88cf60 -r 6cf858411d3a plcopen/iec_std.csv --- a/plcopen/iec_std.csv Fri Oct 17 16:22:15 2008 +0200 +++ b/plcopen/iec_std.csv Fri Oct 24 16:39:32 2008 +0200 @@ -14,66 +14,66 @@ ;;;;;;;; Standard_functions_type;name;baseinputnumber;inputs;outputs;comment;extensible;python_eval_c_code_format;return_type_rule Type conversion;*_TO_**;1;(ANY);ANY;Data type conversion;no;ANY_TO_ANY_FORMAT_GEN(ANY_TO_ANY_LIST,fdecl);defined -;TRUNC;1;(ANY_REAL);ANY_INT;Rounding up/down;no;"(int)%(IN_value)s";&search_constant_type_c::constant_int_type_name +;TRUNC;1;(ANY_REAL);ANY_INT;Rounding up/down;no;("int", None, None);&search_constant_type_c::constant_int_type_name ;BCD_TO_**;1;(ANY_BIT);ANY_INT;Conversion from BCD;no;ANY_TO_ANY_FORMAT_GEN(BCD_TO_ANY_LIST,fdecl);defined ;*_TO_BCD;1;(ANY_INT);ANY_BIT;Conversion to BCD;no;ANY_TO_ANY_FORMAT_GEN(ANY_TO_BCD_LIST,fdecl);&search_constant_type_c::constant_int_type_name -;DATE_AND_TIME_TO_TIME_OF_DAY;1;(DT);TOD;Conversion to time-of-day;no;"__date_and_time_to_time_of_day(%(IN_value)s)";defined -;DATE_AND_TIME_TO_DATE;1;(DT);DATE;Conversion to date;no;"__date_and_time_to_date(%(IN_value)s)";defined -Numerical;ABS;1;(ANY_NUM);ANY_NUM;Absolute number;no;"__abs_%(IN_type)s(%(IN_value)s)";IN_type_symbol -;SQRT;1;(ANY_REAL);ANY_REAL;Square root (base 2);no;"sqrt(%(IN_value)s)";IN_type_symbol -;LN;1;(ANY_REAL);ANY_REAL;Natural logarithm;no;"ln(%(IN_value)s)";IN_type_symbol -;LOG;1;(ANY_REAL);ANY_REAL;Logarithm to base 10;no;"log(%(IN_value)s)";IN_type_symbol -;EXP;1;(ANY_REAL);ANY_REAL;Exponentiation;no;"exp(%(IN_value)s)";IN_type_symbol -;SIN;1;(ANY_REAL);ANY_REAL;Sine;no;"sin(%(IN_value)s)";IN_type_symbol -;COS;1;(ANY_REAL);ANY_REAL;Cosine;no;"cos(%(IN_value)s)";IN_type_symbol -;TAN;1;(ANY_REAL);ANY_REAL;Tangent;no;"tan(%(IN_value)s)";IN_type_symbol -;ASIN;1;(ANY_REAL);ANY_REAL;Arc sine;no;"asin(%(IN_value)s)";IN_type_symbol -;ACOS;1;(ANY_REAL);ANY_REAL;Arc cosine;no;"acos(%(IN_value)s)";IN_type_symbol -;ATAN;1;(ANY_REAL);ANY_REAL;Arc tangent;no;"atan(%(IN_value)s)";IN_type_symbol -Arithmetic;ADD;1;(ANY_NUM, ANY_NUM);ANY_NUM;Addition;yes;("(","+",")");copy_input -;ADD;1;(TIME, TIME);TIME;Time addition;no;"__time_add(%(IN1_value)s, %(IN2_value)s)";defined -;ADD;1;(TOD, TIME);TOD;Time-of-day addition;no;"__time_add(%(IN1_value)s, %(IN2_value)s)";defined -;ADD;1;(DT, TIME);DT;Date addition;no;"__time_add(%(IN1_value)s, %(IN2_value)s)";defined -;MUL;1;(ANY_NUM, ANY_NUM);ANY_NUM;Multiplication;yes;("(","*",")");copy_input -;MUL;1;(TIME, ANY_NUM);TIME;Time multiplication;no;"__time_mul(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(ANY_NUM, ANY_NUM);ANY_NUM;Subtraction;no;("(","-",")");copy_input -;SUB;1;(TIME, TIME);TIME;Time subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(DATE, DATE);TIME;Date subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(TOD, TIME);TOD;Time-of-day subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(TOD, TOD);TIME;Time-of-day subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(DT, TIME);DT;Date and time subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;SUB;1;(DT, DT);TIME;Date and time subtraction;no;"__time_sub(%(IN1_value)s, %(IN2_value)s)";defined -;DIV;1;(ANY_NUM, ANY_NUM);ANY_NUM;Division;no;("(","/",")");copy_input -;DIV;1;(TIME, ANY_NUM);TIME;Time division;no;"__time_div(%(IN1_value)s, %(IN2_value)s)";defined -;MOD;1;(ANY_NUM, ANY_NUM);ANY_NUM;Remainder (modulo);no;("(","%",")");copy_input -;EXPT;1;(ANY_NUM, ANY_NUM);ANY_NUM;Exponent;no;"pow(%(IN1_value)s, %(IN2_value)s)";copy_input -;MOVE;1;(ANY_NUM);ANY_NUM;Assignment;no;"%(IN_value)s";copy_input -Bit-shift;SHL;1;(ANY_BIT, N);ANY_BIT;Shift left;no;"%(IN_value)s<<%(N_value)s";IN_type_symbol -;SHR;1;(ANY_BIT, N);ANY_BIT;Shift right;no;"%(IN_value)s>>%(N_value)s";IN_type_symbol -;ROR;1;(ANY_NBIT, N);ANY_NBIT;Rotate right;no;"__ror_%(IN_type)s(%(IN_value)s, %(N_value)s)";IN_type_symbol -;ROL;1;(ANY_NBIT, N);ANY_NBIT;Rotate left;no;"__rol_%(IN_type)s(%(IN_value)s, %(N_value)s)";IN_type_symbol -Bitwise;AND;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise AND;yes;("(%(start_bool_filter)s","&",")%(end_bool_filter)s");copy_input -;OR;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise OR;yes;("(%(start_bool_filter)s","|",")%(end_bool_filter)s");copy_input -;XOR;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise EXOR;yes;("(%(start_bool_filter)s","^",")%(end_bool_filter)s");copy_input -;NOT;1;(ANY_BIT);ANY_BIT;Bitwise inverting;no;"~%(IN_value)s";IN_type_symbol -Selection;SEL;0;(G, ANY, ANY);ANY;Binary selection (1 of 2);no;"%(G_value)s ? %(IN1_value)s : %(IN0_value)s";copy_input -;MAX;1;(ANY, ANY);ANY;Maximum;yes;("__max_%(return_type)s(%(param_count)s,",",",")");copy_input -;MIN;1;(ANY, ANY);ANY;Minimum;yes;("__min_%(return_type)s(%(param_count)s,",",",")");copy_input -;LIMIT;1;(MN, ANY, MX);ANY;Limitation;no;"__limit_%(IN_type)s(%(MN_value)s, %(IN_value)s, %(MX_value)s)";IN_type_symbol -;MUX;0;(K, ANY, ANY);ANY;Multiplexer (select 1 of N);yes;("__mux_%(return_type)s(%(param_count)s,",",",")");copy_input -Comparison;GT;1;(ANY, ANY);BOOL;Greater than;yes;("__gt_%(common_type)s(%(param_count)s,",",",")");defined -;GE;1;(ANY, ANY);BOOL;Greater than or equal to;yes;("__ge_%(common_type)s(%(param_count)s,",",",")");defined -;EQ;1;(ANY, ANY);BOOL;Equal to;yes;("__eq_%(common_type)s(%(param_count)s,",",",")");defined -;LT;1;(ANY, ANY);BOOL;Less than;yes;("__lt_%(common_type)s(%(param_count)s,",",",")");defined -;LE;1;(ANY, ANY);BOOL;Less than or equal to;yes;("__le_%(common_type)s(%(param_count)s,",",",")");defined -;NE;1;(ANY, ANY);BOOL;Not equal to;yes;("__ne_%(common_type)s(%(param_count)s,",",",")");defined -Character string;LEN;1;(STRING);INT;Length of string;no;"__len(%(IN_value)s)";defined -;LEFT;1;(STRING, L);STRING;string left of;no;"__left(%(IN_value)s, %(L_value)s)";defined -;RIGHT;1;(STRING, L);STRING;string right of;no;"__right(%(IN_value)s, %(L_value)s)";defined -;MID;1;(STRING, L, P);STRING;string from the middle;no;"__mid(%(IN_value)s, %(L_value)s, %(P_value)s)";defined -;CONCAT;1;(STRING, STRING);STRING;Concatenation;yes;("__concat(%(param_count)s,",",",")");defined -;CONCAT;1;(DATE, TOD);DT;Time concatenation;no;"__time_add(%(IN1_value)s, %(IN2_value)s)";defined -;INSERT;1;(STRING, STRING, P);STRING;Insertion (into);no;"__insert(%(IN1_value)s, %(IN2_value)s, %(P_value)s)";defined -;DELETE;1;(STRING, L, P);STRING;Deletion (within);no;"__delete(%(IN_value)s, %(L_value)s, %(P_value)s)";defined -;REPLACE;1;(STRING, STRING, L, P);STRING;Replacement (within);no;"__replace(%(IN1_value)s, %(IN2_value)s, %(L_value)s, %(P_value)s)";defined -;FIND;1;(STRING, STRING);INT;Find position;no;"__find(%(IN1_value)s, %(IN2_value)s)";defined +;DATE_AND_TIME_TO_TIME_OF_DAY;1;(DT);TOD;Conversion to time-of-day;no;(None, "__date_and_time_to_time_of_day", None);defined +;DATE_AND_TIME_TO_DATE;1;(DT);DATE;Conversion to date;no;(None, "__date_and_time_to_date", None);defined +Numerical;ABS;1;(ANY_NUM);ANY_NUM;Absolute number;no;(None, "__abs_", "IN_type");IN_type_symbol +;SQRT;1;(ANY_REAL);ANY_REAL;Square root (base 2);no;(None, "sqrt", None);IN_type_symbol +;LN;1;(ANY_REAL);ANY_REAL;Natural logarithm;no;(None, "ln", None);IN_type_symbol +;LOG;1;(ANY_REAL);ANY_REAL;Logarithm to base 10;no;(None, "log", None);IN_type_symbol +;EXP;1;(ANY_REAL);ANY_REAL;Exponentiation;no;(None, "exp", None);IN_type_symbol +;SIN;1;(ANY_REAL);ANY_REAL;Sine;no;(None, "sin", None);IN_type_symbol +;COS;1;(ANY_REAL);ANY_REAL;Cosine;no;(None, "cos", None);IN_type_symbol +;TAN;1;(ANY_REAL);ANY_REAL;Tangent;no;(None, "tan", None);IN_type_symbol +;ASIN;1;(ANY_REAL);ANY_REAL;Arc sine;no;(None, "asin", None);IN_type_symbol +;ACOS;1;(ANY_REAL);ANY_REAL;Arc cosine;no;(None, "acos", None);IN_type_symbol +;ATAN;1;(ANY_REAL);ANY_REAL;Arc tangent;no;(None, "atan", None);IN_type_symbol +Arithmetic;ADD;1;(ANY_NUM, ANY_NUM);ANY_NUM;Addition;yes;(None, "__add_", "return_type");copy_input +;ADD;1;(TIME, TIME);TIME;Time addition;no;(None, "__time_add", None);defined +;ADD;1;(TOD, TIME);TOD;Time-of-day addition;no;(None, "__time_add", None);defined +;ADD;1;(DT, TIME);DT;Date addition;no;(None, "__time_add", None);defined +;MUL;1;(ANY_NUM, ANY_NUM);ANY_NUM;Multiplication;yes;(None, "__mul_", "return_type");copy_input +;MUL;1;(TIME, ANY_NUM);TIME;Time multiplication;no;(None, "__time_mul", None);defined +;SUB;1;(ANY_NUM, ANY_NUM);ANY_NUM;Subtraction;no;(None, "__sub_", "return_type");copy_input +;SUB;1;(TIME, TIME);TIME;Time subtraction;no;(None, "__time_sub", None);defined +;SUB;1;(DATE, DATE);TIME;Date subtraction;no;(None, "__time_sub", None);defined +;SUB;1;(TOD, TIME);TOD;Time-of-day subtraction;no;(None, "__time_sub", None);defined +;SUB;1;(TOD, TOD);TIME;Time-of-day subtraction;no;(None, "__time_sub", None);defined +;SUB;1;(DT, TIME);DT;Date and time subtraction;no;(None, "__time_sub", None);defined +;SUB;1;(DT, DT);TIME;Date and time subtraction;no;(None, "__time_sub", None);defined +;DIV;1;(ANY_NUM, ANY_NUM);ANY_NUM;Division;no;(None, "__div_", "return_type");copy_input +;DIV;1;(TIME, ANY_NUM);TIME;Time division;no;(None, "__time_div", None);defined +;MOD;1;(ANY_NUM, ANY_NUM);ANY_NUM;Remainder (modulo);no;(None, "__mod_", "return_type");copy_input +;EXPT;1;(ANY_NUM, ANY_NUM);ANY_NUM;Exponent;no;(None, "pow", None);copy_input +;MOVE;1;(ANY_NUM);ANY_NUM;Assignment;no;(None, "__move_", "return_type");copy_input +Bit-shift;SHL;1;(ANY_BIT, N);ANY_BIT;Shift left;no;(None, "__shl_", "IN_type");IN_type_symbol +;SHR;1;(ANY_BIT, N);ANY_BIT;Shift right;no;(None, "__shr_", "IN_type");IN_type_symbol +;ROR;1;(ANY_NBIT, N);ANY_NBIT;Rotate right;no;(None, "__ror_", "IN_type");IN_type_symbol +;ROL;1;(ANY_NBIT, N);ANY_NBIT;Rotate left;no;(None, "__rol_", "IN_type");IN_type_symbol +Bitwise;AND;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise AND;yes;(None, "__and_", "return_type");copy_input +;OR;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise OR;yes;(None, "__or_", "return_type");copy_input +;XOR;1;(ANY_BIT, ANY_BIT);ANY_BIT;Bitwise EXOR;yes;(None, "__xor_", "return_type");copy_input +;NOT;1;(ANY_BIT);ANY_BIT;Bitwise inverting;no;(None, "__not_", "return_type");IN_type_symbol +Selection;SEL;0;(G, ANY, ANY);ANY;Binary selection (1 of 2);no;(None, "__sel_", "IN0_type");copy_input +;MAX;1;(ANY, ANY);ANY;Maximum;yes;(None, "__max_", "return_type");copy_input +;MIN;1;(ANY, ANY);ANY;Minimum;yes;(None, "__min_", "return_type");copy_input +;LIMIT;1;(MN, ANY, MX);ANY;Limitation;no;(None, "__limit_", "IN_type");IN_type_symbol +;MUX;0;(K, ANY, ANY);ANY;Multiplexer (select 1 of N);yes;(None, "__mux_", "return_type");copy_input +Comparison;GT;1;(ANY, ANY);BOOL;Greater than;yes;(None, "__gt_", "common_type");defined +;GE;1;(ANY, ANY);BOOL;Greater than or equal to;yes;(None, "__ge_", "common_type");defined +;EQ;1;(ANY, ANY);BOOL;Equal to;yes;(None, "__eq_", "common_type");defined +;LT;1;(ANY, ANY);BOOL;Less than;yes;(None, "__lt_", "common_type");defined +;LE;1;(ANY, ANY);BOOL;Less than or equal to;yes;(None, "__le_", "common_type");defined +;NE;1;(ANY, ANY);BOOL;Not equal to;yes;(None, "__ne_", "common_type");defined +Character string;LEN;1;(STRING);INT;Length of string;no;(None, "__len", None);defined +;LEFT;1;(STRING, L);STRING;string left of;no;(None, "__left", None);defined +;RIGHT;1;(STRING, L);STRING;string right of;no;(None, "__right", None);defined +;MID;1;(STRING, L, P);STRING;string from the middle;no;(None, "__mid", None);defined +;CONCAT;1;(STRING, STRING);STRING;Concatenation;yes;(None, "__concat", None);defined +;CONCAT;1;(DATE, TOD);DT;Time concatenation;no;(None, "__time_add", None);defined +;INSERT;1;(STRING, STRING, P);STRING;Insertion (into);no;(None, "__insert", None);defined +;DELETE;1;(STRING, L, P);STRING;Deletion (within);no;(None, "__delete", None);defined +;REPLACE;1;(STRING, STRING, L, P);STRING;Replacement (within);no;(None, "__replace", None);defined +;FIND;1;(STRING, STRING);INT;Find position;no;(None, "__find", None);defined diff -r c4199b88cf60 -r 6cf858411d3a plcopen/structures.py --- a/plcopen/structures.py Fri Oct 17 16:22:15 2008 +0200 +++ b/plcopen/structures.py Fri Oct 24 16:39:32 2008 +0200 @@ -409,44 +409,44 @@ ANY_TO_ANY_LIST=[ # simple type conv are let as C cast - (("ANY_NUM","ANY_BIT"),("ANY_NUM","ANY_BIT"), "(%(return_type)s)%(IN_value)s"), + (("ANY_NUM","ANY_BIT"),("ANY_NUM","ANY_BIT"), ("return_type", None, None)), # TO_TIME - (("ANY_INT","ANY_BIT"),("ANY_DATE","TIME"), "(%(return_type)s)__int_to_time(%(IN_value)s)"), - (("ANY_REAL",),("ANY_DATE","TIME"), "(%(return_type)s)__real_to_time(%(IN_value)s)"), - (("ANY_STRING",), ("ANY_DATE","TIME"), "(%(return_type)s)__string_to_time(%(IN_value)s)"), + (("ANY_INT","ANY_BIT"),("ANY_DATE","TIME"), ("return_type", "__int_to_time", None)), + (("ANY_REAL",),("ANY_DATE","TIME"), ("return_type", "__real_to_time", None)), + (("ANY_STRING",), ("ANY_DATE","TIME"), ("return_type", "__string_to_time", None)), # FROM_TIME - (("ANY_DATE","TIME"), ("ANY_REAL",), "(%(return_type)s)__time_to_real(%(IN_value)s)"), - (("ANY_DATE","TIME"), ("ANY_INT","ANY_NBIT"), "(%(return_type)s)__time_to_int(%(IN_value)s)"), - (("TIME",), ("ANY_STRING",), "(%(return_type)s)__time_to_string(%(IN_value)s)"), - (("DATE",), ("ANY_STRING",), "(%(return_type)s)__date_to_string(%(IN_value)s)"), - (("TOD",), ("ANY_STRING",), "(%(return_type)s)__tod_to_string(%(IN_value)s)"), - (("DT",), ("ANY_STRING",), "(%(return_type)s)__dt_to_string(%(IN_value)s)"), + (("ANY_DATE","TIME"), ("ANY_REAL",), ("return_type", "__time_to_real", None)), + (("ANY_DATE","TIME"), ("ANY_INT","ANY_NBIT"), ("return_type", "__time_to_int", None)), + (("TIME",), ("ANY_STRING",), ("return_type", "__time_to_string", None)), + (("DATE",), ("ANY_STRING",), ("return_type", "__date_to_string", None)), + (("TOD",), ("ANY_STRING",), ("return_type", "__tod_to_string", None)), + (("DT",), ("ANY_STRING",), ("return_type", "__dt_to_string", None)), # TO_STRING - (("BOOL",), ("ANY_STRING",), "(%(return_type)s)__bool_to_string(%(IN_value)s)"), - (("ANY_BIT",), ("ANY_STRING",), "(%(return_type)s)__bit_to_string(%(IN_value)s)"), - (("ANY_REAL",), ("ANY_STRING",), "(%(return_type)s)__real_to_string(%(IN_value)s)"), - (("ANY_SINT",), ("ANY_STRING",), "(%(return_type)s)__sint_to_string(%(IN_value)s)"), - (("ANY_UINT",), ("ANY_STRING",), "(%(return_type)s)__uint_to_string(%(IN_value)s)"), + (("BOOL",), ("ANY_STRING",), ("return_type", "__bool_to_string", None)), + (("ANY_BIT",), ("ANY_STRING",), ("return_type", "__bit_to_string", None)), + (("ANY_REAL",), ("ANY_STRING",), ("return_type", "__real_to_string", None)), + (("ANY_SINT",), ("ANY_STRING",), ("return_type", "__sint_to_string", None)), + (("ANY_UINT",), ("ANY_STRING",), ("return_type", "__uint_to_string", None)), # FROM_STRING - (("ANY_STRING",), ("BOOL",), "(%(return_type)s)__string_to_bool(%(IN_value)s)"), - (("ANY_STRING",), ("ANY_BIT",), "(%(return_type)s)__string_to_bit(%(IN_value)s)"), - (("ANY_STRING",), ("ANY_SINT",), "(%(return_type)s)__string_to_sint(%(IN_value)s)"), - (("ANY_STRING",), ("ANY_UINT",), "(%(return_type)s)__string_to_uint(%(IN_value)s)"), - (("ANY_STRING",), ("ANY_REAL",), "(%(return_type)s)__string_to_real(%(IN_value)s)")] + (("ANY_STRING",), ("BOOL",), ("return_type", "__string_to_bool", None)), + (("ANY_STRING",), ("ANY_BIT",), ("return_type", "__string_to_bit", None)), + (("ANY_STRING",), ("ANY_SINT",), ("return_type", "__string_to_sint", None)), + (("ANY_STRING",), ("ANY_UINT",), ("return_type", "__string_to_uint", None)), + (("ANY_STRING",), ("ANY_REAL",), ("return_type", "__string_to_real", None))] BCD_TO_ANY_LIST=[ - (("BYTE",),("USINT",), "(%(return_type)s)__bcd_to_uint(%(IN_value)s)"), - (("WORD",),("UINT",), "(%(return_type)s)__bcd_to_uint(%(IN_value)s)"), - (("DWORD",),("UDINT",), "(%(return_type)s)__bcd_to_uint(%(IN_value)s)"), - (("LWORD",),("ULINT",), "(%(return_type)s)__bcd_to_uint(%(IN_value)s)")] + (("BYTE",),("USINT",), ("return_type", "__bcd_to_uint", None)), + (("WORD",),("UINT",), ("return_type", "__bcd_to_uint", None)), + (("DWORD",),("UDINT",), ("return_type", "__bcd_to_uint", None)), + (("LWORD",),("ULINT",), ("return_type", "__bcd_to_uint", None))] ANY_TO_BCD_LIST=[ - (("USINT",),("BYTE",), "(%(return_type)s)__uint_to_bcd(%(IN_value)s)"), - (("UINT",),("WORD",), "(%(return_type)s)__uint_to_bcd(%(IN_value)s)"), - (("UDINT",),("DWORD",), "(%(return_type)s)__uint_to_bcd(%(IN_value)s)"), - (("ULINT",),("LWORD",), "(%(return_type)s)__uint_to_bcd(%(IN_value)s)")] + (("USINT",),("BYTE",), ("return_type", "__uint_to_bcd", None)), + (("UINT",),("WORD",), ("return_type", "__uint_to_bcd", None)), + (("UDINT",),("DWORD",), ("return_type", "__uint_to_bcd", None)), + (("ULINT",),("LWORD",), ("return_type", "__uint_to_bcd", None))] def ANY_TO_ANY_FORMAT_GEN(any_to_any_list, fdecl):