Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated for _.m examples

  • Loading branch information...
commit 250c7fe5d71c475c20e3c1796f8811b0743a57e4 1 parent 3bb81b2
@kmalakoff authored
View
4 Lib/JavaScript/NSObject+JavaScript.h
@@ -43,4 +43,8 @@
- (B(^)(id key))hasOwnProperty;
- (B(^)(NSO* obj))in;
+// string
+- (NSS*(^)(NSS* string))add;
+- (S*(^)(NSS* string))append;
+
@end
View
32 Lib/JavaScript/NSObject+JavaScript.m
@@ -57,7 +57,7 @@ - (UI)length
- (S*(^)(NSS* separator))join
{
#ifdef DEBUG
- NSAssert(nil, @"join not implemented for this type");
+ NSAssert(nil, @"join not implemented for this type");
#endif
return nil;
@@ -65,9 +65,9 @@ - (UI)length
- (A*(^)(id value))push
{
return ^(NSO* obj) {
- #ifdef DEBUG
- NSAssert(nil, @"push not implemented for this type");
- #endif
+#ifdef DEBUG
+ NSAssert(nil, @"push not implemented for this type");
+#endif
return A.new;
};
}
@@ -76,6 +76,9 @@ - (UI)length
- (B(^)(id key))hasOwnProperty
{
return ^B(id key) {
+#ifdef DEBUG
+ NSAssert(nil, @"hasOwnProperty not implemented for this type");
+#endif
return false;
};
}
@@ -87,4 +90,25 @@ - (UI)length
};
}
+// string
+- (NSS*(^)(NSS* string))add
+{
+ return ^(NSS* string) {
+#ifdef DEBUG
+ NSAssert(nil, @"add not implemented for this type");
+#endif
+ return string;
+ };
+}
+
+- (S*(^)(NSS* string))append
+{
+ return ^(NSS* string) {
+#ifdef DEBUG
+ NSAssert(nil, @"append not implemented for this type");
+#endif
+ return string.mutableCopy;
+ };
+}
+
@end
View
1  Lib/JavaScript/SS+JavaScript.h
@@ -42,6 +42,7 @@
// global functions
+ (N*(^)(NSS* string))parseInt;
+ (const NSS*(^)(id obj))typeof_;
++ (void(^)(NSO* message))alert;
// timeouts
+ (SSTimeout*(^)(SSTaskIdBlock block, I waitNS))setTimeout;
View
12 Lib/JavaScript/SS+JavaScript.m
@@ -35,6 +35,8 @@
#import "SS+Types.h"
#import "SSArguments.h"
+//#import <UIKit/UIKit.h> // TODO: make mac compliant and test-safe version
+
const NSS* SSJSTypeOfObject = @"object";
const NSS* SSJSTypeOfString = @"string";
const NSS* SSJSTypeOfNumber = @"number";
@@ -125,6 +127,16 @@ @implementation SS (JavaScript)
};
}
++ (void(^)(NSO* message))alert
+{
+ return ^(NSO* message) {
+ // TODO: make mac compliant and test-safe version
+// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"alert" message:message.toString() delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
+// [alertView show];
+ NSLog(@"%@", message.toString());
+ };
+}
+
// timeouts
+ (SSTimeout*(^)(SSTaskIdBlock block, I waitNS))setTimeout
{
View
2  Lib/Types/NSArray+SS.m
@@ -141,7 +141,7 @@ - (NSS*)mutableClassName { return NSStringFromClass([S class]); }
return ^(I start, I count) {
if (start<0)
start = self.count + start;
- if (count<0)
+ if (count<=0)
count = (self.count - start) + count;
if ((start + count)>self.count-1)
count = self.count - start;
View
6 Lib/Types/NSObject+SS.m
@@ -139,9 +139,9 @@ - (D)D
// helper
- (NSComparisonResult)compare:(NSO*)other
{
- if (SS.isString(self)) return [(NSS*)self compare:(NSS*)other];
- if (SS.isNumber(self)) return [(N*)self compare:(N*)other];
- if (SS.isDate(self)) return [(Date*)self compare:(Date*)other];
+ if (SS.isString(self)) return [(NSS*)self compare:(NSS*)other];
+ if (SS.isNumber(self)) return [(N*)self compare:(N*)other];
+ if (SS.isDate(self)) return [(Date*)self compare:(Date*)other];
#ifdef DEBUG
NSAssert(nil, @"cannot compare the provided objects");
View
8 SubjectiveScript.m.xcodeproj/project.pbxproj
@@ -252,7 +252,6 @@
0A2A8B8115C7D572002A71DE /* JavaScript */,
0A2A8B9815C7D572002A71DE /* NSDictionary+NamedProperties.h */,
0A2A8B9915C7D572002A71DE /* NSDictionary+NamedProperties.m */,
- 0A2A8B9A15C7D572002A71DE /* Ruby */,
0A2A8B9B15C7D573002A71DE /* SS.h */,
0A2A8B9C15C7D573002A71DE /* SS.m */,
0A2A8B9D15C7D573002A71DE /* SubjectiveScript.h */,
@@ -305,13 +304,6 @@
path = JavaScript;
sourceTree = "<group>";
};
- 0A2A8B9A15C7D572002A71DE /* Ruby */ = {
- isa = PBXGroup;
- children = (
- );
- path = Ruby;
- sourceTree = "<group>";
- };
0A2A8B9F15C7D573002A71DE /* Types */ = {
isa = PBXGroup;
children = (
Please sign in to comment.
Something went wrong with that request. Please try again.