Commit ef80f529 authored by Andrew Twyman's avatar Andrew Twyman

Merge pull request #210 from jrogers/jrogers/rebase2

Fix ObjC interface generated with non-default cpp identifier type formatting
parents 52e40d41 6b50c39b
...@@ -190,7 +190,6 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -190,7 +190,6 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
if (i.ext.objc) { if (i.ext.objc) {
w.wl w.wl
val objcExtSelf = objcppMarshal.helperClass("objc_proxy")
wrapNamespace(w, spec.objcppNamespace, w => { wrapNamespace(w, spec.objcppNamespace, w => {
w.wl(s"class $helperClass::ObjcProxy final") w.wl(s"class $helperClass::ObjcProxy final")
w.wl(s": public $cppSelf") w.wl(s": public $cppSelf")
...@@ -247,7 +246,6 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -247,7 +246,6 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
//w.wl(s"return ${spec.cppNnCheckExpression.getOrElse("")}(objc->_cppRefHandle.get());") //w.wl(s"return ${spec.cppNnCheckExpression.getOrElse("")}(objc->_cppRefHandle.get());")
} else { } else {
// ObjC only, or ObjC and C++. // ObjC only, or ObjC and C++.
val objcExtSelf = objcppMarshal.helperClass("objc_proxy")
if (i.ext.cpp) { if (i.ext.cpp) {
// If it could be implemented in C++, we might have to unwrap a proxy object. // If it could be implemented in C++, we might have to unwrap a proxy object.
w.w(s"if ([(id)objc isKindOfClass:[$objcSelf class]])").braced { w.w(s"if ([(id)objc isKindOfClass:[$objcSelf class]])").braced {
...@@ -255,7 +253,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -255,7 +253,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"return ${nnCheck(getProxyExpr)};") w.wl(s"return ${nnCheck(getProxyExpr)};")
} }
} }
val getProxyExpr = s"::djinni::get_objc_proxy<$objcExtSelf>(objc)" val getProxyExpr = s"::djinni::get_objc_proxy<ObjcProxy>(objc)"
w.wl(s"return ${nnCheck(getProxyExpr)};") w.wl(s"return ${nnCheck(getProxyExpr)};")
} }
} }
...@@ -268,14 +266,12 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -268,14 +266,12 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
if (i.ext.objc && !i.ext.cpp) { if (i.ext.objc && !i.ext.cpp) {
// ObjC only. In this case we *must* unwrap a proxy object - the dynamic_cast will // ObjC only. In this case we *must* unwrap a proxy object - the dynamic_cast will
// throw bad_cast if we gave it something of the wrong type. // throw bad_cast if we gave it something of the wrong type.
val objcExtSelf = objcppMarshal.helperClass("objc_proxy") w.wl(s"return dynamic_cast<ObjcProxy&>(*cpp).Handle::get();")
w.wl(s"return dynamic_cast<$objcExtSelf&>(*cpp).Handle::get();")
} else { } else {
// C++ only, or C++ and ObjC. // C++ only, or C++ and ObjC.
if (i.ext.objc) { if (i.ext.objc) {
// If it could be implemented in ObjC, we might have to unwrap a proxy object. // If it could be implemented in ObjC, we might have to unwrap a proxy object.
val objcExtSelf = objcppMarshal.helperClass("objc_proxy") w.w(s"if (auto cppPtr = dynamic_cast<ObjcProxy*>(cpp.get()))").braced {
w.w(s"if (auto cppPtr = dynamic_cast<$objcExtSelf*>(cpp.get()))").braced {
w.wl("return cppPtr->Handle::get();") w.wl("return cppPtr->Handle::get();")
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment