Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
djinni
Commits
d050d331
Commit
d050d331
authored
May 12, 2015
by
Miro Knejp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command line options to control Objective-C and Objective-C++ generation separately
parent
04da0e9a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
41 deletions
+47
-41
src/source/Main.scala
src/source/Main.scala
+24
-20
src/source/ObjcppGenerator.scala
src/source/ObjcppGenerator.scala
+14
-15
src/source/generator.scala
src/source/generator.scala
+9
-6
No files found.
src/source/Main.scala
View file @
d050d331
...
...
@@ -51,14 +51,15 @@ object Main {
var
cppIdentStyle
=
IdentStyle
.
cppDefault
var
cppTypeEnumIdentStyle
:
IdentConverter
=
null
var
objcOutFolder
:
Option
[
File
]
=
None
var
objc
PrivateOutFolderOptional
:
Option
[
File
]
=
None
var
objcExt
:
String
=
"mm"
var
objc
ppOutFolder
:
Option
[
File
]
=
None
var
objc
pp
Ext
:
String
=
"mm"
var
objcHeaderExt
:
String
=
"h"
var
objcIdentStyle
=
IdentStyle
.
objcDefault
var
objcTypePrefix
:
String
=
""
var
objcIncludePrefix
:
String
=
""
var
objcIncludePrivatePrefixOptional
:
Option
[
String
]
=
None
var
objcIncludeCppPrefix
:
String
=
""
var
objcppIncludePrefix
:
String
=
""
var
objcppIncludeCppPrefix
:
String
=
""
var
objcppIncludeObjcPrefixOptional
:
Option
[
String
]
=
None
var
objcFileIdentStyleOptional
:
Option
[
IdentConverter
]
=
None
var
objcppNamespace
:
String
=
"djinni_generated"
var
objcBaseLibIncludePrefix
:
String
=
""
...
...
@@ -122,22 +123,25 @@ object Main {
note
(
""
)
opt
[
File
](
"objc-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
objcOutFolder
=
Some
(
x
))
.
text
(
"The output folder for Objective-C files (Generator disabled if unspecified)."
)
opt
[
File
](
"objc-private-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
objcPrivateOutFolderOptional
=
Some
(
x
))
.
text
(
"The output folder for private Objective-C header and implementation files (default: the same as --objc-out)"
)
opt
[
String
](
"objc-ext"
).
valueName
(
"<ext>"
).
foreach
(
objcExt
=
_
)
.
text
(
"The filename extension for Objective-C files (default: \"mm\")"
)
opt
[
String
](
"objc-h-ext"
).
valueName
(
"<ext>"
).
foreach
(
objcHeaderExt
=
_
)
.
text
(
"The filename extension for Objective-C header files (default: \"h\")"
)
.
text
(
"The filename extension for Objective-C
[++]
header files (default: \"h\")"
)
opt
[
String
](
"objc-type-prefix"
).
valueName
(
"<pre>"
).
foreach
(
objcTypePrefix
=
_
)
.
text
(
"The prefix for Objective-C data types (usually two or three letters)"
)
opt
[
String
](
"objc-include-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
objcIncludePrefix
=
_
)
.
text
(
"The prefix for #import of header files from Objective-C files."
)
opt
[
String
](
"objc-include-private-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
x
=>
objcIncludePrivatePrefixOptional
=
Some
(
x
))
.
text
(
"The prefix for #import and #include of private header files from Objective-C files (default: the same as --objc-include-prefix)"
)
opt
[
String
](
"objc-include-cpp-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
objcIncludeCppPrefix
=
_
)
.
text
(
"The prefix for #include of the main header files from Objective-C files."
)
note
(
""
)
opt
[
File
](
"objcpp-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
objcppOutFolder
=
Some
(
x
))
.
text
(
"The output folder for private Objective-C++ files (Generator disabled if unspecified)."
)
opt
[
String
](
"objcpp-ext"
).
valueName
(
"<ext>"
).
foreach
(
objcppExt
=
_
)
.
text
(
"The filename extension for Objective-C++ files (default: \"mm\")"
)
opt
[
String
](
"objcpp-include-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
objcppIncludePrefix
=
_
)
.
text
(
"The prefix for #import of Objective-C++ header files from Objective-C++ files."
)
opt
[
String
](
"objcpp-include-cpp-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
objcppIncludeCppPrefix
=
_
)
.
text
(
"The prefix for #include of the main C++ header files from Objective-C++ files."
)
opt
[
String
](
"objcpp-include-objc-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
x
=>
objcppIncludeObjcPrefixOptional
=
Some
(
x
))
.
text
(
"The prefix for #import of the Objective-C header files from Objective-C++ files (default: the same as --objcpp-include-prefix)"
)
opt
[
String
](
"objcpp-namespace"
).
valueName
(
"<prefix>"
).
foreach
(
objcppNamespace
=
_
)
.
text
(
"
Namespace for C++ objects defined in Objective-C++, such as wrapper caches
"
)
.
text
(
"
The namespace name to use for generated Objective-C++ classes.
"
)
opt
[
String
](
"objc-base-lib-include-prefix"
).
valueName
(
"..."
).
foreach
(
x
=>
objcBaseLibIncludePrefix
=
x
)
.
text
(
"The Objective-C++ base library's include path, relative to the Objective-C++ classes."
)
...
...
@@ -174,8 +178,7 @@ object Main {
val
jniBaseLibClassIdentStyle
=
jniBaseLibClassIdentStyleOptional
.
getOrElse
(
jniClassIdentStyle
)
val
jniFileIdentStyle
=
jniFileIdentStyleOptional
.
getOrElse
(
cppFileIdentStyle
)
var
objcFileIdentStyle
=
objcFileIdentStyleOptional
.
getOrElse
(
objcIdentStyle
.
ty
)
val
objcPrivateOutFolder
=
if
(
objcPrivateOutFolderOptional
.
isDefined
)
objcPrivateOutFolderOptional
else
objcOutFolder
var
objcIncludePrivatePrefix
=
objcIncludePrivatePrefixOptional
.
getOrElse
(
objcIncludePrefix
)
val
objcppIncludeObjcPrefix
=
objcppIncludeObjcPrefixOptional
.
getOrElse
(
objcppIncludePrefix
)
// Add ObjC prefix to identstyle
objcIdentStyle
=
objcIdentStyle
.
copy
(
ty
=
IdentStyle
.
prefix
(
objcTypePrefix
,
objcIdentStyle
.
ty
))
...
...
@@ -231,14 +234,15 @@ object Main {
cppExt
,
cppHeaderExt
,
objcOutFolder
,
objc
Private
OutFolder
,
objc
pp
OutFolder
,
objcIdentStyle
,
objcFileIdentStyle
,
objcExt
,
objc
pp
Ext
,
objcHeaderExt
,
objcIncludePrefix
,
objcIncludePrivatePrefix
,
objcIncludeCppPrefix
,
objcppIncludePrefix
,
objcppIncludeCppPrefix
,
objcppIncludeObjcPrefix
,
objcppNamespace
,
objcBaseLibIncludePrefix
)
...
...
src/source/ObjcppGenerator.scala
View file @
d050d331
...
...
@@ -52,17 +52,17 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
val
ext
=
d
.
body
.
asInstanceOf
[
Interface
].
ext
if
(
ext
.
cpp
)
{
header
.
add
(
"@class "
+
objcMarshal
.
typename
(
tm
)
+
";"
)
body
.
add
(
"#import "
+
q
(
spec
.
objc
IncludePrivat
ePrefix
+
privateHeaderName
(
d
.
name
)))
body
.
add
(
"#import "
+
q
(
spec
.
objc
ppInclud
ePrefix
+
privateHeaderName
(
d
.
name
)))
}
if
(
ext
.
objc
)
{
header
.
add
(
"@protocol "
+
objcMarshal
.
typename
(
tm
)
+
";"
)
body
.
add
(
"#import "
+
q
(
spec
.
objc
IncludePrivat
ePrefix
+
privateHeaderName
(
d
.
name
)))
body
.
add
(
"#import "
+
q
(
spec
.
objc
ppInclud
ePrefix
+
privateHeaderName
(
d
.
name
)))
}
case
DRecord
=>
val
r
=
d
.
body
.
asInstanceOf
[
Record
]
val
prefix
=
if
(
r
.
ext
.
objc
)
"../"
else
""
val
objcName
=
d
.
name
+
(
if
(
r
.
ext
.
objc
)
"_base"
else
""
)
header
.
add
(
"@class "
+
objcMarshal
.
typename
(
tm
)
+
";"
)
body
.
add
(
"#import "
+
q
(
spec
.
objc
IncludePrivatePrefix
+
prefix
+
privateHeaderName
(
d
.
n
ame
)))
body
.
add
(
"#import "
+
q
(
spec
.
objc
ppIncludePrefix
+
privateHeaderName
(
objcN
ame
)))
}
case
p
:
MParam
=>
}
...
...
@@ -77,8 +77,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
def
headerName
(
ident
:
String
)
:
String
=
idObjc
.
ty
(
ident
)
+
"."
+
spec
.
objcHeaderExt
def
privateHeaderName
(
ident
:
String
)
:
String
=
idObjc
.
ty
(
ident
)
+
"+Private."
+
spec
.
objcHeaderExt
def
bodyName
(
ident
:
String
)
:
String
=
idObjc
.
ty
(
ident
)
+
"."
+
spec
.
objcExt
def
privateBodyName
(
ident
:
String
)
:
String
=
idObjc
.
ty
(
ident
)
+
"+Private."
+
spec
.
objcExt
def
bodyName
(
ident
:
String
)
:
String
=
idObjc
.
ty
(
ident
)
+
"+Private."
+
spec
.
objcppExt
override
def
generateInterface
(
origin
:
String
,
ident
:
Ident
,
doc
:
Doc
,
typeParams
:
Seq
[
TypeParam
],
i
:
Interface
)
{
val
refs
=
new
ObjcRefs
()
...
...
@@ -94,9 +93,9 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
val
cppSelf
=
cppMarshal
.
fqTypename
(
ident
,
i
)
refs
.
privHeader
.
add
(
"#include <memory>"
)
refs
.
privHeader
.
add
(
"!#include "
+
q
(
spec
.
objcIncludeCppPrefix
+
spec
.
cppFileIdentStyle
(
ident
)
+
"."
+
spec
.
cppHeaderExt
))
refs
.
privHeader
.
add
(
"!#include "
+
q
(
spec
.
objc
pp
IncludeCppPrefix
+
spec
.
cppFileIdentStyle
(
ident
)
+
"."
+
spec
.
cppHeaderExt
))
refs
.
body
.
add
(
"#include <vector>"
)
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
Include
Prefix
+
headerName
(
ident
)))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
ppIncludeObjc
Prefix
+
headerName
(
ident
)))
def
writeObjcFuncDecl
(
method
:
Interface.Method
,
w
:
IndentWriter
)
{
val
label
=
if
(
method
.
static
)
"+"
else
"-"
...
...
@@ -131,7 +130,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
})
if
(
i
.
ext
.
cpp
)
{
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
IncludePrivat
ePrefix
+
privateHeaderName
(
ident
.
name
)))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
ppInclud
ePrefix
+
privateHeaderName
(
ident
.
name
)))
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objcBaseLibIncludePrefix
+
"DJICppWrapperCache+Private.h"
))
refs
.
body
.
add
(
"#include <utility>"
)
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objcBaseLibIncludePrefix
+
"DJIError.h"
))
...
...
@@ -193,7 +192,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
if
(
i
.
ext
.
objc
)
{
val
objcExtSelf
=
objcppMarshal
.
helperClass
(
"objc_proxy"
)
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objcBaseLibIncludePrefix
+
"DJIObjcWrapperCache+Private.h"
))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
IncludePrivat
ePrefix
+
privateHeaderName
(
ident
.
name
)))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
ppInclud
ePrefix
+
privateHeaderName
(
ident
.
name
)))
writeObjcFile
(
bodyName
(
ident
.
name
),
origin
,
refs
.
body
,
w
=>
{
arcAssert
(
w
)
...
...
@@ -250,17 +249,17 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
refs
.
header
.
add
(
"#import <Foundation/Foundation.h>"
)
refs
.
privHeader
.
add
(
"!#import "
+
q
(
spec
.
objcIncludePrefix
+
headerName
(
objcName
)))
refs
.
privHeader
.
add
(
"!#include "
+
q
(
spec
.
objcIncludeCppPrefix
+
spec
.
cppFileIdentStyle
(
ident
)
+
"."
+
spec
.
cppHeaderExt
))
refs
.
privHeader
.
add
(
"!#include "
+
q
(
spec
.
objc
pp
IncludeCppPrefix
+
spec
.
cppFileIdentStyle
(
ident
)
+
"."
+
spec
.
cppHeaderExt
))
refs
.
body
.
add
(
"#import <Foundation/Foundation.h>"
)
refs
.
body
.
add
(
"#include <cassert>"
)
refs
.
body
.
add
(
"#include <utility>"
)
refs
.
body
.
add
(
"#include <vector>"
)
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objcBaseLibIncludePrefix
+
"DJIDate.h"
))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
IncludePrivat
ePrefix
+
privateHeaderName
(
objcName
)))
refs
.
body
.
add
(
"!#import "
+
q
(
spec
.
objc
ppInclud
ePrefix
+
privateHeaderName
(
objcName
)))
if
(
r
.
ext
.
objc
)
{
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objc
Include
Prefix
+
"../"
+
headerName
(
ident
)))
refs
.
body
.
add
(
"#import "
+
q
(
spec
.
objc
ppIncludeObjc
Prefix
+
"../"
+
headerName
(
ident
)))
refs
.
header
.
add
(
s
"@class ${objcMarshal.typename(ident, r)};"
)
}
...
...
@@ -292,7 +291,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
})
})
writeObjcFile
(
privateB
odyName
(
objcName
),
origin
,
refs
.
body
,
w
=>
{
writeObjcFile
(
b
odyName
(
objcName
),
origin
,
refs
.
body
,
w
=>
{
wrapNamespace
(
w
,
spec
.
objcppNamespace
,
w
=>
{
w
.
wl
(
s
"auto $helperClass::toCpp(ObjcType obj) -> CppType"
)
w
.
braced
{
...
...
@@ -316,7 +315,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
}
def
writeObjcFile
(
fileName
:
String
,
origin
:
String
,
refs
:
Iterable
[
String
],
f
:
IndentWriter
=>
Unit
)
{
createFile
(
spec
.
objc
Private
OutFolder
.
get
,
fileName
,
(
w
:
IndentWriter
)
=>
{
createFile
(
spec
.
objc
pp
OutFolder
.
get
,
fileName
,
(
w
:
IndentWriter
)
=>
{
w
.
wl
(
"// AUTOGENERATED FILE - DO NOT MODIFY!"
)
w
.
wl
(
"// This file generated by Djinni from "
+
origin
)
w
.
wl
...
...
src/source/generator.scala
View file @
d050d331
...
...
@@ -53,14 +53,15 @@ package object generatorTools {
cppExt
:
String
,
cppHeaderExt
:
String
,
objcOutFolder
:
Option
[
File
],
objc
Private
OutFolder
:
Option
[
File
],
objc
pp
OutFolder
:
Option
[
File
],
objcIdentStyle
:
ObjcIdentStyle
,
objcFileIdentStyle
:
IdentConverter
,
objcExt
:
String
,
objc
pp
Ext
:
String
,
objcHeaderExt
:
String
,
objcIncludePrefix
:
String
,
objcIncludePrivatePrefix
:
String
,
objcIncludeCppPrefix
:
String
,
objcppIncludePrefix
:
String
,
objcppIncludeCppPrefix
:
String
,
objcppIncludeObjcPrefix
:
String
,
objcppNamespace
:
String
,
objcBaseLibIncludePrefix
:
String
)
...
...
@@ -166,9 +167,11 @@ package object generatorTools {
new
JNIGenerator
(
spec
).
generate
(
idl
)
}
if
(
spec
.
objcOutFolder
.
isDefined
)
{
createFolder
(
"Objective-C[++]"
,
spec
.
objcOutFolder
.
get
)
createFolder
(
"Objective-C[++] private"
,
spec
.
objcPrivateOutFolder
.
get
)
createFolder
(
"Objective-C"
,
spec
.
objcOutFolder
.
get
)
new
ObjcGenerator
(
spec
).
generate
(
idl
)
}
if
(
spec
.
objcppOutFolder
.
isDefined
)
{
createFolder
(
"Objective-C++"
,
spec
.
objcppOutFolder
.
get
)
new
ObjcppGenerator
(
spec
).
generate
(
idl
)
}
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment