cheri 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +98 -0
  3. data/Rakefile +121 -0
  4. data/examples/hello_world_1.rb +28 -0
  5. data/examples/table_1.rb +44 -0
  6. data/lib/cheri/awt.rb +41 -0
  7. data/lib/cheri/builder.rb +31 -0
  8. data/lib/cheri/builder/awt/connecter.rb +63 -0
  9. data/lib/cheri/builder/awt/constants.rb +1003 -0
  10. data/lib/cheri/builder/awt/main.rb +191 -0
  11. data/lib/cheri/builder/awt/types.rb +220 -0
  12. data/lib/cheri/builder/base.rb +533 -0
  13. data/lib/cheri/builder/config.rb +187 -0
  14. data/lib/cheri/builder/connecter.rb +386 -0
  15. data/lib/cheri/builder/context.rb +655 -0
  16. data/lib/cheri/builder/generator.rb +425 -0
  17. data/lib/cheri/builder/html/charsets.rb +154 -0
  18. data/lib/cheri/builder/html/common.rb +32 -0
  19. data/lib/cheri/builder/html/connecter.rb +57 -0
  20. data/lib/cheri/builder/html/element.rb +156 -0
  21. data/lib/cheri/builder/html/main.rb +116 -0
  22. data/lib/cheri/builder/html/types.rb +123 -0
  23. data/lib/cheri/builder/main.rb +483 -0
  24. data/lib/cheri/builder/swing/connecter.rb +141 -0
  25. data/lib/cheri/builder/swing/constants.rb +420 -0
  26. data/lib/cheri/builder/swing/main.rb +446 -0
  27. data/lib/cheri/builder/swing/types.rb +270 -0
  28. data/lib/cheri/builder/xml/charsets.rb +154 -0
  29. data/lib/cheri/builder/xml/common.rb +32 -0
  30. data/lib/cheri/builder/xml/connecter.rb +42 -0
  31. data/lib/cheri/builder/xml/element.rb +189 -0
  32. data/lib/cheri/builder/xml/main.rb +130 -0
  33. data/lib/cheri/builder/xml/types.rb +36 -0
  34. data/lib/cheri/cheri.rb +70 -0
  35. data/lib/cheri/cjx.rb +3 -0
  36. data/lib/cheri/explorer.rb +32 -0
  37. data/lib/cheri/explorer/explorer.rb +560 -0
  38. data/lib/cheri/html.rb +31 -0
  39. data/lib/cheri/image/Delete24.gif +0 -0
  40. data/lib/cheri/image/Find24.gif +0 -0
  41. data/lib/cheri/image/FindAgain24.gif +0 -0
  42. data/lib/cheri/image/Refresh24.gif +0 -0
  43. data/lib/cheri/image/Search24.gif +0 -0
  44. data/lib/cheri/image/Thumbs.db +0 -0
  45. data/lib/cheri/image/cheri_icon_16x16.png +0 -0
  46. data/lib/cheri/image/cheri_icon_24x24.png +0 -0
  47. data/lib/cheri/image/cheri_logo_medium.png +0 -0
  48. data/lib/cheri/image/close_10x10.png +0 -0
  49. data/lib/cheri/image/close_10x10s.png +0 -0
  50. data/lib/cheri/image/close_12x12.png +0 -0
  51. data/lib/cheri/image/close_14x14.png +0 -0
  52. data/lib/cheri/image/close_24x24.png +0 -0
  53. data/lib/cheri/image/close_dim2_12x12.png +0 -0
  54. data/lib/cheri/image/close_dim_12x12.png +0 -0
  55. data/lib/cheri/image/cls_tree.png +0 -0
  56. data/lib/cheri/image/con_tree.png +0 -0
  57. data/lib/cheri/image/jruby_14x16.png +0 -0
  58. data/lib/cheri/image/jruby_logo.png +0 -0
  59. data/lib/cheri/image/mod_tree.png +0 -0
  60. data/lib/cheri/image/obj_tree.png +0 -0
  61. data/lib/cheri/image/ruby_16x16.png +0 -0
  62. data/lib/cheri/image/vars_tree.png +0 -0
  63. data/lib/cheri/java.rb +26 -0
  64. data/lib/cheri/java/builder.rb +28 -0
  65. data/lib/cheri/java/builder/main.rb +407 -0
  66. data/lib/cheri/java/builder/util.rb +480 -0
  67. data/lib/cheri/java/java.rb +56 -0
  68. data/lib/cheri/jruby.rb +32 -0
  69. data/lib/cheri/jruby/explorer.rb +43 -0
  70. data/lib/cheri/jruby/explorer/common.rb +38 -0
  71. data/lib/cheri/jruby/explorer/dialogs.rb +383 -0
  72. data/lib/cheri/jruby/explorer/explorer.rb +904 -0
  73. data/lib/cheri/jruby/explorer/splash.rb +80 -0
  74. data/lib/cheri/jruby/explorer/viewer.rb +619 -0
  75. data/lib/cheri/jruby/explorer/viewers.rb +1057 -0
  76. data/lib/cheri/jruby/jruby.rb +59 -0
  77. data/lib/cheri/swing.rb +41 -0
  78. data/lib/cheri/xml.rb +31 -0
  79. metadata +135 -0
@@ -0,0 +1,32 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+
26
+ module Cheri
27
+ module Html
28
+ VERSION = Cheri::VERSION
29
+ class HtmlException < Cheri::CheriException; end
30
+ class BuilderException < Cheri::Builder::BuilderException; end
31
+ end #Html
32
+ end #Cheri
@@ -0,0 +1,57 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+ module Cheri
26
+ module Html
27
+
28
+ HtmlConnecter = Cheri::Builder::TypeConnecter.new do
29
+
30
+ # This covers the general case, and is all that is really
31
+ # required here.
32
+ type HtmlElement do
33
+ connect HtmlElement, :add
34
+ connect Cheri::Builder::Content
35
+ # something non-html...
36
+ connect Object, :add
37
+ end
38
+
39
+ # These provide more specific, and therefore more efficient (faster)
40
+ # matching, as we won't have to search up the ancestor chain.
41
+ type [Elem, EmptyElem, TextElem, EscElem, HtmlElem, BodyElem,
42
+ HeadElem, TableElem, ProcElem] do
43
+ connect Elem, :add
44
+ connect EmptyElem, :add
45
+ connect TextElem, :add
46
+ connect EscElem, :add
47
+ connect HtmlElem, :add
48
+ connect BodyElem, :add
49
+ connect HeadElem, :add
50
+ connect TableElem, :add
51
+ connect ProcElem, :add
52
+ end
53
+
54
+ end #HtmlConnecter
55
+
56
+ end #Html
57
+ end #Cheri
@@ -0,0 +1,156 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+
26
+ module Cheri
27
+ module Html
28
+
29
+ # Marker 'interface' used by connecter
30
+ module HtmlElement
31
+ end
32
+
33
+
34
+ # Included by all Cheri::Html builders
35
+ module HtmlBuilder
36
+ def esc(inp,out=nil)
37
+ if @ctx[:html_esc] && (cs = Charsets.charset(inp))
38
+ cs.xlat(inp,(out ||= ''))
39
+ out
40
+ elsif out
41
+ out << inp
42
+ else
43
+ inp
44
+ end
45
+ end
46
+ end #XmlBuilder
47
+
48
+ class Elem
49
+ include Cheri::Builder::MarkupBuilder
50
+ include HtmlBuilder
51
+ include HtmlElement
52
+
53
+ def mod
54
+ Cheri::Html
55
+ end
56
+ end
57
+
58
+ class EmptyElem
59
+ include Cheri::Builder::EmptyMarkupBuilder
60
+ include HtmlBuilder
61
+ include HtmlElement
62
+
63
+ def mod
64
+ Cheri::Html
65
+ end
66
+
67
+ def content?(value)
68
+ raise HtmlException,"content not allowed for empty element #{@sym}: #{value}"
69
+ end
70
+ end
71
+
72
+
73
+ class TextElem
74
+ include Cheri::Builder::Builder
75
+ include Cheri::Builder::Content
76
+ include Cheri::Builder::ContentArgs
77
+ include HtmlBuilder
78
+
79
+ def mod
80
+ Cheri::Html
81
+ end
82
+
83
+ def object
84
+ self
85
+ end
86
+
87
+ def run
88
+ value = @ctx.call(self,&@blk) if @blk
89
+ add(value) if value && !(Appendable === value)
90
+ self
91
+ end
92
+
93
+ # Appends content to +str+, or to an empty string if +str+ is omitted.
94
+ # Returns the result.
95
+ def to_s(str='')
96
+ @cont.each do |c|
97
+ if String === c
98
+ esc(c,str)
99
+ else
100
+ esc(c.to_s,str)
101
+ end
102
+ end if @cont
103
+ str
104
+ end
105
+
106
+ # Appends content to +ios+. Returns the result.
107
+ def to_io(ios)
108
+ @cont.each do |c|
109
+ if String === c
110
+ ios << esc(c)
111
+ else
112
+ ios << esc(c.to_s)
113
+ end
114
+ end if @cont
115
+ ios
116
+ end
117
+
118
+ end
119
+
120
+ class EscElem < TextElem
121
+
122
+ def esc(inp,out=nil)
123
+ if (cs = Charsets.charset(inp))
124
+ cs.xlat(inp,(out ||= ''))
125
+ out
126
+ elsif out
127
+ out << inp
128
+ else
129
+ inp
130
+ end
131
+ end
132
+
133
+ end
134
+
135
+ # TODO: special handling for these:
136
+
137
+ class HtmlElem < Elem
138
+ end
139
+
140
+ class BodyElem < Elem
141
+ end
142
+
143
+ class HeadElem < Elem
144
+ end
145
+
146
+ class TableElem < Elem
147
+ end
148
+
149
+ class FramesetElem < Elem
150
+ end
151
+
152
+ class ProcElem < Elem
153
+ end
154
+
155
+ end #Html
156
+ end #Cheri
@@ -0,0 +1,116 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+
26
+ module Cheri
27
+ module Html
28
+
29
+ include Cheri::Builder
30
+
31
+ class << self
32
+ def append_features(clazz)
33
+ Cheri::Builder.module_included(self,clazz)
34
+ super
35
+ end
36
+ private :append_features
37
+
38
+ def factory
39
+ HtmlFactory
40
+ end
41
+
42
+ def connecter
43
+ HtmlConnecter
44
+ end
45
+
46
+ end #self
47
+
48
+ # Instance methods
49
+
50
+ # call-seq:
51
+ # html([*args] [, &block]) -> HtmlProxy if no block given, else result of block
52
+ #
53
+ def html(*r,&k)
54
+ if (ctx = __cheri_ctx)
55
+ if k
56
+
57
+ # TODO: search stack for Html?
58
+ # new HtmlElement if stack empty, maybe other cases?
59
+ if ctx.tos(HtmlElement)
60
+ HtmlFrame.new(ctx,*r,&k).run
61
+ else
62
+ ctx.msend(Cheri::Html,:html,*r,&k)
63
+ end
64
+
65
+ else
66
+ ctx[:html_proxy] ||= HtmlProxy.new(ctx,*r)
67
+ end
68
+ end
69
+ end
70
+ private :html
71
+
72
+
73
+ module HtmlFactory
74
+ def self.builder(ctx,sym,*r,&k)
75
+ clazz = Types[sym]
76
+ clazz ? clazz.new(ctx,sym,*r,&k) : nil
77
+ end
78
+ end #HtmlFactory
79
+
80
+ class HtmlProxy < Cheri::Builder::BaseProxy
81
+
82
+ impl(Types.keys)
83
+
84
+ def mod
85
+ Cheri::Html
86
+ end
87
+ private :mod
88
+
89
+ def [](opts)
90
+ if Symbol === opts
91
+ case opts
92
+ when :esc : @ctx[:html_esc] = true
93
+ else raise ArgumentError,"invalid simple html option: :#{opts}"
94
+ end
95
+ elsif Hash === opts
96
+ @ctx[:html_esc] = opts[:esc] != false if opts[:esc] != nil
97
+ else
98
+ raise Cheri.type_error(opts,Hash,Symbol)
99
+ end
100
+ nil
101
+ end
102
+ end #HtmlProxy
103
+
104
+ class HtmlFrame
105
+ include Cheri::Builder::Frame
106
+ def initialize(ctx,*r,&k)
107
+ super
108
+ @obj = ctx[:html_proxy] ||= HtmlProxy.new(ctx,*r)
109
+ end
110
+ def mod
111
+ Cheri::Html
112
+ end
113
+ end #HtmlFrame
114
+
115
+ end #Html
116
+ end #Cheri
@@ -0,0 +1,123 @@
1
+ #--
2
+ # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ #
24
+
25
+ module Cheri
26
+ module Html
27
+ Types = Hash[
28
+ :tt => Elem,
29
+ :i => Elem,
30
+ :b => Elem,
31
+ :big => Elem,
32
+ :small => Elem,
33
+ :em => Elem,
34
+ :strong => Elem,
35
+ :dfn => Elem,
36
+ :code => Elem,
37
+ :samp => Elem,
38
+ :kbd => Elem,
39
+ :var => Elem,
40
+ :cite => Elem,
41
+ :abbr => Elem,
42
+ :acronym => Elem,
43
+ :sub => Elem,
44
+ :sup => Elem,
45
+ :span => Elem,
46
+ :bdo => Elem,
47
+ :basefont => EmptyElem,
48
+ :font => Elem,
49
+ :br => EmptyElem,
50
+ :body => BodyElem,
51
+ :address => Elem,
52
+ :div => Elem,
53
+ :center => Elem,
54
+ :a => Elem,
55
+ :map => Elem,
56
+ :area => EmptyElem,
57
+ :link => EmptyElem,
58
+ :img => EmptyElem,
59
+ :object => Elem,
60
+ :param => EmptyElem,
61
+ :applet => Elem,
62
+ :hr => EmptyElem,
63
+ :p => Elem,
64
+ :h1 => Elem,
65
+ :h2 => Elem,
66
+ :h3 => Elem,
67
+ :h4 => Elem,
68
+ :h5 => Elem,
69
+ :h6 => Elem,
70
+ :pre => Elem,
71
+ :q => Elem,
72
+ :blockquote => Elem,
73
+ :ins => Elem,
74
+ :del => Elem,
75
+ :dl => Elem,
76
+ :dt => Elem,
77
+ :dd => Elem,
78
+ :ol => Elem,
79
+ :ul => Elem,
80
+ :li => Elem,
81
+ :dir => Elem,
82
+ :menu => Elem,
83
+ :form => Elem,
84
+ :label => Elem,
85
+ :input => EmptyElem,
86
+ :select => Elem,
87
+ :optgroup => Elem,
88
+ :option => Elem,
89
+ :textarea => Elem,
90
+ :fieldset => Elem,
91
+ :legend => Elem,
92
+ :button => Elem,
93
+ :table => TableElem,
94
+ :caption => Elem,
95
+ :thead => Elem,
96
+ :tfoot => Elem,
97
+ :tbody => Elem,
98
+ :colgroup => Elem,
99
+ :col => EmptyElem,
100
+ :tr => Elem,
101
+ :th => Elem,
102
+ :td => Elem,
103
+ :head => HeadElem,
104
+ :title => Elem,
105
+ :base => EmptyElem,
106
+ :meta => EmptyElem,
107
+ :style => Elem,
108
+ :script => Elem,
109
+ :noscript => Elem,
110
+ :html => HtmlElem,
111
+ :frameset => FramesetElem,
112
+ :frame => EmptyElem,
113
+ :text => TextElem,
114
+ :t => TextElem,
115
+ :proc => ProcElem,
116
+ :esc => EscElem
117
+
118
+ # TODO: iframe, noframes
119
+
120
+ ]
121
+
122
+ end #Html
123
+ end #Cheri