Skip to content

Commit

Permalink
Initial Bond v5 work
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed Aug 26, 2016
1 parent 46518e1 commit f8c8c29
Show file tree
Hide file tree
Showing 131 changed files with 3,655 additions and 8,761 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: objective-c
osx_image: xcode7.3
osx_image: xcode8

install:
- gem install xcpretty

script:
- set -o pipefail && xcodebuild -project Bond.xcodeproj -scheme Bond -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0' test | xcpretty
- set -o pipefail && xcodebuild -project Bond.xcodeproj -scheme BondOSX -sdk macosx test | xcpretty
- set -o pipefail && xcodebuild -project Bond.xcodeproj -scheme Bond-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.0' test | xcpretty
# - set -o pipefail && xcodebuild -project Bond.xcodeproj -scheme BondOSX -sdk macosx test | xcpretty

after_success:
- bash <(curl -s https://codecov.io/bash)
25 changes: 13 additions & 12 deletions Bond.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Pod::Spec.new do |s|

s.name = "Bond"
s.version = "4.3.1"
s.version = "5.0.0-beta1"
s.summary = "A Swift binding framework"

s.description = <<-DESC
Bond is a Swift reactive binding framework that takes binding concept to a whole new level - boils it down to just one operator. It's simple, powerful, type-safe and multi-paradigm - just like Swift.
Bond is a Swift reactive binding framework that takes binding concept to a whole new level.
It's simple, powerful, type-safe and multi-paradigm - just like Swift.
Bond was created with two goals in mind: simple to use and simple to understand.
One might argue whether the former implies the latter, but Bond will save you some thinking because both are true in this case.
Its foundation is one simple class - everything else are extensions and syntactic sugars.
Bond is also a framework that bridges the gap between the reactive and imperative paradigms.
You can use it as a standalone framework to simplify your state changes with bindings and reactive data sources,
but you can also use it with ReactiveKit to complement your reactive data flows with bindings and
reactive delegates and data sources.
DESC

s.homepage = "https://github.com/SwiftBond/Bond"
Expand All @@ -19,13 +21,12 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.10"
s.tvos.deployment_target = '9.0'
s.source = { :git => "https://github.com/SwiftBond/Bond.git", :tag => "v4.3.1" }
s.source_files = ["Bond", "Bond/Core", "Bond/Extensions/Shared", "Bond/Extensions/OSX", "Bond/Extensions/iOS"]
s.ios.exclude_files = "Bond/Extensions/OSX"
s.tvos.exclude_files = "Bond/Extensions/OSX"
s.osx.exclude_files = "Bond/Extensions/iOS"
s.framework = 'SystemConfiguration'
s.exclude_files = "Classes/Exclude"
s.source = { :git => "https://github.com/SwiftBond/Bond.git", :tag => "v5.0.0-beta1" }
s.source_files = 'Sources/*.swift', 'Bond/*.{h,m,swift}'
s.ios.exclude_files = "Sources/AppKit"
s.tvos.exclude_files = "Sources/AppKit"
s.osx.exclude_files = "Sources/UIKit"
s.requires_arc = true

s.dependency 'ReactiveKit', '~> 3.0.0-beta1'
end
1,712 changes: 530 additions & 1,182 deletions Bond.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,23 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BAD1A7C217100A13B6B"
BlueprintIdentifier = "16210A3B1D3EC474004AEDF3"
BuildableName = "Bond.framework"
BlueprintName = "Bond"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BB81A7C217100A13B6B"
BuildableName = "BondTests.xctest"
BlueprintName = "BondTests"
BlueprintName = "Bond-iOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -40,14 +26,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BB81A7C217100A13B6B"
BlueprintIdentifier = "16210A441D3EC474004AEDF3"
BuildableName = "BondTests.xctest"
BlueprintName = "BondTests"
ReferencedContainer = "container:Bond.xcodeproj">
Expand All @@ -57,9 +42,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BAD1A7C217100A13B6B"
BlueprintIdentifier = "16210A3B1D3EC474004AEDF3"
BuildableName = "Bond.framework"
BlueprintName = "Bond"
BlueprintName = "Bond-iOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -79,9 +64,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BAD1A7C217100A13B6B"
BlueprintIdentifier = "16210A3B1D3EC474004AEDF3"
BuildableName = "Bond.framework"
BlueprintName = "Bond"
BlueprintName = "Bond-iOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -97,9 +82,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69491BAD1A7C217100A13B6B"
BlueprintIdentifier = "16210A3B1D3EC474004AEDF3"
BuildableName = "Bond.framework"
BlueprintName = "Bond"
BlueprintName = "Bond-iOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,9 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B56989C11BD8A00C00927A6B"
BlueprintIdentifier = "16D30EAD1D6591D300C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondtvOS"
BlueprintName = "Bond-macOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -26,8 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
Expand All @@ -46,9 +45,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B56989C11BD8A00C00927A6B"
BlueprintIdentifier = "16D30EAD1D6591D300C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondtvOS"
BlueprintName = "Bond-macOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -64,9 +63,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B56989C11BD8A00C00927A6B"
BlueprintIdentifier = "16D30EAD1D6591D300C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondtvOS"
BlueprintName = "Bond-macOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,23 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979681A83C3A100DD4A30"
BlueprintIdentifier = "16D30ED51D65D11900C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondOSX"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979721A83C3A200DD4A30"
BuildableName = "BondOSXTests.xctest"
BlueprintName = "BondOSXTests"
BlueprintName = "Bond-tvOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -40,29 +26,9 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979721A83C3A200DD4A30"
BuildableName = "BondOSXTests.xctest"
BlueprintName = "BondOSXTests"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979681A83C3A100DD4A30"
BuildableName = "Bond.framework"
BlueprintName = "BondOSX"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand All @@ -79,9 +45,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979681A83C3A100DD4A30"
BlueprintIdentifier = "16D30ED51D65D11900C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondOSX"
BlueprintName = "Bond-tvOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -97,9 +63,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DCA979681A83C3A100DD4A30"
BlueprintIdentifier = "16D30ED51D65D11900C2435D"
BuildableName = "Bond.framework"
BlueprintName = "BondOSX"
BlueprintName = "Bond-tvOS"
ReferencedContainer = "container:Bond.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
22 changes: 22 additions & 0 deletions Bond/BNDProtocolProxyBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// RKDelegate.h
// ReactiveKit
//
// Created by Srdan Rasic on 14/05/16.
// Copyright © 2016 Srdan Rasic. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface RKProtocolProxyBase : NSObject

@property (nonatomic, readonly, nonnull, strong) Protocol *protocol;

/// An object conforming to protocol `protocol` to which forward methods calls.
@property (nonatomic, nullable, weak) NSObject *forwardTo;

- (nonnull instancetype)initWithProtocol:(nonnull Protocol *)protocol;
- (BOOL)hasHandlerForSelector:(nonnull SEL)selector;
- (void)invokeWithSelector:(nonnull SEL)selector argumentExtractor:(void (^_Nonnull)(NSInteger index, void * _Nullable buffer))argumentExtractor setReturnValue:(void (^_Nullable)(void * _Nullable buffer))setReturnValue;

@end
83 changes: 83 additions & 0 deletions Bond/BNDProtocolProxyBase.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// RKDelegate.m
// ReactiveKit
//
// Created by Srdan Rasic on 14/05/16.
// Copyright © 2016 Srdan Rasic. All rights reserved.
//

#import "BNDProtocolProxyBase.h"
#import <objc/runtime.h>

@interface RKProtocolProxyBase ()
@property (nonatomic, readwrite, strong) Protocol *protocol;
@end

@implementation RKProtocolProxyBase

- (instancetype)initWithProtocol:(Protocol *)protocol
{
self = [super init];
if (self) {
_protocol = protocol;
}
return self;
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
NSMethodSignature *signature = [super methodSignatureForSelector:selector];

if (!signature && [self hasHandlerForSelector:selector]) {
struct objc_method_description description = protocol_getMethodDescription(self.protocol, selector, NO, YES);
if (description.types == NULL) {
description = protocol_getMethodDescription(self.protocol, selector, YES, YES);
}
signature = [NSMethodSignature signatureWithObjCTypes:description.types];
}

if (!signature) {
signature = [self.forwardTo methodSignatureForSelector:selector];
}

return signature;
}

- (BOOL)hasHandlerForSelector:(SEL)selector
{
return NO;
}

- (void)invokeWithSelector:(SEL)selector argumentExtractor:(void (^)(NSInteger index, void *buffer))argumentExtractor setReturnValue:(void (^)(void *buffer))setReturnValue
{
}

- (void)forwardInvocation:(NSInvocation *)invocation
{
if ([self hasHandlerForSelector:invocation.selector]) {
if (invocation.methodSignature.methodReturnLength > 0) {
[invocation retainArguments];
[self invokeWithSelector:invocation.selector argumentExtractor:^(NSInteger index, void *buffer) {
[invocation getArgument:buffer atIndex:index];
} setReturnValue:^(void *buffer) {
[invocation setReturnValue:buffer];
}];
} else {
[self invokeWithSelector:invocation.selector argumentExtractor:^(NSInteger index, void *buffer) {
[invocation getArgument:buffer atIndex:index];
} setReturnValue:nil];
}

if ([self.forwardTo respondsToSelector:invocation.selector]) {
[invocation invokeWithTarget:self.forwardTo];
}
} else {
if ([self.forwardTo respondsToSelector:invocation.selector]) {
[invocation invokeWithTarget:self.forwardTo];
} else {
[super forwardInvocation:invocation];
}
}
}

@end
Loading

0 comments on commit f8c8c29

Please sign in to comment.