adamaig-ruby_activeworld 0.1-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/README +131 -0
- data/examples/configs.yml +10 -0
- data/examples/sample_event_bot.rb +29 -0
- data/ext/extconf.rb +8 -0
- data/lib/ruby_activeworld_enums.rb +1678 -0
- data/lib/ruby_activeworld_support.rb +586 -0
- data/lib/ruby_aw.rb +84 -0
- data/utilities/aw_enums_and_constants.rb +80 -0
- data/utilities/callback_generator.rb +126 -0
- data/utilities/ruby_activeworld_enums.rb +1678 -0
- data/utilities/t.txt +1127 -0
- metadata +68 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
AW_HEADER = "../lib/Aw.h"
|
3
|
+
RUBY_AW_ENUMS = "ruby_activeworld_enums.rb"
|
4
|
+
|
5
|
+
module RubyActiveworldUtils
|
6
|
+
|
7
|
+
@@ENUMS = {}
|
8
|
+
|
9
|
+
def self.parse_enum(typedefed_as)
|
10
|
+
File.open(RUBY_AW_ENUMS, "a") do |rawenum|
|
11
|
+
s = File.open(AW_HEADER,"r") {|f| s = f.read}
|
12
|
+
s =~ /typedef enum \{([^}]+?)\}\s*#{typedefed_as}\s*\;/m
|
13
|
+
enum_name = $~.captures[0]
|
14
|
+
|
15
|
+
enum_name = enum_name.split(/,/).reject {|x| x.strip!; x.nil? || x.empty? }.each do |x|
|
16
|
+
x.gsub!(/\/\/.*$/,"")
|
17
|
+
x.gsub!(/\/\*.*\*\//,"")
|
18
|
+
x.strip!
|
19
|
+
end
|
20
|
+
|
21
|
+
@@ENUMS[typedefed_as.to_sym] = {}
|
22
|
+
rawenum.write "
|
23
|
+
def self.#{typedefed_as.downcase}(v=nil)
|
24
|
+
r = v.nil? ? @@ENUMS[:#{typedefed_as}] : @@ENUMS[:#{typedefed_as}][v.to_sym]
|
25
|
+
raise \"Unknown AWSDK value '\#{v}'\" if r.nil?
|
26
|
+
r
|
27
|
+
end
|
28
|
+
\# Constants for the enum #{typedefed_as}\n"
|
29
|
+
|
30
|
+
next_value = 0
|
31
|
+
enum_name.each_with_index do |x,i|
|
32
|
+
vals = x.split("=").each {|v| v.strip!}
|
33
|
+
next_value = Integer(vals[1]) if vals[1]
|
34
|
+
@@ENUMS[typedefed_as.to_sym][vals[0].to_sym] = next_value
|
35
|
+
|
36
|
+
# define the constant at both the module and application instance levels
|
37
|
+
|
38
|
+
rawenum.write "#{" #{vals[0]} = #{next_value}".ljust(50)}\#original line : #{x}\n"
|
39
|
+
next_value += 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def self.dump_enums
|
46
|
+
File.open(RUBY_AW_ENUMS, "a") do |rawenum|
|
47
|
+
rawenum.write "\n\# This hash provides named access to the enum values if desired\n @@ENUMS = {\n";
|
48
|
+
sorted_keys = @@ENUMS.keys.sort {|a,b| a.to_s <=> b.to_s}
|
49
|
+
sorted_keys.each do |key|
|
50
|
+
rawenum.write " :#{key} => {\n"
|
51
|
+
@@ENUMS[key].each_pair do |k,v|
|
52
|
+
rawenum.write " :#{k} => #{v},\n"
|
53
|
+
end
|
54
|
+
rawenum.write sorted_keys.last == key ? " }\n" : " },\n"
|
55
|
+
end
|
56
|
+
rawenum.write " }\n";
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# when this file is loaded this generates all the enum values as constants
|
62
|
+
s = File.open(AW_HEADER,"r") {|f| s = f.read}
|
63
|
+
enums = []
|
64
|
+
while(s =~ /typedef enum \{[^}]*\}\s*?([^;]+?)\;/m)
|
65
|
+
enums << $~.captures[0].strip
|
66
|
+
s = $~.post_match
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
File.open(RUBY_AW_ENUMS, "w") do |rawenum|
|
71
|
+
rawenum.write "class RubyActiveworld\n def self.enums; @@ENUMS.keys; end;\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
enums.each {|enum| RubyActiveworldUtils.parse_enum(enum)}
|
75
|
+
|
76
|
+
RubyActiveworldUtils.dump_enums
|
77
|
+
|
78
|
+
File.open(RUBY_AW_ENUMS, "a") do |rawenum|
|
79
|
+
rawenum.write "end"
|
80
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
s = "AW_EVENT_ADMIN_WORLD_DELETE
|
2
|
+
AW_EVENT_ADMIN_WORLD_INFO
|
3
|
+
AW_EVENT_AVATAR_ADD
|
4
|
+
AW_EVENT_AVATAR_CHANGE
|
5
|
+
AW_EVENT_AVATAR_CLICK
|
6
|
+
AW_EVENT_AVATAR_DELETE
|
7
|
+
AW_EVENT_AVATAR_RELOAD
|
8
|
+
AW_EVENT_BOTGRAM
|
9
|
+
AW_EVENT_BOTMENU
|
10
|
+
AW_EVENT_CAMERA
|
11
|
+
AW_EVENT_CELL_BEGIN
|
12
|
+
AW_EVENT_CELL_END
|
13
|
+
AW_EVENT_CELL_OBJECT
|
14
|
+
AW_EVENT_CHAT
|
15
|
+
AW_EVENT_CONSOLE_MESSAGE
|
16
|
+
AW_EVENT_CONTACT_STATE
|
17
|
+
AW_EVENT_ENTITY_ADD
|
18
|
+
AW_EVENT_ENTITY_CHANGE
|
19
|
+
AW_EVENT_ENTITY_DELETE
|
20
|
+
AW_EVENT_ENTITY_LINKS
|
21
|
+
AW_EVENT_ENTITY_RIDER_ADD
|
22
|
+
AW_EVENT_ENTITY_RIDER_CHANGE
|
23
|
+
AW_EVENT_ENTITY_RIDER_DELETE
|
24
|
+
AW_EVENT_HUD_CLEAR
|
25
|
+
AW_EVENT_HUD_CLICK
|
26
|
+
AW_EVENT_HUD_CREATE
|
27
|
+
AW_EVENT_HUD_DESTROY
|
28
|
+
AW_EVENT_JOIN
|
29
|
+
AW_EVENT_NOISE
|
30
|
+
AW_EVENT_OBJECT_ADD
|
31
|
+
AW_EVENT_OBJECT_BUMP
|
32
|
+
AW_EVENT_OBJECT_CLICK
|
33
|
+
AW_EVENT_OBJECT_DELETE
|
34
|
+
AW_EVENT_OBJECT_SELECT
|
35
|
+
AW_EVENT_SEND_FILE
|
36
|
+
AW_EVENT_TELEGRAM
|
37
|
+
AW_EVENT_TELEPORT
|
38
|
+
AW_EVENT_TERRAIN_BEGIN
|
39
|
+
AW_EVENT_TERRAIN_CHANGED
|
40
|
+
AW_EVENT_TERRAIN_DATA
|
41
|
+
AW_EVENT_TERRAIN_END
|
42
|
+
AW_EVENT_TOOLBAR_CLICK
|
43
|
+
AW_EVENT_UNIVERSE_ATTRIBUTES
|
44
|
+
AW_EVENT_UNIVERSE_DISCONNECT
|
45
|
+
AW_EVENT_URL
|
46
|
+
AW_EVENT_URL_CLICK
|
47
|
+
AW_EVENT_USER_INFO
|
48
|
+
AW_EVENT_VOIP_DATA
|
49
|
+
AW_EVENT_WORLD_ATTRIBUTES
|
50
|
+
AW_EVENT_WORLD_DISCONNECT
|
51
|
+
AW_EVENT_WORLD_INFO
|
52
|
+
AW_CALLBACK_ADDRESS
|
53
|
+
AW_CALLBACK_ADMIN
|
54
|
+
AW_CALLBACK_ADMIN_WORLD_LIST
|
55
|
+
AW_CALLBACK_ADMIN_WORLD_RESULT
|
56
|
+
AW_CALLBACK_ATTRIBUTES_RESET_RESULT
|
57
|
+
AW_CALLBACK_AVATAR_LOCATION
|
58
|
+
AW_CALLBACK_BOTGRAM_RESULT
|
59
|
+
AW_CALLBACK_BOTMENU_RESULT
|
60
|
+
AW_CALLBACK_CAV
|
61
|
+
AW_CALLBACK_CAV_RESULT
|
62
|
+
AW_CALLBACK_CAV_TEMPLATE
|
63
|
+
AW_CALLBACK_CAV_TEMPLATE_RESULT
|
64
|
+
AW_CALLBACK_CELL_RESULT
|
65
|
+
AW_CALLBACK_CITIZEN_ATTRIBUTES
|
66
|
+
AW_CALLBACK_CITIZEN_RESULT
|
67
|
+
AW_CALLBACK_CONTACT_ADD
|
68
|
+
AW_CALLBACK_CREATE
|
69
|
+
AW_CALLBACK_DELETE_ALL_OBJECTS_RESULT
|
70
|
+
AW_CALLBACK_ENTER
|
71
|
+
AW_CALLBACK_HUD_RESULT
|
72
|
+
AW_CALLBACK_IMMIGRATE
|
73
|
+
AW_CALLBACK_JOIN
|
74
|
+
AW_CALLBACK_LICENSE_ATTRIBUTES
|
75
|
+
AW_CALLBACK_LICENSE_RESULT
|
76
|
+
AW_CALLBACK_LOGIN
|
77
|
+
AW_CALLBACK_OBJECT_RESULT
|
78
|
+
AW_CALLBACK_PASSWORD_SEND
|
79
|
+
AW_CALLBACK_QUERY
|
80
|
+
AW_CALLBACK_REGISTER
|
81
|
+
AW_CALLBACK_RELOAD_REGISTRY
|
82
|
+
AW_CALLBACK_SEND_FILE
|
83
|
+
AW_CALLBACK_TELEGRAM_RESULT
|
84
|
+
AW_CALLBACK_TERRAIN_DELETE_ALL_RESULT
|
85
|
+
AW_CALLBACK_TERRAIN_LOAD_NODE_RESULT
|
86
|
+
AW_CALLBACK_TERRAIN_NEXT_RESULT
|
87
|
+
AW_CALLBACK_TERRAIN_SET_RESULT
|
88
|
+
AW_CALLBACK_UNIVERSE_EJECTION
|
89
|
+
AW_CALLBACK_UNIVERSE_EJECTION_RESULT
|
90
|
+
AW_CALLBACK_USER_LIST
|
91
|
+
AW_CALLBACK_WORLD_EJECTION
|
92
|
+
AW_CALLBACK_WORLD_EJECTION_RESULT
|
93
|
+
AW_CALLBACK_WORLD_INSTANCE
|
94
|
+
AW_CALLBACK_WORLD_LIST"
|
95
|
+
|
96
|
+
meth ="
|
97
|
+
VALUE %s(VALUE self%s) {
|
98
|
+
return Qnil;
|
99
|
+
}
|
100
|
+
void %s_hook(%s) {
|
101
|
+
rb_funcall(ruby_aw_instance(), rb_intern(\"%s\"), %s);
|
102
|
+
}
|
103
|
+
static VALUE receive_%s(VALUE self) {
|
104
|
+
return INT2NUM(aw_instance_%s_set(%s,%s_hook));
|
105
|
+
}
|
106
|
+
"
|
107
|
+
def_str = " rb_define_method(cRubyActiveworld, \"%s\",(VALUE(*)(ANYARGS))%s,%d);\n" +
|
108
|
+
" rb_define_method(cRubyActiveworld, \"receive_%s\",(VALUE(*)(ANYARGS))receive_%s,%d);"
|
109
|
+
|
110
|
+
methods = []
|
111
|
+
defs = []
|
112
|
+
|
113
|
+
s.split.each do |name|
|
114
|
+
lname = name.to_s.downcase
|
115
|
+
ruby_set_method_name = "receive_#{lname}"
|
116
|
+
event = name =~ /event/i ? true : false
|
117
|
+
ruby_callback_method_name = "#{lname.sub(/(aw_callback|aw_event)_/i,"")}#{"_event" if event}_callback"
|
118
|
+
methods.push( meth % [ruby_callback_method_name, event ? "" : ", VALUE rc",
|
119
|
+
ruby_callback_method_name, event ? "" : "int rc", ruby_callback_method_name, event ? "0" : "1, INT2FIX(rc)",
|
120
|
+
name.downcase,event ? "event" : "callback", name,ruby_callback_method_name] )
|
121
|
+
defs.push( def_str % [ruby_callback_method_name, ruby_callback_method_name, event ? 0 : 1,
|
122
|
+
lname, lname, event ? 0 : 1])
|
123
|
+
end
|
124
|
+
|
125
|
+
puts methods.join("\n")
|
126
|
+
puts defs.join("\n")
|