Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewrote some of the examples, without using the []'s. I just don't wa…

…nt to scare folks off.
  • Loading branch information...
commit 26f3bdecbc4fc5962b5b5aeb12d430706f3578d7 1 parent 4d1f04c
@ccgus authored
View
19 example_scripts/Acorn.jstalk
@@ -2,24 +2,25 @@
// http://code.google.com/p/flycode/source/browse/trunk/jstalk/extras/acornplugin/
// application: gets an object from Acorn over DO
-var acorn = [JSTalk application:"Acorn"];
+var acorn = JSTalk.application_("Acorn");
var outPath = "/tmp/jimi.png";
-var firstDoc = [[acorn orderedDocuments] objectAtIndex:0];
+var firstDoc = acorn.orderedDocuments().objectAtIndex_(0);
for (i = 0; i < 10; i++) {
- [[firstDoc windowController] callFilterWithName:"CIGaussianBlur"];
- [NSThread sleepForTimeInterval:0.2];
+ firstDoc.windowController().callFilterWithName_("CIGaussianBlur");
+ NSThread.sleepForTimeInterval_(0.2);
}
-[[firstDoc dataRepresentationOfType:"public.png"] writeToFile:outPath];
+firstDoc.dataRepresentationOfType_("public.png").writeToFile_(outPath);
-[[firstDoc undoManager] undo];
+firstDoc.undoManager().undo();
-var qt = [SBApplication application:"QuickTime Player"];
+var qt = SBApplication.application_("QuickTime Player");
print(qt);
-[qt open:[NSURL fileURLWithPath: outPath]];
-[qt activate];
+qt.open_(NSURL.fileURLWithPath_(outPath));
+qt.activate();
print("Hurray!");
+
View
8 example_scripts/AcornNewImage.jstalk
@@ -1,9 +1,9 @@
-var imageURL = [NSURL URLWithString:"http://flyingmeat.com/images/fmlogo.pdf"];
+var imageURL = NSURL.URLWithString_("http://flyingmeat.com/images/fmlogo.pdf");
-var image = [[[NSImage alloc] initWithContentsOfURL:imageURL] autorelease];
+var image = NSImage.alloc().initWithContentsOfURL_(imageURL).autorelease();
-var acorn = [JSTalk application:"Acorn"];
+var acorn = JSTalk.application_("Acorn");
-[[acorn sharedDocumentController] newDocumentWithImageData:[image TIFFRepresentation]];
+acorn.sharedDocumentController().newDocumentWithImageData_(image.TIFFRepresentation());
View
4 example_scripts/Alert Box.jstalk
@@ -1,6 +1,6 @@
-var jst = [JSTalk application:"JSTalk Editor"];
+var jst = JSTalk.application_("JSTalk Editor");
-if ([jst displayDialog:"Hello" withTitle:@"What?"] == NSOKButton) {
+if (jst.displayDialog_withTitle_("Hello", "What?") == NSOKButton) {
print("woo");
}
View
6 example_scripts/CommandLineArgs.jstalk
@@ -1,12 +1,12 @@
-var pi = [NSProcessInfo processInfo];
-var argCount = [[pi arguments] count];
+var pi = NSProcessInfo.processInfo();
+var argCount = pi.arguments().count();
print("There are " + argCount + " args");
var idx = 0;
while (idx < argCount) {
- print("argument " + idx + ": " + [pi arguments][idx]);
+ print("argument " + idx + ": " + pi.arguments()[idx]);
idx++;
}
View
12 example_scripts/Mail.jstalk
@@ -1,4 +1,4 @@
-var mail = [SBApplication application:"Mail"];
+var mail = SBApplication.application_("Mail");
var to = "someone@somewhere.com";
var from = "someone@somewhere.com";
@@ -6,17 +6,17 @@ var subject = "This is the subject.";
var content = "This is the message content.\n\nIsn't it great?";
var emailMessageProps = {subject:subject, content:content};
-var emailMessage = [[[mail classForScriptingClass:@"outgoing message"] alloc] initWithProperties:emailMessageProps];
+var emailMessage = mail.classForScriptingClass_("outgoing message").alloc().initWithProperties_(emailMessageProps);
-[[mail outgoingMessages] addObject:emailMessage];
+mail.outgoingMessages().addObject_(emailMessage);
emailMessage.sender = from;
emailMessage.visible = true;
theRecipientProps = {address:from};
-theRecipient = [[[mail classForScriptingClass:@"to recipient"] alloc] initWithProperties: theRecipientProps];
+theRecipient = mail.classForScriptingClass_("to recipient").alloc().initWithProperties_(theRecipientProps);
-[[emailMessage toRecipients] addObject:theRecipient];
+emailMessage.toRecipients().addObject_(theRecipient);
-[emailMessage send];
+emailMessage.send();
View
7 example_scripts/NewFolderWithDateInFinder.jstalk
@@ -18,13 +18,6 @@ if ([windows count] > 0) {
var finalPath = path + '/' + folderName;
[[NSFileManager defaultManager] createDirectoryAtPath: finalPath attributes:nil];
-
-
- //var terminal = [SBApplication application:"Terminal"];
-
- //[terminal activate];
-
- //[terminal doScript:"cd '" + [url path] + "'" in:nil];
}
else {
print("There's no window open")
View
14 example_scripts/Open Shell in Finder.jstalk
@@ -1,19 +1,19 @@
-var windows = [[SBApplication application:"Finder"] windows];
+var windows = SBApplication.application_("Finder").windows();
-if ([windows count] > 0) {
+if (windows.count() > 0) {
// from SBObject:
// get() "Forces evaluation of the receiver, causing the real object to be returned immediately."
var win = windows[0].get();
var target = win.target().get();
- var url = [NSURL URLWithString:[target URL]];
- var path = [url path].replace("%20", " ");
+ var url = NSURL.URLWithString_(target.URL());
+ var path = url.path().replace("%20", " ");
- var terminal = [SBApplication application:"Terminal"];
+ var terminal = SBApplication.application_("Terminal");
- [terminal activate];
+ terminal.activate();
- [terminal doScript:"cd '" + path + "'" in:nil];
+ terminal.doScript_in_("cd '" + path + "'", nil);
}
else {
print("There's no window open")
View
4 example_scripts/Set Finder Comment.jstalk
@@ -1,8 +1,8 @@
-var finder = [SBApplication application:"Finder"];
+var finder = SBApplication.application_("Finder");
// notice that the @ is making the string an NSString instance.
// the fileURL method is part of the JSTalk "Extras" categories
-var url = [@"/Volumes/srv/Users/gus/Desktop/foo.pict" fileURL]
+var url = @"/Volumes/srv/Users/gus/Desktop/foo.pict".fileURL();
var item = [[finder items] objectAtLocation:url];
item.comment = "Hello World!";
View
13 example_scripts/Sketch.jstalk
@@ -1,13 +1,12 @@
// this script requires the use of jstalk-sketch, in the extras folder.
-var sketch = [JSTalk application:"Sketch"];
-var doc = [sketch orderedDocuments][0]
-var rectangle = [doc makeNewBox];
-
-[rectangle setSize:NSMakeSize(100, 100)];
-[rectangle setXPosition:100];
-[rectangle setYPosition:100];
+var sketch = JSTalk.application_("Sketch");
+var doc = sketch.orderedDocuments()[0]
+var rectangle = doc.makeNewBox();
+rectangle.setSize_(NSMakeSize(100, 100));
+rectangle.setXPosition_(100);
+rectangle.setYPosition_(100);
/*
tell application "Sketch" tell document 1 set o to make new box set width of o to 100 set height of o to 100 set stroke thickness of o to 10 end tell end tell
View
6 example_scripts/VoodooPad.jstalk
@@ -1,9 +1,9 @@
-var VoodooPad = [JSTalk application:"VoodooPad Pro"];
+var VoodooPad = JSTalk.application_("VoodooPad Pro");
-var firstDoc = [[VoodooPad orderedDocuments] objectAtIndex:0];
+var firstDoc = VoodooPad.orderedDocuments().objectAtIndex_(0);
print(firstDoc);
-indexText = [[[firstDoc pageForKey:"index"] dataAsAttributedString] string];
+indexText = firstDoc.pageForKey_("index").dataAsAttributedString().string();
print(indexText);
View
2  example_scripts/iChat.jstalk
@@ -1,2 +1,2 @@
-[[SBApplication application:"iChat"] setStatusMessage:"Happy (funball)"];
+SBApplication.application_("iChat").setStatusMessage_("Happy (funball)");
View
18 jstalk.xcodeproj/project.pbxproj
@@ -712,20 +712,20 @@
CCC5B92C0F1EFB5900126722 /* JSCocoa */ = {
isa = PBXGroup;
children = (
+ CC1587880F6316B00077A4DF /* BridgeSupportController.h */,
+ CC15878F0F6316B00077A4DF /* BridgeSupportController.m */,
CC1587870F6316B00077A4DF /* class.js */,
- CC1587820F6316B00077A4DF /* JSCocoaFFIClosure.m */,
- CC1587830F6316B00077A4DF /* JSCocoaPrivateObject.m */,
+ CC1587860F6316B00077A4DF /* JSCocoa.h */,
+ CC15878C0F6316B00077A4DF /* JSCocoaController.h */,
+ CC15878B0F6316B00077A4DF /* JSCocoaController.m */,
+ CC15878E0F6316B00077A4DF /* JSCocoaFFIArgument.h */,
CC1587840F6316B00077A4DF /* JSCocoaFFIArgument.m */,
+ CC15878D0F6316B00077A4DF /* JSCocoaFFIClosure.h */,
+ CC1587820F6316B00077A4DF /* JSCocoaFFIClosure.m */,
CC1587850F6316B00077A4DF /* JSCocoaLib.h */,
- CC1587860F6316B00077A4DF /* JSCocoa.h */,
- CC1587880F6316B00077A4DF /* BridgeSupportController.h */,
CC1587890F6316B00077A4DF /* JSCocoaLib.m */,
CC15878A0F6316B00077A4DF /* JSCocoaPrivateObject.h */,
- CC15878B0F6316B00077A4DF /* JSCocoaController.m */,
- CC15878C0F6316B00077A4DF /* JSCocoaController.h */,
- CC15878D0F6316B00077A4DF /* JSCocoaFFIClosure.h */,
- CC15878E0F6316B00077A4DF /* JSCocoaFFIArgument.h */,
- CC15878F0F6316B00077A4DF /* BridgeSupportController.m */,
+ CC1587830F6316B00077A4DF /* JSCocoaPrivateObject.m */,
);
name = JSCocoa;
sourceTree = "<group>";
View
5 src/JSTPreprocessor.m
@@ -241,14 +241,13 @@ - (NSString*) description {
BOOL useMsgSend = NO;
if (useMsgSend) {
- NSMutableString *ret = [NSMutableString stringWithFormat:@"jstalk_msgsend(%@, '%@'", target, selector];
+ NSMutableString *ret = [NSMutableString stringWithFormat:@"JSTalk.msgSend_selector_args_(%@, '%@', [", target, selector];
if ([methodArgs count]) {
- [ret appendString:@", "];
[ret appendString:[methodArgs componentsJoinedByString:@", "]];
}
- [ret appendString:@")"];
+ [ret appendString:@"])"];
return ret;
}
View
2  tests/preprocess.jstalk
@@ -50,7 +50,7 @@ addTest('[fo doSomething:" a " + [b fun] + " c " in:nil];',
addTest('print([NSString stringWithString:@"a"+"b"])',
'print(NSString.stringWithString_(NSString.stringWithString_("a")+"b"))');
-
+
addTest('[NSFullUserName() lowercaseString];',
'NSFullUserName().lowercaseString();');
Please sign in to comment.
Something went wrong with that request. Please try again.