ruboto 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/RELEASE_CANDICATE_DOC.md +4 -17
- data/RELEASE_DOC.md +42 -43
- data/Rakefile +33 -11
- data/assets/rakelib/ruboto.rake +4 -2
- data/assets/samples/sample_broadcast_receiver.rb +1 -1
- data/assets/src/InheritingBroadcastReceiver.java +0 -3
- data/assets/src/InheritingClass.java +4 -9
- data/assets/src/InheritingService.java +0 -5
- data/assets/src/RubotoActivity.java +12 -52
- data/assets/src/RubotoBroadcastReceiver.java +3 -10
- data/assets/src/RubotoService.java +5 -102
- data/assets/src/org/ruboto/JRubyAdapter.java +7 -6
- data/assets/src/org/ruboto/ScriptLoader.java +2 -29
- data/lib/ruboto/util/build.rb +26 -14
- data/lib/ruboto/util/emulator.rb +27 -11
- data/lib/ruboto/util/update.rb +15 -10
- data/lib/ruboto/util/verify.rb +1 -2
- data/lib/ruboto/util/xml_element.rb +53 -23
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/stack_activity_test.rb +3 -2
- data/test/activity/subclass_activity.rb +0 -1
- data/test/arjdbc_test.rb +119 -0
- data/test/rake_test.rb +10 -0
- data/test/ruboto_gen_test.rb +4 -3
- data/test/sample_broadcast_receiver_test.rb +31 -0
- data/test/test_helper.rb +2 -2
- metadata +26 -24
@@ -132,17 +132,18 @@ public class JRubyAdapter {
|
|
132
132
|
// END Ruboto HeapAlloc
|
133
133
|
setDebugBuild(appContext);
|
134
134
|
Log.d("Setting up JRuby runtime (" + (isDebugBuild ? "DEBUG" : "RELEASE") + ")");
|
135
|
-
System.setProperty("jruby.
|
136
|
-
// System.setProperty("jruby.compile.backend", "DALVIK");
|
135
|
+
System.setProperty("jruby.backtrace.style", "normal"); // normal raw full mri
|
137
136
|
System.setProperty("jruby.bytecode.version", "1.6");
|
137
|
+
// System.setProperty("jruby.compat.version", "RUBY2_0"); // RUBY1_9 is the default in JRuby 1.7
|
138
|
+
// System.setProperty("jruby.compile.backend", "DALVIK");
|
139
|
+
System.setProperty("jruby.compile.mode", "OFF"); // OFF OFFIR JITIR? FORCE FORCEIR
|
138
140
|
System.setProperty("jruby.interfaces.useProxy", "true");
|
141
|
+
System.setProperty("jruby.ir.passes", "LocalOptimizationPass,DeadCodeElimination");
|
139
142
|
System.setProperty("jruby.management.enabled", "false");
|
143
|
+
System.setProperty("jruby.native.enabled", "false");
|
140
144
|
System.setProperty("jruby.objectspace.enabled", "false");
|
145
|
+
System.setProperty("jruby.rewrite.java.trace", "true");
|
141
146
|
System.setProperty("jruby.thread.pooling", "true");
|
142
|
-
System.setProperty("jruby.native.enabled", "false");
|
143
|
-
// System.setProperty("jruby.compat.version", "RUBY2_0"); // RUBY1_9 is the default in JRuby 1.7
|
144
|
-
System.setProperty("jruby.ir.passes", "LocalOptimizationPass,DeadCodeElimination");
|
145
|
-
System.setProperty("jruby.backtrace.style", "normal"); // normal raw full mri
|
146
147
|
|
147
148
|
// Uncomment these to debug/profile Ruby source loading
|
148
149
|
// System.setProperty("jruby.debug.loadService", "true");
|
@@ -106,6 +106,7 @@ public class ScriptLoader {
|
|
106
106
|
}
|
107
107
|
component.getScriptInfo().setRubyInstance(rubyInstance);
|
108
108
|
}
|
109
|
+
persistObjectProxy(component);
|
109
110
|
} catch(IOException e){
|
110
111
|
e.printStackTrace();
|
111
112
|
if (component instanceof android.content.Context) {
|
@@ -114,40 +115,12 @@ public class ScriptLoader {
|
|
114
115
|
}
|
115
116
|
}
|
116
117
|
|
117
|
-
public static final void callOnCreate(final RubotoComponent component, Object... args) {
|
118
|
-
persistObjectProxy(component);
|
119
|
-
if (component instanceof android.content.Context) {
|
120
|
-
Log.d("Call onCreate on: " + component.getScriptInfo().getRubyInstance());
|
121
|
-
// FIXME(uwe): Simplify when we stop support for snake case aliasing interface callback methods.
|
122
|
-
if ((Boolean)JRubyAdapter.runScriptlet(component.getScriptInfo().getRubyClassName() + ".instance_methods(false).any?{|m| m.to_sym == :onCreate}")) {
|
123
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onCreate", args);
|
124
|
-
} else if ((Boolean)JRubyAdapter.runScriptlet(component.getScriptInfo().getRubyClassName() + ".instance_methods(true).any?{|m| m.to_sym == :on_create}")) {
|
125
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "on_create", args);
|
126
|
-
} else {
|
127
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onCreate", args);
|
128
|
-
}
|
129
|
-
// EMXIF
|
130
|
-
}
|
131
|
-
}
|
132
|
-
|
133
|
-
public static final void callOnDestroy(final RubotoComponent component) {
|
134
|
-
String rubyClassName = component.getScriptInfo().getRubyClassName();
|
135
|
-
if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :onDestroy}")) {
|
136
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onDestroy");
|
137
|
-
} else if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(true).any?{|m| m.to_sym == :on_destroy}")) {
|
138
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "on_destroy");
|
139
|
-
} else {
|
140
|
-
JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onDestroy");
|
141
|
-
}
|
142
|
-
releaseObjectProxy(component);
|
143
|
-
}
|
144
|
-
|
145
118
|
private static void persistObjectProxy(RubotoComponent component) {
|
146
119
|
JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
|
147
120
|
((Map)JRubyAdapter.get("RUBOTO_JAVA_PROXIES")).put(component.getScriptInfo().getRubyInstance(), component.getScriptInfo().getRubyInstance());
|
148
121
|
}
|
149
122
|
|
150
|
-
|
123
|
+
public static void unloadScript(RubotoComponent component) {
|
151
124
|
((Map)JRubyAdapter.get("RUBOTO_JAVA_PROXIES")).remove(component.getScriptInfo().getRubyInstance());
|
152
125
|
}
|
153
126
|
|
data/lib/ruboto/util/build.rb
CHANGED
@@ -3,7 +3,7 @@ module Ruboto
|
|
3
3
|
module Build
|
4
4
|
include Verify
|
5
5
|
SCRIPTS_DIR = 'src'
|
6
|
-
|
6
|
+
|
7
7
|
###########################################################################
|
8
8
|
#
|
9
9
|
# Build Subclass or Interface:
|
@@ -19,9 +19,9 @@ module Ruboto
|
|
19
19
|
Dir.mkdir(to) unless File.directory?(to)
|
20
20
|
|
21
21
|
text = File.read(File.expand_path(Ruboto::GEM_ROOT + "/assets/src/#{src}.java"))
|
22
|
-
substitutions.each {|k,v| text.gsub!(k, v)}
|
22
|
+
substitutions.each { |k, v| text.gsub!(k, v) }
|
23
23
|
|
24
|
-
File.open(File.join(to, "#{name}.java"), 'w') {|f| f << text}
|
24
|
+
File.open(File.join(to, "#{name}.java"), 'w') { |f| f << text }
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -35,14 +35,11 @@ module Ruboto
|
|
35
35
|
abort "ERROR: #{klass} not found" unless element
|
36
36
|
|
37
37
|
unless force == 'include'
|
38
|
-
abort "#{klass} not available in minSdkVersion, added in #{element.attribute('api_added')}; use '--force include' to create it" if
|
39
|
-
|
40
|
-
abort "#{klass} deprecated for targetSdkVersion, deprecated in #{element.attribute('deprecated')}; use '--force include' to create it" if
|
41
|
-
element.attribute('deprecated') and element.attribute('deprecated').to_i <= verify_target_sdk.to_i
|
38
|
+
abort "#{klass} not available in minSdkVersion, added in #{element.attribute('api_added')}; use '--force include' to create it" if element.attribute('api_added') and element.attribute('api_added').to_i > verify_min_sdk.to_i
|
39
|
+
abort "#{klass} deprecated for targetSdkVersion, deprecated in #{element.attribute('deprecated')}; use '--force include' to create it" if element.attribute('deprecated') and element.attribute('deprecated').to_i <= verify_target_sdk.to_i
|
42
40
|
end
|
43
41
|
|
44
|
-
abort "#{klass} removed for targetSdkVersion, removed in #{element.attribute('api_removed')}" if
|
45
|
-
element.attribute('api_removed') and element.attribute('api_removed').to_i <= verify_target_sdk.to_i
|
42
|
+
abort "#{klass} removed for targetSdkVersion, removed in #{element.attribute('api_removed')}" if element.attribute('api_removed') and element.attribute('api_removed').to_i <= verify_target_sdk.to_i
|
46
43
|
|
47
44
|
element
|
48
45
|
end
|
@@ -55,9 +52,9 @@ module Ruboto
|
|
55
52
|
target_api = verify_target_sdk.to_i
|
56
53
|
|
57
54
|
# Remove methods changed outside of the scope of the sdk versions
|
58
|
-
methods = methods.select{|i| !i.attribute('api_added') || (i.attribute('api_added').to_i <= target_api)}
|
55
|
+
methods = methods.select { |i| !i.attribute('api_added') || (i.attribute('api_added').to_i <= target_api) }
|
59
56
|
# methods = methods.select{|i| !i.attribute('deprecated') || (i.attribute('deprecated').to_i > min_api)}
|
60
|
-
methods = methods.select{|i| !i.attribute('api_removed') || (i.attribute('api_removed').to_i > min_api)}
|
57
|
+
methods = methods.select { |i| !i.attribute('api_removed') || (i.attribute('api_removed').to_i > min_api) }
|
61
58
|
|
62
59
|
# Inform and remove methods that do not exist in one of the sdk versions
|
63
60
|
methods = methods.select do |i|
|
@@ -124,7 +121,7 @@ module Ruboto
|
|
124
121
|
'THE_RUBOTO_CLASS' => params[:name],
|
125
122
|
'THE_CONSTRUCTORS' => class_desc.name == 'class' ?
|
126
123
|
class_desc.get_elements('constructor').map { |i| i.constructor_definition(params[:name]) }.join("\n\n") : '',
|
127
|
-
'THE_METHODS' => methods.map { |i| i.method_definition(params[:name]) }.join("\n\n")
|
124
|
+
'THE_METHODS' => methods_header + methods.map { |i| i.method_definition(params[:name]) }.join("\n\n")
|
128
125
|
}
|
129
126
|
end
|
130
127
|
|
@@ -134,8 +131,8 @@ module Ruboto
|
|
134
131
|
#
|
135
132
|
def generate_core_classes(params)
|
136
133
|
hash = {:package => 'org.ruboto'}
|
137
|
-
%w(method_base method_include implements force).inject(hash) {|h, i| h[i.to_sym] = params[i.to_sym]; h}
|
138
|
-
hash[:method_exclude] = params[:method_exclude]
|
134
|
+
%w(method_base method_include implements force).inject(hash) { |h, i| h[i.to_sym] = params[i.to_sym]; h }
|
135
|
+
hash[:method_exclude] = params[:method_exclude]
|
139
136
|
|
140
137
|
%w(android.app.Activity android.app.Service android.content.BroadcastReceiver).each do |i|
|
141
138
|
name = i.split('.')[-1]
|
@@ -193,6 +190,21 @@ module Ruboto
|
|
193
190
|
puts "Added file #{test_file}."
|
194
191
|
end
|
195
192
|
end
|
193
|
+
|
194
|
+
def methods_header
|
195
|
+
<<EOF
|
196
|
+
private final ScriptInfo scriptInfo = new ScriptInfo();
|
197
|
+
public ScriptInfo getScriptInfo() {
|
198
|
+
return scriptInfo;
|
199
|
+
}
|
200
|
+
|
201
|
+
/****************************************************************************************
|
202
|
+
*
|
203
|
+
* Generated Methods
|
204
|
+
*/
|
205
|
+
EOF
|
206
|
+
end
|
207
|
+
|
196
208
|
end
|
197
209
|
end
|
198
210
|
end
|
data/lib/ruboto/util/emulator.rb
CHANGED
@@ -83,21 +83,37 @@ module Ruboto
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
if [17, 16, 15, 13, 11].include? sdk_level
|
87
|
-
abi_opt = '--abi armeabi-v7a'
|
88
|
-
elsif sdk_level == 10
|
89
|
-
abi_opt = '--abi armeabi'
|
90
|
-
end
|
91
|
-
|
92
86
|
avd_home = "#{ENV['HOME'].gsub('\\', '/')}/.android/avd/#{avd_name}.avd"
|
87
|
+
|
93
88
|
unless File.exists? avd_home
|
94
89
|
puts "Creating AVD #{avd_name}"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
90
|
+
|
91
|
+
target = `android list target`.split(/----------\n/).
|
92
|
+
find { |l| l =~ /android-#{sdk_level}/ }
|
93
|
+
|
94
|
+
if target.nil?
|
95
|
+
puts "Target android-#{sdk_level} not found. You should run"
|
96
|
+
puts "\n ruboto setup -y -t #{sdk_level}\n\nto install it."
|
97
|
+
exit 3
|
98
|
+
end
|
99
|
+
|
100
|
+
if ON_MAC_OS_X || ON_WINDOWS
|
101
|
+
abis = target.slice(/(?<=ABIs : ).*/).split(', ')
|
102
|
+
has_haxm = abis.find { |a| a =~ /x86/ }
|
99
103
|
end
|
100
|
-
|
104
|
+
|
105
|
+
if has_haxm
|
106
|
+
abi_opt = '--abi x86'
|
107
|
+
else
|
108
|
+
if [17, 16, 15, 13, 11].include? sdk_level
|
109
|
+
abi_opt = '--abi armeabi-v7a'
|
110
|
+
elsif sdk_level == 10
|
111
|
+
abi_opt = '--abi armeabi'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
puts `echo n | android create avd -a -n #{avd_name} -t android-#{sdk_level} #{abi_opt} -c 64M -s HVGA`
|
116
|
+
|
101
117
|
if $? != 0
|
102
118
|
puts 'Failed to create AVD.'
|
103
119
|
exit 3
|
data/lib/ruboto/util/update.rb
CHANGED
@@ -17,7 +17,11 @@ module Ruboto
|
|
17
17
|
def update_android
|
18
18
|
root = Dir.getwd
|
19
19
|
build_xml_file = "#{root}/build.xml"
|
20
|
-
|
20
|
+
if File.exists? build_xml_file
|
21
|
+
name = REXML::Document.new(File.read(build_xml_file)).root.attributes['name']
|
22
|
+
else
|
23
|
+
name = File.basename(root)
|
24
|
+
end
|
21
25
|
|
22
26
|
prop_file = "#{root}/project.properties"
|
23
27
|
version_regexp = /^(target=android-)(\d+)$/
|
@@ -286,14 +290,14 @@ module Ruboto
|
|
286
290
|
puts "Regenerating subclass #{package}.#{subclass_name}"
|
287
291
|
generate_inheriting_file 'Class', subclass_name
|
288
292
|
generate_subclass_or_interface(:package => package, :template => 'InheritingClass', :class => class_name,
|
289
|
-
|
293
|
+
:name => subclass_name, :method_base => method_base, :force => force)
|
290
294
|
# FIXME(uwe): Remove when we stop updating from Ruboto 0.7.0 and older
|
291
295
|
elsif source_code =~ /^\s*package\s+(\S+?)\s*;.*public\s+class\s+(\S+?)\s+extends\s+(.*?)\s\{.*^\s*private Object\[\] callbackProcs = new Object\[\d+\];/m
|
292
296
|
package, subclass_name, class_name = $1, $2, $3
|
293
297
|
puts "Regenerating subclass #{package}.#{subclass_name}"
|
294
298
|
generate_inheriting_file 'Class', subclass_name
|
295
299
|
generate_subclass_or_interface(:package => package, :template => 'InheritingClass', :class => class_name,
|
296
|
-
|
300
|
+
:name => subclass_name, :method_base => 'on', :force => force)
|
297
301
|
# EMXIF
|
298
302
|
end
|
299
303
|
end
|
@@ -411,7 +415,8 @@ module Ruboto
|
|
411
415
|
`jar -xf #{jruby_core}`
|
412
416
|
raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
|
413
417
|
File.delete jruby_core
|
414
|
-
|
418
|
+
gem_version = Gem::Version.new(jruby_core_version.tr('-', '.'))
|
419
|
+
if gem_version >= Gem::Version.new('9000.dev')
|
415
420
|
#noinspection RubyLiteralArrayInspection
|
416
421
|
excluded_core_packages = [
|
417
422
|
'**/*Darwin*',
|
@@ -459,17 +464,17 @@ module Ruboto
|
|
459
464
|
# 'org/jruby/runtime/opto/OptoFactory*', # What is this?
|
460
465
|
'org/yecht',
|
461
466
|
]
|
462
|
-
elsif
|
467
|
+
elsif gem_version >= Gem::Version.new('1.7.5')
|
463
468
|
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
|
464
|
-
elsif
|
469
|
+
elsif gem_version >= Gem::Version.new('1.7.4')
|
465
470
|
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/ripper org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
|
466
|
-
elsif
|
471
|
+
elsif gem_version >= Gem::Version.new('1.7.3')
|
467
472
|
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/javasupport/bsf org/yecht)
|
468
|
-
elsif
|
473
|
+
elsif gem_version >= Gem::Version.new('1.7.2')
|
469
474
|
excluded_core_packages = %w(**/*Darwin* **/*Ruby20* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/MacOS* jnr/posix/OpenBSD* org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/javasupport/bsf)
|
470
|
-
elsif
|
475
|
+
elsif gem_version >= Gem::Version.new('1.7.1')
|
471
476
|
excluded_core_packages = %w(**/*Darwin* **/*Ruby20* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/MacOS* jnr/posix/OpenBSD* org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/openssl org/jruby/javasupport/bsf org/jruby/org/bouncycastle)
|
472
|
-
elsif
|
477
|
+
elsif gem_version >= Gem::Version.new('1.7.0')
|
473
478
|
# TODO(uwe): Remove when we stop supporting jruby-jars 1.7.0
|
474
479
|
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/MacOS* jnr/posix/OpenBSD* org/apache org/bouncycastle org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/openssl org/jruby/javasupport/bsf)
|
475
480
|
# ODOT
|
data/lib/ruboto/util/verify.rb
CHANGED
@@ -67,8 +67,7 @@ module Ruboto
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def verify_strings
|
70
|
-
abort "cannot find your strings.xml to extract info from it. Make sure you're in the root directory of your app" unless
|
71
|
-
File.exists? 'res/values/strings.xml'
|
70
|
+
abort "cannot find your strings.xml to extract info from it. Make sure you're in the root directory of your app" unless File.exists? 'res/values/strings.xml'
|
72
71
|
@strings ||= REXML::Document.new(File.read('res/values/strings.xml'))
|
73
72
|
end
|
74
73
|
|
@@ -187,38 +187,68 @@ module Ruboto
|
|
187
187
|
end
|
188
188
|
|
189
189
|
def method_definition(class_name)
|
190
|
+
entry_point_guard = (activity_super_guard(class_name, attribute('name')) ||
|
191
|
+
service_super_guard(class_name, attribute('name')))
|
190
192
|
method_call(
|
191
193
|
(attribute('return') ? attribute('return') : 'void'),
|
192
194
|
attribute('name'), parameters,
|
193
195
|
get_elements('exception').map { |m| m.attribute('type') },
|
194
196
|
["if (ScriptLoader.isCalledFromJRuby()) #{super_return}",
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
197
|
+
(entry_point_guard && (entry_point_guard + load_script)) ||
|
198
|
+
if_else('!JRubyAdapter.isInitialized()',
|
199
|
+
[%Q{Log.i("Method called before JRuby runtime was initialized: #{class_name}##{attribute('name')}");},
|
200
|
+
super_return]),
|
201
|
+
'String rubyClassName = scriptInfo.getRubyClassName();',
|
202
|
+
"if (rubyClassName == null) #{super_return}",
|
203
|
+
if_else(
|
204
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
|
205
|
+
ruby_call,
|
206
|
+
if_else(
|
207
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
|
208
|
+
ruby_call(true),
|
209
|
+
if_else(
|
210
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
|
211
|
+
ruby_call(true),
|
212
|
+
# FIXME(uwe): Can the method be unimplemented? Is the Ruby instance always an instance of this class?
|
213
|
+
#if_else(
|
214
|
+
# "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{attribute('name')}}\")",
|
215
|
+
ruby_call,
|
216
|
+
# [super_return]
|
217
|
+
#)
|
218
|
+
)
|
219
|
+
)
|
220
|
+
),
|
221
|
+
('ScriptLoader.unloadScript(this);' if attribute('name') == 'onDestroy'),
|
218
222
|
]
|
219
223
|
).indent.join("\n")
|
220
224
|
end
|
221
225
|
|
226
|
+
def activity_super_guard(class_name, method_name)
|
227
|
+
if class_name == 'RubotoActivity' && method_name == 'onCreate'
|
228
|
+
"if (preOnCreate(#{parameters.map { |i| i[0] }.join(', ')})) #{super_return};"
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def service_super_guard(class_name, method_name)
|
233
|
+
if class_name == 'RubotoService'
|
234
|
+
if method_name == 'onCreate'
|
235
|
+
'preOnCreate();'
|
236
|
+
elsif method_name == 'onStartCommand' || method_name == 'onBind'
|
237
|
+
'' # Trigger adding of load_script
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def load_script
|
243
|
+
<<EOF
|
244
|
+
if (JRubyAdapter.isInitialized() && scriptInfo.isReadyToLoad()) {
|
245
|
+
ScriptLoader.loadScript(this);
|
246
|
+
} else {
|
247
|
+
#{super_return}
|
248
|
+
}
|
249
|
+
EOF
|
250
|
+
end
|
251
|
+
|
222
252
|
def constructor_definition(class_name)
|
223
253
|
method_call(nil, class_name, parameters, nil, [super_string]).indent.join("\n")
|
224
254
|
end
|
data/lib/ruboto/version.rb
CHANGED
@@ -12,6 +12,7 @@ end
|
|
12
12
|
|
13
13
|
# ANDROID: 10, PLATFORM: 0.5.3, JRuby: 1.7.3 '[28, 33, 46, 63]' expected, but got '[43, 48, 45, 62]'
|
14
14
|
# ANDROID: 10, PLATFORM: 0.5.4, JRuby: 1.7.3 '[28, 33, 45, 62]' expected, but got '[28, 33, 44, 61]'
|
15
|
+
# ANDROID: 16, PLATFORM: 0.5.6, JRuby: 1.7.3 '[28, 33, 45, 62]' expected, but got '[28, 33, 44, 61]'
|
15
16
|
# ANDROID: 16, PLATFORM: 0.6.0, JRuby: 9000.dev '[28, 33, 45, 62]' expected, but got '[28, 33, 45, 63]'
|
16
17
|
# ANDROID: 15, PLATFORM: STANDALONE, JRuby: 1.7.0 '[28, 33, 51, 68]' expected, but got '[28, 33, 47, 64]'
|
17
18
|
test('stack depth') do |activity|
|
@@ -27,8 +28,8 @@ test('stack depth') do |activity|
|
|
27
28
|
version_message ="ANDROID: #{android.os.Build::VERSION::SDK_INT}, PLATFORM: #{org.ruboto.JRubyAdapter.uses_platform_apk ? org.ruboto.JRubyAdapter.platform_version_name : 'STANDALONE'}, JRuby: #{org.jruby.runtime.Constants::VERSION}"
|
28
29
|
assert_equal [28 + os_offset[0] + jruby_offset[0],
|
29
30
|
33 + os_offset[1] + jruby_offset[1],
|
30
|
-
|
31
|
-
|
31
|
+
44 + os_offset[2] + jruby_offset[2],
|
32
|
+
62 + os_offset[3] + jruby_offset[3]], [
|
32
33
|
activity.find_view_by_id(42).text.to_i,
|
33
34
|
activity.find_view_by_id(43).text.to_i,
|
34
35
|
activity.find_view_by_id(44).text.to_i,
|
@@ -4,7 +4,6 @@ ruboto_import_widgets :LinearLayout, :ListView, :TextView
|
|
4
4
|
|
5
5
|
class SubclassOfArrayAdapter < Java::AndroidWidget::ArrayAdapter
|
6
6
|
def getView(position, convert_view, parent)
|
7
|
-
puts 'IN get_view!!!'
|
8
7
|
@inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
|
9
8
|
row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
|
10
9
|
row.findViewById(mFieldId).text = "[#{get_item(position)}]"
|
data/test/arjdbc_test.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
# FIXME(uwe): Remove check when we stop supporting Android < 4.0.3
|
4
|
+
if RubotoTest::ANDROID_OS >= 15 || RubotoTest::RUBOTO_PLATFORM != 'STANDALONE'
|
5
|
+
|
6
|
+
class SqldroidTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
generate_app :bundle => [['activerecord', '<4.0.0'], 'activerecord-jdbcsqlite3-adapter', :sqldroid]
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
cleanup_app
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_sqldroid
|
16
|
+
Dir.chdir APP_DIR do
|
17
|
+
File.open('src/ruboto_test_app_activity.rb', 'w'){|f| f << <<EOF}
|
18
|
+
require 'ruboto/widget'
|
19
|
+
require 'ruboto/util/stack'
|
20
|
+
with_large_stack do
|
21
|
+
require 'active_record'
|
22
|
+
end
|
23
|
+
|
24
|
+
ruboto_import_widgets :LinearLayout, :ListView, :TextView
|
25
|
+
|
26
|
+
class MyArrayAdapter < android.widget.ArrayAdapter
|
27
|
+
def get_view(position, convert_view, parent)
|
28
|
+
@inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
|
29
|
+
row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
|
30
|
+
row.findViewById(mFieldId).text = get_item(position)
|
31
|
+
row
|
32
|
+
rescue Exception
|
33
|
+
puts "Exception getting list item view: \#$!"
|
34
|
+
puts $!.backtrace.join("\\n")
|
35
|
+
convert_view
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class RubotoTestAppActivity
|
40
|
+
def onCreate(bundle)
|
41
|
+
super
|
42
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "\#{s[0..0].upcase}\#{s[1..-1]}" }.join(' ')
|
43
|
+
|
44
|
+
@adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , AndroidIds::text1, [])
|
45
|
+
|
46
|
+
self.content_view =
|
47
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
48
|
+
@text_view_margins = text_view :text => 'What hath Matz wrought?', :id => 42
|
49
|
+
@list_view = list_view :adapter => @adapter, :id => 43
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def onResume
|
54
|
+
super
|
55
|
+
|
56
|
+
db_dir = "\#{application_context.files_dir}/sqlite"
|
57
|
+
|
58
|
+
with_large_stack do
|
59
|
+
|
60
|
+
ActiveRecord::Base.establish_connection(
|
61
|
+
:adapter => 'jdbcsqlite3',
|
62
|
+
:driver => 'org.sqldroid.SQLDroidDriver',
|
63
|
+
:url => "jdbc:sqldroid:\#{db_dir}?timeout=60000&retry=1000",
|
64
|
+
:database => db_dir,
|
65
|
+
)
|
66
|
+
|
67
|
+
begin
|
68
|
+
ActiveRecord::Base.connection.execute "DROP TABLE companions"
|
69
|
+
rescue ActiveRecord::StatementInvalid
|
70
|
+
# Table does not exist
|
71
|
+
end
|
72
|
+
ActiveRecord::Base.connection.execute "CREATE TABLE companions (id INTEGER PRIMARY KEY, name VARCHAR(20) NOT NULL)"
|
73
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (1, 'Frodo')"
|
74
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (2, 'Samwise')"
|
75
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (3, 'Meriadoc')"
|
76
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (4, 'Peregrin')"
|
77
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (5, 'Gandalf')"
|
78
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (6, 'Legolas')"
|
79
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (7, 'Gimli')"
|
80
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (8, 'Aragorn')"
|
81
|
+
ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (9, 'Boromir')"
|
82
|
+
companions = ActiveRecord::Base.connection.execute "SELECT name FROM companions"
|
83
|
+
run_on_ui_thread do
|
84
|
+
@adapter.add_all companions
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
EOF
|
90
|
+
|
91
|
+
File.open('test/src/ruboto_test_app_activity_test.rb', 'w'){|f| f << <<EOF}
|
92
|
+
activity Java::org.ruboto.test_app.RubotoTestAppActivity
|
93
|
+
|
94
|
+
setup do |activity|
|
95
|
+
start = Time.now
|
96
|
+
loop do
|
97
|
+
@text_view = activity.findViewById(42)
|
98
|
+
@list_view = activity.findViewById(43)
|
99
|
+
break if (@text_view && @list_view) || (Time.now - start > 60)
|
100
|
+
sleep 1
|
101
|
+
end
|
102
|
+
assert @text_view
|
103
|
+
assert @list_view
|
104
|
+
end
|
105
|
+
|
106
|
+
test("activity starts") do |activity|
|
107
|
+
assert true
|
108
|
+
end
|
109
|
+
EOF
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
run_app_tests
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
# EMXIF
|