Fixed GnuDemanglerParser Cast Operator

The testOperatorCastTo method has also been added to
GnuDemanglerParserTest.
This commit is contained in:
astrelsky
2020-01-18 15:40:06 -05:00
parent 6ae0c1ce23
commit c697b7a0a8
2 changed files with 27 additions and 6 deletions

View File

@@ -373,9 +373,9 @@ public class GnuDemanglerParser implements DemanglerParser {
} }
// this will yield: // this will yield:
// fullName: NS1::Foo::operator // fullNamespace: NS1::Foo::operator
// fullReturnType: std::string // fullReturnType: std::string
String fullName = matcher.group(1);// group 0 is the entire match string String fullNamespace = matcher.group(1);// group 0 is the entire match string
String fullReturnType = matcher.group(2); String fullReturnType = matcher.group(2);
boolean isConst = false; boolean isConst = false;
@@ -394,8 +394,8 @@ public class GnuDemanglerParser implements DemanglerParser {
// 'conversion operator' syntax is operator <name, which is the type>() // 'conversion operator' syntax is operator <name, which is the type>()
String templatelessName = stripOffTemplates(fullName); String templatelessNamespace = stripOffTemplates(fullNamespace);
setNameAndNamespace(method, templatelessName); setNamespace(method, templatelessNamespace);
// shortReturnType: string // shortReturnType: string
String templatelessReturnType = stripOffTemplates(fullReturnType); String templatelessReturnType = stripOffTemplates(fullReturnType);
@@ -410,7 +410,7 @@ public class GnuDemanglerParser implements DemanglerParser {
// //
method.setName("operator.cast.to." + shortReturnTypeName); method.setName("operator.cast.to." + shortReturnTypeName);
method.setSignature(fullName + " " + fullReturnType); method.setSignature(fullNamespace + " " + fullReturnType);
method.setOverloadedOperator(true); method.setOverloadedOperator(true);
return method; return method;
@@ -449,7 +449,7 @@ public class GnuDemanglerParser implements DemanglerParser {
method.setReturnType(returnType); method.setReturnType(returnType);
// 'conversion operator' syntax is operator <name, which is the type>(), where the // 'conversion operator' syntax is operator <name, which is the type>(), where the
// operator itself cold be in a class namespace // operator itself could be in a class namespace
setNameAndNamespace(method, operatorText); setNameAndNamespace(method, operatorText);
List<DemangledDataType> parameters = parseParameters(parametersText); List<DemangledDataType> parameters = parseParameters(parametersText);

View File

@@ -362,6 +362,27 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
assertEquals("Magick::Coordinate const &", parameters.get(1).toSignature()); assertEquals("Magick::Coordinate const &", parameters.get(1).toSignature());
} }
@Test
public void testOperatorCastTo() throws Exception {
//
// Mangled: _ZNKSt17integral_constantIbLb0EEcvbEv
//
// Demangled: std::integral_constant<bool, false>::operator bool() const
String mangled = "_ZNKSt17integral_constantIbLb0EEcvbEv";
String demangled = process.demangle(mangled);
DemangledObject object = parser.parse(mangled, demangled);
assertNotNull(object);
assertTrue(object instanceof DemangledFunction);
String signature = object.getSignature(false);
assertEquals(
"bool std::integral_constant::operator.cast.to.bool(void)",
signature);
}
@Test @Test
public void testFunctions() throws Exception { public void testFunctions() throws Exception {
String mangled = "_Z7toFloatidcls"; String mangled = "_Z7toFloatidcls";