Преглед изворни кода

Merge branch 'master', remote-tracking branch 'gokr/master'

Nicolas Petton пре 13 година
родитељ
комит
4b8f69079f
4 измењених фајлова са 17 додато и 5 уклоњено
  1. 1 1
      bin/amberc
  2. 1 0
      js/Kernel-Objects.js
  3. 12 0
      st/Kernel-Objects.st
  4. 3 4
      st/Makefile

+ 1 - 1
bin/amberc

@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 # This is a "compiler" for Amber code. Run without arguments for help.
-
+#
 # Get Amber root directory from the location of this script so that
 # we can find the st and js directories etc.
 

+ 1 - 0
js/Kernel-Objects.js

@@ -3420,6 +3420,7 @@ smalltalk.UndefinedObject.klass);
 
 
 smalltalk.addClass('Random', smalltalk.Object, [], 'Kernel-Objects');
+smalltalk.Random.comment=unescape('Random%20is%20just%20a%20wrapper%20around%20javascript%20Math.random%28%29%20and%20is%20trivially%20used%20like%20this%3A%0A%0A%09Random%20new%20next%0A%0AThis%20will%20return%20a%20float%20x%20where%20x%20%3C%201%20and%20x%20%3E%200.%20If%20you%20want%20a%20random%20integer%20between%201%20and%2010%20you%20can%20use%20%23atRandom%0A%0A%0910%20atRandom%0A%0A...which%20is%20also%20implemented%20in%20SequencableCollection%20so%20you%20can%20easy%20pick%20an%20element%20at%20random%3A%0A%0A%09%23%28%27a%27%20%27b%27%20%27c%27%29%20atRandom')
 smalltalk.addMethod(
 unescape('_next'),
 smalltalk.method({

+ 12 - 0
st/Kernel-Objects.st

@@ -1170,6 +1170,18 @@ new
 Object subclass: #Random
 	instanceVariableNames: ''
 	category: 'Kernel-Objects'!
+!Random commentStamp!
+Random is just a wrapper around javascript Math.random() and is trivially used like this:
+
+	Random new next
+
+This will return a float x where x < 1 and x > 0. If you want a random integer between 1 and 10 you can use #atRandom
+
+	10 atRandom
+
+...which is also implemented in SequencableCollection so you can easy pick an element at random:
+
+	#('a' 'b' 'c') atRandom!
 
 !Random methodsFor: 'accessing'!
 

+ 3 - 4
st/Makefile

@@ -56,7 +56,6 @@ Compiler.js: Compiler.st Kernel-Objects.js Kernel-Classes.js Kernel-Methods.js K
 # to compile the rest of st files presuming that they only depend on Kernel, like
 # for example Canvas.js and Benchfib.js.
 %.js: %.st Compiler.js
-	echo $(OBJECTS)
 	$(AMBERC) $(FLAGS) $<
 
 # But for some libraries there are more dependencies to care for. Then
@@ -77,11 +76,11 @@ TrySmalltalk.js: TrySmalltalk.st IDE.js
 
 # Some Examples use SUnit and also IDE
 Examples.js: Examples.st SUnit.js IDE.js
-	$(AMBERC) $(FLAGS) -l SUnit,Canvas,IDE $<;
+	$(AMBERC) $(FLAGS) -l SUnit,Canvas,IDE $<
 
 # Tests typically also use SUnit
 Kernel-Tests.js: Kernel-Tests.st SUnit.js
-	$(AMBERC) $(FLAGS) -l SUnit $<;
+	$(AMBERC) $(FLAGS) -l SUnit $<
 
 # Documentation
 Documentation.js: Documentation.st Canvas.js
@@ -93,7 +92,7 @@ install: all
 
 # And cleaning is trivial also
 clean:
-	rm -f *.js; 
+	rm -f *.js
 
 # These three are phony
 .PHONY: all install clean