Project

General

Profile

Bug #9606 ยป 0001-Proper-dynamic-cast.patch

Raf Pauwels, 01/11/2022 01:38 PM

View differences:

java/src/eu/webtoolkit/jwt/utils/ObjectUtils.java
}
@SuppressWarnings("unchecked")
public static <T> T cast(Object object, Class<T> clazz) {
return clazz.isInstance(object) ? (T)object : null;
}
}
oink/elsa-stack/elsa/java_print.cc
TreeWalkDebug treeDebug("E_keywordCast::iprint");
if (key == CK_DYNAMIC){
// dynamic_cast<T>(o) -> ( o instanceof T ? (T)o : null )
*env.out << "((";
// dynamic_cast<T>(o) -> ObjectUtils.cast(o, T.class)
*env.out << "ObjectUtils.cast(";
expr->jprint(env);
*env.out << ") instanceof ";
*env.out << ", ";
ctype->jprint(env);
*env.out << " ? (";
ctype->jprint(env);
*env.out << ")(";
expr->jprint(env);
*env.out << ") : null)";
*env.out << ".class)";
}
else{
//map static_cast<Enum>0 -> null
oink/elsa-stack/elsa/mapper_filler.cc
mapper.addFunction("", "Utils.stoll", "Long.parseLong", 1);
mapper.addFunction("", "Utils.stof", "Float.parseFloat", 1);
mapper.addFunction("", "Utils.stod", "Double.parseDouble", 1);
mapper.addFunction("", "Utils.dynamic_unique_ptr_cast", "", 1, "(($templates(cppfunction);)$0;)");
mapper.addFunction("", "Utils.dynamic_unique_ptr_cast", "", 1, "ObjectUtils.cast($0;, $templates(cppfunction);.class)");
mapper.addFunction("", "Utils.keyForUniquePtrValue", "CollectionUtils.keyForValue", 2);
mapper.addFunction("", "std.dynamic_pointer_cast", "", 1, "(($templates(cppfunction);)$0;)");
mapper.addFunction("", "std.dynamic_pointer_cast", "", 1, "ObjectUtils.cast($0;, $templates(cppfunction);.class)");
mapper.addClass("boost.intrusive.list", "LinkedList");
mapper.addFunction("boost.intrusive.list", "begin", "iterator", 0);
    (1-1/1)