Changeset 13562


Ignore:
Timestamp:
Sep 20, 2019 3:15:32 PM (3 months ago)
Author:
Christian Andersson
Message:

Added support for evaluating string methods. Related to ticket:5837

Location:
branches/dev-cw-evaluator
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-evaluator/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalProcessCacheImpl.java

    r13550 r13562  
    100100        add("ModelicaStrings_length");
    101101        add("ModelicaStrings_skipWhiteSpace");
     102        add("ModelicaStrings_compare");
    102103    }};
    103104   
     
    109110        add("i+s,");
    110111        add("i+s,i,");
     112        add("i+s,s,i,");
    111113        add("i+i,i,");
    112114        add("void+i,d,d,*R[d,d,d,d,d,d,d,d,d,d,d,],");
  • branches/dev-cw-evaluator/Python/src/tests_jmodelica/files/Modelica/ExtFunctionTests.mo

    r13549 r13562  
    7373    constant Integer len = Modelica.Utilities.Strings.length(string1);
    7474    constant Integer start = Modelica.Utilities.Strings.Advanced.skipWhiteSpace("   Hello", 1);
     75    constant Boolean not_equal = Modelica.Utilities.Strings.isEqual("Temp", "test", true);
     76    constant Boolean equal = Modelica.Utilities.Strings.isEqual("Temp", "Temp", true);
    7577end Evaluator_Substring;
    7678
  • branches/dev-cw-evaluator/Python/src/tests_jmodelica/general/test_extfunctions.py

    r13549 r13562  
    5252            nbr_of_evaluator_calls = len(res)
    5353       
    54         assert nbr_of_evaluator_calls == 3, "Wrong number of external function calls, check log."
     54        assert nbr_of_evaluator_calls == 4, "Wrong number of external function calls, check log."
    5555       
    5656        model = load_fmu(fmu_name)
     
    6060        assert model.get("len") == 16, model.get("len")
    6161        assert model.get("start") == 4, model.get("start")
     62        assert not model.get("not_equal"), model.get("not_equal")
     63        assert model.get("equal"), model.get("equal")
    6264   
    6365    @testattr(stddist_base = True)
  • branches/dev-cw-evaluator/RuntimeLibrary/src/evaluator/jmi_evaluator.c

    r13553 r13562  
    1616extern int ModelicaStrings_length(const char*);
    1717extern int ModelicaStrings_skipWhiteSpace(const char*, int);
     18extern int ModelicaStrings_compare(const char*, const char*, int);
    1819
    1920/* Record definitions */
     
    4142typedef int (__stdcall *f_i_s)(const char*);
    4243typedef int (__stdcall *f_i_si)(const char*, int);
     44typedef int (__stdcall *f_i_ssi)(const char*, const char*, int);
    4345typedef void(__stdcall *f___iddpR_ddddddddddd_)(int, double, double, R_ddddddddddd**);
    4446typedef void(__stdcall *f___ddpd)(double, double, double*);
     
    220222}
    221223
     224void jmi_call_integer_fcn_ssi(generic_funcptr fcn, double *out) {
     225    JMI_DEF(STR, arg_0)
     226    JMI_DEF(STR, arg_1)
     227    JMI_DEF(INT, arg_2)
     228    JMI_DEF(INT_EXT, tmp_2)
     229
     230    JMCEVAL_parse(String, arg_0);
     231    JMCEVAL_parse(String, arg_1);
     232    JMCEVAL_parse(Integer, arg_2);
     233
     234    JMCEVAL_check("CALC");
     235    if (JMCEVAL_try()) {
     236        /* Calc phase */
     237        tmp_2 = (int)arg_2;
     238        *out = ((f_i_ssi)fcn)(arg_0, arg_1, tmp_2);
     239    }
     240    else {
     241        JMCEVAL_failed();
     242    }
     243}
     244
    222245void jmi_call_integer_fcn(generic_funcptr fcn, const char* inputs) {
    223246    JMI_DEF(INT, i_output)
     
    228251    } else if (strcmp(inputs, "s,i,") == 0) {
    229252        jmi_call_integer_fcn_si(fcn, &i_output);
     253    } else if (strcmp(inputs, "s,s,i,") == 0) {
     254        jmi_call_integer_fcn_ssi(fcn, &i_output);
    230255    } else {
    231256        printf(ERROR_NOT_SUPPORTED_INPUT_ARGS_MSG);
     
    308333    } else if (strcmp(argv[2], "ModelicaStrings_skipWhiteSpace") == 0) {
    309334        funci = (generic_funcptr)ModelicaStrings_skipWhiteSpace;
     335    } else if (strcmp(argv[2], "ModelicaStrings_compare") == 0) {
     336        funci = (generic_funcptr)ModelicaStrings_compare;
    310337    }
    311338
Note: See TracChangeset for help on using the changeset viewer.