flashsdk_sqe 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +41 -0
  3. data/POSTINSTALL.rdoc +81 -0
  4. data/README.textile +79 -0
  5. data/VERSION +1 -0
  6. data/bin/flashlog +8 -0
  7. data/bin/flashplayer +9 -0
  8. data/bin/sprout-as3 +9 -0
  9. data/bin/sprout-flex +8 -0
  10. data/ext/CloseFlashPlayerForDumbassOSX.scpt +6 -0
  11. data/ext/OpenFlashPlayerForDumbassOSX.scpt +12 -0
  12. data/flashsdk_sqe.gemspec +25 -0
  13. data/lib/flashplayer.rb +9 -0
  14. data/lib/flashplayer/errors.rb +12 -0
  15. data/lib/flashplayer/executable.rb +142 -0
  16. data/lib/flashplayer/log_file.rb +100 -0
  17. data/lib/flashplayer/mm_config.rb +96 -0
  18. data/lib/flashplayer/module.rb +51 -0
  19. data/lib/flashplayer/specification.rb +45 -0
  20. data/lib/flashplayer/system_mixins.rb +98 -0
  21. data/lib/flashplayer/task.legacy.rb +293 -0
  22. data/lib/flashplayer/task.rb +62 -0
  23. data/lib/flashplayer/trust.rb +45 -0
  24. data/lib/flashsdk.rb +24 -0
  25. data/lib/flashsdk/acompc.rb +29 -0
  26. data/lib/flashsdk/adl.rb +83 -0
  27. data/lib/flashsdk/adt.rb +276 -0
  28. data/lib/flashsdk/amxmlc.rb +28 -0
  29. data/lib/flashsdk/asdoc.rb +164 -0
  30. data/lib/flashsdk/compc.rb +124 -0
  31. data/lib/flashsdk/compiler_base.rb +1131 -0
  32. data/lib/flashsdk/fcsh.rb +173 -0
  33. data/lib/flashsdk/fcsh_socket.rb +167 -0
  34. data/lib/flashsdk/fdb.rb +833 -0
  35. data/lib/flashsdk/generators/class_generator.rb +87 -0
  36. data/lib/flashsdk/generators/flash_helper.rb +234 -0
  37. data/lib/flashsdk/generators/flex_project_generator.rb +30 -0
  38. data/lib/flashsdk/generators/project_generator.rb +31 -0
  39. data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
  40. data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
  41. data/lib/flashsdk/generators/templates/ActionScript3RunnerClass.as +19 -0
  42. data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
  43. data/lib/flashsdk/generators/templates/Flex4Application.mxml +45 -0
  44. data/lib/flashsdk/generators/templates/Flex4Main.css +7 -0
  45. data/lib/flashsdk/generators/templates/Flex4Rakefile.rb +34 -0
  46. data/lib/flashsdk/generators/templates/Flex4RunnerClass.mxml +29 -0
  47. data/lib/flashsdk/generators/templates/FlexTestRunner.mxml +0 -0
  48. data/lib/flashsdk/generators/templates/Gemfile +5 -0
  49. data/lib/flashsdk/generators/templates/rakefile.rb +79 -0
  50. data/lib/flashsdk/module.rb +107 -0
  51. data/lib/flashsdk/mxmlc.rb +160 -0
  52. data/lib/flex3.rb +54 -0
  53. data/lib/flex4.rb +115 -0
  54. data/pkg/flashsdk_sqe-0.0.1.gem +0 -0
  55. data/rakefile.rb +42 -0
  56. data/test/fixtures/acompc/simple/SomeAirFile.as +11 -0
  57. data/test/fixtures/air/simple/SomeProject.apk +1 -0
  58. data/test/fixtures/air/simple/SomeProject.as +11 -0
  59. data/test/fixtures/air/simple/SomeProject.mxml +9 -0
  60. data/test/fixtures/air/simple/SomeProject.pfx +0 -0
  61. data/test/fixtures/air/simple/SomeProject.swf +0 -0
  62. data/test/fixtures/air/simple/SomeProject.xml +13 -0
  63. data/test/fixtures/asdoc/lib/OtherFile.as +17 -0
  64. data/test/fixtures/asdoc/src/SomeFile.as +11 -0
  65. data/test/fixtures/compc/simple/SomeFile.as +11 -0
  66. data/test/fixtures/flashplayer/AsUnit Runner.swf +0 -0
  67. data/test/fixtures/mxmlc/broken/SomeFile.as +10 -0
  68. data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
  69. data/test/fixtures/sdk/fdb +90 -0
  70. data/test/fixtures/sdk/mxmlc +56 -0
  71. data/test/unit/acompc_test.rb +37 -0
  72. data/test/unit/adl_test.rb +32 -0
  73. data/test/unit/adt_test.rb +185 -0
  74. data/test/unit/amxmlc_test.rb +55 -0
  75. data/test/unit/asdoc_test.rb +45 -0
  76. data/test/unit/class_generator_test.rb +56 -0
  77. data/test/unit/compc_test.rb +37 -0
  78. data/test/unit/fake_flashplayer_system.rb +11 -0
  79. data/test/unit/fcsh_socket_test.rb +53 -0
  80. data/test/unit/fcsh_test.rb +55 -0
  81. data/test/unit/fdb_test.rb +54 -0
  82. data/test/unit/flash_helper_test.rb +43 -0
  83. data/test/unit/flashplayer_executable_test.rb +69 -0
  84. data/test/unit/flashplayer_log_file_test.rb +47 -0
  85. data/test/unit/flashplayer_mm_config_test.rb +74 -0
  86. data/test/unit/flashplayer_module_test.rb +56 -0
  87. data/test/unit/flashplayer_task_test.rb +91 -0
  88. data/test/unit/flashplayer_trust_test.rb +30 -0
  89. data/test/unit/flex_compiler_options_test.rb +213 -0
  90. data/test/unit/flex_generator_test.rb +37 -0
  91. data/test/unit/mxmlc_test.rb +65 -0
  92. data/test/unit/project_generator_test.rb +57 -0
  93. data/test/unit/test_helper.rb +18 -0
  94. metadata +200 -0
@@ -0,0 +1,173 @@
1
+
2
+ module FlashSDK
3
+
4
+ class FCSH < Sprout::Executable::Session
5
+
6
+ ##
7
+ # The the Ruby file that will load the expected
8
+ # Sprout::Specification.
9
+ #
10
+ # Default value is 'flex4'
11
+ set :pkg_name, 'flex4'
12
+
13
+ ##
14
+ # The default pkg version
15
+ #
16
+ set :pkg_version, ">= #{FlashSDK::VERSION}"
17
+
18
+ ##
19
+ # The default executable target.
20
+ #
21
+ set :executable, :fcsh
22
+
23
+ ##
24
+ # Set the default prompt that should be presented
25
+ # on stdout when fcsh is ready for input.
26
+ set :prompt, /^\(fcsh\) /
27
+
28
+ ##
29
+ # Clear the saved compilation target
30
+ # from memory.
31
+ #
32
+ # @param id [Integer]
33
+ #
34
+ add_action :clear
35
+
36
+ ##
37
+ # Perform compilation using COMPC and the
38
+ # provided arguments.
39
+ #
40
+ # @param options [String]
41
+ #
42
+ add_action :compc
43
+
44
+ ##
45
+ # Execute a saved compilation from the provided
46
+ # id number.
47
+ #
48
+ # @param id [Integer]
49
+ #
50
+ add_action :compile
51
+
52
+ ##
53
+ # Perform compilation using MXMLC and the
54
+ # provided arguments.
55
+ #
56
+ # @param options [String]
57
+ #
58
+ add_action :mxmlc
59
+
60
+ ##
61
+ # Exit FCSH
62
+ add_action :quit
63
+
64
+
65
+ def system_execute binary, params
66
+ params ||= ''
67
+ ##
68
+ # Combine stdout and stderr for FCSH
69
+ # so that they both arrive on stdout
70
+ params << ' 2<&1'
71
+ super binary, params
72
+ end
73
+
74
+ end
75
+ end
76
+
77
+ ##
78
+ # Rake task that will make any subsequent
79
+ # mxmlc or compc tasks use the FCSH compiler.
80
+ #
81
+ # You can use this task by inserting it
82
+ # before the task you're calling on the
83
+ # command line like:
84
+ #
85
+ # rake fcsh test
86
+ #
87
+ # or:
88
+ #
89
+ # rake fcsh debug
90
+ #
91
+ # Or you can add this task as a prerequisite
92
+ # to your build tasks directly like:
93
+ #
94
+ # mxmlc 'bin/SomeProject.swf' => :fcsh do |t|
95
+ # ...
96
+ # end
97
+ #
98
+ desc "Make subsequent MXMLC or COMPC tasks use FCSH"
99
+ task :fcsh do
100
+ ENV['USE_FCSH'] = 'true'
101
+ end
102
+
103
+ ##
104
+ # Rake task that will make any subsequent
105
+ # mxmlc or compc tasks use the FCSH compiler.
106
+ #
107
+ # You can use this task by inserting it
108
+ # before the task you're calling on the
109
+ # command line like:
110
+ #
111
+ # rake fcsh test
112
+ #
113
+ # or:
114
+ #
115
+ # rake fcsh debug
116
+ #
117
+ # Or you can add this task as a prerequisite
118
+ # to your build tasks directly like:
119
+ #
120
+ # mxmlc 'bin/SomeProject.swf' => :fcsh do |t|
121
+ # ...
122
+ # end
123
+ #
124
+ desc "Make subsequent MXMLC or COMPC tasks use FCSH"
125
+ task :fcsh do
126
+ ENV['USE_FCSH'] = 'true'
127
+ end
128
+ ##
129
+ # Rake task that will make any subsequent
130
+ # mxmlc or compc tasks use the FCSH compiler.
131
+ #
132
+ # You can use this task by inserting it
133
+ # before the task you're calling on the
134
+ # command line like:
135
+ #
136
+ # rake fcsh test
137
+ #
138
+ # or:
139
+ #
140
+ # rake fcsh debug
141
+ #
142
+ # Or you can add this task as a prerequisite
143
+ # to your build tasks directly like:
144
+ #
145
+ # mxmlc 'bin/SomeProject.swf' => :fcsh do |t|
146
+ # ...
147
+ # end
148
+ #
149
+ desc "Make subsequent MXMLC or COMPC tasks use FCSH"
150
+ task :fcsh do
151
+ ENV['USE_FCSH'] = 'true'
152
+ end
153
+
154
+ namespace :fcsh do
155
+ desc "Start the FCSH server"
156
+ task :start do
157
+ server = FlashSDK::FCSHSocket.new
158
+ server.listen ENV['FCSH_PKG_NAME'], ENV['FCSH_PKG_VERSION'], ENV['FCSH_PORT']
159
+ end
160
+
161
+ desc "Clear the cached compilation data"
162
+ task :clear do
163
+ client = FlashSDK::FCSHSocket.new
164
+ client.execute "clear", ENV['FCSH_PORT']
165
+ end
166
+
167
+ desc "Quit the fcsh server"
168
+ task :quit do
169
+ client = FlashSDK::FCSHSocket.new
170
+ client.execute "quit", ENV['FCSH_PORT']
171
+ end
172
+ end
173
+
@@ -0,0 +1,167 @@
1
+ require 'socket'
2
+
3
+ module FlashSDK
4
+
5
+ ##
6
+ # This is a client to the long-running FCSH process.
7
+ #
8
+ # The server side of this connection should be
9
+ # started before starting the client.
10
+ #
11
+ # To do this, just open a new terminal, cd into your
12
+ # project directory, and run:
13
+ #
14
+ # rake fcsh:start
15
+ #
16
+ class FCSHSocket
17
+
18
+ ##
19
+ # The default TCP port that FCSH will use
20
+ # to connect.
21
+ DEFAULT_PORT = 12321
22
+
23
+ attr_accessor :port
24
+
25
+ attr_reader :requests
26
+
27
+ ##
28
+ # Create a new FCSHClient
29
+ def initialize
30
+ @port = DEFAULT_PORT
31
+ @requests = {}
32
+ end
33
+
34
+ def listen pkg_name=nil, pkg_version=nil, port=nil
35
+ port = port || @port
36
+ # Instantiate FCSH:
37
+ fcsh = FlashSDK::FCSH.new
38
+ fcsh.pkg_name = pkg_name unless pkg_name.nil?
39
+ fcsh.pkg_version = pkg_version unless pkg_version.nil?
40
+
41
+ # Notify the outer shell that we're ready:
42
+ Sprout.stdout.puts "FCSH socket open with: #{fcsh.pkg_name} and #{fcsh.pkg_version}, waiting for connections on port #{port}"
43
+ Sprout.stdout.puts ""
44
+
45
+ # Start up the FCSH Session:
46
+ fcsh.execute false
47
+
48
+ # Create a readable IO pipe:
49
+ output = Sprout::OutputBuffer.new
50
+ # Associate the IO pipe with our
51
+ # outputs so that FCSH will write
52
+ # to it.
53
+ Sprout.stdout = output
54
+ Sprout.stderr = output
55
+
56
+ server = TCPServer.new 'localhost', port
57
+
58
+ # Create a thread that will exit
59
+ # when FCSH exits.
60
+ t = Thread.new do
61
+ fcsh.wait
62
+ end
63
+
64
+ while t.alive? do
65
+ Sprout.stdout.puts ""
66
+ session = server.accept
67
+ rendered = render_request session.gets
68
+ parts = rendered.split(" ")
69
+ method = parts.shift.strip
70
+ if parts.size > 0
71
+ fcsh.send method, parts.join(" ")
72
+ else
73
+ fcsh.send method
74
+ end
75
+
76
+ fcsh.wait_for_prompt
77
+
78
+ if method == "clear"
79
+ clear_requests
80
+ end
81
+
82
+ response = "#{rendered}\n"
83
+ response << output.read.gsub(rendered, '')
84
+ session.puts response.gsub(fcsh.prompt, "\n")
85
+ session.flush
86
+ session.close
87
+ end
88
+ end
89
+
90
+ def execute command, port=nil
91
+ duration = Benchmark.measure do
92
+ port = port || @port
93
+ begin
94
+ #Sprout.stdout.puts "[FCSH] #{command}"
95
+ session = TCPSocket.new 'localhost', port
96
+ session.puts command
97
+ response = session.read
98
+ if response.match /Error/
99
+ raise Sprout::Errors::UsageError.new "[FCSH] #{response}"
100
+ else
101
+ Sprout.stdout.puts "[FCSH] #{response}"
102
+ end
103
+ response
104
+ rescue Errno::ECONNREFUSED => e
105
+ message = "[ERROR] "
106
+ message << e.message
107
+ message << ": Could not connect to an FCSH server on port: #{port} at: #{Dir.pwd}.\n\n"
108
+ message << "This is probably because one has not been started. To start a new FCSH server, open a new "
109
+ message << "terminal and run the following:\n\n"
110
+ message << "cd #{Dir.pwd}\n"
111
+ message << "rake fcsh:start\n"
112
+ raise Sprout::Errors::UsageError.new message
113
+ ensure
114
+ if !session.nil? && !session.closed?
115
+ session.flush
116
+ session.close
117
+ end
118
+ end
119
+ end
120
+
121
+ if command.match /^mxmlc|^compc/
122
+ Sprout.stdout.puts "[FCSH] complete in #{duration} seconds."
123
+ end
124
+ end
125
+
126
+ private
127
+
128
+ def render_request request
129
+ if request.match /^mxmlc|^compc/
130
+ hash = Digest::MD5.hexdigest request
131
+
132
+ if requests[hash].nil?
133
+ requests[hash] = next_compiler_index
134
+ request
135
+ else
136
+ "compile #{requests[hash]}"
137
+ end
138
+ else
139
+ request
140
+ end
141
+ end
142
+
143
+ def next_compiler_index
144
+ index = 1
145
+ @requests.each do |key, value|
146
+ value += 1
147
+ index = [index, value].max
148
+ end
149
+ index
150
+ end
151
+
152
+ def clear_requests
153
+ # Clear the cached requests,
154
+ # but leave them in place, the underlying
155
+ # FCSH implementation continues incrementing
156
+ # indices.
157
+
158
+ new_requests = {}
159
+ @requests.each do |key, value|
160
+ new_requests["removed-item"] = value
161
+ end
162
+ @requests = new_requests
163
+ end
164
+
165
+ end
166
+ end
167
+
@@ -0,0 +1,833 @@
1
+
2
+ module FlashSDK
3
+
4
+ ##
5
+ # The FDB task provides an interface to the Flash Debugger.
6
+ #
7
+ # In order to use this tool, you'll need to compile a SWF
8
+ # file with +--debug=true+, and be prepared to open it
9
+ # in a debug Flash Player. You can open the SWF using
10
+ # the desktop debug Flash Player for your platform using
11
+ # the FlashSDK::FlashPlayer task, or you can open the
12
+ # SWF manually on the desktop or the browser - as long
13
+ # as you run it in a Debug Flash Player.
14
+ #
15
+ class FDB < Sprout::Executable::Session
16
+
17
+ ##
18
+ # Path to the file where test results should be written.
19
+ #
20
+ # @default 'TestResults.xml'
21
+ # @see :test_result_prefix
22
+ # @see :test_result_suffix
23
+ attr_accessor :test_result_file
24
+
25
+ ##
26
+ # Regular expression that will match the preamble that is sent
27
+ # by your test framework to indicate the beginning of structured
28
+ # test output.
29
+ #
30
+ # @default /<TestResults>/
31
+ # @see :test_result_file
32
+ # @see :test_result_suffix
33
+ attr_accessor :test_result_prefix
34
+
35
+ ##
36
+ # Regular expression that will match the suffix that is sent
37
+ # by your test framework to indicate the end of structured
38
+ # test output.
39
+ #
40
+ # @default /<\/TestResults>/
41
+ # @see :test_result_file
42
+ # @see :test_result_prefix
43
+ attr_accessor :test_result_suffix
44
+
45
+ def initialize
46
+ super
47
+ @test_result = ''
48
+ @inside_test_result = false
49
+ @test_result_file = 'TestResults.xml'
50
+ @test_result_prefix = /<TestResults>/
51
+ @test_result_suffix = /<\/TestResults>/
52
+ end
53
+
54
+ set :default_prefix, '-'
55
+
56
+ ##
57
+ # The default gem name
58
+ set :pkg_name, 'flex4'
59
+
60
+ ##
61
+ # The default gem version
62
+ set :pkg_version, '>= 4.1.0.pre'
63
+
64
+ ##
65
+ # The default executable target
66
+ set :executable, :fdb
67
+
68
+ set :prompt, /^\(fdb\) |\(y or n\) |Waiting for Player to connect/
69
+
70
+ ##
71
+ # Print a backtrace of all stack frames
72
+ add_action :backtrace
73
+ add_action_alias :bt, :backtrace
74
+ add_action_alias :where, :backtrace
75
+
76
+ ##
77
+ # Set a breakpoint at specified line or function
78
+ #
79
+ # @example Sets a breakpoint at line 87 of the current file.
80
+ # break 87
81
+ #
82
+ # @example Sets a breakpoint at line 56 of myapp.mxml
83
+ # break myapp.mxml:56
84
+ #
85
+ # @example Sets a breakpoint at line 29 of file #3
86
+ # break #3:29
87
+ #
88
+ # @example Sets a breakpoint at function doThis() in the current file
89
+ # break doThis
90
+ #
91
+ # @example Sets a breakpoint at function doThat() in file myapp.mxml
92
+ # break myapp.mxml:doThat
93
+ #
94
+ # @example Sets a breakpoint at function doOther() in file #3
95
+ # break #3:doOther
96
+ #
97
+ # @example Sets a breakpoint at the current execution address in the
98
+ # current stack frame. This is useful for breaking on return
99
+ # to a stack frame.
100
+ # break
101
+ #
102
+ # To see file names and numbers, do 'info sources' or 'info files'.
103
+ # To see function names, do 'info functions'.
104
+ # Abbreviated file names and function names are accepted if unambiguous.
105
+ # If line number is specified, break at start of code for that line.
106
+ # If function is specified, break at start of code for that function.
107
+ # See 'commands' and 'condition' for further breakpoint control.
108
+ add_action :break, Strings
109
+
110
+ ##
111
+ # Halt when an exception is thrown. This only affects caught
112
+ # exceptions -- that is, exceptions that are going to be handled
113
+ # by a "catch" block. Uncaught exceptions always halt in the
114
+ # debugger.
115
+ #
116
+ # Use the "delete" command to delete a catchpoint.
117
+ #
118
+ # Examples:
119
+ #
120
+ # catch *
121
+ #
122
+ # Halts when any exception is thrown.
123
+ #
124
+ # catch ReferenceError
125
+ #
126
+ # Halts whenever a ReferenceError is thrown
127
+ #
128
+ add_action :catch, String
129
+ add_action_alias :ca, :catch
130
+
131
+ ##
132
+ #
133
+ # Display the name and number of the current file
134
+ # or change the current file.
135
+ # Examples:
136
+ #
137
+ # cf
138
+ #
139
+ # Displays the name and number of the current file.
140
+ #
141
+ # cf myapp.mxml
142
+ #
143
+ # Changes the current file to myapp.mxml.
144
+ #
145
+ # cf #29
146
+ #
147
+ # Changes the current file to file #29.
148
+ # To see file names and numbers, do 'info sources' or 'info files'.
149
+ # Abbreviated file names are accepted if unambiguous.
150
+ # Listing a file with 'list' also makes that file the current file.
151
+ #
152
+ add_action :cf, String
153
+
154
+ ##
155
+ # Clear breakpoint at specified line or function.
156
+ # Examples:
157
+ #
158
+ # clear 87
159
+ #
160
+ # Clears the breakpoint at line 87 of the current file.
161
+ #
162
+ # clear myapp.mxml:56
163
+ #
164
+ # Clears the breakpoint at line 56 of myapp.mxml.
165
+ #
166
+ # clear #3:29
167
+ #
168
+ # Clears the breakpoint at line 29 of file #3.
169
+ #
170
+ # clear doThis
171
+ #
172
+ # Clears the breakpoint at function doThis() in the current file.
173
+ #
174
+ # clear myapp.mxml:doThat
175
+ #
176
+ # Clears the breakpoint at function doThat() in file myapp.mxml.
177
+ #
178
+ # clear #3:doOther
179
+ #
180
+ # Clears the breakpoint at function doOther() in file #3.
181
+ #
182
+ # clear
183
+ #
184
+ # Clears breakpoint of the current line in the current file.
185
+ # To see file names and numbers, do 'info sources' or 'info files'.
186
+ # To see function names, do 'info functions'.
187
+ # Abbreviated file names and function names are accepted if unambiguous.
188
+ # If line number is specified, all breakpoints in that line are cleared.
189
+ # If function is specified, breakpoints at beginning of function are cleared.
190
+ add_action :clear, Strings
191
+ add_action_alias :cl, :clear
192
+
193
+ ##
194
+ # Continue execution after stopping at a breakpoint
195
+ # Specify breakpoint number N to break only if COND is true.
196
+ # Usage is `condition N COND', where N is an integer and COND is an
197
+ # expression to be evaluated whenever breakpoint N is reached.
198
+ add_action :condition, String
199
+
200
+ ##
201
+ # Provide an affirmative response to a confirmation screen.
202
+ #
203
+ # See also: unconfirm
204
+ add_action :confirm
205
+
206
+ ##
207
+ # Continue execution after stopping at breakpoint.
208
+ # This command takes no arguments.
209
+ add_action :continue
210
+ add_action_alias :c, :continue
211
+
212
+ ##
213
+ # Set commands to be executed when a breakpoint is hit.
214
+ # Give breakpoint number as argument after `commands`.
215
+ # With no argument, the targeted breakpoint is the last one set.
216
+ # The commands themselves follow starting on the next line.
217
+ # Type a line containing "end" to indicate the end of them.
218
+ # Give "silent" as the first line to make the breakpoint silent;
219
+ # then no output is printed when it is hit, except what the commands print.
220
+ #
221
+ # Example:
222
+ #
223
+ # (fdb) commands
224
+ # Type commands for when breakpoint 1 is hit, one per line.
225
+ # End with a line saying just 'end'.
226
+ # >w
227
+ # >end
228
+ add_action :commands, String
229
+
230
+ ##
231
+ # Delete one or more breakpoints.
232
+ #
233
+ # Examples:
234
+ #
235
+ # delete
236
+ #
237
+ # Deletes all breakpoints.
238
+ #
239
+ # delete 2 5
240
+ #
241
+ # Deletes breakpoints #2 and #5.
242
+ #
243
+ # To see breakpoint numbers, do 'info breakpoints'.
244
+ add_action :delete, Strings
245
+ add_action_alias :d, :delete
246
+
247
+ ##
248
+ # Modify the list of directories in which fdb searches for source files.
249
+ #
250
+ # Examples:
251
+ #
252
+ # directory
253
+ #
254
+ # Restores list to the default, which is the directory in which the source
255
+ # file was compiled into object code, followed by the current working
256
+ # directory.
257
+ #
258
+ # directory C:\MySource (Windows)
259
+ # directory /MySource (Mac)
260
+ #
261
+ # Adds the specified directory to the beginning of the list of directories
262
+ # which will be searched for source. When looking for the source for class
263
+ # mypackage.MyClass, for example, the debugger would look for both
264
+ # C:\MySource\mypackage\MyClass.as and C:\MySource\MyClass.as.
265
+ #
266
+ # directory C:\Dir1;C:\Dir2 (Windows -- use ';' as separator)
267
+ # directory /Dir1:/Dir2 (Mac -- use ':' as separator)
268
+ #
269
+ # Adds several directories to the beginning of the list of directories
270
+ # which will be searched for source.
271
+ #
272
+ # To see the current list, do 'show directories'.
273
+ add_action :directory, Path
274
+ add_action_alias :dir, :directory
275
+
276
+ ##
277
+ # Disable one or more breakpoints or auto-display expressions.
278
+ #
279
+ # Examples:
280
+ #
281
+ # disable
282
+ #
283
+ # disable breakpoints
284
+ #
285
+ # Disables all breakpoints.
286
+ #
287
+ # disable 2 5
288
+ #
289
+ # disable breakpoints 2 5
290
+ #
291
+ # Disables breakpoints #2 and #5.
292
+ #
293
+ # disable display
294
+ #
295
+ # Disables all auto-display expressions.
296
+ #
297
+ # disable display 1 3
298
+ #
299
+ # Disables auto-display expressions #1 and #3.
300
+ #
301
+ # To see breakpoint numbers, do 'info breakpoints'.
302
+ # To see auto-display expression numbers, do 'info display'.
303
+ add_action :disable, String
304
+ add_action_alias :disab, :disable
305
+
306
+ ##
307
+ # (ActionScript 2 only; not supported when debugging ActionScript 3)
308
+ #
309
+ # Disassemble a specified portion of source code.
310
+ # The default is the current listing line.
311
+ # Arguments supported are the same as with the list command
312
+ #
313
+ # Examples:
314
+ #
315
+ # disassemble 87
316
+ #
317
+ # Disassembles line 87 in the current file.
318
+ #
319
+ # disassemble 87 102
320
+ # disassembles lines 87 to 102 in current file.
321
+ # disassemble doThis
322
+ #
323
+ # Disassembles the function doThis() in the current file.
324
+ #
325
+ # In addition to using simple line numbers as above, you can specify lines
326
+ # in additional ways:
327
+ #
328
+ # myapp.mxml
329
+ # Line 1 in myapp.mxml.
330
+ # myapp.mxml:doThat
331
+ # The first line of function doThat() in myapp.mxml.
332
+ # myapp.mxml:56
333
+ # Line 56 in myapp.mxml.
334
+ # #3
335
+ # Line 1 in file #3.
336
+ # #3:doOther
337
+ # The line in file #3 where the function doOther() begins.
338
+ # #3:29
339
+ # Line 29 in file #3.
340
+ add_action :disassemble, String
341
+ add_action_alias :disas, :disassemble
342
+
343
+ ##
344
+ # Add an auto-display expression
345
+ # Add an expression to the list of auto-display expressions.
346
+ #
347
+ # Example:
348
+ #
349
+ # display employee.name
350
+ #
351
+ # Add 'employee.name' to the list of auto-display expressions.
352
+ # Every time fdb stops, the value of employee.name will be displayed.
353
+ # The argument for this command is similar to that for 'print'.
354
+ # To see the list of auto-display expressions and their numbers,
355
+ # do 'info display'.
356
+ #
357
+ # NOTE: Removed because the base class adds this param for some reason.
358
+ # Investigate duplicate add_action calls.
359
+ #add_action :display, String
360
+ #add_action_alias :disp, :display
361
+
362
+ ##
363
+ # Enable breakpoints or auto-display expressions
364
+ add_action :enable
365
+ add_action_alias :e, :enable
366
+
367
+ ##
368
+ # Specify an application to be debugged, without starting it.
369
+ #
370
+ # Examples:
371
+ #
372
+ # file http://www.mysite.com/myapp.mxml
373
+ #
374
+ # Specify an MXML application to be debugged.
375
+ #
376
+ # file myapp.swf
377
+ #
378
+ # Specify a local SWF file to be debugged, in the current directory.
379
+ # In this case myapp.swd (the file containing the debugging information)
380
+ # must also exist in the current directory.
381
+ #
382
+ # This command does not actually cause the application to start;
383
+ # use the 'run' command with no argument to start debugging the application.
384
+ #
385
+ # Instead of using 'file <target>' and then 'run', you can simply specify the
386
+ # application to be debugged as an argument of 'run':
387
+ #
388
+ # run http://mysite.com/myapp.mxml
389
+ # run myapp.swf
390
+ #
391
+ # You can also specify the application to be debugged
392
+ # as a command-line argument when you start fdb:
393
+ #
394
+ # fdb http://www.mysite.com/myapp.mxml
395
+ #
396
+ # fdb myapp.swf
397
+ #
398
+ # In this case you do not need to use either 'file' or 'run'.
399
+ # If you 'run' without specifying an application to debug,
400
+ # (fdb)
401
+ #
402
+ # will wait for any application to connect to it.
403
+ add_action :file, File, { :hidden_name => true }
404
+ add_action_alias :fil, :file
405
+
406
+ ##
407
+ # Execute until current function returns.
408
+ # This command takes no arguments.
409
+ add_action :finish
410
+ add_action_alias :f, :finish
411
+
412
+ ##
413
+ # Specify how fdb should handle a fault in the Flash Player.
414
+ #
415
+ # Examples:
416
+ #
417
+ # handle recursion_limit stop
418
+ #
419
+ # When a recursion_limit fault occurs, display message in fdb
420
+ # and stop as if at breakpoint.
421
+ #
422
+ # handle all print nostop
423
+ #
424
+ # When any kind of fault occurs, display message in fdb but don't stop.
425
+ # First argument is a fault name or 'all'.
426
+ # Additional arguments are actions that apply to that fault.
427
+ # To see fault names, do 'info handle'.
428
+ #
429
+ # Actions are print/noprint and stop/nostop.
430
+ # 'print' means print a message if this fault happens.
431
+ # 'stop' means reenter debugger if this fault happens. Implies 'print'.
432
+ add_action :handle, String
433
+ add_action_alias :han, :handle
434
+
435
+ ##
436
+ # Display help on FDB commands
437
+ # New to fdb? Do 'tutorial' for basic info.
438
+ # List of fdb commands:
439
+ # bt (bt) Print backtrace of all stack frames
440
+ # break (b) Set breakpoint at specified line or function
441
+ # catch (ca) Halt when an exception is thrown
442
+ # cf (cf) Display the name and number of the current file
443
+ # clear (cl) Clear breakpoint at specified line or function
444
+ # condition (cond) Apply/remove conditional expression to a breakpoint
445
+ # continue (c) Continue execution after stopping at breakpoint
446
+ # commands (com) Sets commands to execute when breakpoint hit
447
+ # delete (d) Delete breakpoints or auto-display expressions
448
+ # directory (dir) Add a directory to the search path for source files
449
+ # disable (disab) Disable breakpoints or auto-display expressions
450
+ # disassemble (disas) Disassemble source lines or functions
451
+ # display (disp) Add an auto-display expressions
452
+ # enable (e) Enable breakpoints or auto-display expressions
453
+ # file (fil) Specify application to be debugged.
454
+ # finish (f) Execute until current function returns
455
+ # handle (han) Specify how to handle a fault
456
+ # help (h) Display help on fdb commands
457
+ # home (ho) Set listing location to where execution is halted
458
+ # info (i) Display information about the program being debugged
459
+ # kill (k) Kill execution of program being debugged
460
+ # list (l) List specified function or line
461
+ # next (n) Step program
462
+ # print (p) Print value of variable EXP
463
+ # pwd (pw) Print working directory
464
+ # quit (q) Exit fdb
465
+ # run (r) Start debugged program
466
+ # set (se) Set the value of a variable
467
+ # source (so) Read fdb commands from a file
468
+ # step (s) Step program until it reaches a different source line
469
+ # tutorial (t) Display a tutorial on how to use fdb
470
+ # undisplay (u) Remove an auto-display expression
471
+ # viewswf (v) Set or clear filter for file listing based on swf
472
+ # watch (wa) Add a watchpoint on a given variable
473
+ # what (wh) Displays the context of a variable
474
+ # where (w) Same as bt
475
+ # Type 'help' followed by command name for full documentation.
476
+ add_action :help
477
+ add_action_alias :h, :help
478
+
479
+ ##
480
+ # Set listing location to where execution is halted
481
+ add_action :home, Path
482
+ add_action_alias :ho, :home
483
+
484
+ ##
485
+ # Generic command for showing things about the program being debugged.
486
+ # List of info subcommands:
487
+ # info arguments (i a) Argument variables of current stack frame
488
+ # info breakpoints (i b) Status of user-settable breakpoints
489
+ # info display (i d) Display list of auto-display expressions
490
+ # info files (i f) Names of targets and files being debugged
491
+ # info functions (i fu) All function names
492
+ # info handle (i h) How to handle a fault
493
+ # info locals (i l) Local variables of current stack frame
494
+ # info scopechain (i sc) Scope chain of current stack frame
495
+ # info sources (i so) Source files in the program
496
+ # info stack (i s) Backtrace of the stack
497
+ # info swfs (i sw) List of swfs in this session
498
+ # info targets(i t) Application being debugged
499
+ # info variables (i v) All global and static variable names
500
+ # Type 'help info' followed by info subcommand name for full documentation.
501
+ add_action :info, String
502
+ add_action_alias :i, :info
503
+
504
+ ##
505
+ # Kill execution of program being debugged
506
+ # This command takes no arguments.
507
+ add_action :kill
508
+ add_action_alias :k, :kill
509
+
510
+ ##
511
+ # List lines of code in a source file.
512
+ #
513
+ # Examples:
514
+ #
515
+ # list
516
+ #
517
+ # Lists ten more lines in current file after or around previous listing.
518
+ #
519
+ # list -
520
+ #
521
+ # Lists the ten lines in current file before a previous listing.
522
+ #
523
+ # list 87
524
+ #
525
+ # Lists ten lines in current file around line 87.
526
+ #
527
+ # list 87 102
528
+ #
529
+ # Lists lines 87 to 102 in current file.
530
+ #
531
+ # In addition to using simple line numbers as above, you can specify lines
532
+ # in seven additional ways:
533
+ #
534
+ # doThis
535
+ #
536
+ # The first line of function doThis() in the current file.
537
+ #
538
+ # myapp.mxml
539
+ #
540
+ # Line 1 in myapp.mxml.
541
+ #
542
+ # myapp.mxml:doThat
543
+ #
544
+ # The first line of function doThat() in myapp.mxml.
545
+ #
546
+ # myapp.mxml:56
547
+ #
548
+ # Line 56 in myapp.mxml.
549
+ #
550
+ # #3
551
+ #
552
+ # Line 1 in file #3.
553
+ #
554
+ # #3:doOther
555
+ #
556
+ # The line in file #3 where the function doOther() begins.
557
+ #
558
+ # #3:29
559
+ #
560
+ # Line 29 in file #3.
561
+ #
562
+ # To see file names and numbers, do 'info sources' or 'info files'.
563
+ # To see function names, do 'info functions'.
564
+ # Abbreviated file names and function names are accepted if unambiguous.
565
+ # Listing a file makes that file the current file. (See 'cf' command.)
566
+ add_action :list, String
567
+ add_action_alias :l, :list
568
+
569
+ ##
570
+ # Step program, proceeding through subroutine calls.
571
+ #
572
+ # next
573
+ #
574
+ # Step once.
575
+ #
576
+ # next 3
577
+ #
578
+ # Step 3 times, or until the program stops for another reason.
579
+ #
580
+ # Like the 'step' command as long as subroutine calls do not happen;
581
+ # when they do, the call is treated as one instruction.
582
+ add_action :next, String
583
+ add_action_alias :n, :next
584
+
585
+ ##
586
+ # Print value of variable or expression.
587
+ #
588
+ # Examples:
589
+ #
590
+ # print i
591
+ #
592
+ # Print the value of 'i'.
593
+ #
594
+ # print employee.name
595
+ #
596
+ # Print the value of 'employee.name'.
597
+ #
598
+ # print employee
599
+ #
600
+ # Print the value of the 'employee' Object.
601
+ #
602
+ # This may simplay display something like [Object 10378].
603
+ #
604
+ # print employee.
605
+ #
606
+ # Print the values of all the properties of the 'employee' Object.
607
+ #
608
+ # print *employee
609
+ #
610
+ # Print the values of all the properties of the 'employee' Object.
611
+ # The prefix * operator is the prefix alternative to the postfix . operator.
612
+ #
613
+ # print #10378.
614
+ #
615
+ # Print the values of all the properties of Object #10378.
616
+ # Variables accessible are those of the lexical environment of the selected
617
+ # stack frame, plus all those whose scope is global or an entire file.
618
+ add_action :print, String
619
+ add_action_alias :p, :print
620
+
621
+ ##
622
+ # Print the current working directory.
623
+ # This is the directory from which fdb was launched; it cannot be
624
+ # changed within fdb. The argument for 'run' and 'source' can be
625
+ # specified relative to this directory.
626
+ # This command takes no arguments.
627
+ add_action :pwd
628
+ add_action_alias :pw, :pwd
629
+
630
+ ##
631
+ # Exit FDB
632
+ add_action :quit
633
+ add_action_alias :q, :quit
634
+
635
+ ##
636
+ # Start a debugging session.
637
+ #
638
+ # Examples:
639
+ #
640
+ # run http://www.mysite.com/myapp.mxml
641
+ #
642
+ # Runs the specified MXML application.
643
+ #
644
+ # run myapp.swf
645
+ # run mydir\myapp.swf
646
+ # run c:\mydir\myapp.swf
647
+ #
648
+ # Runs the local SWF file myapp.swf, which can be specified
649
+ # either relative to the current directory (see 'pwd' command)
650
+ # or using an absolute path. In these cases, myapp.swd
651
+ # (the file containing the debugging information) must also
652
+ # exist in the same directory as myapp.swf.
653
+ #
654
+ # run
655
+ #
656
+ # Run the application previously specified by the 'file' command.
657
+ # If no application has been specified, fdb will wait for one
658
+ # to connect to it, and time out if none does so.
659
+ # 'run' will start the application in a browser or standalone Flash Player.
660
+ # As soon as the application starts, it will break into fdb so that you can
661
+ # set breakpoints, etc.
662
+ #
663
+ # On the Macintosh, the only supported form of the command is 'run' with no
664
+ # arguments. You must then manually launch the Flash player.
665
+ add_action :run, String
666
+ add_action_alias :r, :run
667
+
668
+ ##
669
+ # Set the value of a variable or a convenience variable.
670
+ # Convenience variables are variables that exist entirely
671
+ # within fdb; they are not part of your program.
672
+ # Convenience variables are prefixed with '$' and can
673
+ # be any name that does not conflict with any existing
674
+ # variable. For example, $myVar. Convenience variables
675
+ # are also used to control various aspects of fdb.
676
+ #
677
+ # The following convenience variables are used by fdb.
678
+ # $listsize - number of source lines to display for 'list'
679
+ # $columnwrap - column number on which output will wrap
680
+ # $infostackshowthis - if 0, does not display 'this' in stack backtrace
681
+ # $invokegetters - if 0, prevents fdb from firing getter functions
682
+ # $bpnum - the last defined breakpoint number
683
+ # $displayattributes - if 1, 'print var.' displays all attributes of members
684
+ # of 'var' (e.g. private, static)
685
+ #
686
+ # Examples:
687
+ #
688
+ # set i = 3
689
+ #
690
+ # Sets the variable 'i' to the number 3.
691
+ #
692
+ # set employee.name = "Susan"
693
+ #
694
+ # Sets the variable 'employee.name' to the string "Susan".
695
+ #
696
+ # set $myVar = 20
697
+ #
698
+ # Sets the convenience variable '$myVar' to the number 20
699
+ add_action :set, String
700
+ add_action_alias :se, :set
701
+
702
+ ##
703
+ # Read fdb commands from a file and execute them.
704
+ #
705
+ # source mycommands.txt
706
+ # source mydir\mycommands.txt
707
+ # source c:\mydir\mycommands.txt
708
+ #
709
+ # Reads mycommands.txt and executes the fdb commands in it.
710
+ # The file containing the commands can be specified either
711
+ # relative to the current directory (see 'pwd' command)
712
+ # or using an absolute path.
713
+ #
714
+ # The file .fdbinit is read automatically in this way when fdb is started.
715
+ # Only the current directory is searched for .fdbinit. This means that
716
+ # you can have set up multiple .fdbinit files for different projects.
717
+ add_action :source, File
718
+ add_action_alias :so, :source
719
+
720
+ ##
721
+ # Step program until it reaches a different source line.
722
+ #
723
+ # Examples:
724
+ #
725
+ # step
726
+ #
727
+ # Step once.
728
+ #
729
+ # step 3
730
+ #
731
+ # Step 3 times, or until the program stops for another reason.
732
+ add_action :step, Number
733
+ add_action_alias :s, :step
734
+
735
+ ##
736
+ # Display a tutorial on how to use fdb.
737
+ # This command takes no arguments.
738
+ add_action :tutorial
739
+ add_action_alias :t, :tutorial
740
+
741
+ ##
742
+ # Provide a negative response to a confirmation screen.
743
+ #
744
+ # See also: confirm
745
+ add_action :unconfirm
746
+
747
+ ##
748
+ # Remove one or more auto-display expressions.
749
+ #
750
+ # Examples:
751
+ #
752
+ # undisplay
753
+ #
754
+ # Remove all auto-display expressions.
755
+ #
756
+ # undisplay 2 7
757
+ #
758
+ # Remove auto-display expressions #2 and #7.
759
+ #
760
+ # To see the list of auto-display expressions and their numbers,
761
+ # do 'info display'.
762
+ add_action :undisplay, String
763
+ add_action_alias :u, :undisplay
764
+
765
+ ##
766
+ # Set or clear a filter for file listing based on SWF
767
+ add_action :viewswf
768
+ add_action_alias :v, :viewswf
769
+
770
+ ##
771
+ # Add a watchpoint on a given variable. The debugger will halt
772
+ # execution when the variable's value changes.
773
+ #
774
+ # Example:
775
+ #
776
+ # watch foo
777
+ #
778
+ add_action :watch, String
779
+ add_action_alias :wa, :watch
780
+
781
+ ##
782
+ # Displays the context in which a variable is resolved.
783
+ add_action :what
784
+ add_action_alias :wh, :what
785
+
786
+ def system_execute binary, params
787
+ super do |message|
788
+ if message.match test_result_suffix
789
+ write_test_result
790
+ end
791
+ if @inside_test_result
792
+ @test_result << message
793
+ end
794
+ if message.match test_result_prefix
795
+ @inside_test_result = true
796
+ end
797
+ end
798
+ end
799
+
800
+ private
801
+
802
+ def write_test_result
803
+ File.open test_result_file, 'w+' do |f|
804
+ f.write @test_result
805
+ end
806
+ @test_result = ''
807
+ @inside_test_result = false
808
+ end
809
+
810
+ end
811
+ end
812
+
813
+ ##
814
+ # Rake task helper that delegates to
815
+ # the FDB executable.
816
+ #
817
+ # fdb 'bin/SomeProject.swf' do |t|
818
+ # t.break << 'com/foo/bar/SomeClass.as:23'
819
+ # t.continue
820
+ # t.run
821
+ # end
822
+ #
823
+ def fdb *args, &block
824
+ fdb_tool = FlashSDK::FDB.new
825
+ fdb_tool.to_rake *args, &block
826
+ fdb_tool
827
+ end
828
+
829
+ desc "Make subsequent FlashPlayer task(s) use FDB"
830
+ task :fdb do
831
+ ENV['USE_FDB'] = 'true'
832
+ end
833
+