Skip to content

Commit df2f0d5

Browse files
committed
1.1 source code drop.
1 parent 6e91188 commit df2f0d5

File tree

121 files changed

+3017
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3017
-1132
lines changed

Source/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ruby "~> 2.5"
1+
ruby "~> 2.3"
22

33
source "https://rubygems.org"
44

55
gem "jazzy", "~> 0.9"
6-
gem "cocoapods", "1.6.0.beta.2"
6+
gem "cocoapods", "~> 1.8"

Source/Gemfile.lock

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,92 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.0)
4+
CFPropertyList (3.0.1)
55
activesupport (4.2.10)
66
i18n (~> 0.7)
77
minitest (~> 5.1)
88
thread_safe (~> 0.3, >= 0.3.4)
99
tzinfo (~> 1.1)
10+
algoliasearch (1.27.1)
11+
httpclient (~> 2.8, >= 2.8.3)
12+
json (>= 1.5.1)
1013
atomos (0.1.3)
11-
claide (1.0.2)
12-
cocoapods (1.6.0.beta.2)
14+
claide (1.0.3)
15+
cocoapods (1.8.1)
1316
activesupport (>= 4.0.2, < 5)
1417
claide (>= 1.0.2, < 2.0)
15-
cocoapods-core (= 1.6.0.beta.2)
16-
cocoapods-deintegrate (>= 1.0.2, < 2.0)
18+
cocoapods-core (= 1.8.1)
19+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
1720
cocoapods-downloader (>= 1.2.2, < 2.0)
1821
cocoapods-plugins (>= 1.0.0, < 2.0)
1922
cocoapods-search (>= 1.0.0, < 2.0)
2023
cocoapods-stats (>= 1.0.0, < 2.0)
21-
cocoapods-trunk (>= 1.3.1, < 2.0)
24+
cocoapods-trunk (>= 1.4.0, < 2.0)
2225
cocoapods-try (>= 1.1.0, < 2.0)
2326
colored2 (~> 3.1)
2427
escape (~> 0.0.4)
25-
fourflusher (~> 2.0.1)
28+
fourflusher (>= 2.3.0, < 3.0)
2629
gh_inspector (~> 1.0)
2730
molinillo (~> 0.6.6)
2831
nap (~> 1.0)
29-
ruby-macho (~> 1.3, >= 1.3.1)
30-
xcodeproj (>= 1.7.0, < 2.0)
31-
cocoapods-core (1.6.0.beta.2)
32+
ruby-macho (~> 1.4)
33+
xcodeproj (>= 1.11.1, < 2.0)
34+
cocoapods-core (1.8.1)
3235
activesupport (>= 4.0.2, < 6)
36+
algoliasearch (~> 1.0)
37+
concurrent-ruby (~> 1.1)
3338
fuzzy_match (~> 2.0.4)
3439
nap (~> 1.0)
35-
cocoapods-deintegrate (1.0.2)
40+
cocoapods-deintegrate (1.0.4)
3641
cocoapods-downloader (1.2.2)
3742
cocoapods-plugins (1.0.0)
3843
nap
3944
cocoapods-search (1.0.0)
40-
cocoapods-stats (1.0.0)
41-
cocoapods-trunk (1.3.1)
45+
cocoapods-stats (1.1.0)
46+
cocoapods-trunk (1.4.1)
4247
nap (>= 0.8, < 2.0)
4348
netrc (~> 0.11)
4449
cocoapods-try (1.1.0)
4550
colored2 (3.1.2)
46-
concurrent-ruby (1.1.3)
51+
concurrent-ruby (1.1.5)
4752
escape (0.0.4)
48-
ffi (1.9.25)
49-
fourflusher (2.0.1)
53+
ffi (1.11.1)
54+
fourflusher (2.3.1)
5055
fuzzy_match (2.0.4)
5156
gh_inspector (1.1.3)
57+
httpclient (2.8.3)
5258
i18n (0.9.5)
5359
concurrent-ruby (~> 1.0)
54-
jazzy (0.9.4)
55-
cocoapods (~> 1.0)
56-
mustache (~> 0.99)
60+
jazzy (0.11.2)
61+
cocoapods (~> 1.5)
62+
mustache (~> 1.1)
5763
open4
58-
redcarpet (~> 3.2)
64+
redcarpet (~> 3.4)
5965
rouge (>= 2.0.6, < 4.0)
60-
sass (~> 3.4)
66+
sassc (~> 2.1)
6167
sqlite3 (~> 1.3)
6268
xcinvoke (~> 0.3.0)
69+
json (2.2.0)
6370
liferaft (0.0.6)
64-
minitest (5.11.3)
71+
minitest (5.12.2)
6572
molinillo (0.6.6)
66-
mustache (0.99.8)
73+
mustache (1.1.0)
6774
nanaimo (0.2.6)
6875
nap (1.1.0)
6976
netrc (0.11.0)
7077
open4 (1.3.4)
71-
rb-fsevent (0.10.3)
72-
rb-inotify (0.9.10)
73-
ffi (>= 0.5.0, < 2)
74-
redcarpet (3.4.0)
75-
rouge (3.3.0)
76-
ruby-macho (1.3.1)
77-
sass (3.7.2)
78-
sass-listen (~> 4.0.0)
79-
sass-listen (4.0.0)
80-
rb-fsevent (~> 0.9, >= 0.9.4)
81-
rb-inotify (~> 0.9, >= 0.9.7)
82-
sqlite3 (1.3.13)
78+
redcarpet (3.5.0)
79+
rouge (3.12.0)
80+
ruby-macho (1.4.0)
81+
sassc (2.2.1)
82+
ffi (~> 1.9)
83+
sqlite3 (1.4.1)
8384
thread_safe (0.3.6)
8485
tzinfo (1.2.5)
8586
thread_safe (~> 0.1)
8687
xcinvoke (0.3.0)
8788
liferaft (~> 0.0.6)
88-
xcodeproj (1.7.0)
89+
xcodeproj (1.12.0)
8990
CFPropertyList (>= 2.3.3, < 4.0)
9091
atomos (~> 0.1.3)
9192
claide (>= 1.0.2, < 2.0)
@@ -96,11 +97,11 @@ PLATFORMS
9697
ruby
9798

9899
DEPENDENCIES
99-
cocoapods (= 1.6.0.beta.2)
100+
cocoapods (~> 1.8)
100101
jazzy (~> 0.9)
101102

102103
RUBY VERSION
103-
ruby 2.5.1p57
104+
ruby 2.3.7p456
104105

105106
BUNDLED WITH
106-
1.16.4
107+
2.0.2

Source/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ You look at and build the framework itself via `ios-framework/ObjectBox.xcodepro
103103
Caveats
104104
-------
105105

106-
To make to-one relations and their backlinks work, the `Entity` protocol was extended to require (1) an `EntityType` typealias, and (2) an `_id` property. The former was needed to disambiguate which concrete entity we're talking about when all we have is the protocol type, and this in turn is needed to specify the generic type requirement of `Id<T>`. Since the `Entity` protocol itself is intended to be no more than a convenient code annotation (which Sourcery can filter on), it's advised to get rid of this as soon as possible and find a different way to get the data needed for associations in Swift, for example using an `IdGetter<T>` like we do in Java and injecting it into `EntityInfo` from generated code.
106+
To make to-one relations and their backlinks work, the `Entity` protocol was extended to require (1) an `EntityType` typealias, and (2) an `_id` property. The former was needed to disambiguate which concrete entity we're talking about when all we have is the protocol type, and this in turn is needed to specify the generic type requirement of `EntityId<T>`. Since the `Entity` protocol itself is intended to be no more than a convenient code annotation (which Sourcery can filter on), it's advised to get rid of this as soon as possible and find a different way to get the data needed for associations in Swift, for example using an `IdGetter<T>` like we do in Java and injecting it into `EntityInfo` from generated code.
107107

108108
How to Use the Framework
109109
------------------------
@@ -117,7 +117,7 @@ Define entities:
117117

118118
import ObjectBox
119119
final class Person: Entity {
120-
var id: Id<Person> = 0
120+
var id: Id = 0
121121
var age: Int
122122
var name: String
123123
var birthdate: Date
@@ -136,7 +136,7 @@ Run the code generator. This will configure a `ModelBuilder` and get the `Data`
136136
Create and set up the ObjectBox types:
137137

138138
let directory: String = "/path/to/the/store"
139-
let store: Store = try! Store(directoryPath: directory)
139+
let store: Store = try Store(directoryPath: directory)
140140
let personBox: Box<Person> = store.box(for: Person.self)
141141

142142
This will call into the the generated (!) initializer that uses the private model builder's `modelBytes()` automatically.
@@ -150,10 +150,10 @@ Then you're all set to use entities with ObjectBox:
150150
assert(person.id == personId) // ID is set after put
151151

152152
// Get by ID
153-
assert(personBox.get(personId) != nil)
153+
assert(try personBox.get(personId) != nil)
154154

155155
// Get collections of entities
156-
_ = personBox.all()
157-
_ = personBox.query({ Person.name == "Fry" }).build().find()
156+
_ = try personBox.all()
157+
_ = try personBox.query({ Person.name == "Fry" }).build().find()
158158

159159
That's it, it works now!

Source/download_dependencies.command

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
set -e
1010

1111
version=1.1
12-
core_version=0.7.3
12+
core_version=0.7.2
1313

1414
my_dir=`dirname "$0"`
1515
my_dir=`realpath "${my_dir}"`
1616

1717
cd $my_dir
1818
code_dir="${my_dir}/external/objectbox/"
19-
dest_dir="../../../objectbox-static/"
19+
dest_dir="${my_dir}/external/objectbox-static/"
2020
archive_path="${my_dir}/external/objectbox-static.zip"
2121
OBXLIB_URL_apple_static="https://github.com/objectbox/objectbox-swift/releases/download/v${version}/ObjectBoxCore-static-${core_version}.zip"
2222

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/bash
2+
3+
# RunToolTests.sh
4+
# ObjectBox Swift
5+
#
6+
# Created by Uli Kusterer on 07.12.18.
7+
#
8+
9+
echo -n "note: Starting tests at "
10+
date
11+
12+
mydir=`dirname "$0"`
13+
itestdir="$mydir/../IntegrationTests/"
14+
15+
test_target_num () {
16+
testname="$1"
17+
testname="${testname//[ \/]/_}"
18+
testdir="$itestdir/$2_$testname"
19+
mkdir "$testdir"
20+
if [ -f "EntityInfo.generated$2.swift" ]; then
21+
cp "EntityInfo.generated$2.swift" "$testdir/EntityInfo.generated.expected.swift"
22+
fi
23+
if [ -f "EntityInfo.generated$2_original.swift" ]; then
24+
cp "EntityInfo.generated$2_original.swift" "$testdir/EntityInfo.generated.initial.swift"
25+
fi
26+
if [ -f "messages$2.log" ]; then
27+
cp "messages$2.log" "$testdir/messages.expected.log"
28+
fi
29+
if [ -f "model$2.json" ]; then
30+
cp "model$2.json" "$testdir/model.expected.json"
31+
cp "model$2.json" "$testdir/model.initial.json"
32+
fi
33+
if [ -f "model$2_before.json" ]; then
34+
cp "model$2_before.json" "$testdir/model.initial.json"
35+
fi
36+
if [ -f "schemaDump$2.txt" ]; then
37+
cp "schemaDump$2.txt" "$testdir/schemaDump.expected.txt"
38+
fi
39+
if [ -f "schemaDump$2_original.txt" ]; then
40+
cp "schemaDump$2_original.txt" "$testdir/schemaDump_original.txt"
41+
fi
42+
if [ -f "ToolTestProject$2.swift" ]; then
43+
cp "ToolTestProject$2.swift" "$testdir/test.swift"
44+
fi
45+
if [ -f "ToolTestProject$2_original.swift" ]; then
46+
cp "ToolTestProject$2_original.swift" "$testdir/test_original.swift"
47+
fi
48+
if [ -f "xcode$2.log" ]; then
49+
cp "xcode$2.log" "$testdir/xcode.expected.log"
50+
fi
51+
cp -R "$itestdir/8_Empty_Entity/Project.xcodeproj" "$testdir/Project.xcodeproj"
52+
}
53+
54+
fail_codegen_target_num () {
55+
testname="$1"
56+
testname="${testname//[ \/]/_}"
57+
testdir="$itestdir/$2_$testname"
58+
mkdir "$testdir"
59+
if [ -f "EntityInfo.generated$2.swift" ]; then
60+
cp "EntityInfo.generated$2.swift" "$testdir/EntityInfo.generated.expected.swift"
61+
fi
62+
if [ -f "EntityInfo.generated$2_original.swift" ]; then
63+
cp "EntityInfo.generated$2_original.swift" "$testdir/EntityInfo.generated.initial.swift"
64+
fi
65+
if [ -f "messages$2.log" ]; then
66+
cp "messages$2.log" "$testdir/messages.fail.log"
67+
fi
68+
if [ -f "model$2.json" ]; then
69+
cp "model$2.json" "$testdir/model.initial.json"
70+
fi
71+
if [ -f "model$2.before.json" ]; then
72+
if [ -f "$testdir/model.initial.json" ]; then
73+
echo "warning: model.before.json AND model.json found in ${2}_$testname"
74+
cp "model$2.before.json" "$testdir/model.initial2.json"
75+
else
76+
cp "model$2.json" "$testdir/model.expected.json"
77+
fi
78+
fi
79+
if [ -f "schemaDump$2.txt" ]; then
80+
cp "schemaDump$2.txt" "$testdir/schemaDump.initial.txt"
81+
fi
82+
if [ -f "schemaDump$2_original.txt" ]; then
83+
if [ -f "$testdir/schemaDump.initial.txt" ]; then
84+
echo "warning: schemaDump_before.txt AND schemaDump.txt found in ${2}_$testname"
85+
cp "schemaDump$2_original.txt" "$testdir/schemaDump.initial2.txt"
86+
else
87+
cp "schemaDump$2_original.txt" "$testdir/model.initial.txt"
88+
fi
89+
cp "schemaDump$2_original.txt" "$testdir/schemaDump_original.txt"
90+
fi
91+
if [ -f "ToolTestProject$2.swift" ]; then
92+
cp "ToolTestProject$2.swift" "$testdir/test.swift"
93+
fi
94+
if [ -f "ToolTestProject$2_original.swift" ]; then
95+
cp "ToolTestProject$2_original.swift" "$testdir/test_original.swift"
96+
fi
97+
if [ -f "xcode$2.log" ]; then
98+
cp "xcode$2.log" "$testdir/xcode.expected.log"
99+
fi
100+
cp -R "$itestdir/8_Empty_Entity/Project.xcodeproj" "$testdir/Project.xcodeproj"
101+
}
102+
103+
104+
cd "$mydir"
105+
106+
test_target_num "ID and 2 strings entity" 9 || FAIL=1
107+
fail_codegen_target_num "NameInDb collision with other property" 10 || FAIL=1
108+
fail_codegen_target_num "Entity with string but no ID" 11 || FAIL=1
109+
test_target_num "Remove A Property" 12 || FAIL=1
110+
test_target_num "Remove A Property and add one at same time" 13 || FAIL=1
111+
test_target_num "Add a Property after having removed one" 14 || FAIL=1
112+
test_target_num "Remove an index from a property" 15 || FAIL=1
113+
test_target_num "Add and remove an index in one go" 16 || FAIL=1
114+
test_target_num "Add an index after having removed one" 17 || FAIL=1
115+
test_target_num "Rename an entity" 18 || FAIL=1
116+
fail_codegen_target_num "Entity UID printing" 19 || FAIL=1
117+
fail_codegen_target_num "New Entity with empty UID" 20 || FAIL=1
118+
test_target_num "Rename a property" 21 || FAIL=1
119+
fail_codegen_target_num "Property UID printing" 22 || FAIL=1
120+
fail_codegen_target_num "New Property with empty UID" 23 || FAIL=1
121+
fail_codegen_target_num "New Property with UID" 24 || FAIL=1
122+
test_target_num "Read/write all our data types" 25 || FAIL=1
123+
test_target_num "Ensure running codegen on unchanged file changes nothing" 26 || FAIL=1
124+
test_target_num "Ensure assigning a previously proposed UID works [Change/Reset]" 27 || FAIL=1
125+
test_target_num "Ensure moving properties changes nothing" 28 || FAIL=1
126+
test_target_num "Ensure moving entities changes nothing" 29 || FAIL=1
127+
test_target_num "Unique Entity Exception Test" 30 || FAIL=1
128+
test_target_num "Struct Entity Test" 31 || FAIL=1
129+
test_target_num "UInt64 as ID Test" 32 || FAIL=1
130+
test_target_num "Data and [UInt8] Test" 33 || FAIL=1
131+
132+
test_target_num "Converter Test" 34 || FAIL=1
133+
test_target_num "Enum Test" 35 || FAIL=1
134+
test_target_num "Standalone Relations" 36 || FAIL=1
135+
test_target_num "Standalone Backlinks" 37 || FAIL=1
136+
test_target_num "Edit ToOne Backlinks" 38 || FAIL=1
137+
test_target_num "Edit ToOne Backlinks Structs" 39 || FAIL=1
138+
test_target_num "Standalone Backlinks Structs" 40 || FAIL=1
139+
fail_codegen_target_num "ToOne Backlink annotation wrong" 41 || FAIL=1
140+
test_target_num "Standalone Relation Queries" 42 || FAIL=1
141+
test_target_num "ToOne Relation Queries" 43 || FAIL=1
142+
test_target_num "many-to-many reset" 44 || FAIL=1
143+
test_target_num "many-to-many backlink reset" 45 || FAIL=1
144+
test_target_num "Threaded ToOne backlink edit" 46 || FAIL=1
145+
test_target_num "Threaded Many-to-many edit" 47 || FAIL=1
146+
test_target_num "Threaded Many-to-many backlink edit" 48 || FAIL=1
147+
test_target_num "Untyped IDs and queries 1" 49 || FAIL=1
148+
test_target_num "Untyped IDs and queries 2" 50 || FAIL=1
149+
#fail_codegen_target_num "Typed IDs still enforce type?" 51 || FAIL=1
150+
151+
fail_codegen_target_num "Ensure we don't write JSON before ID errors" 52 || FAIL=1
152+
test_target_num "ToOne Backlink ensure applyToDb is needed" 53 || FAIL=1
153+
test_target_num "ToMany ensure applyToDb is needed" 54 || FAIL=1
154+
test_target_num "ToMany Backlink ensure applyToDb is needed" 55 || FAIL=1
155+
test_target_num "Swift Property Wrappers are treated as wrapped type" 56 || FAIL=1
156+
157+
echo "note: Finished tests..."
158+
159+
exit $FAIL

Source/ios-framework/CodeGenTests/EntityInfo.generated1.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,14 @@ internal class BusRouteBinding: NSObject, ObjectBox.EntityBinding {
8888
}
8989

9090
internal func collect(fromEntity entity: EntityType, id: ObjectBox.Id,
91-
propertyCollector: ObjectBox.PropertyCollector, store: ObjectBox.Store) {
92-
var offsets: [(offset: OBXDataOffset, index: UInt16)] = []
93-
offsets.append((propertyCollector.prepare(string: entity.lineName, at: 2 + 2 * 2), 2 + 2 * 2))
91+
propertyCollector: ObjectBox.FlatBufferBuilder, store: ObjectBox.Store) {
92+
let propertyOffset_lineName = propertyCollector.prepare(string: entity.lineName)
9493

9594
propertyCollector.collect(id, at: 2 + 2 * 1)
96-
97-
98-
for value in offsets {
99-
propertyCollector.collect(dataOffset: value.offset, at: value.index)
100-
}
95+
propertyCollector.collect(dataOffset: propertyOffset_lineName, at: 2 + 2 * 2)
10196
}
10297

103-
internal func createEntity(entityReader: ObjectBox.EntityReader, store: ObjectBox.Store) -> EntityType {
98+
internal func createEntity(entityReader: ObjectBox.FlatBufferReader, store: ObjectBox.Store) -> EntityType {
10499
let entity = BusRoute()
105100

106101
entity.id = entityReader.read(at: 2 + 2 * 1)

0 commit comments

Comments
 (0)