generated from yahoo/.github
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yahoo/sal/migrate
migrate from internal repo
- Loading branch information
Showing
46 changed files
with
5,297 additions
and
6 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,93 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
||
## App packaging | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
# *.xcodeproj | ||
# | ||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata | ||
# hence it is not needed unless you have added a package configuration file to your project | ||
# .swiftpm | ||
|
||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
|
||
Pods/ | ||
|
||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build/ | ||
|
||
# Accio dependency management | ||
Dependencies/ | ||
.accio/ | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. | ||
# Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output | ||
|
||
# Code Injection | ||
# | ||
# After new code Injection tools there's a generated folder /iOSInjectionProject | ||
# https://github.com/johnno1962/injectionforxcode | ||
|
||
iOSInjectionProject/ |
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,40 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'BGSwift' | ||
s.platform = :ios, '12.0' | ||
s.version = '0.5.0' | ||
s.summary = 'Behavior Graph is a software library that greatly enhances our ability to program user facing software and control systems.' | ||
|
||
s.description = <<-DESC | ||
Behavior Graph is a software library that greatly enhances our ability to program user facing software and control systems. Programs of this type quickly scale up in complexity as features are added. Behavior Graph directly addresses this complexity by shifting more of the burden to the computer. It works by offering the programmer a new unit of code organization called a behavior. Behaviors are blocks of code enriched with additional information about their stateful relationships. Using this information, Behavior Graph enforces _safe use of mutable state_, arguably the primary source of complexity in this class of software. It does this by taking on the responsibility of control flow between behaviors, ensuring they are are _run at the correct time and in the correct order_. | ||
DESC | ||
|
||
s.license = { :type => 'Apache-2.0', :file => 'LICENSE.txt' } | ||
s.homepage = 'https://www.github.com/yahoo/BGSwift' | ||
s.authors = { | ||
'James Lou' => '[email protected]', | ||
'Sean Levin' => '[email protected]' | ||
} | ||
s.source = { | ||
:git => '[email protected]:yahoo/BGSwift.git', | ||
:tag => s.version.to_s | ||
} | ||
s.requires_arc = true | ||
|
||
s.default_subspecs = 'Core' | ||
|
||
s.subspec "Core" do |sp| | ||
sp.resources = [] | ||
|
||
sp.source_files =[ | ||
'BGSwift/Classes/**/*.{h,m,swift}', | ||
] | ||
|
||
sp.public_header_files = [ | ||
] | ||
|
||
sp.frameworks = [ | ||
'Foundation', | ||
] | ||
end | ||
end | ||
|
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,10 @@ | ||
// | ||
// Copyright © 2021 Yahoo | ||
// | ||
|
||
import Foundation | ||
|
||
struct BGAction { | ||
let impulse: String? | ||
let action: () -> Void | ||
} |
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,63 @@ | ||
// | ||
// Copyright © 2021 Yahoo | ||
// | ||
|
||
import Foundation | ||
|
||
enum OrderingState: Int { | ||
case ordered | ||
case ordering | ||
case unordered | ||
} | ||
|
||
public class BGBehavior { | ||
var orderingState = OrderingState.ordered | ||
var order = UInt(0) | ||
var enqueuedSequence = UInt(0) | ||
var lastUpdateSequence = UInt(0) | ||
var removedSequence = UInt(0) | ||
|
||
var propertyName: String? | ||
|
||
var supplies = WeakSet<BGResource>() | ||
var demands = WeakSet<BGResource>() | ||
|
||
var modifiedDemands: [BGResource]? | ||
var modifiedSupplies: [BGResource]? | ||
|
||
let runBlock: (BGExtent) -> Void | ||
|
||
weak var extent: BGExtent? | ||
|
||
|
||
init(supplies: [BGResource], demands: [BGResource], body: @escaping (BGExtent) -> Void) { | ||
modifiedSupplies = supplies | ||
modifiedDemands = demands | ||
|
||
self.runBlock = body | ||
} | ||
|
||
func run() { | ||
guard let extent = self.extent else { | ||
return | ||
} | ||
runBlock(extent) | ||
} | ||
|
||
|
||
public func setDemands(_ demands: [BGResource]) { | ||
modifiedDemands = demands | ||
extent?.graph?.updateDemands(behavior: self) | ||
} | ||
|
||
public func setSupplies(_ supplies: [BGResource]) { | ||
modifiedSupplies = supplies | ||
extent?.graph?.updateSupplies(behavior: self) | ||
} | ||
} | ||
|
||
extension BGBehavior: CustomDebugStringConvertible { | ||
public var debugDescription: String { | ||
return "<\(String(describing: Self.self)):\(String(format: "%018p", unsafeBitCast(self, to: Int64.self))) (\(propertyName ?? "Unlabeled"))>" | ||
} | ||
} |
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,14 @@ | ||
// | ||
// Copyright © 2021 Yahoo | ||
// | ||
|
||
|
||
import Foundation | ||
|
||
public struct BGEvent: Equatable { | ||
public let sequence: UInt | ||
public let timestamp: Date | ||
public let impulse: String? | ||
|
||
public static let unknownPast = BGEvent(sequence: 0, timestamp: Date(timeIntervalSince1970: 0), impulse: nil) | ||
} |
Oops, something went wrong.