Changeset 13698


Ignore:
Timestamp:
Oct 8, 2019 4:03:53 PM (2 months ago)
Author:
randersson
Message:

#5819 Replaced toString(...) with toPyUnicode(...) in order to test if this resolve the issue with building ModelicaCasADiInterface using a JCC compatible with Python 3. The switch to toPyUnicode is based on using diff on JCCEnv.h from the two different jcc versions. Note that this change is not Python 2 compatible, but, is for testing if it resolves the current build issue.

Location:
branches/dev-5819/ModelicaCasADiInterface/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/ModelicaCasADiInterface/src/CompilerOptionsWrapper.cpp

    r13252 r13698  
    6969        while(iter.hasNext()){
    7070            java::lang::String key(iter.next().this$);
    71             out <<"\033[31m"<<env->toString(key.this$) <<"\033[0m"<< ": ";
    72             out << env->toString(optr.getDescription(key).this$);
     71            out <<"\033[31m"<<env->toPyUnicode(key.this$) <<"\033[0m"<< ": ";
     72            out << env->toPyUnicode(optr.getDescription(key).this$);
    7373            out << "\n";
    7474        }
     
    8989}
    9090
    91 void ModelicaOptionsWrapper::print(std::ostream& os) const { os << "ModelicaOptionsWrapper(" << env->toString(optr.this$) << ")"; }
     91void ModelicaOptionsWrapper::print(std::ostream& os) const { os << "ModelicaOptionsWrapper(" << env->toPyUnicode(optr.this$) << ")"; }
    9292
    9393void OptimicaOptionsWrapper::setStringOption(std::string opt, std::string val) {
     
    130130        while(iter.hasNext()){
    131131            java::lang::String key(iter.next().this$);
    132             out <<"\033[31m"<<env->toString(key.this$) <<"\033[0m"<< ": ";
    133             out << env->toString(optr.getDescription(key).this$);
     132            out <<"\033[31m"<<env->toPyUnicode(key.this$) <<"\033[0m"<< ": ";
     133            out << env->toPyUnicode(optr.getDescription(key).this$);
    134134            out << "\n";
    135135        }
     
    150150}
    151151
    152 void OptimicaOptionsWrapper::print(std::ostream& os) const { os << "OptimicaOptionsWrapper(" << env->toString(optr.this$) << ")"; }
     152void OptimicaOptionsWrapper::print(std::ostream& os) const { os << "OptimicaOptionsWrapper(" << env->toPyUnicode(optr.this$) << ")"; }
    153153}; // End namespace
  • branches/dev-5819/ModelicaCasADiInterface/src/sharedTransferFunctionality.hpp

    r11286 r13698  
    314314        AbstractEquation eq = AbstractEquation(equationList.get(i).this$);
    315315        if (eq.isIgnoredForCasADi()) {
    316             char *str = env->toString(eq.this$);
     316            char *str = env->toPyUnicode(eq.this$);
    317317            std::cerr << "Warning: Ignored equation:\n" << str << std::endl;
    318318            delete[] str;
     
    448448    if(fv.hasFStringComment()) {
    449449        Comment comment = Comment(fv.getFStringComment().this$);
    450         var->setAttribute("comment", casadi::MX::sym(env->toString(comment.getComment().this$)));
     450        var->setAttribute("comment", casadi::MX::sym(env->toPyUnicode(comment.getComment().this$)));
    451451    }
    452452}
     
    466466    for (int i = 0; i < attributeList.getNumChild(); ++i) {
    467467        attr = Attribute(attributeList.getChild(i).this$);
    468         std::string name = env->toString(attr.name().this$);
     468        std::string name = env->toPyUnicode(attr.name().this$);
    469469        if (name != "stateSelect" && name.find("__") != 0) {
    470470            // Don't transfer stateSelect attribute, since enumerations are not supported
     
    561561    List attributeList = derivedType.getFAttributes();
    562562    Attribute  attr;
    563     std::string typeName = env->toString(derivedType.getName().this$);
    564     std::string baseTypeName = env->toString((Type(derivedType.getBaseType().this$)).toString().this$);
     563    std::string typeName = env->toPyUnicode(derivedType.getName().this$);
     564    std::string baseTypeName = env->toPyUnicode((Type(derivedType.getBaseType().this$)).toPyUnicode().this$);
    565565    ModelicaCasADi::Ref<ModelicaCasADi::UserType> userType = new ModelicaCasADi::UserType(typeName, getBaseTypeForDerivedType(m, baseTypeName));
    566566    for (int i = 0; i < attributeList.getNumChild(); ++i) {
    567567        attr = Attribute(attributeList.getChild(i).this$);
    568         userType->setAttribute(env->toString(attr.name().this$), toMX(attr.getValue()));
     568        userType->setAttribute(env->toPyUnicode(attr.name().this$), toMX(attr.getValue()));
    569569    }
    570570    m->addNewVariableType(userType);
     
    607607{
    608608    ModelicaCasADi::Ref<ModelicaCasADi::UserType> userType;
    609     if (!std::string(env->toString(fv.getDerivedType().this$)).empty()) {
    610         userType = (ModelicaCasADi::UserType*) m->getVariableType(env->toString(fv.getDerivedType().this$)).getNode();
     609    if (!std::string(env->toPyUnicode(fv.getDerivedType().this$)).empty()) {
     610        userType = (ModelicaCasADi::UserType*) m->getVariableType(env->toPyUnicode(fv.getDerivedType().this$)).getNode();
    611611        if(userType.getNode() == NULL) {
    612612            throw std::runtime_error("Variable's derived type not present in Model when Variable transferred");
     
    693693    }
    694694   
    695     std::string aliasName = env->toString(fv.alias().name().this$);
     695    std::string aliasName = env->toPyUnicode(fv.alias().name().this$);
    696696    ModelicaCasADi::Ref<ModelicaCasADi::Variable> aliasVariable = m->getVariable(aliasName);
    697697    if (aliasVariable == NULL) {
     
    725725        FVar var = FVar(vars.get(i).this$);
    726726        if (var.type().isEnum()) {
    727             char *str = env->toString(var.this$);
     727            char *str = env->toPyUnicode(var.this$);
    728728            std::cerr << "Warning: Ignored enumeration typed variable:\n" << str << std::endl;
    729729            delete[] str;
  • branches/dev-5819/ModelicaCasADiInterface/src/transferModelica.cpp

    r13252 r13698  
    174174            StringFromUTF(modelName.c_str()));
    175175
    176         std::string identfier = env->toString(fclass.nameUnderscore().this$);
     176        std::string identfier = env->toPyUnicode(fclass.nameUnderscore().this$);
    177177        // Initialize the model with the model identfier.
    178178        m->initializeModel(identfier);
  • branches/dev-5819/ModelicaCasADiInterface/src/transferOptimica.cpp

    r13252 r13698  
    172172                StringFromUTF(modelName.c_str())).this$);
    173173
    174             std::string identfier = env->toString(fclass.nameUnderscore().this$);
     174            std::string identfier = env->toPyUnicode(fclass.nameUnderscore().this$);
    175175            std::string option = "normalize_minimum_time_problems";
    176176            bool normalizedTime = fclass.myOptions().getBooleanOption(StringFromUTF(option.c_str()));
Note: See TracChangeset for help on using the changeset viewer.