Pārlūkot izejas kodu

Changed -g to -d for additionally creating deployment files in jtalkc. Added -S for using libraries files using a common suffix. Fixed jtalkc so that it works on MacOS X (mktemp syntax). Moved all node/webos examples into a new examples directory.

Göran Krampe 12 gadi atpakaļ
vecāks
revīzija
6a29f342de

+ 34 - 27
bin/jtalkc

@@ -15,7 +15,7 @@ popd >/dev/null
 
 function usage {
 	cat <<ENDOFHELP
-Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-g] [-s suffix] [-m class] [-M file]
+Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
           [-i] [-I file] [file1 [file2 ...]] [Program]
 
    Will compile Jtalk files - either separately or into a runnable complete
@@ -61,19 +61,23 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-g] [-s suffix] [-m class] [-M file]
 
   -A Same as -O but use --compilation_level ADVANCED_OPTIMIZATIONS 
 
-  -g
-     Compile Jtalk code in debug mode - include source and references etc.
+  -d
+     Additionally export code for deploy - stripped from source etc.
+     Uses suffix ".deploy.js" in addition to any explicit given suffic using -s.
 
   -s suffix
      Add <suffix> to compiled js files so that File.st is compiled into
-     File.<suffix>.st.
+     File.<suffix>.js.
+
+  -S suffix
+     Use <suffix> for all libraries accessed using -l or -L and other options.
 
   -l library1,library2
-     Load listed libraries (no spaces) into Compiler before compiling.
+     Load listed libraries (no spaces or .js) into Compiler before compiling.
 
   -L library1,library2
-     Load listed libraries (no spaces) into Compiler before compiling and also
-     into Program.js in listed order.
+     Load listed libraries (no spaces or .js) into Compiler before compiling
+     and also into Program.js in listed order.
 
   -i file
      Add library initializer <file>.
@@ -116,11 +120,11 @@ if [ -z $1 ] ; then
 fi
 
 # Define our predefined library combinations
-BOOT="boot.js"
-KERNEL="$BOOT Kernel.js"
-COMPILER="$KERNEL Parser.js Compiler.js"
-CANVAS="$COMPILER Canvas.js"
-IDE="$CANVAS JQuery.js IDE.js SUnit.js Examples.js"
+BOOT="boot"
+KERNEL="$BOOT Kernel"
+COMPILER="$KERNEL Parser Compiler"
+CANVAS="$COMPILER Canvas"
+IDE="$CANVAS JQuery IDE SUnit Examples"
 
 # Predefined initializer
 INITIALIZER="$JTALK/js/init.js"
@@ -137,11 +141,11 @@ CLOSUREOPTS=
 # Ok, bad coding practice but hey, who would use such a suffix?
 SUFFIX=no-silly-suffix
 SUFFIXUSED=
-DEBUG=false
-NODECOMPILE=nodecompile.js
+DEPLOY=false
+NODECOMPILE=nodecompile
 
 # Read options and shift them away
-while getopts "NDEKCJoOAgs:l:L:i:IM:m:h?" o; do
+while getopts "NDEKCJoOAdS:s:l:L:i:IM:m:h?" o; do
 case "$o" in
    N) ENV=NODE
       BASE=$KERNEL
@@ -162,7 +166,9 @@ case "$o" in
    A) CLOSURE=true
       CLOSUREOPTS="$CLOSUREOPTS --compilation_level ADVANCED_OPTIMIZATIONS"
       CLOSUREFULL=true;;
-   g) DEBUG=true;;
+   d) DEPLOY=true;;
+   S) LOADSUFFIX=$OPTARG
+      SUFFIXUSED=$SUFFIX;;
    s) SUFFIX=$OPTARG
       SUFFIXUSED=$SUFFIX;;
    l) LOAD=$OPTARG;;
@@ -193,26 +199,27 @@ fi
 
 # Function for looking up listed js files
 function resolvejs {
-  if [ -f "$1" ]; then
-    RESOLVED="$1" 
+  FNAME="$1$LOADSUFFIX.js"
+  if [ -f $FNAME ]; then
+    RESOLVED="$FNAME" 
   else
-    if [ -f $JTALK/js/$1 ]; then
-      RESOLVED="$JTALK/js/$1"
+    if [ -f $JTALK/js/$FNAME ]; then
+      RESOLVED="$JTALK/js/$FNAME"
     else
-      echo "Javascript file not found: $1"
+      echo "Javascript file not found: $FNAME"
       exit 1
     fi
   fi
 }
 
-# Resolve listed libraries in $BASE separated by spaces
+# Resolve listed libraries in $BASE deparated by spaces
 for FILE in $BASE
 do
    resolvejs $FILE
    TOBASE="$TOBASE $RESOLVED"
 done
 
-# Resolve listed libraries in $LOAD separated by spaces
+# Resolve listed libraries in $LOAD separated by ,
 LOAD=${LOAD//,/\ }
 for FILE in $LOAD
 do
@@ -220,7 +227,7 @@ do
    TOLOAD="$TOLOAD $RESOLVED"
 done
 
-# Resolve listed libraries in $LOADANDADD separated by spaces
+# Resolve listed libraries in $LOADANDADD separated by ,
 LOADANDADD=${LOADANDADD//,/\ }
 for FILE in $LOADANDADD
 do
@@ -230,7 +237,7 @@ do
 done
 
 # Define our Compiler loading supplied libraries
-OURCOMPILER="$COMPILER $TOLOAD init.js $JTALK/nodejs/$NODECOMPILE"
+OURCOMPILER="$COMPILER $TOLOAD init $JTALK/bin/$NODECOMPILE"
 
 # Resolve OURCOMPILER
 for FILE in $OURCOMPILER
@@ -243,7 +250,7 @@ done
 LIBS="$TOBASE $TOADD"
 
 # Get a unique tempdir and make it get auto removed on exit
-TMPDIR=`mktemp -d`
+TMPDIR=`mktemp -d jtalkc.XXXXXX`
 trap "rm -rf $TMPDIR" EXIT
 
 
@@ -292,7 +299,7 @@ cat $TOOURCOMPILER > $TMPDIR/compiler.js
  
 # Compile all collected .st files to .js
 echo "Loading libraries $TOOURCOMPILER and compiling ..."
-node $TMPDIR/compiler.js $DEBUG $SUFFIX $COMPILE
+node $TMPDIR/compiler.js $DEPLOY $SUFFIX $COMPILE
 
 # Verify all .js files corresponding to .st files were created, otherwise exit
 IFS=" "

+ 7 - 9
nodejs/nodecompile.js → bin/nodecompile.js

@@ -7,12 +7,8 @@ var sys = require('sys'), fs = require('fs');
 // Only care about our arguments, strip away node, all.js and debug flag.
 var arguments = process.argv.splice(4);
 
-// First argument is debugMode: "true" or "false"
-if (process.argv[2] == "true") {
-  smalltalk.debugMode = true;
-} else {
-  smalltalk.debugMode = false;
-}
+// First argument is also produce deploy files: "true" or "false"
+var deploy = (process.argv[2] == "true");
 
 // Second argument is suffix: "no-silly-suffix" means none
 suffix = process.argv[3];
@@ -20,8 +16,6 @@ if (suffix == "no-silly-suffix") {
   suffix = "";
 }
 
-console.log("Compiling in debugMode: " + smalltalk.debugMode);
-
 // If it ends with .st, import it, otherwise export category as .js
 arguments.forEach(function(val, index, array) {
   if (/\.st/.test(val)) {
@@ -29,7 +23,11 @@ arguments.forEach(function(val, index, array) {
     code = fs.readFileSync(val, "utf8");
     smalltalk.Importer._new()._import_(code._stream());
   } else {
-    sys.puts("Exporting category " + val + " as " + val + suffix + ".js");
+    sys.puts("Exporting " + (deploy ? "(debug + deploy)" : "(debug)") + " category "
+		+ val + " as " + val + suffix + ".js" + (deploy ? " and " + val + suffix + ".deploy.js" : ""));
     fs.writeFileSync(val + suffix + ".js", smalltalk.Exporter._new()._exportCategory_(val));
+    if (deploy) {
+	fs.writeFileSync(val + suffix + ".deploy.js", smalltalk.StrippedExporter._new()._exportCategory_(val));
+    }
   }
 });

+ 0 - 0
nodejs/README → examples/nodejs/README


+ 0 - 0
nodejs/benchfib/Benchfib.st → examples/nodejs/benchfib/Benchfib.st


+ 1 - 1
nodejs/benchfib/Makefile → examples/nodejs/benchfib/Makefile

@@ -1,5 +1,5 @@
 Program.js: Benchfib.st
-	../../bin/jtalkc -N -m Benchfib Benchfib.st Program
+	../../../bin/jtalkc -N -m Benchfib Benchfib.st Program
 
 run: Program.js
 	./benchfib

+ 0 - 0
nodejs/benchfib/benchfib → examples/nodejs/benchfib/benchfib


+ 0 - 0
nodejs/hello/Hello.st → examples/nodejs/hello/Hello.st


+ 1 - 1
nodejs/hello/Makefile → examples/nodejs/hello/Makefile

@@ -1,5 +1,5 @@
 Program.js: Hello.st
-	../../bin/jtalkc -N -m Hello Hello.st Program
+	../../../bin/jtalkc -N -m Hello Hello.st Program
 
 run: Program.js
 	./hello

+ 0 - 0
nodejs/hello/README → examples/nodejs/hello/README


+ 0 - 0
nodejs/hello/hello → examples/nodejs/hello/hello


+ 1 - 1
nodejs/meta/Makefile → examples/nodejs/meta/Makefile

@@ -1,5 +1,5 @@
 Program.js: MyScript.st
-	../../bin/jtalkc -N -C -m MyScript MyScript.st Program
+	../../../bin/jtalkc -N -C -m MyScript MyScript.st Program
 
 run: Program.js
 	node Program.js

+ 0 - 0
nodejs/meta/MyScript.st → examples/nodejs/meta/MyScript.st


+ 1 - 1
nodejs/trivialserver/Makefile → examples/nodejs/trivialserver/Makefile

@@ -1,5 +1,5 @@
 Program.js: TrivialServer.st
-	../../bin/jtalkc -N -m TrivialServer TrivialServer.st Program
+	../../../bin/jtalkc -N -m TrivialServer TrivialServer.st Program
 
 run: Program.js
 	./trivial

+ 0 - 0
nodejs/trivialserver/TrivialServer.st → examples/nodejs/trivialserver/TrivialServer.st


+ 0 - 0
nodejs/trivialserver/trivial → examples/nodejs/trivialserver/trivial


+ 11 - 0
examples/webos/README

@@ -0,0 +1,11 @@
+These are examples that can be run in webOS 3.0 using Enyo - the new UI framework that was released with 3.0.
+
+You can play with them:
+
+- In a real device (a Touchpad or Pre 3 at the moment), but then you would first need to install the webOS SDK 3.0. With your device connected through USB you should be able to do "make run" and it should get installed and started on your device!
+
+- In the emulator included in the SDK. Just start "palm-emulator" and then do "make run" in any of the examples.
+
+- In a WebKit based browser, like Chromium (on Linux, do "make chromium") or Safari on the Mac (yes, it works). But first you would need to ensure that you have a copy of the enyo directory (normally you find it in /opt/PalmSDK/0.1/share/refcode/framework/enyo on Linux, just copy that whole directory into the directory in which you have the jtalk clone from github. Then the relative path in the index.html file referencing Enyo should work.
+
+

+ 0 - 0
webos/eris/DuckQwaq.wav → examples/webos/eris/DuckQwaq.wav


+ 0 - 0
webos/eris/EnyoJtalk.st → examples/webos/eris/EnyoJtalk.st


+ 0 - 0
webos/eris/Eris.css → examples/webos/eris/Eris.css


+ 10 - 5
webos/eris/Eris.st → examples/webos/eris/Eris.st

@@ -5,7 +5,12 @@ EnyoFriend subclass: #Eris
 !Eris methodsFor: 'actions'!
 
 doIt
-    ^self eval: self dollar richText getValue
+    | result |
+    [ result := self eval: self dollar richText getValue ]
+	on: Error
+	do: [:ex |
+		^self warn: ex messageText title: 'Error' button: 'Ooops...'].
+    ^result
 !
 
 clear
@@ -17,7 +22,7 @@ eval: aString
     compiler := Compiler new.
     node := compiler parseExpression: aString.
     node isParseFailure ifTrue: [
-	^self warn: 'Ehrm, you are a Smalltalk n00b, right?' button: 'Yup'].
+	^self warn: 'Ehrm, you are a Smalltalk n00b, right? That is not valid syntax.' title: 'Parsing Error' button: 'Okidoki...'].
     ^compiler loadExpression: aString.
 !
 
@@ -25,10 +30,10 @@ printString
 	^''
 !
 
-warn: aString button: caption
+warn: aString title: aTitle button: caption
 	| block popup |
 	block := [popup close].
-	<props = {kind: 'ModalDialog', caption: 'Parsing error', components: [
+	<props = {kind: 'ModalDialog', caption: aTitle, components: [
 			{kind: 'Control', content: aString, className: 'enyo-text-error warning-icon'},
 			{kind: 'Button', caption: caption, onclick: 'closePopup', style: 'margin-top:10px'}],
 		 closePopup: block}>.
@@ -71,7 +76,7 @@ initialize
 					{caption: 'Print it', onclick: 'printit'},
 					{caption: 'Clear', onclick: 'clear'},
 					{kind: 'Spacer'},
-					{caption: 'Quack!', onclick: 'quack'}]}]}],
+					{caption: 'Quack!!', onclick: 'quack'}]}]}],
 		doit: doItBlock,
 		printit: printItBlock,
 		quack: quackBlock,

+ 1 - 1
webos/eris/Makefile → examples/webos/eris/Makefile

@@ -16,7 +16,7 @@ OBJECTS  := $(patsubst %.st,%.js,$(wildcard *.st))
 FILEJS   := $(FILE).js
 
 $(FILEJS): $(SOURCES)
-	../../bin/jtalkc $(FLAGS) $(SOURCES) $(FILE)
+	../../../bin/jtalkc $(FLAGS) $(SOURCES) $(FILE)
 
 $(IPK): $(FILEJS)
 	palm-package .

+ 3 - 0
examples/webos/eris/README

@@ -0,0 +1,3 @@
+This is an example that was shown at ESUG 2011 running on a HP Touhpad with webOS 3.0.2.
+It shows the minimal beginning of a Jtalk development environment that dynamically can run and build Enyo applications.
+

+ 0 - 0
webos/eris/appinfo.json → examples/webos/eris/appinfo.json


+ 0 - 0
webos/eris/depends.js → examples/webos/eris/depends.js


+ 1 - 1
webos/eris/index.html → examples/webos/eris/index.html

@@ -2,7 +2,7 @@
 <html>
 <head>
 	<title>Eris</title>
-	<script src="../../../enyo/1.0/framework/enyo.js" type="text/javascript"></script>
+	<script src="../../../../enyo/1.0/framework/enyo.js" type="text/javascript"></script>
 </head>
 <body>
 <script type="text/javascript">

+ 0 - 0
webos/hellojtalk/EnyoJtalk.st → examples/webos/hellojtalk/EnyoJtalk.st


+ 0 - 0
webos/hellojtalk/HelloJtalk.css → examples/webos/hellojtalk/HelloJtalk.css


+ 0 - 0
webos/hellojtalk/HelloJtalk.st → examples/webos/hellojtalk/HelloJtalk.st


+ 1 - 1
webos/hellojtalk/Makefile → examples/webos/hellojtalk/Makefile

@@ -16,7 +16,7 @@ OBJECTS  := $(patsubst %.st,%.js,$(wildcard *.st))
 FILEJS   := $(FILE).js
 
 $(FILEJS): $(SOURCES)
-	../../bin/jtalkc $(FLAGS) $(SOURCES) $(FILE)
+	../../../bin/jtalkc $(FLAGS) $(SOURCES) $(FILE)
 
 $(IPK): $(FILEJS)
 	palm-package .

+ 1 - 0
examples/webos/hellojtalk/README

@@ -0,0 +1 @@
+This is just a first kinda messy experiment with Enyo, doesn't do anything sensible.

+ 0 - 0
webos/hellojtalk/appinfo.json → examples/webos/hellojtalk/appinfo.json


+ 0 - 0
webos/hellojtalk/depends.js → examples/webos/hellojtalk/depends.js


+ 0 - 0
webos/hellojtalk/index.html → examples/webos/hellojtalk/index.html