Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow editing of main script of iOS example.

  • Loading branch information...
commit dcffc78e038ac228f12ad0edb5613b6c21ce3044 1 parent 431c27a
@feeley authored
View
231 examples/iOS/ViewController.xib
@@ -3,15 +3,19 @@
<data>
<int key="IBDocument.SystemTarget">1056</int>
<string key="IBDocument.SystemVersion">10J567</string>
- <string key="IBDocument.InterfaceBuilderVersion">823</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1305</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">132</string>
+ <string key="NS.object.0">300</string>
</object>
- <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>IBUIWebView</string>
+ <string>IBUITextView</string>
+ <string>IBUIView</string>
+ <string>IBProxyObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -22,9 +26,7 @@
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.values" ref="0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -47,6 +49,7 @@
<string key="NSFrameSize">{768, 1004}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="742341718"/>
<object class="NSColor" key="IBUIBackgroundColor" id="735581002">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
@@ -64,18 +67,20 @@
</object>
<object class="IBUIWebView" id="742341718">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">274</int>
+ <int key="NSvFlags">-2147483374</int>
<string key="NSFrameSize">{768, 1004}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
<reference key="IBUIBackgroundColor" ref="735581002"/>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
</object>
- <string key="NSFrameSize">{768, 1004}</string>
+ <string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="382596724"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
@@ -206,17 +211,13 @@
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">28</int>
@@ -363,204 +364,7 @@
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">Classes/ViewController.h</string>
- </object>
- </object>
- </object>
- <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="786211723">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIResponder</string>
- <string key="superclassName">NSObject</string>
- <reference key="sourceIdentifier" ref="786211723"/>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIScrollView</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIScrollView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UISearchBar</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UISearchDisplayController</string>
- <string key="superclassName">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UITextView</string>
- <string key="superclassName">UIScrollView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UITextView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIPrintFormatter.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIView</string>
- <string key="superclassName">UIResponder</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <string key="superclassName">UIResponder</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIViewController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIWebView</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIWebView.h</string>
+ <string key="minorKey">./Classes/ViewController.h</string>
</object>
</object>
</object>
@@ -576,8 +380,7 @@
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <string key="IBDocument.LastKnownRelativeProjectPath">GambitREPL.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">132</string>
+ <string key="IBCocoaTouchPluginVersion">300</string>
</data>
</archive>
View
7 examples/iOS/makefile.in
@@ -1,4 +1,4 @@
-# makefile for iOS example, Time-stamp: <2011-03-15 02:06:11 feeley>
+# makefile for iOS example, Time-stamp: <2011-03-20 20:23:45 feeley>
# Copyright (c) 1994-2011 by Marc Feeley, All Rights Reserved.
@@ -86,6 +86,7 @@ all-post:
examples: prepare-for-xcode
prepare-for-xcode: program.m program_.c GambitREPL.xcodeproj
+ chmod +x build-gambit-iOS
@echo "***********************************************************"
@echo "* *"
@echo "* To complete the iOS example the following steps must be *"
@@ -95,11 +96,11 @@ prepare-for-xcode: program.m program_.c GambitREPL.xcodeproj
@echo "* => this builds the Gambit runtime library for *"
@echo "* the iPhone/iPad/iTouch devices and simulators *"
@echo "* *"
- @echo "* 2) open GambitREPL.xcodeproj in XCode 4.0 *"
+ @echo "* 2) open GambitREPL.xcodeproj in XCode 4.0 (or later) *"
@echo "* *"
@echo "* 3) select the appropriate target (simulator or device) *"
@echo "* *"
- @echo "* 4) select menu "Product" -> "Run" *"
+ @echo "* 4) select menu Product -> Run *"
@echo "* *"
@echo "***********************************************************"
View
131 examples/iOS/program.scm
@@ -15,6 +15,7 @@
(##namespace (""
splash
+ repl
edit
reset-scripts
start-repl-server
@@ -32,6 +33,7 @@
(declare
(standard-bindings)
(extended-bindings)
+ (block)
(fixnum)
;;(not safe)
)
@@ -252,19 +254,6 @@ c-declare-end
(input-port-timeout-set! o -inf.0))
-;; Start the main REPL in the primordial thread, and create a second
-;; thread which executes the rest of the program and also takes care
-;; of the interaction with the ViewController.
-
-(continuation-capture
- (lambda (cont)
- (thread-start!
- (make-thread
- (lambda ()
- (continuation-return cont #f))))
- (##repl-debug-main)
- (exit)))
-
;;;----------------------------------------------------------------------------
;; Handling of events from the webView.
@@ -811,7 +800,7 @@ common-html-header-end
;; Splash page.
-(define splash-page-content #<<splash-page-content-end
+(define splash-page-content-head #<<splash-page-content-head-end
<body>
<p>
@@ -845,27 +834,54 @@ After the "<strong><code>&gt;</code></strong>" prompt enter your command then RE
</strong>
<center>
+
+splash-page-content-head-end
+)
+
+(define splash-page-content-button1 #<<splash-page-content-button1-end
+
<div class="button" onClick="window.location='event:start-repl';">Start REPL</div>
+
+splash-page-content-button1-end
+)
+
+(define splash-page-content-button2 #<<splash-page-content-button2-end
+
<div class="button" onClick="window.location='event:edit-scripts';">Edit Scripts</div>
+
+splash-page-content-button2-end
+)
+
+(define splash-page-content-tail #<<splash-page-content-tail-end
+
</center>
</body>
</html>
-splash-page-content-end
+splash-page-content-tail-end
)
-(define (splash)
+(define (splash #!optional (enable-edit-scripts? #f))
(set-page
- (string-append common-html-header splash-page-content)
+ (string-append common-html-header
+ splash-page-content-head
+ splash-page-content-button1
+ (if enable-edit-scripts?
+ splash-page-content-button2
+ "")
+ splash-page-content-tail)
(lambda (event)
(cond ((equal? event "event:start-repl")
- (show-textView))
+ (repl))
((equal? event "event:edit-scripts")
(edit))
((equal? event "event:visit-wiki")
- (show-textView)
+ (repl)
(open-URL "http://gambit.iro.umontreal.ca/"))))))
+(define (repl)
+ (show-textView))
+
;;;----------------------------------------------------------------------------
;; Script editing.
@@ -873,6 +889,14 @@ splash-page-content-end
(define predefined-scripts '(
#<<EOF
+;; Main script.
+;;
+;; Start with splash screen.
+
+(splash)
+EOF
+
+#<<EOF
;; Show "Hello!" for a few seconds.
(set-webView-content "<h1>Hello!</h1>")
@@ -890,7 +914,7 @@ EOF
1
(* n (fact (- n 1)))))
-(show-textView) ;; show the REPL
+(repl) ;; show the REPL
(pp (fact 100))
EOF
@@ -902,7 +926,7 @@ EOF
n
(+ (fib (- n 1)) (fib (- n 2)))))
-(show-textView) ;; show the REPL
+(repl) ;; show the REPL
(pp (time (fib 25)))
EOF
@@ -918,7 +942,7 @@ EOF
(map tree lst))))
p))
-(show-textView) ;; show the REPL
+(repl) ;; show the REPL
(pp (tree "~~"))
EOF
@@ -934,7 +958,7 @@ EOF
(thread-sleep! 10)
(edit)))
-(metar "cyul") ;; Montreal airport
+(metar "cymx") ;; Mirabel airport
EOF
#<<EOF
@@ -958,7 +982,7 @@ EOF
(define (get-script-db)
(if (not script-db)
(set! script-db
- (let ((x (get-pref "SCRIPTS")))
+ (let ((x (get-pref "script-db")))
(if x
(with-input-from-string x read)
predefined-scripts))))
@@ -966,7 +990,7 @@ EOF
(define (save-script-db)
(if script-db
- (set-pref "SCRIPTS"
+ (set-pref "script-db"
(with-output-to-string "" (lambda () (write script-db))))))
(define edit-page-content-head #<<edit-page-content-head-end
@@ -987,16 +1011,20 @@ edit-page-content-head-end
edit-page-content-tail-end
)
-(define (html-for-scripts scripts)
+(define (html-for-scripts scripts enable-edit-main-script?)
(define (html script index)
- (list "<br>\n"
- "<textarea class=\"script\" id=\"script" index "\" rows=9>" (html-escape script) "</textarea>\n"
- "<center>\n"
- "<div class=\"button\" onClick=\"window.location='event:save:" index " '+encodeURIComponent(document.getElementById('script" index "').value);\">Save</div>\n"
- "<div class=\"button\" onClick=\"window.location='event:run:" index " '+encodeURIComponent(document.getElementById('script" index "').value);\">Run</div>\n"
- "<div class=\"button\" onClick=\"if (confirm('Are you sure you want to delete this script?')) window.location='event:delete:" index "';\">Delete</div>\n"
- "</center>\n"))
+ (if (and (= index 0) (not enable-edit-main-script?))
+ ""
+ (list "<br>\n"
+ "<textarea class=\"script\" id=\"script" index "\" rows=9>" (html-escape script) "</textarea>\n"
+ "<center>\n"
+ "<div class=\"button\" onClick=\"window.location='event:save:" index " '+encodeURIComponent(document.getElementById('script" index "').value);\">Save</div>\n"
+ "<div class=\"button\" onClick=\"window.location='event:run:" index " '+encodeURIComponent(document.getElementById('script" index "').value);\">Run</div>\n"
+ (if (= index 0)
+ ""
+ (list "<div class=\"button\" onClick=\"if (confirm('Are you sure you want to delete this script?')) window.location='event:delete:" index "';\">Delete</div>\n"))
+ "</center>\n")))
(let loop ((scripts scripts) (i 0) (accum '("<body>\n")))
(if (pair? scripts)
@@ -1007,7 +1035,7 @@ edit-page-content-tail-end
(lambda ()
(print (reverse accum)))))))
-(define (edit)
+(define (edit #!optional (enable-edit-main-script? #f))
(define (get-parameters rest)
(call-with-input-string
@@ -1020,7 +1048,7 @@ edit-page-content-tail-end
(set-page
(string-append common-html-header
edit-page-content-head
- (html-for-scripts (get-script-db))
+ (html-for-scripts (get-script-db) enable-edit-main-script?)
edit-page-content-tail)
(lambda (event)
(cond ((has-prefix? event "event:save:") =>
@@ -1044,7 +1072,7 @@ edit-page-content-tail-end
(edit))
((equal? event "event:show-repl")
- (show-textView))))))
+ (repl))))))
(define (save-script-at-index index script)
(let loop ((scripts (get-script-db)) (i 0) (accum '()))
@@ -1053,6 +1081,8 @@ edit-page-content-tail-end
(set! script-db (append (reverse accum)
(cons script (cdr scripts))))
(loop (cdr scripts) (+ i 1) (cons (car scripts) accum)))))
+ (if (= index 0)
+ (set-pref "run-main-script" "yes"))
(save-script-db))
(define (run-script-at-index index script)
@@ -1080,8 +1110,33 @@ edit-page-content-tail-end
;;;----------------------------------------------------------------------------
-;; Install the splash page.
+;; Start the main REPL in the primordial thread, and create a second
+;; thread which executes the rest of the program (returning back from
+;; the C call to ___setup) and later takes care of the interaction
+;; with the ViewController.
-(splash)
+(continuation-capture
+ (lambda (cont)
+
+ (thread-start!
+ (make-thread
+ (lambda ()
+ (continuation-return cont #f))))
+
+ ;; the primordial thread is running this...
+
+ (if (get-pref "run-main-script")
+
+ (begin
+ (set-pref "run-main-script" #f)
+ (let ((script (list-ref (get-script-db) 0)))
+ (eval (cons 'begin (with-input-from-string script read-all))))
+ (set-pref "run-main-script" "yes"))
+
+ (splash)) ;; show splash screen if main script did not work last time
+
+ (##repl-debug-main)
+
+ (exit)))
;;;----------------------------------------------------------------------------
View
4 include/stamp.h
@@ -2,5 +2,5 @@
* Time stamp of last source code repository commit.
*/
-#define ___STAMP_YMD 20110315
-#define ___STAMP_HMS 60851
+#define ___STAMP_YMD 20110321
+#define ___STAMP_HMS 4157
Please sign in to comment.
Something went wrong with that request. Please try again.