Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate from internal repo #1

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .gitignore
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/
40 changes: 40 additions & 0 deletions BGSwift.podspec
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

10 changes: 10 additions & 0 deletions BGSwift/Classes/BGAction.swift
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
}
63 changes: 63 additions & 0 deletions BGSwift/Classes/BGBehavior.swift
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"))>"
}
}
14 changes: 14 additions & 0 deletions BGSwift/Classes/BGEvent.swift
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)
}
Loading