Class: IDL::Delegator
- Inherits:
-
Object
- Object
- IDL::Delegator
- Defined in:
- lib/ridl/delegate.rb
Constant Summary collapse
- @@pragma_handlers =
#pragma handler registry each keyed entry a callable object:
-
responds to #call(delegator, cur_node, pragma_string)
-
returns boolean to indicate pragma recognized and handled (true) or not (false)
-
{}
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#root_namespace ⇒ Object
readonly
Returns the value of attribute root_namespace.
Class Method Summary collapse
Instance Method Summary collapse
- #cur_parsed_name_scope ⇒ Object
- #declare_attribute(_type, _name, _readonly = false) ⇒ Object
- #declare_component(name) ⇒ Object
- #declare_enumerator(_name) ⇒ Object
- #declare_eventtype(name, attrib = nil) ⇒ Object
- #declare_finder(name, params_, raises_) ⇒ Object
- #declare_include(s) ⇒ Object
- #declare_initializer(name, params_, raises_) ⇒ Object
- #declare_interface(name, attrib = nil) ⇒ Object
- #declare_member(_type, _name) ⇒ Object
- #declare_op_footer(_raises, _context) ⇒ Object
- #declare_op_header(_oneway, _type, _name) ⇒ Object
- #declare_op_parameter(_attribute, _type, _name) ⇒ Object
- #declare_port(name, porttype, type, multiple = false) ⇒ Object
- #declare_state_member(type, name, public_) ⇒ Object
- #declare_struct(_name) ⇒ Object
- #declare_template_reference(name, type, tpl_params) ⇒ Object
- #declare_typedef(_type, _name) ⇒ Object
- #declare_union(_name) ⇒ Object
- #declare_valuetype(name, attrib = nil) ⇒ Object
- #define_annotation(annid, annbody) ⇒ Object
- #define_case(_labels, _type, _name) ⇒ Object
- #define_component(name, base, supports = nil) ⇒ Object
- #define_connector(name, base = nil) ⇒ Object
- #define_const(_type, _name, _expression) ⇒ Object
- #define_enum(_name) ⇒ Object
- #define_eventtype(name, attrib, inherits = {}) ⇒ Object
- #define_exception(_name) ⇒ Object
- #define_home(name, base, component, key = nil, supports = nil) ⇒ Object
- #define_interface(name, attrib, inherits = []) ⇒ Object
- #define_module(name) ⇒ Object
- #define_porttype(name) ⇒ Object
- #define_struct(_name) ⇒ Object
- #define_template_module(global, names) ⇒ Object
- #define_template_parameter(name, type) ⇒ Object
- #define_typeid(type, tid) ⇒ Object
- #define_typeprefix(type, pfx) ⇒ Object
- #define_union(_name) ⇒ Object
- #define_union_switchtype(union_node, switchtype) ⇒ Object
- #define_valuebox(name, type) ⇒ Object
- #define_valuetype(name, attrib, inherits = {}) ⇒ Object
- #end_component(node) ⇒ Object
- #end_connector(node) ⇒ Object
- #end_enum(node) ⇒ Object
- #end_exception(node) ⇒ Object
- #end_home(node) ⇒ Object
- #end_interface(node) ⇒ Object
- #end_module(node) ⇒ Object (also: #end_template_module)
- #end_porttype(node) ⇒ Object
- #end_struct(node) ⇒ Object
- #end_union(node) ⇒ Object
- #end_valuetype(node) ⇒ Object (also: #end_eventtype)
- #enter_include(s) ⇒ Object
- #handle_pragma(pragma_string) ⇒ Object
-
#initialize(params = {}) ⇒ Delegator
constructor
A new instance of Delegator.
- #instantiate_template_module(name, parameters) ⇒ Object
- #is_included?(s) ⇒ Boolean
- #leave_include ⇒ Object
- #parse_literal(_typestring, _value) ⇒ Object
- #parse_positive_int(_expression) ⇒ Object
- #parse_scopedname(global, namelist) ⇒ Object
- #post_parse ⇒ Object
- #pragma_id(id, repo_id) ⇒ Object
- #pragma_prefix(s) ⇒ Object
- #pragma_version(id, major, minor) ⇒ Object
- #pre_parse ⇒ Object
- #register_template_module_name(name_spec) ⇒ Object
- #visit_nodes(walker) ⇒ Object
- #walk_member(m, w) ⇒ Object
- #walk_nodes(walker, root_node = nil) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Delegator
Returns a new instance of Delegator.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ridl/delegate.rb', line 37 def initialize(params = {}) @annotation_stack = IDL::AST::Annotations.new @includes = {} @expand_includes = params[:expand_includes] || false @preprocess = params[:preprocess] || false @preprocout = params[:output] if @preprocess @ignore_pidl = params[:ignore_pidl] || false @root_namespace = nil if not params[:namespace].nil? @root_namespace = IDL::AST::Module.new(params[:namespace], nil, {}) end end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
50 51 52 |
# File 'lib/ridl/delegate.rb', line 50 def root @root end |
#root_namespace ⇒ Object (readonly)
Returns the value of attribute root_namespace.
50 51 52 |
# File 'lib/ridl/delegate.rb', line 50 def root_namespace @root_namespace end |
Class Method Details
.add_pragma_handler(key, h = nil, &block) ⇒ Object
28 29 30 31 |
# File 'lib/ridl/delegate.rb', line 28 def self.add_pragma_handler(key, h = nil, &block) raise RuntimeError, 'add_pragma_handler requires a callable object or a block' unless (h && h.respond_to?(:call)) || block_given? @@pragma_handlers[key] = block_given? ? block : h end |
.get_pragma_handler(key) ⇒ Object
33 34 35 |
# File 'lib/ridl/delegate.rb', line 33 def self.get_pragma_handler(key) @@pragma_handlers[key] end |
Instance Method Details
#cur_parsed_name_scope ⇒ Object
194 195 196 |
# File 'lib/ridl/delegate.rb', line 194 def cur_parsed_name_scope @cur ? @cur.parsed_name_scope : '' end |
#declare_attribute(_type, _name, _readonly = false) ⇒ Object
629 630 631 632 633 634 635 636 |
# File 'lib/ridl/delegate.rb', line 629 def declare_attribute(_type, _name, _readonly=false) params = Hash.new params[:type] = _type params[:readonly] = _readonly params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Attribute, _name, params) end |
#declare_component(name) ⇒ Object
367 368 369 370 371 372 373 |
# File 'lib/ridl/delegate.rb', line 367 def declare_component(name) params = {} params[:forward] = true raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Component, name, params) end |
#declare_enumerator(_name) ⇒ Object
715 716 717 718 719 720 721 722 723 724 725 |
# File 'lib/ridl/delegate.rb', line 715 def declare_enumerator(_name) n = @cur.enumerators.length params = { :value => n, :enum => @cur } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.enclosure.define(IDL::AST::Enumerator, _name, params) @cur end |
#declare_eventtype(name, attrib = nil) ⇒ Object
421 422 423 424 425 426 427 428 429 |
# File 'lib/ridl/delegate.rb', line 421 def declare_eventtype(name, attrib=nil) params = {} params[:abstract] = attrib == :abstract params[:forward] = true raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Eventtype, name, params) @cur end |
#declare_finder(name, params_, raises_) ⇒ Object
501 502 503 504 505 506 507 508 509 |
# File 'lib/ridl/delegate.rb', line 501 def declare_finder(name, params_, raises_) params = {} params[:params] = params_ params[:raises] = raises_ params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Finder, name, params) @cur end |
#declare_include(s) ⇒ Object
215 216 217 218 219 220 |
# File 'lib/ridl/delegate.rb', line 215 def declare_include(s) params = { :filename => s } params[:defined] = false params[:preprocessed] = @includes[s].is_preprocessed? @cur.define(IDL::AST::Include, "$INC:"+s, params) end |
#declare_initializer(name, params_, raises_) ⇒ Object
491 492 493 494 495 496 497 498 499 |
# File 'lib/ridl/delegate.rb', line 491 def declare_initializer(name, params_, raises_) params = {} params[:params] = params_ params[:raises] = raises_ params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Initializer, name, params) @cur end |
#declare_interface(name, attrib = nil) ⇒ Object
326 327 328 329 330 331 332 333 334 335 |
# File 'lib/ridl/delegate.rb', line 326 def declare_interface(name, attrib=nil) params = {} params[:abstract] = attrib == :abstract params[:local] = attrib == :local params[:forward] = true params[:pseudo] = false raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Interface, name, params) end |
#declare_member(_type, _name) ⇒ Object
651 652 653 654 655 656 657 |
# File 'lib/ridl/delegate.rb', line 651 def declare_member(_type, _name) params = Hash.new params[:type] = _type params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Member, _name, params) end |
#declare_op_footer(_raises, _context) ⇒ Object
620 621 622 623 624 625 626 627 |
# File 'lib/ridl/delegate.rb', line 620 def (_raises, _context) @cur.raises = _raises || [] @cur.context = _context if not @cur.context.nil? raise RuntimeError, "context phrase's not supported" end @cur = @cur.enclosure end |
#declare_op_header(_oneway, _type, _name) ⇒ Object
604 605 606 607 608 609 610 611 |
# File 'lib/ridl/delegate.rb', line 604 def declare_op_header(_oneway, _type, _name) params = Hash.new params[:oneway] = (_oneway == :oneway) params[:type] = _type params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Operation, _name, params) end |
#declare_op_parameter(_attribute, _type, _name) ⇒ Object
612 613 614 615 616 617 618 619 |
# File 'lib/ridl/delegate.rb', line 612 def declare_op_parameter(_attribute, _type, _name) params = Hash.new params[:attribute] = _attribute params[:type] = _type params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Parameter, _name, params) end |
#declare_port(name, porttype, type, multiple = false) ⇒ Object
411 412 413 414 415 416 417 418 419 |
# File 'lib/ridl/delegate.rb', line 411 def declare_port(name, porttype, type, multiple = false) params = {} params[:porttype] = porttype params[:type] = type params[:multiple] = multiple params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Port, name, params) end |
#declare_state_member(type, name, public_) ⇒ Object
473 474 475 476 477 478 479 480 481 |
# File 'lib/ridl/delegate.rb', line 473 def declare_state_member(type, name, public_) params = {} params[:type] = type params[:visibility] = (public_ ? :public : :private) params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::StateMember, name, params) @cur end |
#declare_struct(_name) ⇒ Object
638 639 640 641 642 643 644 |
# File 'lib/ridl/delegate.rb', line 638 def declare_struct(_name) params = { :forward => true } raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Struct, _name, params) @cur end |
#declare_template_reference(name, type, tpl_params) ⇒ Object
317 318 319 320 321 322 323 324 |
# File 'lib/ridl/delegate.rb', line 317 def declare_template_reference(name, type, tpl_params) params = {} params[:tpl_type] = type params[:tpl_params] = tpl_params || [] params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::TemplateModuleReference, name, params) end |
#declare_typedef(_type, _name) ⇒ Object
732 733 734 735 736 737 738 |
# File 'lib/ridl/delegate.rb', line 732 def declare_typedef(_type, _name) params = Hash.new params[:type] = _type params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Typedef, _name, params) end |
#declare_union(_name) ⇒ Object
676 677 678 679 680 681 682 |
# File 'lib/ridl/delegate.rb', line 676 def declare_union(_name) params = { :forward => true } raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Union, _name, params) @cur end |
#declare_valuetype(name, attrib = nil) ⇒ Object
443 444 445 446 447 448 449 450 451 |
# File 'lib/ridl/delegate.rb', line 443 def declare_valuetype(name, attrib=nil) params = {} params[:abstract] = attrib == :abstract params[:forward] = true raise RuntimeError, "annotations with forward declaration of #{name} not allowed" unless @annotation_stack.empty? @cur.define(IDL::AST::Valuetype, name, params) @cur end |
#define_annotation(annid, annbody) ⇒ Object
262 263 264 265 |
# File 'lib/ridl/delegate.rb', line 262 def define_annotation(annid, annbody) IDL.log(3, "parsed Annotation #{annid}(#{annbody})") @annotation_stack << IDL::AST::Annotation.new(annid, annbody) end |
#define_case(_labels, _type, _name) ⇒ Object
693 694 695 696 697 698 699 700 |
# File 'lib/ridl/delegate.rb', line 693 def define_case(_labels, _type, _name) params = Hash.new params[:type] = _type params[:labels] = _labels params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::UnionMember, _name, params) end |
#define_component(name, base, supports = nil) ⇒ Object
375 376 377 378 379 380 381 382 |
# File 'lib/ridl/delegate.rb', line 375 def define_component(name, base, supports = nil) params = {} params[:base] = base params[:supports] = supports || [] params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Component, name, params) end |
#define_connector(name, base = nil) ⇒ Object
388 389 390 391 392 393 394 |
# File 'lib/ridl/delegate.rb', line 388 def define_connector(name, base = nil) params = {} params[:base] = base params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Connector, name, params) end |
#define_const(_type, _name, _expression) ⇒ Object
596 597 598 599 600 601 602 |
# File 'lib/ridl/delegate.rb', line 596 def define_const(_type, _name, _expression) params = { :type => _type, :expression => _expression } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear node = @cur.define(IDL::AST::Const, _name, params) @cur end |
#define_enum(_name) ⇒ Object
709 710 711 712 713 714 |
# File 'lib/ridl/delegate.rb', line 709 def define_enum(_name) params = {} params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Enum, _name, params) end |
#define_eventtype(name, attrib, inherits = {}) ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/ridl/delegate.rb', line 431 def define_eventtype(name, attrib, inherits={}) params = {} params[:abstract] = attrib == :abstract params[:custom] = attrib == :custom params[:forward] = false params[:inherits] = inherits params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Eventtype, name, params) @cur end |
#define_exception(_name) ⇒ Object
664 665 666 667 668 669 |
# File 'lib/ridl/delegate.rb', line 664 def define_exception(_name) params = { :forward => false } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Exception, _name, params) end |
#define_home(name, base, component, key = nil, supports = nil) ⇒ Object
352 353 354 355 356 357 358 359 360 361 |
# File 'lib/ridl/delegate.rb', line 352 def define_home(name, base, component, key = nil, supports = nil) params = {} params[:base] = base params[:component] = component params[:key] = key params[:supports] = supports || [] params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Home, name, params) end |
#define_interface(name, attrib, inherits = []) ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/ridl/delegate.rb', line 337 def define_interface(name, attrib, inherits = []) params = {} params[:abstract] = attrib == :abstract params[:local] = attrib == :local params[:pseudo] = attrib == :pseudo params[:forward] = false params[:inherits] = inherits params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Interface, name, params) end |
#define_module(name) ⇒ Object
267 268 269 270 271 272 |
# File 'lib/ridl/delegate.rb', line 267 def define_module(name) @cur = @cur.define(IDL::AST::Module, name) @cur.annotations.concat(@annotation_stack) unless @annotation_stack.empty? @annotation_stack.clear @cur end |
#define_porttype(name) ⇒ Object
400 401 402 403 404 405 |
# File 'lib/ridl/delegate.rb', line 400 def define_porttype(name) params = {} params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Porttype, name, params) end |
#define_struct(_name) ⇒ Object
645 646 647 648 649 650 |
# File 'lib/ridl/delegate.rb', line 645 def define_struct(_name) params = { :forward => false } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Struct, _name, params) end |
#define_template_module(global, names) ⇒ Object
281 282 283 284 285 286 287 288 289 |
# File 'lib/ridl/delegate.rb', line 281 def define_template_module(global, names) if global || names.size>1 raise RuntimeError, "no scoped identifier allowed for template module: #{(global ? '::' : '')+names.join('::')}" end @cur = @cur.define(IDL::AST::TemplateModule, names[0]) @cur.annotations.concat(@annotation_stack) unless @annotation_stack.empty? @annotation_stack.clear @cur end |
#define_template_parameter(name, type) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/ridl/delegate.rb', line 292 def define_template_parameter(name, type) if @template_module_name tmp = @template_module_name @template_module_name = nil # reset define_template_module(*tmp) end params = { :type => type } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::TemplateParam, name, params) end |
#define_typeid(type, tid) ⇒ Object
258 259 260 |
# File 'lib/ridl/delegate.rb', line 258 def define_typeid(type, tid) type.node.set_repo_id(tid.to_s) end |
#define_typeprefix(type, pfx) ⇒ Object
254 255 256 |
# File 'lib/ridl/delegate.rb', line 254 def define_typeprefix(type, pfx) type.node.replace_prefix(pfx.to_s) end |
#define_union(_name) ⇒ Object
683 684 685 686 687 688 |
# File 'lib/ridl/delegate.rb', line 683 def define_union(_name) params = { :forward => false } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Union, _name, params) end |
#define_union_switchtype(union_node, switchtype) ⇒ Object
689 690 691 692 |
# File 'lib/ridl/delegate.rb', line 689 def define_union_switchtype(union_node, switchtype) union_node.set_switchtype(switchtype) union_node end |
#define_valuebox(name, type) ⇒ Object
483 484 485 486 487 488 489 |
# File 'lib/ridl/delegate.rb', line 483 def define_valuebox(name, type) params = { :type => type } params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur.define(IDL::AST::Valuebox, name, params) @cur end |
#define_valuetype(name, attrib, inherits = {}) ⇒ Object
453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/ridl/delegate.rb', line 453 def define_valuetype(name, attrib, inherits={}) params = {} params[:abstract] = attrib == :abstract params[:custom] = attrib == :custom params[:forward] = false params[:inherits] = inherits params[:annotations] = @annotation_stack.dup unless @annotation_stack.empty? @annotation_stack.clear @cur = @cur.define(IDL::AST::Valuetype, name, params) @cur end |
#end_component(node) ⇒ Object
384 385 386 |
# File 'lib/ridl/delegate.rb', line 384 def end_component(node) @cur = @cur.enclosure end |
#end_connector(node) ⇒ Object
396 397 398 |
# File 'lib/ridl/delegate.rb', line 396 def end_connector(node) @cur = @cur.enclosure end |
#end_enum(node) ⇒ Object
726 727 728 729 730 |
# File 'lib/ridl/delegate.rb', line 726 def end_enum(node) ret = IDL::Type::ScopedName.new(@cur) @cur = @cur.enclosure ret end |
#end_exception(node) ⇒ Object
670 671 672 673 674 |
# File 'lib/ridl/delegate.rb', line 670 def end_exception(node) ret = IDL::Type::ScopedName.new(@cur) @cur = @cur.enclosure ret end |
#end_home(node) ⇒ Object
363 364 365 |
# File 'lib/ridl/delegate.rb', line 363 def end_home(node) @cur = @cur.enclosure end |
#end_interface(node) ⇒ Object
348 349 350 |
# File 'lib/ridl/delegate.rb', line 348 def end_interface(node) @cur = @cur.enclosure # must equals to argument mod end |
#end_module(node) ⇒ Object Also known as: end_template_module
273 274 275 |
# File 'lib/ridl/delegate.rb', line 273 def end_module(node) @cur = @cur.enclosure # must equals to argument mod end |
#end_porttype(node) ⇒ Object
407 408 409 |
# File 'lib/ridl/delegate.rb', line 407 def end_porttype(node) @cur = @cur.enclosure end |
#end_struct(node) ⇒ Object
658 659 660 661 662 663 |
# File 'lib/ridl/delegate.rb', line 658 def end_struct(node) node.defined = true ret = IDL::Type::ScopedName.new(@cur) @cur = @cur.enclosure ret end |
#end_union(node) ⇒ Object
701 702 703 704 705 706 707 |
# File 'lib/ridl/delegate.rb', line 701 def end_union(node) node.validate_labels node.defined = true ret = IDL::Type::ScopedName.new(@cur) @cur = @cur.enclosure ret end |
#end_valuetype(node) ⇒ Object Also known as: end_eventtype
465 466 467 468 469 470 |
# File 'lib/ridl/delegate.rb', line 465 def end_valuetype(node) node.defined = true ret = IDL::Type::ScopedName.new(@cur) @cur = @cur.enclosure # must equals to argument mod ret end |
#enter_include(s) ⇒ Object
202 203 204 205 206 207 208 209 |
# File 'lib/ridl/delegate.rb', line 202 def enter_include(s) params = { :filename => s } params[:defined] = true params[:preprocessed] = @preprocess @cur = @cur.define(IDL::AST::Include, "$INC:"+s, params) @includes[s] = @cur @cur end |
#handle_pragma(pragma_string) ⇒ Object
248 249 250 251 252 |
# File 'lib/ridl/delegate.rb', line 248 def handle_pragma(pragma_string) unless @@pragma_handlers.values.any? {|h| h.call(self, @cur, pragma_string)} IDL.log(1, "RIDL - unrecognized pragma encountered: #{pragma_string}.") end end |
#instantiate_template_module(name, parameters) ⇒ Object
304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/ridl/delegate.rb', line 304 def instantiate_template_module(name, parameters) tmp = @template_module_name @template_module_name = nil # reset template_type = parse_scopedname(*tmp) mod_inst = @cur.define(IDL::AST::Module, name) mod_inst.annotations.concat(@annotation_stack) unless @annotation_stack.empty? @annotation_stack.clear unless template_type.node.is_a?(IDL::AST::TemplateModule) raise RuntimeError, "invalid module template specification: #{template_type.node.typename} #{template_type.node.scoped_lm_name}" end template_type.node.instantiate(mod_inst, parameters) end |
#is_included?(s) ⇒ Boolean
198 199 200 |
# File 'lib/ridl/delegate.rb', line 198 def is_included?(s) @includes.has_key?(s) end |
#leave_include ⇒ Object
211 212 213 |
# File 'lib/ridl/delegate.rb', line 211 def leave_include() @cur = @cur.enclosure end |
#parse_literal(_typestring, _value) ⇒ Object
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/ridl/delegate.rb', line 548 def parse_literal(_typestring, _value) k = Expression::Value case _typestring when :boolean k.new(Type::Boolean.new, _value) when :integer _type = [ Type::Octet, Type::Short, Type::Long, Type::LongLong, Type::ULongLong, ].detect {|t| t::Range === _value } if _type.nil? raise RuntimeError, "it's not a valid integer: #{v.to_s}" end k.new(_type.new, _value) when :string k.new(Type::String.new, _value) when :wstring k.new(Type::WString.new, _value) when :char k.new(Type::Char.new, _value) when :wchar k.new(Type::WChar.new, _value) when :fixed k.new(Type::Fixed.new, _value) when :float k.new(Type::Float.new, _value) else raise ParseError, "unknown literal type: #{type}" end end |
#parse_positive_int(_expression) ⇒ Object
583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/ridl/delegate.rb', line 583 def parse_positive_int(_expression) if _expression.is_template? _expression else if not ::Integer === _expression.value raise RuntimeError, "must be integer: #{_expression.value.inspect}" elsif _expression.value < 0 raise RuntimeError, "must be positive integer: #{_expression.value.to_s}" end _expression.value end end |
#parse_scopedname(global, namelist) ⇒ Object
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 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/ridl/delegate.rb', line 511 def parse_scopedname(global, namelist) node = root = if global then @root else @cur end first = nil namelist.each do |nm| n = node.resolve(nm) if n.nil? raise RuntimeError, "cannot find type name '#{nm}' in scope '#{node.scoped_name}'" end node = n first = node if first.nil? end root.introduce(first) case node when IDL::AST::Module, IDL::AST::TemplateModule, IDL::AST::Interface,IDL::AST::Home, IDL::AST::Component, IDL::AST::Porttype, IDL::AST::Connector, IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef, IDL::AST::Exception, IDL::AST::Enum, IDL::AST::Valuetype, IDL::AST::Valuebox Type::ScopedName.new(node) when IDL::AST::TemplateParam if node.idltype.is_a?(IDL::Type::Const) Expression::ScopedName.new(node) else Type::ScopedName.new(node) end when IDL::AST::Const Expression::ScopedName.new(node) when IDL::AST::Enumerator Expression::Enumerator.new(node) else raise RuntimeError, "invalid reference to #{node.class.name}: #{node.scoped_name}" end end |
#post_parse ⇒ Object
72 73 74 75 76 |
# File 'lib/ridl/delegate.rb', line 72 def post_parse if @preprocess Marshal.dump([@root, @includes], @preprocout) end end |
#pragma_id(id, repo_id) ⇒ Object
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/ridl/delegate.rb', line 237 def pragma_id(id, repo_id) ids = id.split('::') global = false if ids.first.empty? global = true ids.shift end t = parse_scopedname(global, ids) t.node.set_repo_id(repo_id) end |
#pragma_prefix(s) ⇒ Object
222 223 224 |
# File 'lib/ridl/delegate.rb', line 222 def pragma_prefix(s) @cur.prefix = s end |
#pragma_version(id, major, minor) ⇒ Object
226 227 228 229 230 231 232 233 234 235 |
# File 'lib/ridl/delegate.rb', line 226 def pragma_version(id, major, minor) ids = id.split('::') global = false if ids.first.empty? global = true ids.shift end t = parse_scopedname(global, ids) t.node.set_repo_version(major, minor) end |
#pre_parse ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ridl/delegate.rb', line 52 def pre_parse @root = nil unless @preprocess || @ignore_pidl IDL.backend.lookup_path.each do |be_root| pidl_file = File.join(be_root, ORB_PIDL) if File.file?(pidl_file) && File.readable?(pidl_file) f = File.open(pidl_file, 'r') begin @root, @includes = Marshal.load(f) @cur = @root ensure f.close end break end end return if @root end @root = @cur = IDL::AST::Module.new(nil, nil, {}) # global root end |
#register_template_module_name(name_spec) ⇒ Object
277 278 279 |
# File 'lib/ridl/delegate.rb', line 277 def register_template_module_name(name_spec) @template_module_name = name_spec end |
#visit_nodes(walker) ⇒ Object
78 79 80 |
# File 'lib/ridl/delegate.rb', line 78 def visit_nodes(walker) walker.visit_nodes(self) end |
#walk_member(m, w) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/ridl/delegate.rb', line 86 def walk_member(m, w) case m when IDL::AST::Include if !m.is_preprocessed? if @expand_includes if m.is_defined? w.enter_include(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_include(m) end else w.visit_include(m) end end when IDL::AST::Porttype, IDL::AST::TemplateModule # these are template types and do not generally generate # code by themselves but only when 'instantiated' (used) # in another type when IDL::AST::Module w.enter_module(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_module(m) when IDL::AST::Interface if m.is_forward? w.declare_interface(m) else w.enter_interface(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_interface(m) end when IDL::AST::Home _te = w.respond_to?(:enter_home) _tl = w.respond_to?(:leave_home) return unless _te || _tl w.enter_home(m) if _te m.walk_members { |cm| walk_member(cm, w) } w.leave_home(m) if _tl when IDL::AST::Component if m.is_forward? w.declare_component(m) if w.respond_to?(:declare_component) else _te = w.respond_to?(:enter_component) _tl = w.respond_to?(:leave_component) return unless _te || _tl w.enter_component(m) if _te m.walk_members { |cm| walk_member(cm, w) } w.leave_component(m) if _tl end when IDL::AST::Connector _te = w.respond_to?(:enter_connector) _tl = w.respond_to?(:leave_connector) return unless _te || _tl w.enter_connector(m) if _te m.walk_members { |cm| walk_member(cm, w) } w.leave_connector(m) if _tl when IDL::AST::Port w.visit_port(m) if w.respond_to?(:visit_port) when IDL::AST::Valuebox w.visit_valuebox(m) when IDL::AST::Valuetype, IDL::AST::Eventtype if m.is_forward? w.declare_valuetype(m) else w.enter_valuetype(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_valuetype(m) end when IDL::AST::Finder w.visit_finder(m) if w.respond_to?(:visit_finder) when IDL::AST::Initializer w.visit_factory(m) if w.respond_to?(:visit_factory) when IDL::AST::Const w.visit_const(m) when IDL::AST::Operation w.visit_operation(m) when IDL::AST::Attribute w.visit_attribute(m) when IDL::AST::Exception w.enter_exception(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_exception(m) when IDL::AST::Struct if m.is_forward? w.declare_struct(m) else w.enter_struct(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_struct(m) end when IDL::AST::Union if m.is_forward? w.declare_union(m) else w.enter_union(m) m.walk_members { |cm| walk_member(cm, w) } w.leave_union(m) end when IDL::AST::Typedef w.visit_typedef(m) when IDL::AST::Enum w.visit_enum(m) when IDL::AST::Enumerator w.visit_enumerator(m) else raise RuntimeError, "Invalid IDL member type for walkthrough: #{m.class.name}" end end |
#walk_nodes(walker, root_node = nil) ⇒ Object
82 83 84 |
# File 'lib/ridl/delegate.rb', line 82 def walk_nodes(walker, root_node = nil) (root_node || @root).walk_members { |m| walk_member(m, walker) } end |