Module: IDL

Defined in:
lib/ridl/ridl.rb,
lib/ridl/type.rb,
lib/ridl/parser.rb,
lib/ridl/runner.rb,
lib/ridl/backend.rb,
lib/ridl/genfile.rb,
lib/ridl/options.rb,
lib/ridl/scanner.rb,
lib/ridl/version.rb,
lib/ridl/delegate.rb,
lib/ridl/expression.rb,
lib/ridl/optparse_ext.rb

Overview


version.rb - Version file for Ruby IDL compiler

Author: Martin Corino

This program is free software; you can redistribute it and/or modify it under the terms of the RIDL LICENSE which is included with this program.

Copyright © Remedy IT Expertise BV


Defined Under Namespace

Modules: AST Classes: Backend, Delegator, Engine, Expression, GenFile, OptionList, Options, ParseError, Parser, Scanner, Type

Constant Summary collapse

OPTIONS =
Options.new({
    outputdir: nil,
    includepaths: [],
    xincludepaths: [],
    verbose: (ENV['RIDL_VERBOSE'] || 0).to_i,
    debug: false,
    namespace: nil,
    search_incpath: false,
    backend: nil,
    macros: {
    },
    idlversion: 3
})
CORE_OPTIONS =
OPTIONS.keys
RIDLRC =
'.ridlrc'
RIDLRC_GLOBAL =
File.expand_path(File.join(ENV['HOME'] || ENV['HOMEPATH'] || '~', RIDLRC))
RIDL_VERSION_MAJOR =
2
RIDL_VERSION_MINOR =
10
RIDL_VERSION_RELEASE =
0
RIDL_VERSION =
"#{RIDL_VERSION_MAJOR}.#{RIDL_VERSION_MINOR}.#{RIDL_VERSION_RELEASE}"
"Copyright (c) 2007-#{Time.now.year} Remedy IT Expertise BV, The Netherlands".freeze
ORB_PIDL =
'orb.pidlc'.freeze

Class Method Summary collapse

Class Method Details

.backendObject



422
423
424
# File 'lib/ridl/runner.rb', line 422

def IDL.backend
  Thread.current[:ridl_engine] ? Thread.current[:ridl_engine].backend : nil
end

.engine?Boolean

Returns:

  • (Boolean)


418
419
420
# File 'lib/ridl/runner.rb', line 418

def IDL.engine?
  !Thread.current[:ridl_engine].nil?
end

.error(message) ⇒ Object



492
493
494
# File 'lib/ridl/runner.rb', line 492

def IDL.error(message)
  STDERR.puts(message)
end

.fatal(message) ⇒ Object



496
497
498
499
# File 'lib/ridl/runner.rb', line 496

def IDL.fatal(message)
  STDERR.puts(message, 'Exiting.')
  exit 1
end

.has_input?Boolean

Returns:

  • (Boolean)


442
443
444
# File 'lib/ridl/runner.rb', line 442

def IDL.has_input?
  engine? && Thread.current[:ridl_engine].has_input?
end

.has_production?(id) ⇒ Boolean

Returns:

  • (Boolean)


466
467
468
# File 'lib/ridl/runner.rb', line 466

def IDL.has_production?(id)
  engine? && Thread.current[:ridl_engine].has_production?(id)
end

.has_productions?Boolean

Returns:

  • (Boolean)


462
463
464
# File 'lib/ridl/runner.rb', line 462

def IDL.has_productions?
  engine? && Thread.current[:ridl_engine].has_productions?
end

.init(argv = ARGV) ⇒ Object



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/ridl/runner.rb', line 501

def IDL.init(argv = ARGV)
  options = OPTIONS.dup

  # load config file(s) if any
  Options.load_config(options)

  IDL.log(2, "Configuration [#{options}]")

  # check commandline args for explicit language mapping backend
  if argv.first =~ /^:\S+/
    be_name = argv.shift.reverse.chop.reverse.to_sym
  elsif ENV['RIDL_BE_SELECT']   # or from environment
    be_name = ENV['RIDL_BE_SELECT'].to_sym
  elsif options[:backend]       # or from configuration
    be_name = options[:backend].to_sym
  end

  # add optional search paths for RIDL backends
  options[:be_path] ||= []
  options[:be_path].unshift(*ENV['RIDL_BE_PATH'].split(/#{File::PATH_SEPARATOR}/)) if ENV['RIDL_BE_PATH']
  options[:be_path].collect! { |p| p.gsub('\\', '/') } # cleanup to prevent mixed path separators
  $:.concat(options[:be_path]) unless options[:be_path].empty?

  # check for special bootstrapping switches
  if argv.first == '--preprocess'
    options[:preprocess] = true
    argv.shift
  elsif argv.first == '--ignore-pidl'
    options[:ignore_pidl] = true
    argv.shift
  end

  # create RIDL engine
  Thread.current[:ridl_engine] = Engine.new(be_name, options)
end

.log(level, message) ⇒ Object



488
489
490
# File 'lib/ridl/runner.rb', line 488

def IDL.log(level, message)
  STDERR.puts message if verbose_level >= level
end

.peek_inputObject



436
437
438
439
440
# File 'lib/ridl/runner.rb', line 436

def IDL.peek_input
  return nil unless engine?

  Thread.current[:ridl_engine].peek_input
end

.pop_inputObject



430
431
432
433
434
# File 'lib/ridl/runner.rb', line 430

def IDL.pop_input
  return nil unless engine?

  Thread.current[:ridl_engine].pop_input
end

.pop_productionObject



450
451
452
453
454
# File 'lib/ridl/runner.rb', line 450

def IDL.pop_production
  return nil unless engine?

  Thread.current[:ridl_engine].pop_production
end

.production(id) ⇒ Object



470
471
472
473
474
# File 'lib/ridl/runner.rb', line 470

def IDL.production(id)
  return nil unless engine?

  Thread.current[:ridl_engine].production(id)
end

.push_input(idlfile, opts) ⇒ Object



426
427
428
# File 'lib/ridl/runner.rb', line 426

def IDL.push_input(idlfile, opts)
  Thread.current[:ridl_engine].push_input(idlfile, opts) if engine?
end

.push_production(id, producer) ⇒ Object



446
447
448
# File 'lib/ridl/runner.rb', line 446

def IDL.push_production(id, producer)
  Thread.current[:ridl_engine].push_production(id, producer) if engine?
end

.remove_production(id) ⇒ Object



456
457
458
459
460
# File 'lib/ridl/runner.rb', line 456

def IDL.remove_production(id)
  return nil unless engine?

  Thread.current[:ridl_engine].remove_production(id)
end

.run(argv = ARGV) ⇒ Object

main run method



539
540
541
542
543
544
# File 'lib/ridl/runner.rb', line 539

def IDL.run(argv = ARGV)
  # run default engine if available
  if Thread.current[:ridl_engine]
    exit(1) unless Thread.current[:ridl_engine].run(argv)
  end
end

.verbose_levelObject



476
477
478
# File 'lib/ridl/runner.rb', line 476

def IDL.verbose_level
  Thread.current[:ridl_engine] ? Thread.current[:ridl_engine].verbose_level : OPTIONS[:verbose]
end

.verbose_level=(l) ⇒ Object



480
481
482
483
484
485
486
# File 'lib/ridl/runner.rb', line 480

def IDL.verbose_level=(l)
  if Thread.current[:ridl_engine]
    Thread.current[:ridl_engine].verbose_level = l.to_i
  else
    OPTIONS[:verbose] = l.to_i
  end
end