Class: BitClust::RRDParser::Context

Inherits:
Object
  • Object
show all
Includes:
NameUtils
Defined in:
lib/bitclust/rrdparser.rb

Constant Summary

Constants included from NameUtils

NameUtils::CHAR_TO_MARK, NameUtils::CHAR_TO_NAME, NameUtils::CLASS_NAME_RE, NameUtils::CLASS_PATH_RE, NameUtils::CONST_PATH_RE, NameUtils::CONST_RE, NameUtils::GVAR_RE, NameUtils::LIBNAME_RE, NameUtils::MARK_TO_CHAR, NameUtils::MARK_TO_NAME, NameUtils::METHOD_NAME_RE, NameUtils::METHOD_SPEC_RE, NameUtils::MID, NameUtils::NAME_TO_CHAR, NameUtils::NAME_TO_MARK, NameUtils::TYPEMARK_RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NameUtils

build_method_id, classid2name, classname2id, classname?, decodeid, decodename_fs, decodename_url, encodeid, encodename_fs, encodename_rdocurl, encodename_url, functionname?, gvarname?, html_filename, libid2name, libname2id, libname?, method_spec?, methodid2classid, methodid2libid, methodid2mname, methodid2specparts, methodid2specstring, methodid2typechar, methodid2typemark, methodid2typename, methodname?, split_method_id, split_method_spec, typechar2mark, typechar2name, typechar?, typemark2char, typemark2name, typemark?, typename2char, typename2mark, typename?

Constructor Details

#initialize(db, libname) ⇒ Context

Returns a new instance of Context.


330
331
332
333
334
335
336
337
# File 'lib/bitclust/rrdparser.rb', line 330

def initialize(db, libname)
  @db = db
  #@library = @db.open_library(libname)
  @library = @db.open_library(libname, true)   # FIXME: always reopen
  @klass = nil
  @type = nil
  @visibility = nil
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass


340
341
342
# File 'lib/bitclust/rrdparser.rb', line 340

def klass
  @klass
end

#libraryObject (readonly)

Returns the value of attribute library


339
340
341
# File 'lib/bitclust/rrdparser.rb', line 339

def library
  @library
end

#typeObject

Returns the value of attribute type


341
342
343
# File 'lib/bitclust/rrdparser.rb', line 341

def type
  @type
end

#visibilityObject

Returns the value of attribute visibility


342
343
344
# File 'lib/bitclust/rrdparser.rb', line 342

def visibility
  @visibility
end

Instance Method Details

#alias(name) ⇒ Object

Add a alias name to the alias list.


421
422
423
424
425
426
427
428
429
430
# File 'lib/bitclust/rrdparser.rb', line 421

def alias(name)
  @db.open_class(name) do |c|
    c.type = @klass.type
    c.library = @library
    c.aliasof = @klass
    c.source = "Alias of [[c:#{@klass.name}]]\n"
    @library.add_class c
    @klass.alias c
  end
end

#categorize(category) ⇒ Object


344
345
346
# File 'lib/bitclust/rrdparser.rb', line 344

def categorize(category)
  @library.category = category
end

#constantObject


436
437
438
# File 'lib/bitclust/rrdparser.rb', line 436

def constant
  @type = :constant
end

#define_class(name, supername) ⇒ Object


356
357
358
359
360
361
362
363
364
# File 'lib/bitclust/rrdparser.rb', line 356

def define_class(name, supername)
  if @db.properties['version'] >= "1.9.0"
    top = 'BasicObject'
  else
    top = 'Object'
  end
  superclass = (name == top ? nil : @db.get_class(supername))
  register_class :class, name, superclass
end

#define_method(chunk) ⇒ Object


452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/bitclust/rrdparser.rb', line 452

def define_method(chunk)
  id = method_id(chunk)
  @db.open_method(id) {|m|
    m.names      = chunk.names.sort
    m.kind       = @kind
    m.visibility = @visibility || :public
    m.source     = chunk.source
    case @kind
    when :added, :redefined
      @library.add_method m
    end
  }
end

#define_module(name) ⇒ Object


366
367
368
# File 'lib/bitclust/rrdparser.rb', line 366

def define_module(name)
  register_class :module, name, nil
end

#define_object(name) ⇒ Object


370
371
372
# File 'lib/bitclust/rrdparser.rb', line 370

def define_object(name)
  register_class :object, name, nil
end

#dynamic_extend(name) ⇒ Object


416
417
418
# File 'lib/bitclust/rrdparser.rb', line 416

def dynamic_extend(name)
  @klass.dynamic_extend(@db.get_class(name), @library)
end

#dynamic_include(name) ⇒ Object


412
413
414
# File 'lib/bitclust/rrdparser.rb', line 412

def dynamic_include(name)
  @klass.dynamic_include(@db.get_class(name), @library)
end

#extend(name) ⇒ Object


408
409
410
# File 'lib/bitclust/rrdparser.rb', line 408

def extend(name)
  @klass.extend @db.get_class(name)
end

#include(name) ⇒ Object


404
405
406
# File 'lib/bitclust/rrdparser.rb', line 404

def include(name)
  @klass.include @db.get_class(name)
end

#method_id(chunk) ⇒ Object


466
467
468
469
470
471
472
473
# File 'lib/bitclust/rrdparser.rb', line 466

def method_id(chunk)
  id = MethodID.new
  id.library = @library
  id.klass   = chunk.signature.klass ? @db.get_class(chunk.signature.klass) : @klass
  id.type    = chunk.signature.typename || @type
  id.name    = chunk.names.sort.first
  id
end

#module_functionObject


432
433
434
# File 'lib/bitclust/rrdparser.rb', line 432

def module_function
  @type = :module_function
end

#redefine_class(name) ⇒ Object


398
399
400
401
402
# File 'lib/bitclust/rrdparser.rb', line 398

def redefine_class(name)
  @kind = :redefined
  @klass = name ? @db.get_class(name) : nil
  clear_scope
end

#reopen_class(name) ⇒ Object


392
393
394
395
396
# File 'lib/bitclust/rrdparser.rb', line 392

def reopen_class(name)
  @kind = :added
  @klass = name ? @db.get_class(name) : nil
  clear_scope
end

#require(libname) ⇒ Object


348
349
350
# File 'lib/bitclust/rrdparser.rb', line 348

def require(libname)
  @library.require @db.get_library(libname)
end

#signatureObject


447
448
449
450
# File 'lib/bitclust/rrdparser.rb', line 447

def signature
  return nil unless @klass
  Signature.new(@klass.name, @type ? typename2mark(@type) : nil, nil)
end

#special_variableObject


440
441
442
443
444
445
# File 'lib/bitclust/rrdparser.rb', line 440

def special_variable
  unless @klass and @klass.name == 'Kernel'
    raise "must not happen: type=special_variable but class!=Kernel"
  end
  @type = :special_variable
end

#sublibrary(libname) ⇒ Object


352
353
354
# File 'lib/bitclust/rrdparser.rb', line 352

def sublibrary(libname)
  @library.sublibrary @db.get_library(libname)
end