red 3.4.1 → 3.4.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 +8 -0
- data/lib/red/assignment_nodes.rb +1 -1
- data/lib/red/definition_nodes.rb +26 -8
- data/lib/red/version.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 3.4.2 2008-08-12
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
* Added Prototype support for constructible class definition.
|
5
|
+
|
6
|
+
* 1 bug fix:
|
7
|
+
* @instance_variable no longer initializes with reduplicated "this". Bug was introduced with addition of incremental operators.
|
8
|
+
|
1
9
|
== 3.4.1 2008-08-09
|
2
10
|
|
3
11
|
* 1 major enhancement:
|
data/lib/red/assignment_nodes.rb
CHANGED
@@ -42,7 +42,7 @@ module Red
|
|
42
42
|
def compile_node(options = {})
|
43
43
|
receiver = "this.%s" % @variable_name.compile_node
|
44
44
|
return self.compile_increment(:receiver => receiver) if self.call_to_increment?
|
45
|
-
return "
|
45
|
+
return "%s = %s" % [receiver, @expression.compile_node(:as_argument => true)]
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/red/definition_nodes.rb
CHANGED
@@ -2,18 +2,25 @@ module Red
|
|
2
2
|
class DefinitionNode # :nodoc:
|
3
3
|
class ClassNode # :nodoc:
|
4
4
|
def initialize(class_name, superclass, scope)
|
5
|
-
raise(BuildError::NoClassInheritance, "Class inheritance is currently not supported#{"for the #{@@red_library} JavaScript library";''}") if superclass
|
5
|
+
raise(BuildError::NoClassInheritance, "Class inheritance is currently not supported#{" for the #{@@red_library} JavaScript library";''}") if superclass
|
6
6
|
old_class = @@red_class
|
7
7
|
@@red_class = @class = class_name
|
8
8
|
@class_name, @superclass = [class_name, superclass].build_nodes
|
9
9
|
block_node = scope.assoc(:block) || scope
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
10
|
+
case @@red_library
|
11
|
+
when :Prototype
|
12
|
+
@initializer = block_node.rassoc(:initialize)
|
13
|
+
@properties = block_node.select {|node| (node.first == :cvdecl) rescue false }.build_nodes
|
14
|
+
@functions = block_node.select {|node| ![:block, :scope].include?(node) && ((node.first != :cvdecl) rescue false) }.build_nodes
|
15
|
+
else
|
16
|
+
if initializer_node = block_node.rassoc(:initialize)
|
17
|
+
args_node = initializer_node.assoc(:scope).assoc(:block).assoc(:args)
|
18
|
+
@arguments = (args_node[1..-1] || []).build_nodes
|
19
|
+
@initializer = initializer_node.assoc(:scope).assoc(:block).reject {|node| node == args_node}.build_node
|
20
|
+
end
|
21
|
+
@properties = block_node.select {|node| (node.first == :cvdecl) rescue false }.build_nodes
|
22
|
+
@functions = block_node.select {|node| (node != initializer_node) && ![:block, :scope].include?(node) && ((node.first != :cvdecl) rescue false) }.build_nodes
|
14
23
|
end
|
15
|
-
@properties = block_node.select {|node| (node.first == :cvdecl) rescue false }.build_nodes
|
16
|
-
@functions = block_node.select {|node| (node != initializer_node) && ![:block, :scope].include?(node) && ((node.first != :cvdecl) rescue false) }.build_nodes
|
17
24
|
@@red_class = old_class
|
18
25
|
end
|
19
26
|
|
@@ -21,7 +28,12 @@ module Red
|
|
21
28
|
old_class = @@red_class
|
22
29
|
@@red_class = @class
|
23
30
|
if @initializer
|
24
|
-
|
31
|
+
case @@red_library
|
32
|
+
when :Prototype
|
33
|
+
output = self.compile_as_prototype_class
|
34
|
+
else
|
35
|
+
output = self.compile_as_standard_class
|
36
|
+
end
|
25
37
|
else
|
26
38
|
output = self.compile_as_virtual_class
|
27
39
|
end
|
@@ -29,6 +41,12 @@ module Red
|
|
29
41
|
return output
|
30
42
|
end
|
31
43
|
|
44
|
+
def compile_as_prototype_class
|
45
|
+
class_name = @class_name.compile_node
|
46
|
+
slots = (@properties | @functions).compile_nodes(:as_prototype => true).compact.join(', ')
|
47
|
+
return "%s%s = Class.create({ %s })" % [self.var?, class_name, slots]
|
48
|
+
end
|
49
|
+
|
32
50
|
def compile_as_standard_class(options = {})
|
33
51
|
class_name = @class_name.compile_node
|
34
52
|
arguments = @arguments.compile_nodes.join(', ')
|
data/lib/red/version.rb
CHANGED
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: 3.4.
|
4
|
+
version: 3.4.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-08-
|
12
|
+
date: 2008-08-12 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|