Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

add support of symbols export define in cpp interfaces #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/source/CppGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,17 @@ class CppGenerator(spec: Spec) extends Generator(spec) {

val self = marshal.typename(ident, i)
val methodNamesInScope = i.methods.map(m => idCpp.method(m.ident))
val exportDefine = spec.cppExportDefine.getOrElse("")

spec.cppExportDefineHeader match {
case Some(defineHeader) => refs.hpp.add("#include " + defineHeader)
case _ =>
}

writeHppFile(ident, origin, refs.hpp, refs.hppFwds, w => {
writeDoc(w, doc)
writeCppTypeParams(w, typeParams)
w.w(s"class $self").bracedSemi {
w.w(s"class $exportDefine $self").bracedSemi {
w.wlOutdent("public:")
// Destructor
w.wl(s"virtual ~$self() {}")
Expand Down
8 changes: 8 additions & 0 deletions src/source/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ object Main {
var cppNnType: Option[String] = None
var cppNnCheckExpression: Option[String] = None
var cppUseWideStrings: Boolean = false
var cppExportDefine: Option[String] = None
var cppExportDefineHeader: Option[String] = None
var javaOutFolder: Option[File] = None
var javaPackage: Option[String] = None
var javaClassAccessModifier: JavaAccessModifier.Value = JavaAccessModifier.Public
Expand Down Expand Up @@ -150,6 +152,10 @@ object Main {
.text("The expression to use for building non-nullable pointers")
opt[Boolean]( "cpp-use-wide-strings").valueName("<true/false>").foreach(x => cppUseWideStrings = x)
.text("Use wide strings in C++ code (default: false)")
opt[String]("cpp-export-define").valueName("<header>").foreach(x => cppExportDefine = Some(x))
.text("The export define name for interfaces")
opt[String]("cpp-export-define-header").valueName("<header>").foreach(x => cppExportDefineHeader = Some(x))
.text("The header which defines export define")
note("")
opt[File]("jni-out").valueName("<out-folder>").foreach(x => jniOutFolder = Some(x))
.text("The folder for the JNI C++ output files (Generator disabled if unspecified).")
Expand Down Expand Up @@ -329,6 +335,8 @@ object Main {
cppNnType,
cppNnCheckExpression,
cppUseWideStrings,
cppExportDefine,
cppExportDefineHeader,
jniOutFolder,
jniHeaderOutFolder,
jniIncludePrefix,
Expand Down
2 changes: 2 additions & 0 deletions src/source/generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ package object generatorTools {
cppNnType: Option[String],
cppNnCheckExpression: Option[String],
cppUseWideStrings: Boolean,
cppExportDefine: Option[String],
cppExportDefineHeader: Option[String],
jniOutFolder: Option[File],
jniHeaderOutFolder: Option[File],
jniIncludePrefix: String,
Expand Down