Commit 047a3afe authored by Stephen Poletto's avatar Stephen Poletto Committed by Jacob Potter

Wrap C++ -> ObjC call paths in autoreleasepool

parent cd05b91d
...@@ -27,7 +27,9 @@ namespace djinni_generated ...@@ -27,7 +27,9 @@ namespace djinni_generated
void TextboxListenerObjcProxy::update (const ::textsort::ItemList & items) void TextboxListenerObjcProxy::update (const ::textsort::ItemList & items)
{ {
TXSItemList *cpp_items = [[TXSItemList alloc] initWithCppItemList:items]; @autoreleasepool {
[objcRef update:cpp_items]; TXSItemList *cpp_items = [[TXSItemList alloc] initWithCppItemList:items];
[objcRef update:cpp_items];
}
} }
} }
...@@ -351,20 +351,22 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -351,20 +351,22 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
val ret = m.ret.fold("void")(toCppType(_)) val ret = m.ret.fold("void")(toCppType(_))
val params = m.params.map(p => "const " + toCppType(p.ty, spec.cppNamespace) + " & " + idCpp.local(p.ident)) val params = m.params.map(p => "const " + toCppType(p.ty, spec.cppNamespace) + " & " + idCpp.local(p.ident))
w.wl(s"$ret $objcExtSelf::${idCpp.method(m.ident)} ${params.mkString("(", ", ", ")")}").braced { w.wl(s"$ret $objcExtSelf::${idCpp.method(m.ident)} ${params.mkString("(", ", ", ")")}").braced {
m.params.foreach(p => w.w("@autoreleasepool").braced {
translateCppTypeToObjc(idCpp.local("cpp_" + p.ident.name), idCpp.local(p.ident), p.ty, true, w)) m.params.foreach(p =>
m.ret.fold()(r => w.w(toObjcTypeDef(r) + "objcRet = ")) translateCppTypeToObjc(idCpp.local("cpp_" + p.ident.name), idCpp.local(p.ident), p.ty, true, w))
w.w("[objcRef " + idObjc.method(m.ident)) m.ret.fold()(r => w.w(toObjcTypeDef(r) + "objcRet = "))
val skipFirst = SkipFirst() w.w("[objcRef " + idObjc.method(m.ident))
for (p <- m.params) { val skipFirst = SkipFirst()
skipFirst { w.w(" " + idObjc.local(p.ident)) } for (p <- m.params) {
w.w(":" + idCpp.local("cpp_" + p.ident.name)) skipFirst { w.w(" " + idObjc.local(p.ident)) }
w.w(":" + idCpp.local("cpp_" + p.ident.name))
}
w.wl("];")
m.ret.fold()(r => {
translateObjcTypeToCpp("cppRet", "objcRet", r, w)
w.wl("return cppRet;")
})
} }
w.wl("];")
m.ret.fold()(r => {
translateObjcTypeToCpp("cppRet", "objcRet", r, w)
w.wl("return cppRet;")
})
} }
} }
} }
......
...@@ -27,11 +27,13 @@ namespace djinni_generated ...@@ -27,11 +27,13 @@ namespace djinni_generated
ClientReturnedRecord ClientInterfaceObjcProxy::get_record (const std::string & utf8string) ClientReturnedRecord ClientInterfaceObjcProxy::get_record (const std::string & utf8string)
{ {
NSString *cpp_utf8string = [[NSString alloc] initWithBytes:utf8string.data() @autoreleasepool {
length:utf8string.length() NSString *cpp_utf8string = [[NSString alloc] initWithBytes:utf8string.data()
encoding:NSUTF8StringEncoding]; length:utf8string.length()
DBClientReturnedRecord *objcRet = [objcRef getRecord:cpp_utf8string]; encoding:NSUTF8StringEncoding];
ClientReturnedRecord cppRet = std::move([objcRet cppClientReturnedRecord]); DBClientReturnedRecord *objcRet = [objcRef getRecord:cpp_utf8string];
return cppRet; ClientReturnedRecord cppRet = std::move([objcRet cppClientReturnedRecord]);
return cppRet;
}
} }
} }
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