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
6d79895c
Commit
6d79895c
authored
Mar 27, 2015
by
Miro Knejp
Committed by
Jacob Potter
May 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup record constructor with function call writer
parent
b4f335b9
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
78 additions
and
143 deletions
+78
-143
example/generated-src/cpp/item_list.hpp
example/generated-src/cpp/item_list.hpp
+3
-6
example/generated-src/objc/TXSSortItems.mm
example/generated-src/objc/TXSSortItems.mm
+2
-2
example/generated-src/objc/TXSTextboxListener.mm
example/generated-src/objc/TXSTextboxListener.mm
+1
-1
src/source/CppGenerator.scala
src/source/CppGenerator.scala
+7
-22
test-suite/generated-src/cpp/assorted_integers.hpp
test-suite/generated-src/cpp/assorted_integers.hpp
+17
-27
test-suite/generated-src/cpp/client_returned_record.hpp
test-suite/generated-src/cpp/client_returned_record.hpp
+5
-9
test-suite/generated-src/cpp/constants.hpp
test-suite/generated-src/cpp/constants.hpp
+5
-9
test-suite/generated-src/cpp/date_record.hpp
test-suite/generated-src/cpp/date_record.hpp
+3
-6
test-suite/generated-src/cpp/map_date_record.hpp
test-suite/generated-src/cpp/map_date_record.hpp
+3
-6
test-suite/generated-src/cpp/map_list_record.hpp
test-suite/generated-src/cpp/map_list_record.hpp
+3
-6
test-suite/generated-src/cpp/map_record.hpp
test-suite/generated-src/cpp/map_record.hpp
+3
-6
test-suite/generated-src/cpp/nested_collection.hpp
test-suite/generated-src/cpp/nested_collection.hpp
+3
-6
test-suite/generated-src/cpp/primitive_list.hpp
test-suite/generated-src/cpp/primitive_list.hpp
+3
-6
test-suite/generated-src/cpp/record_with_derivings.hpp
test-suite/generated-src/cpp/record_with_derivings.hpp
+5
-9
test-suite/generated-src/cpp/record_with_nested_derivings.hpp
...-suite/generated-src/cpp/record_with_nested_derivings.hpp
+5
-9
test-suite/generated-src/cpp/set_record.hpp
test-suite/generated-src/cpp/set_record.hpp
+3
-6
test-suite/generated-src/objc/DBClientInterface.mm
test-suite/generated-src/objc/DBClientInterface.mm
+1
-1
test-suite/generated-src/objc/DBCppException.mm
test-suite/generated-src/objc/DBCppException.mm
+2
-2
test-suite/generated-src/objc/DBTestHelpers.mm
test-suite/generated-src/objc/DBTestHelpers.mm
+2
-2
test-suite/generated-src/objc/DBToken.mm
test-suite/generated-src/objc/DBToken.mm
+2
-2
No files found.
example/generated-src/cpp/item_list.hpp
View file @
6d79895c
...
...
@@ -10,14 +10,11 @@
namespace
textsort
{
struct
ItemList
final
{
std
::
vector
<
std
::
string
>
items
;
ItemList
(
std
::
vector
<
std
::
string
>
items
)
:
items
(
std
::
move
(
items
))
{
}
ItemList
(
std
::
vector
<
std
::
string
>
items
)
:
items
(
std
::
move
(
items
))
{}
};
}
// namespace textsort
example/generated-src/objc/TXSSortItems.mm
View file @
6d79895c
...
...
@@ -18,7 +18,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
@interface
TXSSortItems
()
@property
(
nonatomic
,
readonly
)
djinni
::
DbxCppWrapperCache
<::
textsort
::
SortItems
>::
Handle
cppRef
;
@property
(
nonatomic
,
readonly
)
::
djinni
::
DbxCppWrapperCache
<::
textsort
::
SortItems
>::
Handle
cppRef
;
-
(
id
)
initWithCpp
:(
const
std
::
shared_ptr
<::
textsort
::
SortItems
>&
)
cppRef
;
...
...
@@ -33,7 +33,7 @@ auto SortItems::toCpp(ObjcType objc) -> CppType
auto
SortItems
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
{
return
!
cpp
?
nil
:
djinni
::
DbxCppWrapperCache
<::
textsort
::
SortItems
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
return
!
cpp
?
nil
:
::
djinni
::
DbxCppWrapperCache
<::
textsort
::
SortItems
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
{
return
[[
TXSSortItems
alloc
]
initWithCpp
:
p
];
});
...
...
example/generated-src/objc/TXSTextboxListener.mm
View file @
6d79895c
...
...
@@ -27,7 +27,7 @@ public:
auto
TextboxListener
::
toCpp
(
ObjcType
objc
)
->
CppType
{
return
objc
?
djinni
:
:
DbxObjcWrapperCache
<
ObjcProxy
>::
getInstance
()
->
get
(
objc
)
:
nullptr
;
return
objc
?
:
:
djinni
::
DbxObjcWrapperCache
<
ObjcProxy
>::
getInstance
()
->
get
(
objc
)
:
nullptr
;
}
auto
TextboxListener
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
...
...
src/source/CppGenerator.scala
View file @
6d79895c
...
...
@@ -186,7 +186,6 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
generateHppConstants
(
w
,
r
.
consts
)
// Field definitions.
for
(
f
<-
r
.
fields
)
{
w
.
wl
writeDoc
(
w
,
f
.
doc
)
w
.
wl
(
marshal
.
fieldType
(
f
.
ty
)
+
" "
+
idCpp
.
field
(
f
.
ident
)
+
";"
)
}
...
...
@@ -206,27 +205,13 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
}
// Constructor.
w
.
wl
if
(
r
.
fields
.
nonEmpty
)
{
w
.
wl
(
actualSelf
+
"("
).
nestedN
(
2
)
{
val
skipFirst
=
SkipFirst
()
for
(
f
<-
r
.
fields
)
{
skipFirst
{
w
.
wl
(
","
)
}
w
.
w
(
marshal
.
fieldType
(
f
.
ty
)
+
" "
+
idCpp
.
local
(
f
.
ident
))
}
w
.
wl
(
") :"
)
w
.
nested
{
val
skipFirst
=
SkipFirst
()
for
(
f
<-
r
.
fields
)
{
skipFirst
{
w
.
wl
(
","
)
}
w
.
w
(
idCpp
.
field
(
f
.
ident
)
+
"(std::move("
+
idCpp
.
local
(
f
.
ident
)
+
"))"
)
}
w
.
wl
(
" {"
)
}
}
w
.
wl
(
"}"
)
}
else
{
w
.
wl
(
actualSelf
+
"() {};"
)
if
(
r
.
fields
.
nonEmpty
)
{
writeAlignedCall
(
w
,
actualSelf
+
"("
,
r
.
fields
,
")"
,
f
=>
marshal
.
fieldType
(
f
.
ty
)
+
" "
+
idCpp
.
local
(
f
.
ident
))
w
.
wl
val
init
=
(
f
:
Field
)
=>
idCpp
.
field
(
f
.
ident
)
+
"(std::move("
+
idCpp
.
local
(
f
.
ident
)
+
"))"
w
.
wl
(
": "
+
init
(
r
.
fields
.
head
))
r
.
fields
.
tail
.
map
(
f
=>
", "
+
init
(
f
)).
foreach
(
w
.
wl
)
w
.
wl
(
"{}"
)
}
if
(
r
.
ext
.
cpp
)
{
...
...
test-suite/generated-src/cpp/assorted_integers.hpp
View file @
6d79895c
...
...
@@ -8,42 +8,32 @@
#include <utility>
struct
AssortedIntegers
final
{
int8_t
eight
;
int16_t
sixteen
;
int32_t
thirtytwo
;
int64_t
sixtyfour
;
std
::
experimental
::
optional
<
int8_t
>
o_eight
;
std
::
experimental
::
optional
<
int16_t
>
o_sixteen
;
std
::
experimental
::
optional
<
int32_t
>
o_thirtytwo
;
std
::
experimental
::
optional
<
int64_t
>
o_sixtyfour
;
bool
operator
==
(
const
AssortedIntegers
&
other
)
const
;
bool
operator
!=
(
const
AssortedIntegers
&
other
)
const
;
AssortedIntegers
(
int8_t
eight
,
int16_t
sixteen
,
int32_t
thirtytwo
,
int64_t
sixtyfour
,
std
::
experimental
::
optional
<
int8_t
>
o_eight
,
std
::
experimental
::
optional
<
int16_t
>
o_sixteen
,
std
::
experimental
::
optional
<
int32_t
>
o_thirtytwo
,
std
::
experimental
::
optional
<
int64_t
>
o_sixtyfour
)
:
eight
(
std
::
move
(
eight
)),
sixteen
(
std
::
move
(
sixteen
)),
thirtytwo
(
std
::
move
(
thirtytwo
)),
sixtyfour
(
std
::
move
(
sixtyfour
)),
o_eight
(
std
::
move
(
o_eight
)),
o_sixteen
(
std
::
move
(
o_sixteen
)),
o_thirtytwo
(
std
::
move
(
o_thirtytwo
)),
o_sixtyfour
(
std
::
move
(
o_sixtyfour
))
{
}
AssortedIntegers
(
int8_t
eight
,
int16_t
sixteen
,
int32_t
thirtytwo
,
int64_t
sixtyfour
,
std
::
experimental
::
optional
<
int8_t
>
o_eight
,
std
::
experimental
::
optional
<
int16_t
>
o_sixteen
,
std
::
experimental
::
optional
<
int32_t
>
o_thirtytwo
,
std
::
experimental
::
optional
<
int64_t
>
o_sixtyfour
)
:
eight
(
std
::
move
(
eight
))
,
sixteen
(
std
::
move
(
sixteen
))
,
thirtytwo
(
std
::
move
(
thirtytwo
))
,
sixtyfour
(
std
::
move
(
sixtyfour
))
,
o_eight
(
std
::
move
(
o_eight
))
,
o_sixteen
(
std
::
move
(
o_sixteen
))
,
o_thirtytwo
(
std
::
move
(
o_thirtytwo
))
,
o_sixtyfour
(
std
::
move
(
o_sixtyfour
))
{}
};
test-suite/generated-src/cpp/client_returned_record.hpp
View file @
6d79895c
...
...
@@ -8,16 +8,12 @@
#include <utility>
struct
ClientReturnedRecord
final
{
int64_t
record_id
;
std
::
string
content
;
ClientReturnedRecord
(
int64_t
record_id
,
std
::
string
content
)
:
record_id
(
std
::
move
(
record_id
)),
content
(
std
::
move
(
content
))
{
}
ClientReturnedRecord
(
int64_t
record_id
,
std
::
string
content
)
:
record_id
(
std
::
move
(
record_id
))
,
content
(
std
::
move
(
content
))
{}
};
test-suite/generated-src/cpp/constants.hpp
View file @
6d79895c
...
...
@@ -27,16 +27,12 @@ struct Constants final {
static
const
std
::
experimental
::
optional
<
int32_t
>
OPTIONAL_INTEGER_CONSTANT
;
static
const
Constants
OBJECT_CONSTANT
;
int32_t
some_integer
;
std
::
string
some_string
;
Constants
(
int32_t
some_integer
,
std
::
string
some_string
)
:
some_integer
(
std
::
move
(
some_integer
)),
some_string
(
std
::
move
(
some_string
))
{
}
Constants
(
int32_t
some_integer
,
std
::
string
some_string
)
:
some_integer
(
std
::
move
(
some_integer
))
,
some_string
(
std
::
move
(
some_string
))
{}
};
test-suite/generated-src/cpp/date_record.hpp
View file @
6d79895c
...
...
@@ -7,12 +7,9 @@
#include <utility>
struct
DateRecord
final
{
std
::
chrono
::
system_clock
::
time_point
created_at
;
DateRecord
(
std
::
chrono
::
system_clock
::
time_point
created_at
)
:
created_at
(
std
::
move
(
created_at
))
{
}
DateRecord
(
std
::
chrono
::
system_clock
::
time_point
created_at
)
:
created_at
(
std
::
move
(
created_at
))
{}
};
test-suite/generated-src/cpp/map_date_record.hpp
View file @
6d79895c
...
...
@@ -9,12 +9,9 @@
#include <utility>
struct
MapDateRecord
final
{
std
::
unordered_map
<
std
::
string
,
std
::
chrono
::
system_clock
::
time_point
>
dates_by_id
;
MapDateRecord
(
std
::
unordered_map
<
std
::
string
,
std
::
chrono
::
system_clock
::
time_point
>
dates_by_id
)
:
dates_by_id
(
std
::
move
(
dates_by_id
))
{
}
MapDateRecord
(
std
::
unordered_map
<
std
::
string
,
std
::
chrono
::
system_clock
::
time_point
>
dates_by_id
)
:
dates_by_id
(
std
::
move
(
dates_by_id
))
{}
};
test-suite/generated-src/cpp/map_list_record.hpp
View file @
6d79895c
...
...
@@ -10,12 +10,9 @@
#include <vector>
struct
MapListRecord
final
{
std
::
vector
<
std
::
unordered_map
<
std
::
string
,
int64_t
>>
map_list
;
MapListRecord
(
std
::
vector
<
std
::
unordered_map
<
std
::
string
,
int64_t
>>
map_list
)
:
map_list
(
std
::
move
(
map_list
))
{
}
MapListRecord
(
std
::
vector
<
std
::
unordered_map
<
std
::
string
,
int64_t
>>
map_list
)
:
map_list
(
std
::
move
(
map_list
))
{}
};
test-suite/generated-src/cpp/map_record.hpp
View file @
6d79895c
...
...
@@ -9,12 +9,9 @@
#include <utility>
struct
MapRecord
final
{
std
::
unordered_map
<
std
::
string
,
int64_t
>
map
;
MapRecord
(
std
::
unordered_map
<
std
::
string
,
int64_t
>
map
)
:
map
(
std
::
move
(
map
))
{
}
MapRecord
(
std
::
unordered_map
<
std
::
string
,
int64_t
>
map
)
:
map
(
std
::
move
(
map
))
{}
};
test-suite/generated-src/cpp/nested_collection.hpp
View file @
6d79895c
...
...
@@ -9,12 +9,9 @@
#include <vector>
struct
NestedCollection
final
{
std
::
vector
<
std
::
unordered_set
<
std
::
string
>>
set_list
;
NestedCollection
(
std
::
vector
<
std
::
unordered_set
<
std
::
string
>>
set_list
)
:
set_list
(
std
::
move
(
set_list
))
{
}
NestedCollection
(
std
::
vector
<
std
::
unordered_set
<
std
::
string
>>
set_list
)
:
set_list
(
std
::
move
(
set_list
))
{}
};
test-suite/generated-src/cpp/primitive_list.hpp
View file @
6d79895c
...
...
@@ -8,12 +8,9 @@
#include <vector>
struct
PrimitiveList
final
{
std
::
vector
<
int64_t
>
list
;
PrimitiveList
(
std
::
vector
<
int64_t
>
list
)
:
list
(
std
::
move
(
list
))
{
}
PrimitiveList
(
std
::
vector
<
int64_t
>
list
)
:
list
(
std
::
move
(
list
))
{}
};
test-suite/generated-src/cpp/record_with_derivings.hpp
View file @
6d79895c
...
...
@@ -8,9 +8,7 @@
#include <utility>
struct
RecordWithDerivings
final
{
int32_t
key1
;
std
::
string
key2
;
bool
operator
==
(
const
RecordWithDerivings
&
other
)
const
;
...
...
@@ -19,11 +17,9 @@ struct RecordWithDerivings final {
bool
operator
>
(
const
RecordWithDerivings
&
other
)
const
;
bool
operator
<=
(
const
RecordWithDerivings
&
other
)
const
;
bool
operator
>=
(
const
RecordWithDerivings
&
other
)
const
;
RecordWithDerivings
(
int32_t
key1
,
std
::
string
key2
)
:
key1
(
std
::
move
(
key1
)),
key2
(
std
::
move
(
key2
))
{
}
RecordWithDerivings
(
int32_t
key1
,
std
::
string
key2
)
:
key1
(
std
::
move
(
key1
))
,
key2
(
std
::
move
(
key2
))
{}
};
test-suite/generated-src/cpp/record_with_nested_derivings.hpp
View file @
6d79895c
...
...
@@ -8,9 +8,7 @@
#include <utility>
struct
RecordWithNestedDerivings
final
{
int32_t
key
;
RecordWithDerivings
rec
;
bool
operator
==
(
const
RecordWithNestedDerivings
&
other
)
const
;
...
...
@@ -19,11 +17,9 @@ struct RecordWithNestedDerivings final {
bool
operator
>
(
const
RecordWithNestedDerivings
&
other
)
const
;
bool
operator
<=
(
const
RecordWithNestedDerivings
&
other
)
const
;
bool
operator
>=
(
const
RecordWithNestedDerivings
&
other
)
const
;
RecordWithNestedDerivings
(
int32_t
key
,
RecordWithDerivings
rec
)
:
key
(
std
::
move
(
key
)),
rec
(
std
::
move
(
rec
))
{
}
RecordWithNestedDerivings
(
int32_t
key
,
RecordWithDerivings
rec
)
:
key
(
std
::
move
(
key
))
,
rec
(
std
::
move
(
rec
))
{}
};
test-suite/generated-src/cpp/set_record.hpp
View file @
6d79895c
...
...
@@ -8,12 +8,9 @@
#include <utility>
struct
SetRecord
final
{
std
::
unordered_set
<
std
::
string
>
set
;
SetRecord
(
std
::
unordered_set
<
std
::
string
>
set
)
:
set
(
std
::
move
(
set
))
{
}
SetRecord
(
std
::
unordered_set
<
std
::
string
>
set
)
:
set
(
std
::
move
(
set
))
{}
};
test-suite/generated-src/objc/DBClientInterface.mm
View file @
6d79895c
...
...
@@ -30,7 +30,7 @@ public:
auto
ClientInterface
::
toCpp
(
ObjcType
objc
)
->
CppType
{
return
objc
?
djinni
:
:
DbxObjcWrapperCache
<
ObjcProxy
>::
getInstance
()
->
get
(
objc
)
:
nullptr
;
return
objc
?
:
:
djinni
::
DbxObjcWrapperCache
<
ObjcProxy
>::
getInstance
()
->
get
(
objc
)
:
nullptr
;
}
auto
ClientInterface
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
...
...
test-suite/generated-src/objc/DBCppException.mm
View file @
6d79895c
...
...
@@ -16,7 +16,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
@interface
DBCppException
()
@property
(
nonatomic
,
readonly
)
djinni
::
DbxCppWrapperCache
<::
CppException
>::
Handle
cppRef
;
@property
(
nonatomic
,
readonly
)
::
djinni
::
DbxCppWrapperCache
<::
CppException
>::
Handle
cppRef
;
-
(
id
)
initWithCpp
:(
const
std
::
shared_ptr
<::
CppException
>&
)
cppRef
;
...
...
@@ -31,7 +31,7 @@ auto CppException::toCpp(ObjcType objc) -> CppType
auto
CppException
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
{
return
!
cpp
?
nil
:
djinni
::
DbxCppWrapperCache
<::
CppException
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
return
!
cpp
?
nil
:
::
djinni
::
DbxCppWrapperCache
<::
CppException
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
{
return
[[
DBCppException
alloc
]
initWithCpp
:
p
];
});
...
...
test-suite/generated-src/objc/DBTestHelpers.mm
View file @
6d79895c
...
...
@@ -22,7 +22,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
@interface
DBTestHelpers
()
@property
(
nonatomic
,
readonly
)
djinni
::
DbxCppWrapperCache
<::
TestHelpers
>::
Handle
cppRef
;
@property
(
nonatomic
,
readonly
)
::
djinni
::
DbxCppWrapperCache
<::
TestHelpers
>::
Handle
cppRef
;
-
(
id
)
initWithCpp
:(
const
std
::
shared_ptr
<::
TestHelpers
>&
)
cppRef
;
...
...
@@ -37,7 +37,7 @@ auto TestHelpers::toCpp(ObjcType objc) -> CppType
auto
TestHelpers
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
{
return
!
cpp
?
nil
:
djinni
::
DbxCppWrapperCache
<::
TestHelpers
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
return
!
cpp
?
nil
:
::
djinni
::
DbxCppWrapperCache
<::
TestHelpers
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
{
return
[[
DBTestHelpers
alloc
]
initWithCpp
:
p
];
});
...
...
test-suite/generated-src/objc/DBToken.mm
View file @
6d79895c
...
...
@@ -14,7 +14,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
@interface
DBToken
()
@property
(
nonatomic
,
readonly
)
djinni
::
DbxCppWrapperCache
<::
Token
>::
Handle
cppRef
;
@property
(
nonatomic
,
readonly
)
::
djinni
::
DbxCppWrapperCache
<::
Token
>::
Handle
cppRef
;
-
(
id
)
initWithCpp
:(
const
std
::
shared_ptr
<::
Token
>&
)
cppRef
;
...
...
@@ -29,7 +29,7 @@ auto Token::toCpp(ObjcType objc) -> CppType
auto
Token
::
fromCpp
(
const
CppType
&
cpp
)
->
ObjcType
{
return
!
cpp
?
nil
:
djinni
::
DbxCppWrapperCache
<::
Token
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
return
!
cpp
?
nil
:
::
djinni
::
DbxCppWrapperCache
<::
Token
>::
getInstance
()
->
get
(
cpp
,
[]
(
const
auto
&
p
)
{
return
[[
DBToken
alloc
]
initWithCpp
:
p
];
});
...
...
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