Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extern type usage with non-nullable ptrs #179

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/source/CppMarshal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* This file has been modified by Snap, Inc.
*/

Expand Down Expand Up @@ -117,7 +117,12 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
case e: MExtern => e.defType match {
// Do not forward declare extern types, they might be in arbitrary namespaces.
// This isn't a problem as extern types cannot cause dependency cycles with types being generated here
case DInterface => List(ImportRef("<memory>"), ImportRef(e.cpp.header))
case DInterface =>
val base = List(ImportRef("<memory>"), ImportRef(e.cpp.header))
spec.cppNnHeader match {
case Some(nnHdr) => ImportRef(nnHdr) :: base
case _ => base
}
case _ => List(ImportRef(resolveExtCppHdr(e.cpp.header)))
}
case p: MProtobuf =>
Expand Down Expand Up @@ -211,13 +216,23 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
case DInterface => s"${nnType}<${withNamespace(idCpp.ty(d.name))}>"
case _ => base(tm.base) + args
}
case e: MExtern =>
e.defType match {
case DInterface => s"${nnType}<${e.cpp.typename}>"
case _ => base(tm.base) + args
}
case MOptional =>
tm.args.head.base match {
case d: MDef =>
d.defType match {
case DInterface => s"std::shared_ptr<${withNamespace(idCpp.ty(d.name))}>"
case _ => base(tm.base) + args
}
case e: MExtern =>
e.defType match {
case DInterface => s"std::shared_ptr<${e.cpp.typename}>"
case _ => base(tm.base) + args
}
case _ => base(tm.base) + args
}
case _ => base(tm.base) + args
Expand Down
Loading