Class: Revparsel

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-rad/lib/tk/al-tk.rb

Instance Method Summary collapse

Constructor Details

#initialize(_code, _filename = nil) ⇒ Revparsel

Returns a new instance of Revparsel.



1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1178

def initialize(_code, _filename=nil)
  #p "-------- revparsel ------------"
  _code.gsub!('TkScrollbar','QTkScrollbar')
  _code.gsub!('bind(','wbind(')
  if $arcadia.objects('code')
    $arcadia['code']=_code
  else
    $arcadia.publish('code',_code)
  end
  @filename = _filename
  _re_string = ''
  ['TkToplevel','Tk::Toplevel','TkRoot','TkToplevelLayer'].each{|top|
    if _re_string.length > 0
      _re_string = _re_string+'|'
    end
    _re_string = _re_string+'class\s*[A-Za-z0-9_]*\s*<\s*'+top
  }
  m = Regexp::new(_re_string).match(_code)
  if m
    _c,_class_name,_c,_class = m[0].split
    _obj_name = _class_name.sub(/^./) { $&.downcase}
    cod = _code + "\n@"+ _obj_name + "="+ _class_name+".new('class'=>"+_class+")\n"
    cod = cod +"Tk.update\n"
    #p cod
    eval(cod)
    cod = ''
    cod = cod + '@ag'+ _obj_name + "="+'AG'+ _class.sub('::','')+".new(nil,@"+_obj_name+"){\n"
    cod = cod + "|_self|\n"
    cod = cod + "  _self.i_name='"+_obj_name+"' \n"
    cod = cod + "  _self.i_ag='"+'ag'+_obj_name+"' \n"
    cod = cod + '}'+"\n"
    #p "-------------------"
    #p cod
    eval(cod)
  end
end

Instance Method Details

#eval_obj(_obj_name, _ag_obj_name) ⇒ Object



1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
# File 'ext/ae-rad/lib/tk/al-tk.rb', line 1215

def eval_obj(_obj_name, _ag_obj_name)
  _obj_name_base = _obj_name.delete('@')
  cod = " @istancev = "+ _obj_name +".instance_variables\n"
  eval(cod)
  cod = " @tkv = TkWinfo.children("+_obj_name+")\n"
  eval(cod)
  if @tkv.length > 0
    array_eval = "["
    l=0
    @istancev.each{|i|
      array_eval = array_eval + "," if l>0
      array_eval = array_eval +i+'.object_id'
      l=l+1
    }
    array_eval = array_eval +"]"
    @tkv.each{|k|
      $k=k
      _name = '@j'+$k.object_id.abs.to_s
      cod = "if !"+ array_eval
      cod = cod+".include?("+$k.object_id.to_s+")"+"\n"
      cod = cod + _name +'=$k'
      cod = cod + "\nelse\n" + '$k=nil'
      cod = cod+"\nend\n"
      eval(_obj_name+'.instance_eval{|k| '+cod+'}')
      if $k
        @istancev << _name
      end
    }
  end
  if @istancev.length > 0
    cod = " class << "+_obj_name+"\n"
    @istancev.each{|i|
      i.delete!('@')
      cod = cod + "  attr_reader  :"+i+"\n"
    }
    cod = cod +"end\n"
    eval(cod)
    cod = ''
    @istancev.each{|v|
      v.delete!('@')
      path_obj =  _obj_name+'.'+ v
      eval('@gong = '+ path_obj)
      _agclass=ArcadiaLibs.wrapper_class(@gong.class)
      if _agclass
        cod = "@ag"+v+"="+_agclass+".new("+ _ag_obj_name +","+path_obj+"){|_self|\n"
        cod = cod + " _self.i_name = '"+v+"'\n"
        cod = cod + " _self.i_ag = 'ag"+v+"'\n"
        cod = cod + "}\n"
        eval(cod)
        eval_obj(path_obj, "@ag"+v)
      end
    }
  end
end