From b10d3fcabd1b36406987911f48e05ff58b84d46b Mon Sep 17 00:00:00 2001 From: Thomas Mertes Date: Tue, 30 Jan 2024 18:42:48 +0100 Subject: [PATCH] Introduce category POINTLISTOBJECT for pointList objects --- lib/category.s7i | 1 + lib/comp/action.s7i | 14 ++ lib/comp/const.s7i | 3 +- lib/comp/copy.s7i | 1 + lib/comp/create.s7i | 1 + lib/comp/destr.s7i | 5 +- lib/comp/drw_act.s7i | 143 ++++++++++++++++++++ lib/comp/expr_utl.s7i | 5 +- lib/comp/literal.s7i | 21 +++ lib/comp/ref_act.s7i | 2 + lib/comp/type.s7i | 7 +- lib/graph.s7i | 17 ++- lib/progs.s7i | 1 + prg/s7c.sd7 | 108 ++++++++++++++- src/bstlib.c | 9 +- src/data.h | 3 +- src/data_rtl.h | 2 +- src/datautl.c | 1 + src/drwlib.c | 297 +++++++++++++++++++++++++++++++++++++++++- src/drwlib.h | 11 ++ src/exec.c | 3 + src/objutl.c | 20 +++ src/objutl.h | 6 + src/primitiv.c | 13 ++ src/ref_data.c | 34 +++++ src/ref_data.h | 1 + src/traceutl.c | 4 + 27 files changed, 707 insertions(+), 26 deletions(-) diff --git a/lib/category.s7i b/lib/category.s7i index 1f101211..550c99dd 100644 --- a/lib/category.s7i +++ b/lib/category.s7i @@ -134,6 +134,7 @@ const category: POLLOBJECT is category("POLLOBJECT"); const category: LISTOBJECT is category("LISTOBJECT"); const category: FLOATOBJECT is category("FLOATOBJECT"); const category: WINOBJECT is category("WINOBJECT"); +const category: POINTLISTOBJECT is category("POINTLISTOBJECT"); const category: PROCESSOBJECT is category("PROCESSOBJECT"); const category: ENUMLITERALOBJECT is category("ENUMLITERALOBJECT"); const category: CONSTENUMOBJECT is category("CONSTENUMOBJECT"); diff --git a/lib/comp/action.s7i b/lib/comp/action.s7i index 1e995a1b..1e5139c5 100644 --- a/lib/comp/action.s7i +++ b/lib/comp/action.s7i @@ -1316,6 +1316,20 @@ const proc: process_action (in reference: function, in ref_list: params, process(PCS_VALUE, function, params, c_expr); when {"PCS_WAIT_FOR"}: process(PCS_WAIT_FOR, function, params, c_expr); + when {"PLT_BSTRING"}: + process(PLT_BSTRING, function, params, c_expr); + when {"PLT_CMP"}: + process(PLT_CMP, function, params, c_expr); + when {"PLT_CPY"}: + process(PLT_CPY, function, params, c_expr); + when {"PLT_EQ"}: + process(PLT_EQ, function, params, c_expr); + when {"PLT_HASHCODE"}: + process(PLT_HASHCODE, function, params, c_expr); + when {"PLT_NE"}: + process(PLT_NE, function, params, c_expr); + when {"PLT_VALUE"}: + process(PLT_VALUE, function, params, c_expr); when {"POL_ADD_CHECK"}: process(POL_ADD_CHECK, function, params, c_expr); when {"POL_CLEAR"}: diff --git a/lib/comp/const.s7i b/lib/comp/const.s7i index 28f6eddb..38c99dad 100644 --- a/lib/comp/const.s7i +++ b/lib/comp/const.s7i @@ -28,7 +28,8 @@ const set of category: constantExpressionCategories is { TYPEOBJECT, INTOBJECT, BIGINTOBJECT, CHAROBJECT, STRIOBJECT, BSTRIOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT, SETOBJECT, FILEOBJECT, SOCKETOBJECT, LISTOBJECT, FLOATOBJECT, WINOBJECT, - PROCESSOBJECT, ENUMLITERALOBJECT, REFLISTOBJECT, SYMBOLOBJECT}; + POINTLISTOBJECT, PROCESSOBJECT, ENUMLITERALOBJECT, REFLISTOBJECT, + SYMBOLOBJECT}; const set of string: specialActions is {"BIG_PARSE1", "BIN_AND", "BIN_OR", "BIN_XOR", "BLN_ICONV1", diff --git a/lib/comp/copy.s7i b/lib/comp/copy.s7i index c9b08d76..2cad3e96 100644 --- a/lib/comp/copy.s7i +++ b/lib/comp/copy.s7i @@ -312,6 +312,7 @@ const proc: process_cpy_call (in type: object_type, when {POLLOBJECT}: expr &:= "polCpy(" & param_a & ", " & param_b & ")"; when {REFLISTOBJECT}: expr &:= "rflCpy(&(" & param_a & "), " & param_b & ")"; when {WINOBJECT}: expr &:= "drwCpy(&(" & param_a & "), " & param_b & ")"; + when {POINTLISTOBJECT}: expr &:= "bstCpy(&(" & param_a & "), " & param_b & ")"; when {PROCESSOBJECT}: expr &:= "pcsCpy(&(" & param_a & "), " & param_b & ")"; when {PROGOBJECT}: expr &:= "prgCpy(&(" & param_a & "), " & param_b & ")"; when {DATABASEOBJECT}: expr &:= "sqlCpyDb(&(" & param_a & "), " & param_b & ")"; diff --git a/lib/comp/create.s7i b/lib/comp/create.s7i index 8697c7d6..d31a738e 100644 --- a/lib/comp/create.s7i +++ b/lib/comp/create.s7i @@ -331,6 +331,7 @@ const proc: process_create_call (in type: object_type, when {POLLOBJECT}: expr &:= "polCreate(" & param_b & ")"; when {REFLISTOBJECT}: expr &:= "rflCreate(" & param_b & ")"; when {WINOBJECT}: expr &:= "drwCreate(" & param_b & ")"; + when {POINTLISTOBJECT}: expr &:= "bstCreate(" & param_b & ")"; when {PROCESSOBJECT}: expr &:= "pcsCreate(" & param_b & ")"; when {PROGOBJECT}: expr &:= "prgCreate(" & param_b & ")"; when {DATABASEOBJECT}: expr &:= "sqlCreateDb(" & param_b & ")"; diff --git a/lib/comp/destr.s7i b/lib/comp/destr.s7i index bc6a1095..b399ca10 100644 --- a/lib/comp/destr.s7i +++ b/lib/comp/destr.s7i @@ -378,8 +378,8 @@ const proc: declare_missing_destr_declarations (inout expr_type: c_expr) is func const set of category: destrNecessary is { BIGINTOBJECT, STRIOBJECT, BSTRIOBJECT, FILEOBJECT, SETOBJECT, - REFLISTOBJECT, WINOBJECT, PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT, - SQLSTMTOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT}; + REFLISTOBJECT, WINOBJECT, POINTLISTOBJECT, PROCESSOBJECT, PROGOBJECT, + DATABASEOBJECT, SQLSTMTOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT}; const proc: process_destr_call (in type: object_type, @@ -397,6 +397,7 @@ const proc: process_destr_call (in type: object_type, when {POLLOBJECT}: expr &:= "polDestr(" & param_b & ");\n"; when {REFLISTOBJECT}: expr &:= "rflDestr(" & param_b & ");\n"; when {WINOBJECT}: expr &:= "drwDestr(" & param_b & ");\n"; + when {POINTLISTOBJECT}: expr &:= "bstDestr(" & param_b & ");\n"; when {PROCESSOBJECT}: expr &:= "pcsDestr(" & param_b & ");\n"; when {PROGOBJECT}: expr &:= "prgDestr(" & param_b & ");\n"; when {DATABASEOBJECT}: expr &:= "sqlDestrDb(" & param_b & ");\n"; diff --git a/lib/comp/drw_act.s7i b/lib/comp/drw_act.s7i index a5758470..8618122b 100644 --- a/lib/comp/drw_act.s7i +++ b/lib/comp/drw_act.s7i @@ -94,6 +94,14 @@ const ACTION: DRW_WIDTH is action "DRW_WIDTH"; const ACTION: DRW_XPOS is action "DRW_XPOS"; const ACTION: DRW_YPOS is action "DRW_YPOS"; +const ACTION: PLT_BSTRING is action "PLT_BSTRING"; +const ACTION: PLT_CMP is action "PLT_CMP"; +const ACTION: PLT_CPY is action "PLT_CPY"; +const ACTION: PLT_EQ is action "PLT_EQ"; +const ACTION: PLT_HASHCODE is action "PLT_HASHCODE"; +const ACTION: PLT_NE is action "PLT_NE"; +const ACTION: PLT_VALUE is action "PLT_VALUE"; + const proc: constructRgbMacroPart (in string: colorName, in integer: colorMask, inout string: macroBody) is func @@ -227,6 +235,8 @@ const proc: drw_prototypes (inout file: c_prog) is func declareExtern(c_prog, "intType drwWidth (const_winType);"); declareExtern(c_prog, "intType drwXPos (const_winType);"); declareExtern(c_prog, "intType drwYPos (const_winType);"); + + declareExtern(c_prog, "bstriType pltValue (const const_objRefType);"); end func; @@ -1416,3 +1426,136 @@ const proc: process (DRW_YPOS, in reference: function, getAnyParamToExpr(params[1], c_expr); c_expr.expr &:= ")"; end func; + + +const proc: process (PLT_BSTRING, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + begin + c_expr.expr &:= "("; + process_expr(params[1], c_expr); + c_expr.expr &:= ")"; + end func; + + +const proc: process (PLT_CMP, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + begin + c_expr.expr &:= "bstCmp("; + getAnyParamToExpr(params[1], c_expr); + c_expr.expr &:= ", "; + getAnyParamToExpr(params[2], c_expr); + c_expr.expr &:= ")"; + end func; + + +const proc: process (PLT_CPY, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + local + var expr_type: statement is expr_type.value; + var expr_type: c_param1 is expr_type.value; + var expr_type: c_param3 is expr_type.value; + begin + statement.temp_num := c_expr.temp_num; + prepareAnyParamTemporarys(params[1], c_param1, statement); + c_param3.demand := ASSIGN_RESULT; + prepareAnyParamTemporarys(params[3], c_param3, statement); + if c_param3.result_expr <> "" then + if isNormalVariable(params[1]) then + statement.temp_decls &:= "bstriType old_bstri="; + statement.temp_decls &:= c_param1.expr; + statement.temp_decls &:= ";\n"; + statement.expr &:= c_param1.expr; + statement.expr &:= "="; + else + statement.temp_decls &:= "bstriType *bstri_ptr=&("; + statement.temp_decls &:= c_param1.expr; + statement.temp_decls &:= ");\n"; + statement.temp_decls &:= "bstriType old_bstri=*bstri_ptr;\n"; + statement.expr &:= "*bstri_ptr="; + end if; + statement.expr &:= c_param3.result_expr; + statement.expr &:= ";\n"; + statement.expr &:= "bstDestr(old_bstri);\n"; + else + statement.expr &:= "bstCpy(&("; + statement.expr &:= c_param1.expr; + statement.expr &:= "), "; + statement.expr &:= c_param3.expr; + statement.expr &:= ");\n"; + end if; + doLocalDeclsOfStatement(statement, c_expr); + end func; + + +const proc: process (PLT_EQ, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + local + var string: bstri_a_name is ""; + var string: bstri_b_name is ""; + begin + c_expr.expr &:= "("; + bstri_a_name := getParameterAsVariable("const_bstriType", "tmp_a_", params[1], c_expr); + bstri_b_name := getParameterAsVariable("const_bstriType", "tmp_b_", params[3], c_expr); + (* Formula used: (a->size==b->size&&memcmp(a->mem,b->mem, + a->size*sizeof(unsigned char))==0) *) + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->size=="; + c_expr.expr &:= bstri_b_name; + c_expr.expr &:= "->size&&memcmp("; + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->mem,"; + c_expr.expr &:= bstri_b_name; + c_expr.expr &:= "->mem,"; + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->size*sizeof(unsigned char))==0)"; + end func; + + +const proc: process (PLT_HASHCODE, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + begin + c_expr.expr &:= "bstHashCode("; + getAnyParamToExpr(params[1], c_expr); + c_expr.expr &:= ")"; + end func; + + +const proc: process (PLT_NE, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + local + var string: bstri_a_name is ""; + var string: bstri_b_name is ""; + begin + c_expr.expr &:= "("; + bstri_a_name := getParameterAsVariable("const_bstriType", "tmp_a_", params[1], c_expr); + bstri_b_name := getParameterAsVariable("const_bstriType", "tmp_b_", params[3], c_expr); + (* Formula used: (a->size!=b->size||memcmp(a->mem,b->mem, + a->size*sizeof(unsigned char))!=0) *) + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->size!="; + c_expr.expr &:= bstri_b_name; + c_expr.expr &:= "->size||memcmp("; + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->mem,"; + c_expr.expr &:= bstri_b_name; + c_expr.expr &:= "->mem,"; + c_expr.expr &:= bstri_a_name; + c_expr.expr &:= "->size*sizeof(unsigned char))!=0)"; + end func; + + +const proc: process (PLT_VALUE, in reference: function, + in ref_list: params, inout expr_type: c_expr) is func + + begin + prepare_bstri_result(c_expr); + c_expr.result_expr := "pltValue("; + getStdParamToResultExpr(params[1], c_expr); + c_expr.result_expr &:= ")"; + end func; diff --git a/lib/comp/expr_utl.s7i b/lib/comp/expr_utl.s7i index 0e58da65..e6478182 100644 --- a/lib/comp/expr_utl.s7i +++ b/lib/comp/expr_utl.s7i @@ -806,8 +806,9 @@ const func boolean: isNormalVariable (in reference: a_param) is CHAROBJECT, STRIOBJECT, BSTRIOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT, INTERFACEOBJECT, SETOBJECT, FILEOBJECT, SOCKETOBJECT, POLLOBJECT, LISTOBJECT, FLOATOBJECT, WINOBJECT, - PROCESSOBJECT, REFOBJECT, REFLISTOBJECT, ACTOBJECT, VALUEPARAMOBJECT, - REFPARAMOBJECT, RESULTOBJECT, LOCALVOBJECT, PROGOBJECT}; + POINTLISTOBJECT, PROCESSOBJECT, REFOBJECT, REFLISTOBJECT, + ACTOBJECT, VALUEPARAMOBJECT, REFPARAMOBJECT, RESULTOBJECT, + LOCALVOBJECT, PROGOBJECT}; const func string: normalVariable (in reference: aParam, inout expr_type: c_expr) is func diff --git a/lib/comp/literal.s7i b/lib/comp/literal.s7i index 9eac1062..c5c23b9a 100644 --- a/lib/comp/literal.s7i +++ b/lib/comp/literal.s7i @@ -69,6 +69,13 @@ const type: win_bstri_hash is hash [integer] integer; var win_table_hash: win_const_table is win_table_hash.EMPTY_HASH; var win_bstri_hash: win_bstri_table is win_bstri_hash.EMPTY_HASH; +const type: plist_table_hash is hash [pointList] integer; +const type: plist_index_hash is hash [integer] array pointList; +const type: plist_bstri_hash is hash [integer] integer; + +var plist_table_hash: plist_const_table is plist_table_hash.EMPTY_HASH; +var plist_bstri_hash: plist_bstri_table is plist_bstri_hash.EMPTY_HASH; + const type: const_table_hash is hash [reference] integer; const type: const_index_hash is hash [integer] array reference; @@ -284,3 +291,17 @@ const func string: windowLiteral (in PRIMITIVE_WINDOW: aWindow) is func expr &:= str(win_const_table[aWindow]); expr &:= "]"; end func; + + +const func string: pointListLiteral (in pointList: aPointList) is func + + result + var string: expr is ""; + begin + if aPointList not in plist_const_table then + plist_const_table @:= [aPointList] length(plist_const_table); + end if; + expr &:= "plist["; + expr &:= str(plist_const_table[aPointList]); + expr &:= "]"; + end func; diff --git a/lib/comp/ref_act.s7i b/lib/comp/ref_act.s7i index 197f790c..a8ad9e15 100644 --- a/lib/comp/ref_act.s7i +++ b/lib/comp/ref_act.s7i @@ -718,6 +718,8 @@ const proc: process (REF_TRACE, in reference: function, c_expr.expr &:= "printf(\" window [%lu] %lu\", win->usage_count, win);\n"; c_expr.expr &:= "}\n"; c_expr.expr &:= "}\n"; + when {POINTLISTOBJECT}: + c_expr.expr &:= "printf(\"\")"; when {PROCESSOBJECT}: c_expr.expr &:= "{\n"; c_expr.expr &:= "processType process="; diff --git a/lib/comp/type.s7i b/lib/comp/type.s7i index 0de94f49..b0fbfba1 100644 --- a/lib/comp/type.s7i +++ b/lib/comp/type.s7i @@ -86,6 +86,7 @@ const func string: raw_type_name (in type: object_type) is func when {POLLOBJECT}: typeName := "pollType"; when {SETOBJECT}: typeName := "setType"; when {WINOBJECT}: typeName := "winType"; + when {POINTLISTOBJECT}: typeName := "bstriType"; when {PROCESSOBJECT}: typeName := "processType"; when {PROGOBJECT}: typeName := "progType"; when {DATABASEOBJECT}: typeName := "databaseType"; @@ -192,6 +193,7 @@ const func string: raw_type_value (in type: object_type) is func when {POLLOBJECT}: valueName := "pollValue"; when {SETOBJECT}: valueName := "setValue"; when {WINOBJECT}: valueName := "winValue"; + when {POINTLISTOBJECT}: valueName := "bstriValue"; when {PROCESSOBJECT}: valueName := "processValue"; when {PROGOBJECT}: valueName := "progValue"; when {DATABASEOBJECT}: valueName := "databaseValue"; @@ -227,8 +229,9 @@ const func boolean: valueIsAtHeap (in type: aType) is func local const set of category: heapCategories is { BIGINTOBJECT, STRIOBJECT, BSTRIOBJECT, FILEOBJECT, WINOBJECT, - PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT, SQLSTMTOBJECT, SETOBJECT, - ARRAYOBJECT, STRUCTOBJECT, HASHOBJECT, INTERFACEOBJECT, REFLISTOBJECT}; + POINTLISTOBJECT, PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT, + SQLSTMTOBJECT, SETOBJECT, ARRAYOBJECT, STRUCTOBJECT, HASHOBJECT, + INTERFACEOBJECT, REFLISTOBJECT}; begin if aType in typeCategory and typeCategory[aType] in heapCategories then isAtHeap := TRUE; diff --git a/lib/graph.s7i b/lib/graph.s7i index 994dee95..84615146 100644 --- a/lib/graph.s7i +++ b/lib/graph.s7i @@ -398,13 +398,22 @@ const type: pointList is newtype; IN_PARAM_IS_REFERENCE(pointList); -const proc: destroy (ref pointList: aValue) is action "BST_DESTR"; -const proc: (ref pointList: dest) ::= (ref pointList: source) is action "BST_CREATE"; -const proc: (inout pointList: dest) := (ref pointList: source) is action "BST_CPY"; +const proc: destroy (ref pointList: aValue) is action "PLT_DESTR"; +const proc: (ref pointList: dest) ::= (in pointList: source) is action "PLT_CREATE"; +const proc: (inout pointList: dest) := (in pointList: source) is action "PLT_CPY"; -const func pointList: _GENERATE_EMPTY_POINT_LIST is action "BST_EMPTY"; +const func pointList: _GENERATE_EMPTY_POINT_LIST is action "PLT_EMPTY"; const pointList: (attr pointList) . value is _GENERATE_EMPTY_POINT_LIST; +const func bstring: bstring (in pointList: aPointList) is action "PLT_BSTRING"; + +const func boolean: (in pointList: pointList1) = (in pointList: pointList2) is action "PLT_EQ"; +const func boolean: (in pointList: pointList1) <> (in pointList: pointList2) is action "PLT_NE"; + +const func integer: hashCode (in pointList: aPointList) is action "PLT_HASHCODE"; +const func integer: compare (in pointList: pointList1, + in pointList: pointList2) is action "PLT_CMP"; + (** * The function 'genPointList' creates a 'pointList'. * It converts an array of alternate x and y values to a 'pointList'. diff --git a/lib/progs.s7i b/lib/progs.s7i index 22fe11cc..ec569887 100644 --- a/lib/progs.s7i +++ b/lib/progs.s7i @@ -463,6 +463,7 @@ const func float: getValue (in reference: aReference, attr float) is const func reference: getValue (in reference: aReference, attr reference) is action "REF_VALUE"; const func PRIMITIVE_WINDOW: getValue (in reference: aReference, attr PRIMITIVE_WINDOW) is action "DRW_VALUE"; +const func pointList: getValue (in reference: aReference, attr pointList) is action "PLT_VALUE"; const func process: getValue (in reference: aReference, attr process) is action "PCS_VALUE"; # const func type: getValue (in reference: aReference, attr type) is action "TYP_VALUE"; diff --git a/prg/s7c.sd7 b/prg/s7c.sd7 index 680b9c5a..f9caa907 100644 --- a/prg/s7c.sd7 +++ b/prg/s7c.sd7 @@ -302,7 +302,8 @@ const proc: getAnyParamToTempAssigns (in reference: aParam, inout expr_type: c_e exprCategory = FLOATOBJECT or exprCategory = CHAROBJECT or exprCategory = STRIOBJECT or - exprCategory = BSTRIOBJECT) then + exprCategory = BSTRIOBJECT or + exprCategory = POINTLISTOBJECT) then incr(c_expr.temp_num); variableName := "tmp_" & str(c_expr.temp_num); c_expr.temp_decls &:= type_name(getType(paramValue)); @@ -564,6 +565,8 @@ const func boolean: identical_values (in reference: object1, in reference: objec isIdentical := getValue(object1, reference) = getValue(object2, reference); when {FILEOBJECT}: isIdentical := getValue(object1, clib_file) = getValue(object2, clib_file); + when {POINTLISTOBJECT}: + isIdentical := getValue(object1, pointList) = getValue(object2, pointList); when {CONSTENUMOBJECT, VARENUMOBJECT}: isIdentical := getValue(object1, reference) = getValue(object2, reference); when {ARRAYOBJECT}: @@ -939,6 +942,16 @@ const proc: process_local_declaration (in reference: current_object, in var refe c_declaration.temp_frees &:= "drwDestr(o_"; create_name(current_object, c_declaration.temp_frees); c_declaration.temp_frees &:= ");\n"; + elsif valueCategory = POINTLISTOBJECT then + c_declaration.temp_assigns &:= diagnosticLine(current_object); + c_declaration.temp_assigns &:= "o_"; + create_name(current_object, c_declaration.temp_assigns); + c_declaration.temp_assigns &:= "=bstCreate("; + c_declaration.temp_assigns &:= pointListLiteral(getValue(object_value, pointList)); + c_declaration.temp_assigns &:= ");\n"; + c_declaration.temp_frees &:= "bstDestr(o_"; + create_name(current_object, c_declaration.temp_frees); + c_declaration.temp_frees &:= ");\n"; elsif valueCategory = PROCESSOBJECT then c_declaration.temp_decls &:= "=NULL"; c_declaration.temp_frees &:= "pcsDestr(o_"; @@ -1604,6 +1617,7 @@ const proc: process_call (in reference: current_expression, inout expr_type: c_e functionCategory = INTERFACEOBJECT or functionCategory = FILEOBJECT or functionCategory = WINOBJECT or + functionCategory = POINTLISTOBJECT or functionCategory = PROCESSOBJECT or functionCategory = PROGOBJECT or functionCategory = DATABASEOBJECT or @@ -1961,6 +1975,13 @@ const proc: process_expr (in var reference: current_expression, inout expr_type: else c_expr.expr &:= windowLiteral(getValue(current_expression, PRIMITIVE_WINDOW)); end if; + elsif exprCategory = POINTLISTOBJECT then + if isVar(current_expression) then + c_expr.expr &:= "o_"; + create_name(current_expression, c_expr.expr); + else + c_expr.expr &:= pointListLiteral(getValue(current_expression, pointList)); + end if; elsif exprCategory = PROCESSOBJECT then if isVar(current_expression) then c_expr.expr &:= "o_"; @@ -3503,6 +3524,25 @@ const proc: process_win_declaration (in reference: current_object, end func; +const proc: process_plist_declaration (in reference: current_object, + inout expr_type: c_expr) is func + + begin + if isVar(current_object) then + c_expr.expr &:= "bstriType o_"; + create_name(current_object, c_expr.expr); + c_expr.expr &:= ";\n\n"; + global_init.expr &:= diagnosticLine(current_object); + global_init.expr &:= "o_"; + create_name(current_object, global_init.expr); + global_init.expr &:= "=bstCreate("; + global_init.expr &:= pointListLiteral(getValue(current_object, pointList)); + global_init.expr &:= ");\n"; + count_declarations(c_expr); + end if; + end func; + + const proc: process_process_declaration (in reference: current_object, inout expr_type: c_expr) is func @@ -3822,6 +3862,7 @@ const proc: process_dynamic_call (in reference: function, objectCategory = STRUCTOBJECT or objectCategory = SETOBJECT or objectCategory = WINOBJECT or + objectCategory = POINTLISTOBJECT or objectCategory = PROCESSOBJECT or objectCategory = CONSTENUMOBJECT then c_expr.expr &:= "return "; @@ -4782,6 +4823,9 @@ const proc: process_action_declaration (in reference: current_object, elsif action_name = "DRW_CPY" or action_name = "DRW_CREATE" then defineParam1TypeCategory(current_object, WINOBJECT); count_declarations(c_expr); + elsif action_name = "PLT_CPY" or action_name = "PLT_CREATE" then + defineParam1TypeCategory(current_object, POINTLISTOBJECT); + count_declarations(c_expr); elsif action_name = "PCS_CPY" or action_name = "PCS_CREATE" then defineParam1TypeCategory(current_object, PROCESSOBJECT); count_declarations(c_expr); @@ -4916,6 +4960,8 @@ const proc: process_object_declaration (in reference: current_object, process_interface_declaration(current_object, c_expr); elsif objectCategory = WINOBJECT then process_win_declaration(current_object, c_expr); + elsif objectCategory = POINTLISTOBJECT then + process_plist_declaration(current_object, c_expr); elsif objectCategory = PROCESSOBJECT then process_process_declaration(current_object, c_expr); elsif objectCategory = PROGOBJECT then @@ -5487,6 +5533,7 @@ const proc: write_file_head is func writeln(c_prog, "extern double2BitsUnion nanValue[];"); writeln(c_prog, "bigIntType *big;"); writeln(c_prog, "winType *win;"); + writeln(c_prog, "bstriType *plist;"); writeln(c_prog, "arrayType *arr;"); writeln(c_prog, "structType *sct;"); writeln(c_prog, "hashType *hsh;"); @@ -5813,6 +5860,10 @@ const proc: walk_const_list (in ref_list: const_list, inout ref_list: sorted_lis if getValue(current_object, PRIMITIVE_WINDOW) not in win_const_table then win_const_table @:= [getValue(current_object, PRIMITIVE_WINDOW)] length(win_const_table); end if; + elsif objectCategory = POINTLISTOBJECT then + if getValue(current_object, pointList) not in plist_const_table then + plist_const_table @:= [getValue(current_object, pointList)] length(plist_const_table); + end if; elsif objectCategory = ARRAYOBJECT then if current_object not in const_table then const_table @:= [current_object] length(const_table); @@ -5943,6 +5994,9 @@ const proc: init_const_value (in reference: current_object, inout expr_type: c_e c_expr.expr &:= ".value.winValue=drwCreate("; c_expr.expr &:= windowLiteral(getValue(current_object, PRIMITIVE_WINDOW)); c_expr.expr &:= ")"; + elsif objectCategory = POINTLISTOBJECT then + c_expr.expr &:= ".value.bstriValue="; + c_expr.expr &:= pointListLiteral(getValue(current_object, pointList)); elsif objectCategory = PROCESSOBJECT then c_expr.expr &:= ".value.processValue="; c_expr.expr &:= "NULL"; @@ -6265,6 +6319,56 @@ const proc: assign_win_constants (inout expr_type: c_expr) is func end func; +const proc: init_plist_constants is func + + local + var plist_index_hash: plist_index is plist_index_hash.EMPTY_HASH; + var pointList: plist is pointList.value; + var integer: number is 0; + var bstring: bstri is bstring.value; + begin + plist_index := flip(plist_const_table); + for number range sort(keys(plist_index)) do + plist := plist_index[number][1]; + bstri := bstring(plist); + if bstri not in bstri_const_table then + bstri_const_table @:= [bstri] length(bstri_const_table); + end if; + plist_bstri_table @:= [number] bstri_const_table[bstri]; + end for; + end func; + + +const proc: assign_plist_constants (inout expr_type: c_expr) is func + + local + var plist_index_hash: plist_index is plist_index_hash.EMPTY_HASH; + var pointList: plist is pointList.value; + var integer: number is 0; + begin + if length(win_const_table) = 0 then + c_expr.expr &:= "plist = NULL;\n"; + else + c_expr.expr &:= "plist = (bstriType *)(malloc("; + c_expr.expr &:= str(length(plist_const_table)); + c_expr.expr &:= " * sizeof(bstriType)));\n"; + plist_index := flip(plist_const_table); + for number range sort(keys(plist_index)) do + plist := plist_index[number][1]; + c_expr.expr &:= "plist["; + c_expr.expr &:= str(number); + c_expr.expr &:= "]="; + if ccConf.ALLOW_BSTRITYPE_SLICES then + c_expr.expr &:= "&"; + end if; + c_expr.expr &:= "bst["; + c_expr.expr &:= str(plist_bstri_table[number]); + c_expr.expr &:= "];\n"; + end for; + end if; + end func; + + const proc: write_striChars (in string: striChars, inout expr_type: c_expr) is func local var integer: countChars is 0; @@ -7124,6 +7228,7 @@ const proc: init_values (inout expr_type: c_expr) is func init_bigint_constants; init_win_constants; + init_plist_constants; init_string_constants(c_expr); init_bstri_constants(c_expr); init_set_constants(c_expr); @@ -7135,6 +7240,7 @@ const proc: init_values (inout expr_type: c_expr) is func initPollOperations(c_expr); assign_bigint_constants(c_expr); assign_win_constants(c_expr); + assign_plist_constants(c_expr); c_expr.expr &:= "arr = (arrayType *)(malloc("; c_expr.expr &:= str(length(const_table)); c_expr.expr &:= " * sizeof(arrayType)));\n"; diff --git a/src/bstlib.c b/src/bstlib.c index 59410c83..f064d423 100644 --- a/src/bstlib.c +++ b/src/bstlib.c @@ -250,7 +250,6 @@ objectType bst_create (listType arguments) dest->value.bstriValue = take_bstri(source); source->value.bstriValue = NULL; } else { -/* printf("bstri_create %d !!!\n", in_file.line); */ new_size = take_bstri(source)->size; if (unlikely(!ALLOC_BSTRI_SIZE_OK(new_bstri, new_size))) { dest->value.bstriValue = NULL; @@ -329,8 +328,8 @@ objectType bst_eq (listType arguments) isit_bstri(arg_3(arguments)); bstri1 = take_bstri(arg_1(arguments)); bstri2 = take_bstri(arg_3(arguments)); - if (bstri1->size == bstri2->size && memcmp(bstri1->mem, bstri2->mem, - bstri1->size) == 0) { + if (bstri1->size == bstri2->size && + memcmp(bstri1->mem, bstri2->mem, bstri1->size) == 0) { return SYS_TRUE_OBJECT; } else { return SYS_FALSE_OBJECT; @@ -433,8 +432,8 @@ objectType bst_ne (listType arguments) isit_bstri(arg_3(arguments)); bstri1 = take_bstri(arg_1(arguments)); bstri2 = take_bstri(arg_3(arguments)); - if (bstri1->size != bstri2->size || memcmp(bstri1->mem, bstri2->mem, - bstri1->size) != 0) { + if (bstri1->size != bstri2->size || + memcmp(bstri1->mem, bstri2->mem, bstri1->size) != 0) { return SYS_TRUE_OBJECT; } else { return SYS_FALSE_OBJECT; diff --git a/src/data.h b/src/data.h index d00a8d82..2344fa28 100644 --- a/src/data.h +++ b/src/data.h @@ -64,6 +64,7 @@ typedef enum { LISTOBJECT, /* listValue - list */ FLOATOBJECT, /* floatValue - float */ WINOBJECT, /* winValue - Window */ + POINTLISTOBJECT, /* bstriValue - Points of a polyline */ PROCESSOBJECT, /* processValue - Process */ ENUMLITERALOBJECT, /* objValue - Enumeration literal */ CONSTENUMOBJECT, /* objValue - Constant enumeration obj */ @@ -201,7 +202,7 @@ typedef union { bigIntType bigIntValue; /* BIGINTOBJECT */ charType charValue; /* CHAROBJECT */ striType striValue; /* STRIOBJECT */ - bstriType bstriValue; /* BSTRIOBJECT */ + bstriType bstriValue; /* BSTRIOBJECT, POINTLISTOBJECT */ arrayType arrayValue; /* ARRAYOBJECT */ hashType hashValue; /* HASHOBJECT */ setType setValue; /* SETOBJECT */ diff --git a/src/data_rtl.h b/src/data_rtl.h index c0aaa117..512f3390 100644 --- a/src/data_rtl.h +++ b/src/data_rtl.h @@ -104,7 +104,7 @@ typedef union { bigIntType bigIntValue; /* BIGINTOBJECT */ charType charValue; /* CHAROBJECT */ striType striValue; /* STRIOBJECT */ - bstriType bstriValue; /* BSTRIOBJECT */ + bstriType bstriValue; /* BSTRIOBJECT, POINTLISTOBJECT */ rtlArrayType arrayValue; /* ARRAYOBJECT */ rtlHashType hashValue; /* HASHOBJECT */ setType setValue; /* SETOBJECT */ diff --git a/src/datautl.c b/src/datautl.c index b8e44391..4a580b1e 100644 --- a/src/datautl.c +++ b/src/datautl.c @@ -78,6 +78,7 @@ static const const_cstriType category_name[] = { "LISTOBJECT", /* listValue - list */ "FLOATOBJECT", /* floatValue - float */ "WINOBJECT", /* winValue - Window */ + "POINTLISTOBJECT", /* bstriValue - Points of a polyline */ "PROCESSOBJECT", /* processValue - Process */ "ENUMLITERALOBJECT", /* objValue - Enumeration literal */ "CONSTENUMOBJECT", /* objValue - Constant enumeration obj */ diff --git a/src/drwlib.c b/src/drwlib.c index b5faf61b..5c16405d 100644 --- a/src/drwlib.c +++ b/src/drwlib.c @@ -415,8 +415,8 @@ objectType drw_color (listType arguments) objectType drw_conv_point_list (listType arguments) { /* drw_conv_point_list */ - isit_bstri(arg_1(arguments)); - return toIntArray(drwConvPointList(take_bstri(arg_1(arguments)))); + isit_pointlist(arg_1(arguments)); + return toIntArray(drwConvPointList(take_pointlist(arg_1(arguments)))); } /* drw_conv_point_list */ @@ -671,12 +671,12 @@ objectType drw_fpoly_line (listType arguments) isit_win(arg_1(arguments)); isit_int(arg_2(arguments)); isit_int(arg_3(arguments)); - isit_bstri(arg_4(arguments)); + isit_pointlist(arg_4(arguments)); isit_int(arg_5(arguments)); actual_window = take_win(arg_1(arguments)); x = take_int(arg_2(arguments)); y = take_int(arg_3(arguments)); - point_list = take_bstri(arg_4(arguments)); + point_list = take_pointlist(arg_4(arguments)); col = take_int(arg_5(arguments)); drwFPolyLine(actual_window, x, y, point_list, col); return SYS_EMPTY_OBJECT; @@ -719,7 +719,7 @@ objectType drw_gen_point_list (listType arguments) FREE_RTL_ARRAY(xyArray, len); } /* if */ } /* if */ - return bld_bstri_temp(result); + return bld_pointlist_temp(result); } /* drw_gen_point_list */ @@ -1426,12 +1426,12 @@ objectType drw_poly_line (listType arguments) isit_win(arg_1(arguments)); isit_int(arg_2(arguments)); isit_int(arg_3(arguments)); - isit_bstri(arg_4(arguments)); + isit_pointlist(arg_4(arguments)); isit_int(arg_5(arguments)); actual_window = take_win(arg_1(arguments)); x = take_int(arg_2(arguments)); y = take_int(arg_3(arguments)); - point_list = take_bstri(arg_4(arguments)); + point_list = take_pointlist(arg_4(arguments)); col = take_int(arg_5(arguments)); drwPolyLine(actual_window, x, y, point_list, col); return SYS_EMPTY_OBJECT; @@ -1831,3 +1831,286 @@ objectType drw_ypos (listType arguments) return bld_int_temp( drwYPos(take_win(arg_1(arguments)))); } /* drw_ypos */ + + + +objectType plt_bstring (listType arguments) + + { + objectType argument1; + bstriType plist; + bstriType result; + + /* plt_bstring */ + argument1 = arg_1(arguments); + isit_pointlist(argument1); + plist = take_pointlist(argument1); + logFunction(printf("plt_bstring(\"%s\")\n", + bstriAsUnquotedCStri(plist));); + if (TEMP_OBJECT(argument1)) { + result = plist; + argument1->value.bstriValue = NULL; + } else { + if (unlikely(!ALLOC_BSTRI_SIZE_OK(result, plist->size))) { + return raise_exception(SYS_MEM_EXCEPTION); + } else { + result->size = plist->size; + memcpy(result->mem, plist->mem, plist->size); + } /* if */ + } /* if */ + logFunction(printf("plt_bstring --> \"%s\"\n", + bstriAsUnquotedCStri(result));); + return bld_bstri_temp(result); + } /* plt_bstring */ + + + +objectType plt_cmp (listType arguments) + + { /* plt_cmp */ + isit_pointlist(arg_1(arguments)); + isit_pointlist(arg_2(arguments)); + return bld_int_temp( + bstCmp(take_pointlist(arg_1(arguments)), + take_pointlist(arg_2(arguments)))); + } /* plt_cmp */ + + + +/** + * Assign source/arg_3 to dest/arg_1. + * A copy function assumes that dest/arg_1 contains a legal value. + * @exception MEMORY_ERROR Not enough memory to create dest. + */ +objectType plt_cpy (listType arguments) + + { + objectType dest; + objectType source; + memSizeType new_size; + bstriType plist_dest; + + /* plt_cpy */ + dest = arg_1(arguments); + source = arg_3(arguments); + isit_pointlist(dest); + isit_pointlist(source); + is_variable(dest); + plist_dest = take_pointlist(dest); + if (TEMP_OBJECT(source)) { + FREE_BSTRI(plist_dest, plist_dest->size); + dest->value.bstriValue = take_pointlist(source); + source->value.bstriValue = NULL; + } else { + new_size = take_pointlist(source)->size; + if (plist_dest->size == new_size) { + if (plist_dest != take_pointlist(source)) { + /* It is possible that dest == source holds. The */ + /* behavior of memcpy() is undefined if source and */ + /* destination areas overlap (or are identical). */ + /* Therefore a check for this case is necessary. */ + memcpy(plist_dest->mem, take_pointlist(source)->mem, new_size); + } /* if */ + } else { + if (unlikely(!ALLOC_BSTRI_SIZE_OK(plist_dest, new_size))) { + return raise_exception(SYS_MEM_EXCEPTION); + } else { + FREE_BSTRI(take_pointlist(dest), take_pointlist(dest)->size); + dest->value.bstriValue = plist_dest; + plist_dest->size = new_size; + } /* if */ + memcpy(plist_dest->mem, take_pointlist(source)->mem, new_size); + } /* if */ + } /* if */ + return SYS_EMPTY_OBJECT; + } /* plt_cpy */ + + + +/** + * Initialize dest/arg_1 and assign source/arg_3 to it. + * A create function assumes that the contents of dest/arg_1 + * is undefined. Create functions can be used to initialize + * constants. + * @exception MEMORY_ERROR Not enough memory to represent the result. + */ +objectType plt_create (listType arguments) + + { + objectType dest; + objectType source; + memSizeType new_size; + bstriType new_plist; + + /* plt_create */ + dest = arg_1(arguments); + source = arg_3(arguments); + isit_pointlist(source); + SET_CATEGORY_OF_OBJ(dest, POINTLISTOBJECT); + if (TEMP_OBJECT(source)) { + dest->value.bstriValue = take_pointlist(source); + source->value.bstriValue = NULL; + } else { + new_size = take_pointlist(source)->size; + if (unlikely(!ALLOC_BSTRI_SIZE_OK(new_plist, new_size))) { + dest->value.bstriValue = NULL; + return raise_exception(SYS_MEM_EXCEPTION); + } /* if */ + dest->value.bstriValue = new_plist; + new_plist->size = new_size; + memcpy(new_plist->mem, take_pointlist(source)->mem, new_size); + } /* if */ + return SYS_EMPTY_OBJECT; + } /* plt_create */ + + + +/** + * Free the memory referred by 'old_plist/arg_1'. + * After plt_destr is left 'old_plist/arg_1' is NULL. + * The memory where 'old_plist/arg_1' is stored can be + * freed afterwards. + */ +objectType plt_destr (listType arguments) + + { + bstriType old_plist; + + /* plt_destr */ + isit_pointlist(arg_1(arguments)); + old_plist = take_pointlist(arg_1(arguments)); + if (old_plist != NULL) { + FREE_BSTRI(old_plist, old_plist->size); + arg_1(arguments)->value.bstriValue = NULL; + } /* if */ + SET_UNUSED_FLAG(arg_1(arguments)); + return SYS_EMPTY_OBJECT; + } /* plt_destr */ + + + +objectType plt_empty (listType arguments) + + { + bstriType result; + + /* plt_empty */ + if (unlikely(!ALLOC_BSTRI_SIZE_OK(result, 0))) { + return raise_exception(SYS_MEM_EXCEPTION); + } else { + /* Note that the size of the allocated memory is smaller than */ + /* the size of the struct. But this is okay, because the */ + /* elements 'mem' respectively 'mem1' are not used. */ + result->size = 0; + return bld_pointlist_temp(result); + } /* if */ + } /* plt_empty */ + + + +/** + * Check if two pointLists are equal. + * @return TRUE if both pointLists are equal, + * FALSE otherwise. + */ +objectType plt_eq (listType arguments) + + { + bstriType plist1; + bstriType plist2; + + /* plt_eq */ + isit_pointlist(arg_1(arguments)); + isit_pointlist(arg_3(arguments)); + plist1 = take_pointlist(arg_1(arguments)); + plist2 = take_pointlist(arg_3(arguments)); + if (plist1->size == plist2->size && + memcmp(plist1->mem, plist2->mem, plist1->size) == 0) { + return SYS_TRUE_OBJECT; + } else { + return SYS_FALSE_OBJECT; + } /* if */ + } /* plt_eq */ + + + +objectType plt_hashcode (listType arguments) + + { + bstriType plist; + intType result; + + /* plt_hashcode */ + isit_pointlist(arg_1(arguments)); + plist = take_pointlist(arg_1(arguments)); + if (plist->size == 0) { + result = 0; + } else { + result = (intType) ((memSizeType) plist->mem[0] << 5 ^ + plist->size << 3 ^ plist->mem[plist->size - 1]); + } /* if */ + return bld_int_temp(result); + } /* plt_hashcode */ + + + +/** + * Check if two pointLists are not equal. + * @return FALSE if both pointLists are equal, + * TRUE otherwise. + */ +objectType plt_ne (listType arguments) + + { + bstriType plist1; + bstriType plist2; + + /* plt_ne */ + isit_pointlist(arg_1(arguments)); + isit_pointlist(arg_3(arguments)); + plist1 = take_pointlist(arg_1(arguments)); + plist2 = take_pointlist(arg_3(arguments)); + if (plist1->size != plist2->size || + memcmp(plist1->mem, plist2->mem, plist1->size) != 0) { + return SYS_TRUE_OBJECT; + } else { + return SYS_FALSE_OBJECT; + } /* if */ + } /* plt_ne */ + + + +/** + * Get 'pointList' value of the object referenced by 'aReference/arg_1'. + * @return the 'pointList' value of the referenced object. + * @exception RANGE_ERROR If 'aReference/arg_1' is NIL or + * category(aReference) <> POINTLISTOBJECT holds. + */ +objectType plt_value (listType arguments) + + { + objectType aReference; + bstriType plist; + bstriType result; + + /* plt_value */ + isit_reference(arg_1(arguments)); + aReference = take_reference(arg_1(arguments)); + if (unlikely(aReference == NULL || + CATEGORY_OF_OBJ(aReference) != POINTLISTOBJECT || + take_pointlist(aReference) == NULL)) { + logError(printf("plt_value("); + trace1(aReference); + printf("): Category is not POINTLISTOBJECT.\n");); + return raise_exception(SYS_RNG_EXCEPTION); + } else { + plist = take_pointlist(aReference); + if (unlikely(!ALLOC_BSTRI_SIZE_OK(result, plist->size))) { + return raise_exception(SYS_MEM_EXCEPTION); + } else { + result->size = plist->size; + memcpy(result->mem, plist->mem, result->size); + return bld_pointlist_temp(result); + } /* if */ + } /* if */ + } /* plt_value */ diff --git a/src/drwlib.h b/src/drwlib.h index 3560acda..c30cc87f 100644 --- a/src/drwlib.h +++ b/src/drwlib.h @@ -110,3 +110,14 @@ objectType drw_value (listType arguments); objectType drw_width (listType arguments); objectType drw_xpos (listType arguments); objectType drw_ypos (listType arguments); + +objectType plt_bstring (listType arguments); +objectType plt_cmp (listType arguments); +objectType plt_cpy (listType arguments); +objectType plt_create (listType arguments); +objectType plt_destr (listType arguments); +objectType plt_empty (listType arguments); +objectType plt_eq (listType arguments); +objectType plt_hashcode (listType arguments); +objectType plt_ne (listType arguments); +objectType plt_value (listType arguments); diff --git a/src/exec.c b/src/exec.c index 6f505aca..abcc0c7a 100644 --- a/src/exec.c +++ b/src/exec.c @@ -131,6 +131,7 @@ objectType exec_object (register objectType object) case FLOATOBJECT: #endif case WINOBJECT: + case POINTLISTOBJECT: case REFOBJECT: case REFLISTOBJECT: case EXPROBJECT: @@ -774,6 +775,7 @@ objectType exec_call (objectType object) case FLOATOBJECT: #endif case WINOBJECT: + case POINTLISTOBJECT: case PROCESSOBJECT: case VARENUMOBJECT: case ENUMLITERALOBJECT: @@ -902,6 +904,7 @@ objectType evaluate (objectType object) case FLOATOBJECT: #endif case WINOBJECT: + case POINTLISTOBJECT: case REFOBJECT: case REFLISTOBJECT: case ENUMLITERALOBJECT: diff --git a/src/objutl.c b/src/objutl.c index ae147361..16962ff2 100644 --- a/src/objutl.c +++ b/src/objutl.c @@ -605,6 +605,25 @@ objectType bld_win_temp (winType temp_win) +objectType bld_pointlist_temp (bstriType temp_pointlist) + + { + register objectType result; + + /* bld_pointlist_temp */ + if (ALLOC_OBJECT(result)) { + result->type_of = NULL; + result->descriptor.property = NULL; + INIT_CATEGORY_OF_TEMP(result, POINTLISTOBJECT); + result->value.bstriValue = temp_pointlist; + return result; + } else { + return raise_exception(SYS_MEM_EXCEPTION); + } /* if */ + } /* bld_pointlist_temp */ + + + objectType bld_process_temp (processType temp_process) { @@ -680,6 +699,7 @@ void dump_temp_value (objectType object) SET_UNUSED_FLAG(object); break; case BSTRIOBJECT: + case POINTLISTOBJECT: if (object->value.bstriValue != NULL) { FREE_BSTRI(object->value.bstriValue, object->value.bstriValue->size); } /* if */ diff --git a/src/objutl.h b/src/objutl.h index 4ff8e235..4d75a5b8 100644 --- a/src/objutl.h +++ b/src/objutl.h @@ -67,6 +67,7 @@ #define take_struct(arg) (arg)->value.structValue #define take_type(arg) (arg)->value.typeValue #define take_win(arg) (arg)->value.winValue +#define take_pointlist(arg) (arg)->value.bstriValue #define take_process(arg) (arg)->value.processValue #if WITH_TYPE_CHECK @@ -119,6 +120,8 @@ #define isit_struct_ok(arg) if (unlikely(take_struct(arg) == NULL)) { empty_value(arg); return NULL; } #define isit_type(arg) hasCategory(arg, TYPEOBJECT) #define isit_win(arg) hasCategory(arg, WINOBJECT) +#define isit_pointlist(arg) hasCategory(arg, POINTLISTOBJECT); \ + if (unlikely(take_bstri(arg) == NULL)) { empty_value(arg); return NULL; } #define isit_process(arg) hasCategory(arg, PROCESSOBJECT) #define is_variable(arg) if (unlikely(!VAR_OBJECT(arg))) { var_required(arg); return NULL; } #define isit_int2(arg) if (unlikely(CATEGORY_OF_OBJ(arg) != INTOBJECT)) run_error(INTOBJECT, arg) @@ -155,6 +158,7 @@ #define isit_struct_ok(arg) #define isit_type(arg) #define isit_win(arg) +#define isit_pointlist(arg) #define isit_process(arg) #define is_variable(arg) #define isit_int2(arg) @@ -189,6 +193,7 @@ void isit_list (objectType argument); /* void isit_struct (objectType argument); */ /* void isit_type (objectType argument); */ /* void isit_win (objectType argument); */ +/* void isit_pointlist (objectType argument); */ /* void isit_process (objectType argument); */ #endif objectType bld_action_temp (actType temp_action); @@ -217,6 +222,7 @@ objectType bld_stri_temp (striType temp_stri); objectType bld_struct_temp (structType temp_struct); objectType bld_type_temp (typeType temp_type); objectType bld_win_temp (winType temp_win); +objectType bld_pointlist_temp (bstriType temp_pointlist); objectType bld_process_temp (processType temp_win); void dump_temp_value (objectType object); void dump_any_temp (objectType object); diff --git a/src/primitiv.c b/src/primitiv.c index c8d0464b..cff10910 100644 --- a/src/primitiv.c +++ b/src/primitiv.c @@ -679,6 +679,19 @@ static const actEntryRecord actEntryTable[] = { { "PCS_VALUE", pcs_value, }, { "PCS_WAIT_FOR", pcs_wait_for, }, +#if WITH_DRAW + { "PLT_BSTRING", plt_bstring }, + { "PLT_CMP", plt_cmp, }, + { "PLT_CPY", plt_cpy, }, + { "PLT_CREATE", plt_create, }, + { "PLT_DESTR", plt_destr, }, + { "PLT_EMPTY", plt_empty, }, + { "PLT_EQ", plt_eq, }, + { "PLT_HASHCODE", plt_hashcode, }, + { "PLT_NE", plt_ne, }, + { "PLT_VALUE", plt_value, }, +#endif + { "POL_ADD_CHECK", pol_add_check, }, { "POL_CLEAR", pol_clear, }, { "POL_CPY", pol_cpy, }, diff --git a/src/ref_data.c b/src/ref_data.c index a56e003b..e41b59ca 100644 --- a/src/ref_data.c +++ b/src/ref_data.c @@ -1235,6 +1235,40 @@ processType pcsValue (const const_objectType aReference) +/** + * Get 'pointList' value of the object referenced by 'aReference'. + * @return the 'pointList' value of the referenced object. + * @exception RANGE_ERROR If 'aReference' is NIL or + * category(aReference) <> POINTLISTOBJECT holds. + */ +bstriType pltValue (const const_objectType aReference) + + { + bstriType plist; + bstriType result; + + /* pltValue */ + if (unlikely(aReference == NULL || + CATEGORY_OF_OBJ(aReference) != POINTLISTOBJECT || + (plist = take_pointlist(aReference)) == NULL)) { + logError(printf("pltValue("); + trace1(aReference); + printf("): Category is not POINTLISTOBJECT.\n");); + raise_error(RANGE_ERROR); + result = NULL; + } else { + if (unlikely(!ALLOC_BSTRI_SIZE_OK(result, plist->size))) { + raise_error(MEMORY_ERROR); + } else { + result->size = plist->size; + memcpy(result->mem, plist->mem, (size_t) (result->size)); + } /* if */ + } /* if */ + return result; + } /* pltValue */ + + + /** * Get 'pollData' value of the object referenced by 'aReference'. * @return the 'pollData' value of the referenced object. diff --git a/src/ref_data.h b/src/ref_data.h index b3055bcc..b7cb7f94 100644 --- a/src/ref_data.h +++ b/src/ref_data.h @@ -69,6 +69,7 @@ fileType filValue (const const_objectType aReference); floatType fltValue (const const_objectType aReference); intType intValue (const const_objectType aReference); processType pcsValue (const const_objectType aReference); +bstriType pltValue (const const_objectType aReference); pollType polValue (const const_objectType aReference); progType prgValue (const const_objectType aReference); objectType refValue (const const_objectType aReference); diff --git a/src/traceutl.c b/src/traceutl.c index fe1cacf5..7c432117 100644 --- a/src/traceutl.c +++ b/src/traceutl.c @@ -508,6 +508,7 @@ static void print_real_value (const_objectType anyobject) prot_stri(anyobject->value.striValue); break; case BSTRIOBJECT: + case POINTLISTOBJECT: prot_bstri(anyobject->value.bstriValue); break; case FILEOBJECT: @@ -736,6 +737,7 @@ void printobject (const_objectType anyobject) case SETOBJECT: case BLOCKOBJECT: case WINOBJECT: + case POINTLISTOBJECT: case PROCESSOBJECT: case PROGOBJECT: printvalue(anyobject); @@ -945,6 +947,7 @@ void prot_list_limited (const_listType list, int depthLimit) case ACTOBJECT: case BLOCKOBJECT: case WINOBJECT: + case POINTLISTOBJECT: case PROCESSOBJECT: printvalue(list->obj); break; @@ -1559,6 +1562,7 @@ void trace1 (const_objectType traceobject) case ACTOBJECT: case BLOCKOBJECT: case WINOBJECT: + case POINTLISTOBJECT: case PROCESSOBJECT: print_real_value(traceobject); break;