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.



327
328
329
330
331
332
333
334
# File 'lib/bitclust/rrdparser.rb', line 327

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.



337
338
339
# File 'lib/bitclust/rrdparser.rb', line 337

def klass
  @klass
end

#libraryObject (readonly)

Returns the value of attribute library.



336
337
338
# File 'lib/bitclust/rrdparser.rb', line 336

def library
  @library
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#visibilityObject

Returns the value of attribute visibility.



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

def visibility
  @visibility
end

Instance Method Details

#alias(name) ⇒ Object

Add a alias name to the alias list.



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

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



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

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

#constantObject



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

def constant
  @type = :constant
end

#define_class(name, supername, location: nil) ⇒ Object



353
354
355
356
357
358
359
360
361
# File 'lib/bitclust/rrdparser.rb', line 353

def define_class(name, supername, location: nil)
  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, location: location
end

#define_method(chunk) ⇒ Object



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

def define_method(chunk)
  id = method_id(chunk)
  @db.open_method(id) {|m|
    m.names           = chunk.names.sort
    m.kind            = chunk.source.match?(/^@undef$/) ? :undefined : @kind
    m.visibility      = @visibility || :public
    m.source          = chunk.source
    m.source_location = chunk.source.location
    case @kind
    when :added, :redefined
      @library.add_method m
    end
  }
end

#define_module(name, location: nil) ⇒ Object



363
364
365
# File 'lib/bitclust/rrdparser.rb', line 363

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

#define_object(name, singleton_object_class, location: nil) ⇒ Object



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

def define_object(name, singleton_object_class, location: nil)
  singleton_object_class = @db.get_class(singleton_object_class) if singleton_object_class
  register_class :object, name, singleton_object_class, location: location
end

#dynamic_extend(name) ⇒ Object



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

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

#dynamic_include(name) ⇒ Object



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

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

#extend(name) ⇒ Object



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

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

#include(name) ⇒ Object



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

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



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

def module_function
  @type = :module_function
end

#redefine_class(name) ⇒ Object



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

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

#reopen_class(name) ⇒ Object



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

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

#require(libname) ⇒ Object



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

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

#signatureObject



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

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

#special_variableObject



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

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



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

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