rhodes 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/LICENSE +19 -674
- data/Manifest.txt +21 -4
- data/README.textile +5 -36
- data/Rakefile +5 -0
- data/lib/build/jake.rb +3 -1
- data/lib/extensions/rexml/rexml/document.rb +2 -0
- data/lib/extensions/rexml/rexml/parsers/baseparser.rb +0 -6
- data/lib/extensions/rhoxml/rexml/child.rb +96 -0
- data/lib/extensions/rhoxml/rexml/document.rb +527 -0
- data/lib/extensions/rhoxml/rexml/element.rb +987 -0
- data/lib/extensions/rhoxml/rexml/encoding.rb +71 -0
- data/lib/extensions/rhoxml/rexml/encodings/US-ASCII.rb +30 -0
- data/lib/extensions/rhoxml/rexml/encodings/UTF-16.rb +35 -0
- data/lib/extensions/rhoxml/rexml/encodings/UTF-8.rb +18 -0
- data/lib/extensions/rhoxml/rexml/namespace.rb +47 -0
- data/lib/extensions/rhoxml/rexml/node.rb +76 -0
- data/lib/extensions/rhoxml/rexml/parent.rb +166 -0
- data/lib/extensions/rhoxml/rexml/parseexception.rb +51 -0
- data/lib/extensions/rhoxml/rexml/parsers/baseparser.rb +531 -0
- data/lib/extensions/rhoxml/rexml/parsers/treeparser.rb +100 -0
- data/lib/extensions/rhoxml/rexml/parsers/xpathparser.rb +698 -0
- data/lib/extensions/rhoxml/rexml/set.rb +1274 -0
- data/lib/extensions/rhoxml/rexml/source.rb +258 -0
- data/lib/extensions/rhoxml/rexml/xmltokens.rb +18 -0
- data/lib/extensions/rhoxml/rexml/xpath.rb +77 -0
- data/lib/extensions/rhoxml/rexml/xpath_parser.rb +806 -0
- data/lib/framework/builtinME.rb +2 -0
- data/lib/framework/dateME.rb +5 -1
- data/lib/framework/rho/render.rb +10 -2
- data/lib/framework/rhom/rhom_object_factory.rb +2 -1
- data/lib/framework/singleton.rb +1 -1
- data/platform/android/Rhodes/jni/src/rhodes.cpp +2 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +23 -18
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +42 -69
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +59 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Annotation.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +97 -85
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/SmsUriHandler.java +52 -0
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +38 -14
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +44 -2
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +1 -1
- data/platform/bb/rhodes/rhodes.jdp +4 -4
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +8 -4
- data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +149 -17
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +20 -17
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +54 -28
- data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +1 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +37 -11
- data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +49 -19
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +6 -0
- data/platform/iphone/Classes/MapView/GoogleGeocoder.h +6 -7
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +70 -70
- data/platform/iphone/Classes/MapView/MapAnnotation.h +5 -3
- data/platform/iphone/Classes/MapView/MapAnnotation.m +10 -8
- data/platform/iphone/Classes/MapView/MapViewController.h +13 -10
- data/platform/iphone/Classes/MapView/MapViewController.m +131 -72
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +13 -1
- data/platform/iphone/Classes/SimpleMainView.m +0 -1
- data/platform/iphone/Classes/TabbedMainView.m +5 -6
- data/platform/shared/common/RhoTime.h +2 -2
- data/platform/shared/common/RhodesApp.cpp +1 -1
- data/platform/shared/db/DBAdapter.cpp +6 -0
- data/platform/shared/net/CURLNetRequest.cpp +23 -1
- data/platform/shared/ruby/thread_win32.c +9 -1
- data/platform/shared/rubyJVM/src/com/rho/Capabilities.java +6 -0
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +1 -1
- data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubySymbol_Methods.java +6 -1
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyTime_Methods.java +3 -3
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/InputStreamExecutor.java +1 -1
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyArray.java +15 -3
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyString.java +10 -2
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTime.java +12 -1
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyKernelModule.java +18 -9
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubySymbol.java +5 -0
- data/platform/shared/rubyJVM/src/org/json/me/JSONArray.java +2 -1
- data/platform/shared/unzip/unzip.cpp +1 -1
- data/platform/wm/build/wm.rake +27 -6
- data/platform/wm/rhodes/Alert.cpp +335 -5
- data/platform/wm/rhodes/Alert.h +84 -1
- data/platform/wm/rhodes/MainWindow.cpp +28 -6
- data/platform/wm/rhodes/MainWindow.h +7 -2
- data/platform/wm/rhodes/Rhodes.cpp +23 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +2 -1
- data/platform/wm/rhodes/stdafx.h +1 -0
- data/platform/wm/tools/detool/detool.cpp +405 -14
- data/rakefile.rb +5 -0
- data/res/build-tools/detool.exe +0 -0
- data/res/generators/rhogen.rb +2 -0
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/spec/fixtures/object_values.txt +1 -1
- data/spec/framework_spec/app/spec/pagination/fixtures/object_values.txt +1 -1
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +12 -12
- metadata +23 -6
- data/LICENSING_OPTIONS +0 -1
- data/platform/bb/build/rhodesApp.rapc +0 -9
- data/res/generators/templates/source/source_adapter.rb +0 -48
- data/rhobuild.yml +0 -37
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- mode: ruby; ruby-indent-level: 2; indent-tabs-mode: t; tab-width: 2 -*- vim: sw=2 ts=2
|
2
|
+
module REXML
|
3
|
+
module Encoding
|
4
|
+
@encoding_methods = {}
|
5
|
+
def self.register(enc, &block)
|
6
|
+
@encoding_methods[enc] = block
|
7
|
+
end
|
8
|
+
def self.apply(obj, enc)
|
9
|
+
@encoding_methods[enc][obj]
|
10
|
+
end
|
11
|
+
def self.encoding_method(enc)
|
12
|
+
@encoding_methods[enc]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Native, default format is UTF-8, so it is declared here rather than in
|
16
|
+
# an encodings/ definition.
|
17
|
+
UTF_8 = 'UTF-8'
|
18
|
+
UTF_16 = 'UTF-16'
|
19
|
+
UNILE = 'UNILE'
|
20
|
+
|
21
|
+
# ID ---> Encoding name
|
22
|
+
attr_reader :encoding
|
23
|
+
def encoding=( enc )
|
24
|
+
old_verbosity = $VERBOSE
|
25
|
+
begin
|
26
|
+
$VERBOSE = false
|
27
|
+
enc = enc.nil? ? nil : enc.upcase
|
28
|
+
return false if defined?( @encoding ) and enc == @encoding
|
29
|
+
if enc and enc != UTF_8
|
30
|
+
@encoding = enc
|
31
|
+
raise ArgumentError, "Bad encoding name #@encoding" unless @encoding =~ /^[\w-]+$/
|
32
|
+
@encoding.untaint
|
33
|
+
begin
|
34
|
+
require 'rexml/encodings/ICONV.rb'
|
35
|
+
Encoding.apply(self, "ICONV")
|
36
|
+
rescue LoadError, Exception
|
37
|
+
begin
|
38
|
+
enc_file = File.join( "rexml", "encodings", "#@encoding.rb" )
|
39
|
+
require enc_file
|
40
|
+
Encoding.apply(self, @encoding)
|
41
|
+
rescue LoadError => err
|
42
|
+
puts err.message
|
43
|
+
raise ArgumentError, "No decoder found for encoding #@encoding. Please install iconv."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
else
|
47
|
+
@encoding = UTF_8
|
48
|
+
require 'rexml/encodings/UTF-8.rb'
|
49
|
+
Encoding.apply(self, @encoding)
|
50
|
+
end
|
51
|
+
ensure
|
52
|
+
$VERBOSE = old_verbosity
|
53
|
+
end
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_encoding str
|
58
|
+
# We have to recognize UTF-16, LSB UTF-16, and UTF-8
|
59
|
+
if str[0,2] == "\xfe\xff"
|
60
|
+
str[0,2] = ""
|
61
|
+
return UTF_16
|
62
|
+
elsif str[0,2] == "\xff\xfe"
|
63
|
+
str[0,2] = ""
|
64
|
+
return UNILE
|
65
|
+
end
|
66
|
+
str =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\1\s+encoding\s*=\s*(["'])(.*?)\2/m
|
67
|
+
return $3.upcase if $3
|
68
|
+
return UTF_8
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module REXML
|
2
|
+
module Encoding
|
3
|
+
# Convert from UTF-8
|
4
|
+
def encode_ascii content
|
5
|
+
array_utf8 = content.unpack('U*')
|
6
|
+
array_enc = []
|
7
|
+
array_utf8.each do |num|
|
8
|
+
if num <= 0x7F
|
9
|
+
array_enc << num
|
10
|
+
else
|
11
|
+
# Numeric entity (&#nnnn;); shard by Stefan Scholl
|
12
|
+
array_enc.concat "&\##{num};".unpack('C*')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
array_enc.pack('C*')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Convert to UTF-8
|
19
|
+
def decode_ascii(str)
|
20
|
+
str.unpack('C*').pack('U*')
|
21
|
+
end
|
22
|
+
|
23
|
+
register("US-ASCII") do |obj|
|
24
|
+
class << obj
|
25
|
+
alias decode decode_ascii
|
26
|
+
alias encode encode_ascii
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module REXML
|
2
|
+
module Encoding
|
3
|
+
def encode_utf16 content
|
4
|
+
array_utf8 = content.unpack("U*")
|
5
|
+
array_enc = []
|
6
|
+
array_utf8.each do |num|
|
7
|
+
if ((num>>16) > 0)
|
8
|
+
array_enc << 0
|
9
|
+
array_enc << ??
|
10
|
+
else
|
11
|
+
array_enc << (num >> 8)
|
12
|
+
array_enc << (num & 0xFF)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
array_enc.pack('C*')
|
16
|
+
end
|
17
|
+
|
18
|
+
def decode_utf16(str)
|
19
|
+
str = str[2..-1] if /^\376\377/n =~ str
|
20
|
+
array_enc=str.unpack('C*')
|
21
|
+
array_utf8 = []
|
22
|
+
0.step(array_enc.size-1, 2){|i|
|
23
|
+
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
|
24
|
+
}
|
25
|
+
array_utf8.pack('U*')
|
26
|
+
end
|
27
|
+
|
28
|
+
register(UTF_16) do |obj|
|
29
|
+
class << obj
|
30
|
+
alias decode decode_utf16
|
31
|
+
alias encode encode_utf16
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rexml/xmltokens'
|
2
|
+
|
3
|
+
module REXML
|
4
|
+
# Adds named attributes to an object.
|
5
|
+
module Namespace
|
6
|
+
# The name of the object, valid if set
|
7
|
+
attr_reader :name, :expanded_name
|
8
|
+
# The expanded name of the object, valid if name is set
|
9
|
+
attr_accessor :prefix
|
10
|
+
include XMLTokens
|
11
|
+
NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
|
12
|
+
|
13
|
+
# Sets the name and the expanded name
|
14
|
+
def name=( name )
|
15
|
+
@expanded_name = name
|
16
|
+
name =~ NAMESPLIT
|
17
|
+
if $1
|
18
|
+
@prefix = $1
|
19
|
+
else
|
20
|
+
@prefix = ""
|
21
|
+
@namespace = ""
|
22
|
+
end
|
23
|
+
@name = $2
|
24
|
+
end
|
25
|
+
|
26
|
+
# Compares names optionally WITH namespaces
|
27
|
+
def has_name?( other, ns=nil )
|
28
|
+
if ns
|
29
|
+
return (namespace() == ns and name() == other)
|
30
|
+
elsif other.include? ":"
|
31
|
+
return fully_expanded_name == other
|
32
|
+
else
|
33
|
+
return name == other
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
alias :local_name :name
|
38
|
+
|
39
|
+
# Fully expand the name, even if the prefix wasn't specified in the
|
40
|
+
# source file.
|
41
|
+
def fully_expanded_name
|
42
|
+
ns = prefix
|
43
|
+
return "#{ns}:#@name" if ns.size > 0
|
44
|
+
return @name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#require "rexml/parseexception"
|
2
|
+
#require "rexml/formatters/pretty"
|
3
|
+
#require "rexml/formatters/default"
|
4
|
+
|
5
|
+
module REXML
|
6
|
+
# Represents a node in the tree. Nodes are never encountered except as
|
7
|
+
# superclasses of other objects. Nodes have siblings.
|
8
|
+
module Node
|
9
|
+
# @return the next sibling (nil if unset)
|
10
|
+
def next_sibling_node
|
11
|
+
return nil if @parent.nil?
|
12
|
+
@parent[ @parent.index(self) + 1 ]
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return the previous sibling (nil if unset)
|
16
|
+
def previous_sibling_node
|
17
|
+
return nil if @parent.nil?
|
18
|
+
ind = @parent.index(self)
|
19
|
+
return nil if ind == 0
|
20
|
+
@parent[ ind - 1 ]
|
21
|
+
end
|
22
|
+
|
23
|
+
# indent::
|
24
|
+
# *DEPRECATED* This parameter is now ignored. See the formatters in the
|
25
|
+
# REXML::Formatters package for changing the output style.
|
26
|
+
def to_s indent=nil
|
27
|
+
unless indent.nil?
|
28
|
+
#Kernel.warn( "#{self.class.name}.to_s(indent) parameter is deprecated" )
|
29
|
+
#f = REXML::Formatters::Pretty.new( indent )
|
30
|
+
#f.write( self, rv = "" )
|
31
|
+
else
|
32
|
+
#f = REXML::Formatters::Default.new
|
33
|
+
#f.write( self, rv = "" )
|
34
|
+
end
|
35
|
+
#return rv
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def indent to, ind
|
40
|
+
if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
|
41
|
+
indentstyle = @parent.context[:indentstyle]
|
42
|
+
else
|
43
|
+
indentstyle = ' '
|
44
|
+
end
|
45
|
+
to << indentstyle*ind unless ind<1
|
46
|
+
end
|
47
|
+
|
48
|
+
def parent?
|
49
|
+
false;
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# Visit all subnodes of +self+ recursively
|
54
|
+
def each_recursive(&block) # :yields: node
|
55
|
+
self.elements.each {|node|
|
56
|
+
block.call(node)
|
57
|
+
node.each_recursive(&block)
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Find (and return) first subnode (recursively) for which the block
|
62
|
+
# evaluates to true. Returns +nil+ if none was found.
|
63
|
+
def find_first_recursive(&block) # :yields: node
|
64
|
+
each_recursive {|node|
|
65
|
+
return node if block.call(node)
|
66
|
+
}
|
67
|
+
return nil
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the position that +self+ holds in its parent's array, indexed
|
71
|
+
# from 1.
|
72
|
+
def index_in_parent
|
73
|
+
parent.index(self)+1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require "rexml/child"
|
2
|
+
|
3
|
+
module REXML
|
4
|
+
# A parent has children, and has methods for accessing them. The Parent
|
5
|
+
# class is never encountered except as the superclass for some other
|
6
|
+
# object.
|
7
|
+
class Parent < Child
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
# Constructor
|
11
|
+
# @param parent if supplied, will be set as the parent of this object
|
12
|
+
def initialize parent=nil
|
13
|
+
super(parent)
|
14
|
+
@children = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def add( object )
|
18
|
+
#puts "PARENT GOTS #{size} CHILDREN"
|
19
|
+
object.parent = self
|
20
|
+
@children << object
|
21
|
+
#puts "PARENT NOW GOTS #{size} CHILDREN"
|
22
|
+
object
|
23
|
+
end
|
24
|
+
|
25
|
+
alias :push :add
|
26
|
+
alias :<< :push
|
27
|
+
|
28
|
+
def unshift( object )
|
29
|
+
object.parent = self
|
30
|
+
@children.unshift object
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete( object )
|
34
|
+
found = false
|
35
|
+
@children.delete_if {|c| c.equal?(object) and found = true }
|
36
|
+
object.parent = nil if found
|
37
|
+
end
|
38
|
+
|
39
|
+
def each(&block)
|
40
|
+
@children.each(&block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete_if( &block )
|
44
|
+
@children.delete_if(&block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_at( index )
|
48
|
+
@children.delete_at index
|
49
|
+
end
|
50
|
+
|
51
|
+
def each_index( &block )
|
52
|
+
@children.each_index(&block)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Fetches a child at a given index
|
56
|
+
# @param index the Integer index of the child to fetch
|
57
|
+
def []( index )
|
58
|
+
@children[index]
|
59
|
+
end
|
60
|
+
|
61
|
+
alias :each_child :each
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# Set an index entry. See Array.[]=
|
66
|
+
# @param index the index of the element to set
|
67
|
+
# @param opt either the object to set, or an Integer length
|
68
|
+
# @param child if opt is an Integer, this is the child to set
|
69
|
+
# @return the parent (self)
|
70
|
+
def []=( *args )
|
71
|
+
args[-1].parent = self
|
72
|
+
@children[*args[0..-2]] = args[-1]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Inserts an child before another child
|
76
|
+
# @param child1 this is either an xpath or an Element. If an Element,
|
77
|
+
# child2 will be inserted before child1 in the child list of the parent.
|
78
|
+
# If an xpath, child2 will be inserted before the first child to match
|
79
|
+
# the xpath.
|
80
|
+
# @param child2 the child to insert
|
81
|
+
# @return the parent (self)
|
82
|
+
def insert_before( child1, child2 )
|
83
|
+
if child1.kind_of? String
|
84
|
+
child1 = XPath.first( self, child1 )
|
85
|
+
child1.parent.insert_before child1, child2
|
86
|
+
else
|
87
|
+
ind = index(child1)
|
88
|
+
child2.parent.delete(child2) if child2.parent
|
89
|
+
@children[ind,0] = child2
|
90
|
+
child2.parent = self
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# Inserts an child after another child
|
96
|
+
# @param child1 this is either an xpath or an Element. If an Element,
|
97
|
+
# child2 will be inserted after child1 in the child list of the parent.
|
98
|
+
# If an xpath, child2 will be inserted after the first child to match
|
99
|
+
# the xpath.
|
100
|
+
# @param child2 the child to insert
|
101
|
+
# @return the parent (self)
|
102
|
+
def insert_after( child1, child2 )
|
103
|
+
if child1.kind_of? String
|
104
|
+
child1 = XPath.first( self, child1 )
|
105
|
+
child1.parent.insert_after child1, child2
|
106
|
+
else
|
107
|
+
ind = index(child1)+1
|
108
|
+
child2.parent.delete(child2) if child2.parent
|
109
|
+
@children[ind,0] = child2
|
110
|
+
child2.parent = self
|
111
|
+
end
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_a
|
116
|
+
@children.dup
|
117
|
+
end
|
118
|
+
|
119
|
+
# Fetches the index of a given child
|
120
|
+
# @param child the child to get the index of
|
121
|
+
# @return the index of the child, or nil if the object is not a child
|
122
|
+
# of this parent.
|
123
|
+
def index( child )
|
124
|
+
count = -1
|
125
|
+
@children.find { |i| count += 1 ; i.hash == child.hash }
|
126
|
+
count
|
127
|
+
end
|
128
|
+
|
129
|
+
# @return the number of children of this parent
|
130
|
+
def size
|
131
|
+
@children.size
|
132
|
+
end
|
133
|
+
|
134
|
+
alias :length :size
|
135
|
+
|
136
|
+
# Replaces one child with another, making sure the nodelist is correct
|
137
|
+
# @param to_replace the child to replace (must be a Child)
|
138
|
+
# @param replacement the child to insert into the nodelist (must be a
|
139
|
+
# Child)
|
140
|
+
def replace_child( to_replace, replacement )
|
141
|
+
@children.map! {|c| c.equal?( to_replace ) ? replacement : c }
|
142
|
+
to_replace.parent = nil
|
143
|
+
replacement.parent = self
|
144
|
+
end
|
145
|
+
|
146
|
+
# Deeply clones this object. This creates a complete duplicate of this
|
147
|
+
# Parent, including all descendants.
|
148
|
+
def deep_clone
|
149
|
+
cl = clone()
|
150
|
+
each do |child|
|
151
|
+
if child.kind_of? Parent
|
152
|
+
cl << child.deep_clone
|
153
|
+
else
|
154
|
+
cl << child.clone
|
155
|
+
end
|
156
|
+
end
|
157
|
+
cl
|
158
|
+
end
|
159
|
+
|
160
|
+
alias :children :to_a
|
161
|
+
|
162
|
+
def parent?
|
163
|
+
true
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|