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
da4ef208
Commit
da4ef208
authored
Sep 15, 2014
by
Jacob Potter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forward-declare interface crossreferences. Fixes #4
parent
127fa967
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
16 deletions
+33
-16
example/generated-src/cpp/sort_items.hpp
example/generated-src/cpp/sort_items.hpp
+2
-1
example/handwritten-src/cpp/sort_items_impl.hpp
example/handwritten-src/cpp/sort_items_impl.hpp
+1
-0
src/source/CppGenerator.scala
src/source/CppGenerator.scala
+12
-8
src/source/JNIGenerator.scala
src/source/JNIGenerator.scala
+3
-3
src/source/generator.scala
src/source/generator.scala
+11
-3
test-suite/generated-src/cpp/test_helpers.hpp
test-suite/generated-src/cpp/test_helpers.hpp
+2
-1
test-suite/handwritten-src/cpp/test_helpers.cpp
test-suite/handwritten-src/cpp/test_helpers.cpp
+2
-0
No files found.
example/generated-src/cpp/sort_items.hpp
View file @
da4ef208
...
@@ -4,11 +4,12 @@
...
@@ -4,11 +4,12 @@
#pragma once
#pragma once
#include "item_list.hpp"
#include "item_list.hpp"
#include "textbox_listener.hpp"
#include <memory>
#include <memory>
namespace
textsort
{
namespace
textsort
{
class
TextboxListener
;
class
SortItems
{
class
SortItems
{
public:
public:
virtual
~
SortItems
()
{}
virtual
~
SortItems
()
{}
...
...
example/handwritten-src/cpp/sort_items_impl.hpp
View file @
da4ef208
#pragma once
#pragma once
#include "sort_items.hpp"
#include "sort_items.hpp"
#include "textbox_listener.hpp"
namespace
textsort
{
namespace
textsort
{
...
...
src/source/CppGenerator.scala
View file @
da4ef208
...
@@ -31,6 +31,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
...
@@ -31,6 +31,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
class
CppRefs
(
name
:
String
)
{
class
CppRefs
(
name
:
String
)
{
var
hpp
=
mutable
.
TreeSet
[
String
]()
var
hpp
=
mutable
.
TreeSet
[
String
]()
var
hppFwds
=
mutable
.
TreeSet
[
String
]()
var
cpp
=
mutable
.
TreeSet
[
String
]()
var
cpp
=
mutable
.
TreeSet
[
String
]()
def
find
(
ty
:
TypeRef
)
{
find
(
ty
.
resolved
)
}
def
find
(
ty
:
TypeRef
)
{
find
(
ty
.
resolved
)
}
...
@@ -61,14 +62,17 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
...
@@ -61,14 +62,17 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
hpp
.
add
(
"#include <unordered_map>"
)
hpp
.
add
(
"#include <unordered_map>"
)
}
}
case
d
:
MDef
=>
case
d
:
MDef
=>
if
(
d
.
name
!=
name
)
{
hpp
.
add
(
"#include "
+
q
(
spec
.
cppIncludePrefix
+
spec
.
cppFileIdentStyle
(
d
.
name
)
+
"."
+
spec
.
cppHeaderExt
))
}
d
.
defType
match
{
d
.
defType
match
{
case
DEnum
=>
case
DEnum
case
DRecord
=>
|
DRecord
=>
if
(
d
.
name
!=
name
)
{
hpp
.
add
(
"#include "
+
q
(
spec
.
cppIncludePrefix
+
spec
.
cppFileIdentStyle
(
d
.
name
)
+
"."
+
spec
.
cppHeaderExt
))
}
case
DInterface
=>
case
DInterface
=>
hpp
.
add
(
"#include <memory>"
)
hpp
.
add
(
"#include <memory>"
)
if
(
d
.
name
!=
name
)
{
hppFwds
.
add
(
s
"class ${idCpp.ty(d.name)};"
)
}
}
}
case
p
:
MParam
=>
case
p
:
MParam
=>
}
}
...
@@ -79,7 +83,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
...
@@ -79,7 +83,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
val
refs
=
new
CppRefs
(
ident
.
name
)
val
refs
=
new
CppRefs
(
ident
.
name
)
val
self
=
idCpp
.
enumType
(
ident
)
val
self
=
idCpp
.
enumType
(
ident
)
writeHppFile
(
ident
,
origin
,
refs
.
hpp
,
w
=>
{
writeHppFile
(
ident
,
origin
,
refs
.
hpp
,
refs
.
hppFwds
,
w
=>
{
w
.
w
(
s
"enum class $self : int"
).
bracedSemi
{
w
.
w
(
s
"enum class $self : int"
).
bracedSemi
{
for
(
o
<-
e
.
options
)
{
for
(
o
<-
e
.
options
)
{
writeDoc
(
w
,
o
.
doc
)
writeDoc
(
w
,
o
.
doc
)
...
@@ -206,7 +210,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
...
@@ -206,7 +210,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
}
}
}
}
writeHppFile
(
cppName
,
origin
,
refs
.
hpp
,
writeCppPrototype
)
writeHppFile
(
cppName
,
origin
,
refs
.
hpp
,
refs
.
hppFwds
,
writeCppPrototype
)
if
(
r
.
consts
.
nonEmpty
||
r
.
derivingTypes
.
nonEmpty
)
{
if
(
r
.
consts
.
nonEmpty
||
r
.
derivingTypes
.
nonEmpty
)
{
writeCppFile
(
cppName
,
origin
,
refs
.
cpp
,
w
=>
{
writeCppFile
(
cppName
,
origin
,
refs
.
cpp
,
w
=>
{
...
@@ -274,7 +278,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
...
@@ -274,7 +278,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
val
self
=
idCpp
.
ty
(
ident
)
val
self
=
idCpp
.
ty
(
ident
)
writeHppFile
(
ident
,
origin
,
refs
.
hpp
,
w
=>
{
writeHppFile
(
ident
,
origin
,
refs
.
hpp
,
refs
.
hppFwds
,
w
=>
{
writeDoc
(
w
,
doc
)
writeDoc
(
w
,
doc
)
writeCppTypeParams
(
w
,
typeParams
)
writeCppTypeParams
(
w
,
typeParams
)
w
.
w
(
s
"class $self"
).
bracedSemi
{
w
.
w
(
s
"class $self"
).
bracedSemi
{
...
...
src/source/JNIGenerator.scala
View file @
da4ef208
...
@@ -58,7 +58,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
...
@@ -58,7 +58,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
val
selfQ
=
withNs
(
spec
.
cppNamespace
,
self
)
val
selfQ
=
withNs
(
spec
.
cppNamespace
,
self
)
val
jniClassName
=
spec
.
jniClassIdentStyle
(
ident
)
val
jniClassName
=
spec
.
jniClassIdentStyle
(
ident
)
writeJniHppFile
(
ident
,
origin
,
Iterable
.
concat
(
refs
.
jniHpp
,
refs
.
jniCpp
),
w
=>
{
writeJniHppFile
(
ident
,
origin
,
Iterable
.
concat
(
refs
.
jniHpp
,
refs
.
jniCpp
),
Nil
,
w
=>
{
w
.
w
(
s
"class $jniClassName final : djinni::JniEnum"
).
bracedSemi
{
w
.
w
(
s
"class $jniClassName final : djinni::JniEnum"
).
bracedSemi
{
w
.
wlOutdent
(
"public:"
)
w
.
wlOutdent
(
"public:"
)
w
.
wl
(
s
"using CppType = $selfQ;"
)
w
.
wl
(
s
"using CppType = $selfQ;"
)
...
@@ -349,7 +349,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
...
@@ -349,7 +349,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
def
writeJniFiles
(
origin
:
String
,
allInHeader
:
Boolean
,
ident
:
Ident
,
refs
:
JNIRefs
,
writeProto
:
IndentWriter
=>
Unit
,
writeBody
:
IndentWriter
=>
Unit
)
{
def
writeJniFiles
(
origin
:
String
,
allInHeader
:
Boolean
,
ident
:
Ident
,
refs
:
JNIRefs
,
writeProto
:
IndentWriter
=>
Unit
,
writeBody
:
IndentWriter
=>
Unit
)
{
if
(
allInHeader
)
{
if
(
allInHeader
)
{
// Template class. Write both parts to .hpp.
// Template class. Write both parts to .hpp.
writeJniHppFile
(
ident
,
origin
,
Iterable
.
concat
(
refs
.
jniHpp
,
refs
.
jniCpp
),
w
=>
{
writeJniHppFile
(
ident
,
origin
,
Iterable
.
concat
(
refs
.
jniHpp
,
refs
.
jniCpp
),
Nil
,
w
=>
{
writeProto
(
w
)
writeProto
(
w
)
w
.
wl
w
.
wl
writeBody
(
w
)
writeBody
(
w
)
...
@@ -357,7 +357,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
...
@@ -357,7 +357,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
}
}
else
{
else
{
// Write prototype to .hpp and body to .cpp
// Write prototype to .hpp and body to .cpp
writeJniHppFile
(
ident
,
origin
,
refs
.
jniHpp
,
writeProto
)
writeJniHppFile
(
ident
,
origin
,
refs
.
jniHpp
,
Nil
,
writeProto
)
writeJniCppFile
(
ident
,
origin
,
refs
.
jniCpp
,
writeBody
)
writeJniCppFile
(
ident
,
origin
,
refs
.
jniCpp
,
writeBody
)
}
}
}
}
...
...
src/source/generator.scala
View file @
da4ef208
...
@@ -219,7 +219,7 @@ abstract class Generator(spec: Spec)
...
@@ -219,7 +219,7 @@ abstract class Generator(spec: Spec)
}
}
}
}
def
writeHppFileGeneric
(
folder
:
File
,
namespace
:
Option
[
String
],
fileIdentStyle
:
IdentConverter
)(
name
:
String
,
origin
:
String
,
includes
:
Iterable
[
String
],
f
:
IndentWriter
=>
Unit
)
{
def
writeHppFileGeneric
(
folder
:
File
,
namespace
:
Option
[
String
],
fileIdentStyle
:
IdentConverter
)(
name
:
String
,
origin
:
String
,
includes
:
Iterable
[
String
],
f
wds
:
Iterable
[
String
],
f
:
IndentWriter
=>
Unit
)
{
createFile
(
folder
,
fileIdentStyle
(
name
)
+
"."
+
spec
.
cppHeaderExt
,
(
w
:
IndentWriter
)
=>
{
createFile
(
folder
,
fileIdentStyle
(
name
)
+
"."
+
spec
.
cppHeaderExt
,
(
w
:
IndentWriter
)
=>
{
w
.
wl
(
"// AUTOGENERATED FILE - DO NOT MODIFY!"
)
w
.
wl
(
"// AUTOGENERATED FILE - DO NOT MODIFY!"
)
w
.
wl
(
"// This file generated by Djinni from "
+
origin
)
w
.
wl
(
"// This file generated by Djinni from "
+
origin
)
...
@@ -227,10 +227,18 @@ abstract class Generator(spec: Spec)
...
@@ -227,10 +227,18 @@ abstract class Generator(spec: Spec)
w
.
wl
(
"#pragma once"
)
w
.
wl
(
"#pragma once"
)
if
(
includes
.
nonEmpty
)
{
if
(
includes
.
nonEmpty
)
{
w
.
wl
w
.
wl
includes
.
foreach
(
w
.
wl
(
_
)
)
includes
.
foreach
(
w
.
wl
)
}
}
w
.
wl
w
.
wl
wrapNamespace
(
w
,
namespace
,
f
)
wrapNamespace
(
w
,
namespace
,
(
w
:
IndentWriter
)
=>
{
if
(
fwds
.
nonEmpty
)
{
fwds
.
foreach
(
w
.
wl
)
w
.
wl
}
f
(
w
)
}
)
})
})
}
}
...
...
test-suite/generated-src/cpp/test_helpers.hpp
View file @
da4ef208
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#pragma once
#pragma once
#include "client_interface.hpp"
#include "map_list_record.hpp"
#include "map_list_record.hpp"
#include "nested_collection.hpp"
#include "nested_collection.hpp"
#include "primitive_list.hpp"
#include "primitive_list.hpp"
...
@@ -14,6 +13,8 @@
...
@@ -14,6 +13,8 @@
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
class
ClientInterface
;
class
TestHelpers
{
class
TestHelpers
{
public:
public:
virtual
~
TestHelpers
()
{}
virtual
~
TestHelpers
()
{}
...
...
test-suite/handwritten-src/cpp/test_helpers.cpp
View file @
da4ef208
#include "test_helpers.hpp"
#include "test_helpers.hpp"
#include "client_returned_record.hpp"
#include "client_interface.hpp"
#include <exception>
#include <exception>
SetRecord
TestHelpers
::
get_set_record
()
{
SetRecord
TestHelpers
::
get_set_record
()
{
...
...
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