forked from dropbox/djinni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide the builtin "date" as example of a external type
This is a demonstration that the generator can be further simplified by moving types which do not require dedicated generator magic to externally declared types.
- Loading branch information
Showing
11 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
@extern "date.yaml" | ||
|
||
date_record = record { | ||
created_at: date; | ||
} | ||
created_at: extern_date; | ||
} deriving(eq, ord) | ||
|
||
map_date_record = record { | ||
dates_by_id: map<string, date>; | ||
dates_by_id: map<string, extern_date>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This is an example YAML file mimicking the builtin "date" type as external type | ||
--- | ||
name: extern_date | ||
typedef: 'record deriving(eq, ord)' | ||
params: [] | ||
prefix: '' | ||
cpp: | ||
typename: 'std::chrono::system_clock::time_point' | ||
header: '<chrono>' | ||
byValue: true | ||
objc: | ||
typename: 'NSDate' | ||
header: '<Foundation/Foundation.h>' | ||
boxed: 'NSDate' | ||
pointer: true | ||
hash: '(NSUInteger)%s.timeIntervalSinceReferenceDate' | ||
objcpp: | ||
translator: '::djinni::Date' | ||
header: '"DJIMarshal+Private.h"' | ||
java: | ||
typename: 'java.util.Date' | ||
boxed: 'java.util.Date' | ||
reference: true | ||
generic: true | ||
hash: '%s.hashCode()' | ||
jni: | ||
translator: '::djinni::Date' | ||
header: '"Marshal.hpp"' | ||
typename: jobject | ||
typeSignature: 'Ljava/util/Date;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from date.djinni | ||
|
||
#include "date_record.hpp" // my header | ||
|
||
|
||
bool operator==(const DateRecord& lhs, const DateRecord& rhs) { | ||
return lhs.created_at == rhs.created_at; | ||
} | ||
|
||
bool operator!=(const DateRecord& lhs, const DateRecord& rhs) { | ||
return !(lhs == rhs); | ||
} | ||
|
||
bool operator<(const DateRecord& lhs, const DateRecord& rhs) { | ||
if (lhs.created_at < rhs.created_at) { | ||
return true; | ||
} | ||
if (rhs.created_at < lhs.created_at) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
|
||
bool operator>(const DateRecord& lhs, const DateRecord& rhs) { | ||
return rhs < lhs; | ||
} | ||
|
||
bool operator<=(const DateRecord& lhs, const DateRecord& rhs) { | ||
return !(rhs < lhs); | ||
} | ||
|
||
bool operator>=(const DateRecord& lhs, const DateRecord& rhs) { | ||
return !(lhs < rhs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ djinni/test.djinni | |
djinni/primtypes.djinni | ||
djinni/constants.djinni | ||
djinni/date.djinni | ||
djinni/date.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters