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
ad018408
Commit
ad018408
authored
Mar 05, 2015
by
Miro Knejp
Committed by
Jacob Potter
Apr 29, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce marshalling object for Objective-C++ code generator
parent
d0d4cc93
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
31 deletions
+94
-31
src/source/ObjcppGenerator.scala
src/source/ObjcppGenerator.scala
+33
-29
src/source/ObjcppMarshal.scala
src/source/ObjcppMarshal.scala
+59
-0
src/source/generator.scala
src/source/generator.scala
+2
-2
No files found.
src/source/ObjcppGenerator.scala
View file @
ad018408
This diff is collapsed.
Click to expand it.
src/source/ObjcppMarshal.scala
0 → 100644
View file @
ad018408
package
djinni
import
djinni.ast._
import
djinni.generatorTools._
import
djinni.meta._
class
ObjcppMarshal
(
spec
:
Spec
)
extends
Marshal
(
spec
)
{
override
def
typename
(
tm
:
MExpr
)
:
String
=
throw
new
AssertionError
(
"Objcpp has no public types"
)
def
typename
(
name
:
String
,
ty
:
TypeDef
)
:
String
=
throw
new
AssertionError
(
"Objcpp has no public types"
)
override
def
fqTypename
(
tm
:
MExpr
)
:
String
=
throw
new
AssertionError
(
"Objcpp has no public types"
)
def
fqTypename
(
name
:
String
,
ty
:
TypeDef
)
:
String
=
throw
new
AssertionError
(
"Objcpp has no public types"
)
// Name for the autogenerated proxy class wrapping +o interfaces
def
helperClass
(
name
:
String
)
=
idCpp
.
ty
(
name
)
def
fqHelperClass
(
name
:
String
)
=
withNs
(
Some
(
spec
.
objcppNamespace
),
helperClass
(
name
))
// Return value: (Type_Name, Is_Class_Or_Not)
def
toObjcType
(
ty
:
TypeRef
)
:
(
String
,
Boolean
)
=
toObjcType
(
ty
.
resolved
,
false
)
def
toObjcType
(
ty
:
TypeRef
,
needRef
:
Boolean
)
:
(
String
,
Boolean
)
=
toObjcType
(
ty
.
resolved
,
needRef
)
def
toObjcType
(
tm
:
MExpr
)
:
(
String
,
Boolean
)
=
toObjcType
(
tm
,
false
)
def
toObjcType
(
tm
:
MExpr
,
needRef
:
Boolean
)
:
(
String
,
Boolean
)
=
{
def
f
(
tm
:
MExpr
,
needRef
:
Boolean
)
:
(
String
,
Boolean
)
=
{
tm
.
base
match
{
case
MOptional
=>
// We use "nil" for the empty optional.
assert
(
tm
.
args
.
size
==
1
)
val
arg
=
tm
.
args
.
head
arg
.
base
match
{
case
MOptional
=>
throw
new
AssertionError
(
"nested optional?"
)
case
m
=>
f
(
arg
,
true
)
}
case
o
=>
val
base
=
o
match
{
case
p
:
MPrimitive
=>
if
(
needRef
)
(
p
.
objcBoxed
,
true
)
else
(
p
.
objcName
,
false
)
case
MString
=>
(
"NSString"
,
true
)
case
MDate
=>
(
"NSDate"
,
true
)
case
MBinary
=>
(
"NSData"
,
true
)
case
MOptional
=>
throw
new
AssertionError
(
"optional should have been special cased"
)
case
MList
=>
(
"NSArray"
,
true
)
case
MSet
=>
(
"NSSet"
,
true
)
case
MMap
=>
(
"NSDictionary"
,
true
)
case
d
:
MDef
=>
d
.
defType
match
{
case
DEnum
=>
if
(
needRef
)
(
"NSNumber"
,
true
)
else
(
idObjc
.
ty
(
d
.
name
),
false
)
case
DRecord
=>
(
idObjc
.
ty
(
d
.
name
),
true
)
case
DInterface
=>
val
ext
=
d
.
body
.
asInstanceOf
[
Interface
].
ext
(
idObjc
.
ty
(
d
.
name
),
false
)
}
case
p
:
MParam
=>
throw
new
AssertionError
(
"Parameter should not happen at Obj-C top level"
)
}
base
}
}
f
(
tm
,
needRef
)
}
}
src/source/generator.scala
View file @
ad018408
...
...
@@ -281,8 +281,8 @@ abstract class Generator(spec: Spec)
// --------------------------------------------------------------------------
// Render type expression
def
toCppType
(
ty
:
TypeRef
,
namespace
:
Option
[
String
]
=
None
)
:
String
=
toCppType
(
ty
.
resolved
,
namespace
)
def
toCppType
(
tm
:
MExpr
,
namespace
:
Option
[
String
])
:
String
=
{
private
def
toCppType
(
ty
:
TypeRef
,
namespace
:
Option
[
String
]
=
None
)
:
String
=
toCppType
(
ty
.
resolved
,
namespace
)
private
def
toCppType
(
tm
:
MExpr
,
namespace
:
Option
[
String
])
:
String
=
{
def
base
(
m
:
Meta
)
:
String
=
m
match
{
case
p
:
MPrimitive
=>
p
.
cName
case
MString
=>
"std::string"
...
...
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