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)
{ {
@autoreleasepool {
TXSItemList *cpp_items = [[TXSItemList alloc] initWithCppItemList:items]; TXSItemList *cpp_items = [[TXSItemList alloc] initWithCppItemList:items];
[objcRef update:cpp_items]; [objcRef update:cpp_items];
} }
}
} }
...@@ -351,6 +351,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -351,6 +351,7 @@ 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 {
w.w("@autoreleasepool").braced {
m.params.foreach(p => m.params.foreach(p =>
translateCppTypeToObjc(idCpp.local("cpp_" + p.ident.name), idCpp.local(p.ident), p.ty, true, w)) translateCppTypeToObjc(idCpp.local("cpp_" + p.ident.name), idCpp.local(p.ident), p.ty, true, w))
m.ret.fold()(r => w.w(toObjcTypeDef(r) + "objcRet = ")) m.ret.fold()(r => w.w(toObjcTypeDef(r) + "objcRet = "))
...@@ -368,6 +369,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -368,6 +369,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
} }
} }
} }
}
}) })
} }
} }
......
...@@ -27,6 +27,7 @@ namespace djinni_generated ...@@ -27,6 +27,7 @@ namespace djinni_generated
ClientReturnedRecord ClientInterfaceObjcProxy::get_record (const std::string & utf8string) ClientReturnedRecord ClientInterfaceObjcProxy::get_record (const std::string & utf8string)
{ {
@autoreleasepool {
NSString *cpp_utf8string = [[NSString alloc] initWithBytes:utf8string.data() NSString *cpp_utf8string = [[NSString alloc] initWithBytes:utf8string.data()
length:utf8string.length() length:utf8string.length()
encoding:NSUTF8StringEncoding]; encoding:NSUTF8StringEncoding];
...@@ -34,4 +35,5 @@ namespace djinni_generated ...@@ -34,4 +35,5 @@ namespace djinni_generated
ClientReturnedRecord cppRet = std::move([objcRet cppClientReturnedRecord]); ClientReturnedRecord cppRet = std::move([objcRet cppClientReturnedRecord]);
return cppRet; 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