red 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,18 @@
1
+ == 4.0.2 2008-10-14
2
+
3
+ * 2 bug fixes:
4
+ * Fixed the newly introduced namespacing issue.
5
+ * Adjusted send, and attr and similar methods to properly cache their referred-to methods.
6
+
7
+ == 4.0.1 2008-10-13
8
+
9
+ * 1 major enhancement:
10
+ * Improved flexibility for platforming Red into browsers.
11
+
12
+ * 2 bug fixes:
13
+ * Fixed a namespacing issue for Constants.
14
+ * Added a few more essential internally-referenced methods.
15
+
1
16
  == 4.0.0 2008-10-12
2
17
 
3
18
  * New version released.
@@ -14,7 +14,7 @@ module Red
14
14
  class Constant < AssignmentNode # :nodoc:
15
15
  # [:cdecl, :Foo, {expression}]
16
16
  def initialize(constant_name_sexp, expression_sexp, options)
17
- constant_name = (@@namespace_stack + ["%s" % constant_name_sexp.red!]).join(".c$")
17
+ constant_name = ("c$" + (@@namespace_stack + ["%s" % constant_name_sexp.red!]).join(".c$")).gsub("c$c$","c$")
18
18
  @@red_constants |= [constant_name]
19
19
  expression = expression_sexp.red!(:as_assignment => true)
20
20
  self << "%s=%s" % [constant_name, expression]
data/lib/red/version.rb CHANGED
@@ -2,7 +2,7 @@ module Red
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/source/ruby.rb CHANGED
@@ -665,7 +665,7 @@ class Object
665
665
  # k.send(:hello, "gentle", "readers") #=> "Hello gentle readers"
666
666
  #
667
667
  def send(method,*args)
668
- `this[method].apply(this,args)`
668
+ `this['m$'+method._value.replace('=','Eql')].apply(this,args)`
669
669
  end
670
670
 
671
671
  # FIX: Incomplete
@@ -805,17 +805,20 @@ class Module
805
805
  #return other_module
806
806
  end
807
807
 
808
- def attr(a, writer = false)
809
- `this.prototype['m$'+a._value]=function(){return this['i$'+a._value];}`
810
- `if(writer){this.prototype['m$'+a._value+'Eql']=function(x){return this['i$'+a._value]=x;};}`
808
+ def attr(attribute, writer = false)
809
+ `var a=attribute._value`
810
+ `f1=this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};f1._name=a`
811
+ `if(writer){f2=this.prototype['m$'+a._value+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};f2._name=a;}`
811
812
  return nil
812
813
  end
813
814
 
814
815
  def attr_accessor(*symbols)
815
816
  `for(var i=0,l=symbols.length;i<l;++i){
816
817
  var a=symbols[i]._value;
817
- this.prototype['m$'+a]=function(){return this['i$'+a];};
818
- this.prototype['m$'+a+'Eql']=function(x){return this['i$'+a]=x;};
818
+ f1=this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};
819
+ f2=this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};
820
+ f1._name = a
821
+ f2._name = a
819
822
  }`
820
823
  return nil
821
824
  end
@@ -823,7 +826,8 @@ class Module
823
826
  def attr_reader(*symbols)
824
827
  `for(var i=0,l=symbols.length;i<l;++i){
825
828
  var a=symbols[i]._value;
826
- this.prototype['m$'+a]=function(){return this['i$'+a];};
829
+ f = this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};
830
+ f._name = a
827
831
  }`
828
832
  return nil
829
833
  end
@@ -831,7 +835,8 @@ class Module
831
835
  def attr_writer(*symbols)
832
836
  `for(var i=0,l=symbols.length;i<l;++i){
833
837
  var a=symbols[i]._value;
834
- this.prototype['m$'+a+'Eql']=function(x){return this['i$'+a]=x;};
838
+ f = this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};
839
+ f._name = a
835
840
  }`
836
841
  return nil
837
842
  end
@@ -5004,16 +5009,36 @@ class Regexp
5004
5009
  Regexp.new(value,options)
5005
5010
  end
5006
5011
 
5007
- # FIX: Incomplete
5008
- def self.escape
5012
+ # call-seq:
5013
+ # Regexp.escape(str) -> string
5014
+ # Regexp.quote(str) -> string
5015
+ #
5016
+ # Escapes any characters that would have special meaning in a regular
5017
+ # expression. Returns a new escaped string, or _str_ if no characters are
5018
+ # escaped. For any string, <tt>Regexp.escape(str) =~ str</tt> will be true.
5019
+ #
5020
+ # Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\.
5021
+ #
5022
+ def self.escape(str)
5023
+ `$q(str._value.replace(/([-.*+?^${}()|[\\]\\/\\\\])/g, '\\\\$1'))`
5009
5024
  end
5010
5025
 
5011
5026
  # FIX: Incomplete
5012
5027
  def self.last_match
5013
5028
  end
5014
5029
 
5015
- # FIX: Incomplete
5016
- def self.quote
5030
+ # call-seq:
5031
+ # Regexp.escape(str) -> string
5032
+ # Regexp.quote(str) -> string
5033
+ #
5034
+ # Escapes any characters that would have special meaning in a regular
5035
+ # expression. Returns a new escaped string, or _str_ if no characters are
5036
+ # escaped. For any string, <tt>Regexp.quote(str) =~ str</tt> will be true.
5037
+ #
5038
+ # Regexp.quote('\\*?{}.') #=> \\\\\*\?\{\}\.
5039
+ #
5040
+ def self.quote(str)
5041
+ `str._value.replace(/([-.*+?^${}()|[\\]\\/\\\\])/g, '\\\\$1')`
5017
5042
  end
5018
5043
 
5019
5044
  # FIX: Incomplete
@@ -6732,7 +6757,7 @@ end
6732
6757
 
6733
6758
  `
6734
6759
 
6735
- c$Exception.prototype.toString=function(){var class_name=this.m$class()._name,str=class_name+': '+(this._message||class_name);m$puts(str+(this._stack!=null?'\\n from '+this.m$backtrace().join('\\n from '):''));return '#<'+str+'>';}
6760
+ c$Exception.prototype.toString=function(){var class_name=this.m$class()._name,str=class_name+': '+(this._message||class_name);console.log(str+(this._stack!=null?'\\n from '+this.m$backtrace().join('\\n from '):''));return '#<'+str+'>';}
6736
6761
  c$NilClass.prototype.toString=function(){return 'nil';};
6737
6762
  c$Range.prototype.toString=function(){return ''+this._start+(this._exclusive?'...':'..')+this._end;};
6738
6763
  c$Regexp.prototype.toString=function(){return '/'+this._source+'/'+(/s/.test(this._options)?'m':'')+(/i/.test(this._options)?'i':'')+(/x/.test(this._options)?'x':'');};
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Sielaff
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-13 00:00:00 -04:00
12
+ date: 2008-10-14 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency