-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
3,437 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build --strategy=ObjcLink=standalone | ||
build --disk_cache=/tmp/bazel |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") | ||
|
||
git_repository( | ||
name = "build_bazel_rules_apple", | ||
remote = "https://github.com/bazelbuild/rules_apple.git", | ||
tag = "0.19.0", | ||
) | ||
|
||
git_repository( | ||
name = "build_bazel_rules_swift", | ||
remote = "https://github.com/bazelbuild/rules_swift.git", | ||
tag = "0.13.0", | ||
) | ||
|
||
git_repository( | ||
name = "build_bazel_apple_support", | ||
remote = "https://github.com/bazelbuild/apple_support.git", | ||
tag = "0.7.2", | ||
) | ||
|
||
git_repository( | ||
name = "bazel_skylib", | ||
remote = "https://github.com/bazelbuild/bazel-skylib.git", | ||
tag = "0.9.0", | ||
) | ||
|
||
load( | ||
"@build_bazel_rules_swift//swift:repositories.bzl", | ||
"swift_rules_dependencies", | ||
) | ||
|
||
swift_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_apple_support//lib:repositories.bzl", | ||
"apple_support_dependencies", | ||
) | ||
|
||
apple_support_dependencies() | ||
|
||
load( | ||
"@com_google_protobuf//:protobuf_deps.bzl", | ||
"protobuf_deps", | ||
) | ||
|
||
protobuf_deps() | ||
|
||
http_file( | ||
name = "xctestrunner", | ||
executable = 1, | ||
sha256 = "8b7352f7414de4b54478563c90d55509030baa531696dfe9c4e1bf0617ee5eb0", | ||
urls = ["https://github.com/google/xctestrunner/releases/download/0.2.12/ios_test_runner.par"], | ||
) |
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,50 @@ | ||
#!/bin/bash | ||
# Copyright 2016 The Tulsi Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# | ||
# Helper script to invoke Tulsi in commandline mode. | ||
# The path to the Tulsi.app bundle may be provided though the TULSI_APP | ||
# environment variable. If it is not, the script will attempt to find | ||
# Tulsi using the first result returned by the Spotlight index. | ||
|
||
set -eu | ||
|
||
# If the TULSI_APP environment variable is set, use it. | ||
if [[ "${TULSI_APP:-}" != "" ]]; then | ||
readonly app_bundle_path="${TULSI_APP}" | ||
else | ||
readonly tulsi_bundle_id=com.google.Tulsi | ||
app_bundle_path=$(mdfind kMDItemCFBundleIdentifier=${tulsi_bundle_id} | head -1) | ||
fi | ||
|
||
if [[ "${app_bundle_path}" == "" ]]; then | ||
if [[ -f "/Applications/Tulsi.app/Contents/MacOS/Tulsi" ]]; then | ||
readonly app_bundle_path="/Applications/Tulsi.app" | ||
else | ||
echo "Tulsi.app could not be located. Please ensure that you have built\ | ||
Tulsi and that it exists in an accessible location." | ||
|
||
exit 1 | ||
fi | ||
fi | ||
|
||
readonly tulsi_path="${app_bundle_path}/Contents/MacOS/Tulsi" | ||
|
||
if [[ $# == 0 ]]; then | ||
exec "${tulsi_path}" -- -h | ||
else | ||
echo "Using Tulsi at ${app_bundle_path}" | ||
exec "${tulsi_path}" -- "$@" | ||
fi |
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,44 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | ||
|
||
swift_library( | ||
name = "FlatBuffers", | ||
module_name = "FlatBuffers", | ||
srcs = glob(["FlatBuffers/*.swift"]), | ||
) | ||
|
||
swift_library( | ||
name = "Dflat", | ||
module_name = "Dflat", | ||
visibility = ["//visibility:public"], | ||
srcs = [ | ||
"Expr.swift", | ||
"Dflat.swift", | ||
"DflatAtom.swift", | ||
"DflatChangeRequest.swift", | ||
"DflatQueryBuilder.swift", | ||
"DflatFetchedResult.swift", | ||
"DflatTransactionContext.swift", | ||
] + glob(["exprs/*.swift"]), | ||
deps = [ | ||
":FlatBuffers", | ||
] | ||
) | ||
|
||
swift_library( | ||
name = "SQLiteDflat", | ||
module_name = "SQLiteDflat", | ||
visibility = ["//visibility:public"], | ||
srcs = [ | ||
"sqlite/SQLiteConnection.swift", | ||
"sqlite/SQLiteConnectionPool.swift", | ||
"sqlite/SQLiteDflat.swift", | ||
"sqlite/SQLiteDflatAtom.swift", | ||
"sqlite/SQLiteDflatQueryBuilder.swift", | ||
"sqlite/SQLiteDflatFetchedResult.swift", | ||
"sqlite/SQLiteDflatTransactionContext.swift", | ||
"sqlite/SQLiteExpr.swift", | ||
] + glob(["sqlite/exprs/*.swift"]), | ||
deps = [ | ||
":Dflat" | ||
] | ||
) |
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,6 @@ | ||
public protocol Dflat { | ||
typealias ChangesHandler = (_ transactionContext: DflatTransactionContext) -> Void | ||
typealias CompletionHandler = (_ success: Bool) -> Void | ||
func performChanges(_ anyPool: [Any.Type], changesHandler: @escaping ChangesHandler, completionHandler: CompletionHandler?) | ||
func fetchFor<T: DflatAtom>(ofType: T.Type) -> DflatQueryBuilder<T> | ||
} |
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,7 @@ | ||
import FlatBuffers | ||
|
||
open class DflatAtom { | ||
public final var _rowid: Int64 = -1 | ||
public init() {} | ||
public init(bb: ByteBuffer) {} | ||
} |
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,4 @@ | ||
|
||
public protocol DflatChangeRequest { | ||
|
||
} |
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,21 @@ | ||
// Using abstract class so we can provide implementation for array. | ||
open class DflatFetchedResult<Element: DflatAtom>: RandomAccessCollection { | ||
let array: [Element] | ||
|
||
public typealias Element = Element | ||
public typealias Index = Int | ||
public typealias Indices = Range<Index> | ||
public typealias SubSequence = Array<Element>.SubSequence | ||
public var endIndex: Index{ array.endIndex } | ||
public var indices: Indices { array.indices } | ||
public var startIndex: Index { array.startIndex } | ||
public func formIndex(after i: inout Index) { array.formIndex(after: &i) } | ||
public func formIndex(before i: inout Index) { array.formIndex(before: &i) } | ||
public subscript(position: Index) -> Element { array[position] } | ||
public subscript(x: Indices) -> SubSequence { array[x] } | ||
|
||
public init(_ array: [Element]) { | ||
self.array = array | ||
} | ||
|
||
} |
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,27 @@ | ||
import FlatBuffers | ||
|
||
public enum SortingOrder { | ||
case ascending | ||
case descending | ||
} | ||
|
||
public protocol OrderBy { | ||
var name: String { get } | ||
var sortingOrder: SortingOrder { get } | ||
func areInIncreasingOrder(_ a: FlatBufferObject, _ b: FlatBufferObject) -> Bool | ||
func areInIncreasingOrder(_ a: DflatAtom, _ b: DflatAtom) -> Bool | ||
} | ||
|
||
public enum Limit { | ||
case noLimit | ||
case limit(_: Int) | ||
} | ||
|
||
// This can be converted to PAT if we can use `some`. That requires the whole Dflat object to be PAT such that the returned | ||
// DflatQueryBuilder can be an associated type. | ||
open class DflatQueryBuilder<Element: DflatAtom> { | ||
public init() {} | ||
open func `where`<T: Expr>(_ clause: T, limit: Limit = .noLimit, orderBy: [OrderBy] = []) -> DflatFetchedResult<Element> where T.ResultType == Bool { | ||
fatalError() | ||
} | ||
} |
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,3 @@ | ||
public protocol DflatTransactionContext { | ||
func submit(_: DflatChangeRequest) -> Bool | ||
} |
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,24 @@ | ||
import FlatBuffers | ||
|
||
// See And.swift discussion for why we need 3-value. | ||
public enum IndexUsefulness { | ||
case none | ||
case partial | ||
case full | ||
} | ||
|
||
public protocol Expr { | ||
associatedtype ResultType | ||
func evaluate(table: FlatBufferObject?, object: DflatAtom?) -> (result: ResultType, unknown: Bool) | ||
func canUsePartialIndex(_ availableIndexes: Set<String>) -> IndexUsefulness | ||
var useScanToRefine: Bool { get } | ||
} | ||
|
||
public extension Expr { | ||
func evaluate(table: FlatBufferObject) -> (result: ResultType, unknown: Bool) { | ||
evaluate(table: table, object: nil) | ||
} | ||
func evaluate(object: DflatAtom) -> (result: ResultType, unknown: Bool) { | ||
evaluate(table: nil, object: object) | ||
} | ||
} |
Oops, something went wrong.