ruboto-core 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +16 -0
- data/README.md +65 -3
- data/Rakefile +1 -135
- data/assets/Rakefile +2 -0
- data/assets/assets/scripts/ruboto.rb +243 -97
- data/assets/src/InheritingClass.java +28 -0
- data/assets/src/RubotoActivity.java +122 -0
- data/assets/src/RubotoBroadcastReceiver.java +77 -0
- data/assets/src/RubotoService.java +75 -0
- data/bin/ruboto +732 -44
- data/lib/java_class_gen/android_api.xml +1 -0
- metadata +11 -11
- data/assets/src/org/ruboto/RubotoActivity.java +0 -1406
- data/assets/src/org/ruboto/RubotoBroadcastReceiver.java +0 -126
- data/assets/src/org/ruboto/RubotoService.java +0 -233
- data/assets/src/org/ruboto/RubotoView.java +0 -30
- data/lib/java_class_gen/RubotoClass.java.erb +0 -197
- data/lib/java_class_gen/callback_reflection.rb +0 -109
- data/lib/java_class_gen/interfaces.txt +0 -1
@@ -1,109 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Run on a device and then copy interfaces.txt back to the callback_gen directory.
|
3
|
-
#
|
4
|
-
# The result is a hash.
|
5
|
-
# The keys are names the names of the classes, sometimes followed by a
|
6
|
-
# $ and then the name of the interface.
|
7
|
-
# The keys are hashes themselves. These hashes have keys of the method
|
8
|
-
# names and values of yet another hash, which gives the argument types
|
9
|
-
# (and thus implicitly the number of args), the return type, etc.
|
10
|
-
|
11
|
-
require 'java'
|
12
|
-
|
13
|
-
class ReflectionBuilder
|
14
|
-
attr_reader :methods
|
15
|
-
|
16
|
-
def initialize(class_name, callbacks_only=false)
|
17
|
-
@methods = {}
|
18
|
-
@@count = 0 unless defined?(@@count)
|
19
|
-
reflect class_name, callbacks_only
|
20
|
-
end
|
21
|
-
|
22
|
-
def reflect(klass, callbacks_only=false)
|
23
|
-
# klass can be the java class object or a string
|
24
|
-
klass = java_class klass if klass.class == String
|
25
|
-
|
26
|
-
hash = @methods[klass.getName] = {}
|
27
|
-
|
28
|
-
# iterate over the public methods of the class
|
29
|
-
klass.getDeclaredMethods.reject {|method| java.lang.reflect.Modifier.isPrivate(method.getModifiers) || java.lang.reflect.Modifier.isFinal(method.getModifiers) }.each do |method|
|
30
|
-
if !callbacks_only or method.getName[0..1] == "on"
|
31
|
-
hash[method.getName] = {}
|
32
|
-
hash[method.getName]["return_type"] = method.getReturnType.getName unless method.getReturnType.getName == "void"
|
33
|
-
# the gsub below converts [Ljava nonsense to ClassName[]
|
34
|
-
hash[method.getName]["args"] = method.getParameterTypes.map {|i| i.getName.gsub(/\[Ljava\.[\w\.]+;/) {|m| "#{m[2..-2]}[]"}} unless method.getParameterTypes.empty?
|
35
|
-
hash[method.getName]["abstract"] = java.lang.reflect.Modifier.isAbstract(method.getModifiers)
|
36
|
-
@@count += 1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def interfaces(*args)
|
42
|
-
args.each {|arg| reflect arg}
|
43
|
-
end
|
44
|
-
|
45
|
-
def interfaces_under(*args)
|
46
|
-
args.each do |name|
|
47
|
-
interfaces *java.lang.Class.forName(name).getClasses.select {|klass| klass.isInterface}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.count
|
52
|
-
@@count
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.reset_count
|
56
|
-
@@count = 0
|
57
|
-
end
|
58
|
-
|
59
|
-
protected
|
60
|
-
def java_class(class_name)
|
61
|
-
java.lang.Class.forName(class_name)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def java_reflect(class_name, callbacks_only=false, &block)
|
66
|
-
r = ReflectionBuilder.new(class_name, callbacks_only)
|
67
|
-
yield r if block
|
68
|
-
$result[class_name] = r.methods
|
69
|
-
end
|
70
|
-
|
71
|
-
def reflect_multiple(*classes)
|
72
|
-
classes.each {|c| java_reflect c }
|
73
|
-
end
|
74
|
-
|
75
|
-
$result = {}
|
76
|
-
ReflectionBuilder.reset_count
|
77
|
-
|
78
|
-
java_reflect 'android.app.Activity', true do |r|
|
79
|
-
r.interfaces *%w(
|
80
|
-
android.hardware.SensorEventListener
|
81
|
-
java.lang.Runnable
|
82
|
-
)
|
83
|
-
|
84
|
-
r.interfaces_under *%w(
|
85
|
-
android.view.View
|
86
|
-
android.widget.AdapterView
|
87
|
-
android.widget.TabHost
|
88
|
-
android.widget.TextView
|
89
|
-
android.widget.DatePicker
|
90
|
-
android.widget.TimePicker
|
91
|
-
android.app.DatePickerDialog
|
92
|
-
android.app.TimePickerDialog
|
93
|
-
android.content.DialogInterface
|
94
|
-
)
|
95
|
-
end
|
96
|
-
|
97
|
-
reflect_multiple *%w(
|
98
|
-
android.app.Service
|
99
|
-
android.content.BroadcastReceiver
|
100
|
-
)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
File.open("/sdcard/jruby/interfaces.txt", "w") do |file|
|
105
|
-
file.write $result.inspect
|
106
|
-
end
|
107
|
-
|
108
|
-
puts ReflectionBuilder.count
|
109
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
{"android.app.Activity"=>{"android.app.Activity"=>{"onActivityResult"=>{"args"=>["int", "int", "android.content.Intent"], "abstract"=>false}, "onApplyThemeResource"=>{"args"=>["android.content.res.Resources$Theme", "int", "boolean"], "abstract"=>false}, "onAttachedToWindow"=>{"abstract"=>false}, "onBackPressed"=>{"abstract"=>false}, "onChildTitleChanged"=>{"args"=>["android.app.Activity", "java.lang.CharSequence"], "abstract"=>false}, "onConfigurationChanged"=>{"args"=>["android.content.res.Configuration"], "abstract"=>false}, "onContentChanged"=>{"abstract"=>false}, "onContextItemSelected"=>{"return_type"=>"boolean", "args"=>["android.view.MenuItem"], "abstract"=>false}, "onContextMenuClosed"=>{"args"=>["android.view.Menu"], "abstract"=>false}, "onCreate"=>{"args"=>["android.os.Bundle"], "abstract"=>false}, "onCreateContextMenu"=>{"args"=>["android.view.ContextMenu", "android.view.View", "android.view.ContextMenu$ContextMenuInfo"], "abstract"=>false}, "onCreateDescription"=>{"return_type"=>"java.lang.CharSequence", "abstract"=>false}, "onCreateDialog"=>{"return_type"=>"android.app.Dialog", "args"=>["int", "android.os.Bundle"], "abstract"=>false}, "onCreateOptionsMenu"=>{"return_type"=>"boolean", "args"=>["android.view.Menu"], "abstract"=>false}, "onCreatePanelMenu"=>{"return_type"=>"boolean", "args"=>["int", "android.view.Menu"], "abstract"=>false}, "onCreatePanelView"=>{"return_type"=>"android.view.View", "args"=>["int"], "abstract"=>false}, "onCreateThumbnail"=>{"return_type"=>"boolean", "args"=>["android.graphics.Bitmap", "android.graphics.Canvas"], "abstract"=>false}, "onCreateView"=>{"return_type"=>"android.view.View", "args"=>["java.lang.String", "android.content.Context", "android.util.AttributeSet"], "abstract"=>false}, "onDestroy"=>{"abstract"=>false}, "onDetachedFromWindow"=>{"abstract"=>false}, "onKeyDown"=>{"return_type"=>"boolean", "args"=>["int", "android.view.KeyEvent"], "abstract"=>false}, "onKeyLongPress"=>{"return_type"=>"boolean", "args"=>["int", "android.view.KeyEvent"], "abstract"=>false}, "onKeyMultiple"=>{"return_type"=>"boolean", "args"=>["int", "int", "android.view.KeyEvent"], "abstract"=>false}, "onKeyUp"=>{"return_type"=>"boolean", "args"=>["int", "android.view.KeyEvent"], "abstract"=>false}, "onLowMemory"=>{"abstract"=>false}, "onMenuItemSelected"=>{"return_type"=>"boolean", "args"=>["int", "android.view.MenuItem"], "abstract"=>false}, "onMenuOpened"=>{"return_type"=>"boolean", "args"=>["int", "android.view.Menu"], "abstract"=>false}, "onNewIntent"=>{"args"=>["android.content.Intent"], "abstract"=>false}, "onOptionsItemSelected"=>{"return_type"=>"boolean", "args"=>["android.view.MenuItem"], "abstract"=>false}, "onOptionsMenuClosed"=>{"args"=>["android.view.Menu"], "abstract"=>false}, "onPanelClosed"=>{"args"=>["int", "android.view.Menu"], "abstract"=>false}, "onPause"=>{"abstract"=>false}, "onPostCreate"=>{"args"=>["android.os.Bundle"], "abstract"=>false}, "onPostResume"=>{"abstract"=>false}, "onPrepareDialog"=>{"args"=>["int", "android.app.Dialog", "android.os.Bundle"], "abstract"=>false}, "onPrepareOptionsMenu"=>{"return_type"=>"boolean", "args"=>["android.view.Menu"], "abstract"=>false}, "onPreparePanel"=>{"return_type"=>"boolean", "args"=>["int", "android.view.View", "android.view.Menu"], "abstract"=>false}, "onRestart"=>{"abstract"=>false}, "onRestoreInstanceState"=>{"args"=>["android.os.Bundle"], "abstract"=>false}, "onResume"=>{"abstract"=>false}, "onRetainNonConfigurationChildInstances"=>{"return_type"=>"java.util.HashMap", "abstract"=>false}, "onRetainNonConfigurationInstance"=>{"return_type"=>"java.lang.Object", "abstract"=>false}, "onSaveInstanceState"=>{"args"=>["android.os.Bundle"], "abstract"=>false}, "onSearchRequested"=>{"return_type"=>"boolean", "abstract"=>false}, "onStart"=>{"abstract"=>false}, "onStop"=>{"abstract"=>false}, "onTitleChanged"=>{"args"=>["java.lang.CharSequence", "int"], "abstract"=>false}, "onTouchEvent"=>{"return_type"=>"boolean", "args"=>["android.view.MotionEvent"], "abstract"=>false}, "onTrackballEvent"=>{"return_type"=>"boolean", "args"=>["android.view.MotionEvent"], "abstract"=>false}, "onUserInteraction"=>{"abstract"=>false}, "onUserLeaveHint"=>{"abstract"=>false}, "onWindowAttributesChanged"=>{"args"=>["android.view.WindowManager$LayoutParams"], "abstract"=>false}, "onWindowFocusChanged"=>{"args"=>["boolean"], "abstract"=>false}}, "android.hardware.SensorEventListener"=>{"onAccuracyChanged"=>{"args"=>["android.hardware.Sensor", "int"], "abstract"=>true}, "onSensorChanged"=>{"args"=>["android.hardware.SensorEvent"], "abstract"=>true}}, "java.lang.Runnable"=>{"run"=>{"abstract"=>true}}, "android.view.View$OnCreateContextMenuListener"=>{"onCreateContextMenu"=>{"args"=>["android.view.ContextMenu", "android.view.View", "android.view.ContextMenu$ContextMenuInfo"], "abstract"=>true}}, "android.view.View$OnClickListener"=>{"onClick"=>{"args"=>["android.view.View"], "abstract"=>true}}, "android.view.View$OnFocusChangeListener"=>{"onFocusChange"=>{"args"=>["android.view.View", "boolean"], "abstract"=>true}}, "android.view.View$OnLongClickListener"=>{"onLongClick"=>{"return_type"=>"boolean", "args"=>["android.view.View"], "abstract"=>true}}, "android.view.View$OnTouchListener"=>{"onTouch"=>{"return_type"=>"boolean", "args"=>["android.view.View", "android.view.MotionEvent"], "abstract"=>true}}, "android.view.View$OnKeyListener"=>{"onKey"=>{"return_type"=>"boolean", "args"=>["android.view.View", "int", "android.view.KeyEvent"], "abstract"=>true}}, "android.widget.AdapterView$OnItemSelectedListener"=>{"onItemSelected"=>{"args"=>["android.widget.AdapterView", "android.view.View", "int", "long"], "abstract"=>true}, "onNothingSelected"=>{"args"=>["android.widget.AdapterView"], "abstract"=>true}}, "android.widget.AdapterView$OnItemLongClickListener"=>{"onItemLongClick"=>{"return_type"=>"boolean", "args"=>["android.widget.AdapterView", "android.view.View", "int", "long"], "abstract"=>true}}, "android.widget.AdapterView$OnItemClickListener"=>{"onItemClick"=>{"args"=>["android.widget.AdapterView", "android.view.View", "int", "long"], "abstract"=>true}}, "android.view.ViewGroup$OnHierarchyChangeListener"=>{"onChildViewAdded"=>{"args"=>["android.view.View", "android.view.View"], "abstract"=>true}, "onChildViewRemoved"=>{"args"=>["android.view.View", "android.view.View"], "abstract"=>true}}, "android.widget.TabHost$TabContentFactory"=>{"createTabContent"=>{"return_type"=>"android.view.View", "args"=>["java.lang.String"], "abstract"=>true}}, "android.widget.TabHost$OnTabChangeListener"=>{"onTabChanged"=>{"args"=>["java.lang.String"], "abstract"=>true}}, "android.widget.TextView$OnEditorActionListener"=>{"onEditorAction"=>{"return_type"=>"boolean", "args"=>["android.widget.TextView", "int", "android.view.KeyEvent"], "abstract"=>true}}, "android.widget.DatePicker$OnDateChangedListener"=>{"onDateChanged"=>{"args"=>["android.widget.DatePicker", "int", "int", "int"], "abstract"=>true}}, "android.widget.TimePicker$OnTimeChangedListener"=>{"onTimeChanged"=>{"args"=>["android.widget.TimePicker", "int", "int"], "abstract"=>true}}, "android.app.DatePickerDialog$OnDateSetListener"=>{"onDateSet"=>{"args"=>["android.widget.DatePicker", "int", "int", "int"], "abstract"=>true}}, "android.app.TimePickerDialog$OnTimeSetListener"=>{"onTimeSet"=>{"args"=>["android.widget.TimePicker", "int", "int"], "abstract"=>true}}, "android.content.DialogInterface$OnKeyListener"=>{"onKey"=>{"return_type"=>"boolean", "args"=>["android.content.DialogInterface", "int", "android.view.KeyEvent"], "abstract"=>true}}, "android.content.DialogInterface$OnMultiChoiceClickListener"=>{"onClick"=>{"args"=>["android.content.DialogInterface", "int", "boolean"], "abstract"=>true}}, "android.content.DialogInterface$OnClickListener"=>{"onClick"=>{"args"=>["android.content.DialogInterface", "int"], "abstract"=>true}}, "android.content.DialogInterface$OnShowListener"=>{"onShow"=>{"args"=>["android.content.DialogInterface"], "abstract"=>true}}, "android.content.DialogInterface$OnDismissListener"=>{"onDismiss"=>{"args"=>["android.content.DialogInterface"], "abstract"=>true}}, "android.content.DialogInterface$OnCancelListener"=>{"onCancel"=>{"args"=>["android.content.DialogInterface"], "abstract"=>true}}}, "android.app.Service"=>{"android.app.Service"=>{"dump"=>{"args"=>["java.io.FileDescriptor", "java.io.PrintWriter", "java.lang.String[]"], "abstract"=>false}, "finalize"=>{"abstract"=>false}, "onBind"=>{"return_type"=>"android.os.IBinder", "args"=>["android.content.Intent"], "abstract"=>true}, "onConfigurationChanged"=>{"args"=>["android.content.res.Configuration"], "abstract"=>false}, "onCreate"=>{"abstract"=>false}, "onDestroy"=>{"abstract"=>false}, "onLowMemory"=>{"abstract"=>false}, "onRebind"=>{"args"=>["android.content.Intent"], "abstract"=>false}, "onStart"=>{"args"=>["android.content.Intent", "int"], "abstract"=>false}, "onStartCommand"=>{"return_type"=>"int", "args"=>["android.content.Intent", "int", "int"], "abstract"=>false}, "onUnbind"=>{"return_type"=>"boolean", "args"=>["android.content.Intent"], "abstract"=>false}}}, "android.content.BroadcastReceiver"=>{"android.content.BroadcastReceiver"=>{"checkSynchronousHint"=>{"abstract"=>false}, "onReceive"=>{"args"=>["android.content.Context", "android.content.Intent"], "abstract"=>true}, "peekService"=>{"return_type"=>"android.os.IBinder", "args"=>["android.content.Context", "android.content.Intent"], "abstract"=>false}}}}
|