-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlang.rb
43 lines (33 loc) · 894 Bytes
/
lang.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Lang
module_function
def load_run(name)
data = File.read(name)
if data.unpack("C").first>=0x7f
eval data[3, data.length-3],TOPLEVEL_BINDING,name,1
else
eval data,TOPLEVEL_BINDING,name,1
end
end
def load_lit_module(name)
load_run name
rescue Object => ex
print "语言插件载入出错\n\t"+
"异常 #{ex.to_s}\n\t" +
"模块 #{name}\n\t" +
"回溯\n\t#{ex.backtrace.join("\n")}"
exit
end
def load_lit_modules
open('C:/RMSFX/conf/lang.txt') {|f| load_lit_module "C:/RMSFX/plugins/#{$_.chomp}" if $_[0,1]!=';' while f.gets }
end
load_lit_modules
class Lang::Opt
def initialize(opt = {})
@opt = opt
end
end
# S::virtual不意味一定要实现,而是不实现也不会报错
def virtual(*sym)
sym.each{|x| send :define_method, x, lambda{|*_|} }
end
end