Class: EasySwig::ApiNode
- Inherits:
-
Object
- Object
- EasySwig::ApiNode
- Includes:
- Util
- Defined in:
- lib/apinodes/api_node.rb
Direct Known Subclasses
ApiClass, ApiEnum, ApiFunction, ApiGroup, ApiNamespace, ApiVariable, IncFile
Instance Attribute Summary collapse
-
#basename ⇒ Object
Returns the value of attribute basename.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#features ⇒ Object
Returns the value of attribute features.
-
#header_file ⇒ Object
Returns the value of attribute header_file.
-
#ignore ⇒ Object
Returns the value of attribute ignore.
-
#match ⇒ Object
Returns the value of attribute match.
-
#node_type ⇒ Object
Returns the value of attribute node_type.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#target_name ⇒ Object
Returns the value of attribute target_name.
-
#wrapped_node ⇒ Object
readonly
Returns the value of attribute wrapped_node.
Instance Method Summary collapse
- #assoc_functions(all_functions, api_functions, ignored_functions) ⇒ Object
- #assoc_members(all_members, api_members, ignored_members) ⇒ Object
- #assoc_with_node(node) ⇒ Object
- #fullname ⇒ Object
-
#initialize(hash) ⇒ ApiNode
constructor
A new instance of ApiNode.
-
#method_missing(sym, *args) ⇒ Object
Redirects calls to lang_settings before completely initialized and to wrapper_node afterwards.
- #to_str ⇒ Object
Methods included from Util
#del_prefix_class, #escape_all, #escape_const_ref_ptr, #escape_template, #gen_dir, #home_dir, #is_primitive?, #is_std?, #lib_dir, #logs_dir, #output_dir, #read_file, #rename_files, #swig_dir, #write_file
Constructor Details
#initialize(hash) ⇒ ApiNode
Returns a new instance of ApiNode.
42 43 44 45 46 47 48 49 |
# File 'lib/apinodes/api_node.rb', line 42 def initialize(hash) hash.each_key { |k| send(k.to_s+"=", hash[k]) # TODO features must always come first in the # hash } @basename || @features.infer_native_name(self) unless @target_name.nil? self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
Redirects calls to lang_settings before completely initialized and to wrapper_node afterwards
19 20 21 22 23 24 25 |
# File 'lib/apinodes/api_node.rb', line 19 def method_missing sym, *args if @wrapped_node.nil? @features.send sym, *args else @wrapped_node.send sym, *args end end |
Instance Attribute Details
#basename ⇒ Object
Returns the value of attribute basename.
6 7 8 |
# File 'lib/apinodes/api_node.rb', line 6 def basename @basename end |
#directory ⇒ Object
Returns the value of attribute directory.
8 9 10 |
# File 'lib/apinodes/api_node.rb', line 8 def directory @directory end |
#features ⇒ Object
Returns the value of attribute features.
14 15 16 |
# File 'lib/apinodes/api_node.rb', line 14 def features @features end |
#header_file ⇒ Object
Returns the value of attribute header_file.
10 11 12 |
# File 'lib/apinodes/api_node.rb', line 10 def header_file @header_file end |
#ignore ⇒ Object
Returns the value of attribute ignore.
15 16 17 |
# File 'lib/apinodes/api_node.rb', line 15 def ignore @ignore end |
#match ⇒ Object
Returns the value of attribute match.
13 14 15 |
# File 'lib/apinodes/api_node.rb', line 13 def match @match end |
#node_type ⇒ Object
Returns the value of attribute node_type.
12 13 14 |
# File 'lib/apinodes/api_node.rb', line 12 def node_type @node_type end |
#parent ⇒ Object
Returns the value of attribute parent.
9 10 11 |
# File 'lib/apinodes/api_node.rb', line 9 def parent @parent end |
#target_name ⇒ Object
Returns the value of attribute target_name.
7 8 9 |
# File 'lib/apinodes/api_node.rb', line 7 def target_name @target_name end |
#wrapped_node ⇒ Object (readonly)
Returns the value of attribute wrapped_node.
11 12 13 |
# File 'lib/apinodes/api_node.rb', line 11 def wrapped_node @wrapped_node end |
Instance Method Details
#assoc_functions(all_functions, api_functions, ignored_functions) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/apinodes/api_node.rb', line 59 def assoc_functions(all_functions, api_functions, ignored_functions) api_mets=[] new_mets=[] del_mets=[] api_functions.each { |f| all_found=all_functions.select { |func| func.basename == f.basename } if all_found.empty? EasySwig::Logger.log("WARNING: Function not found: #{f.to_str}") del_mets << f next end if all_found.size > 1 EasySwig::Logger.log("WARNING: Found several matching functions for #{f.to_str}: "+all_found.map { |func| func.basename+func.args }.join(" -- ")+"All of them will be matched") all_found[1..-1].each { |found| new_met=f.clone new_met.assoc_with_node found new_mets << new_met } end f.assoc_with_node all_found[0] api_mets.push(*all_found) } api_functions.reject! { |f| del_mets.include?(f)} api_functions.push(*new_mets) ignored_functions.push(*(all_functions - api_mets)); end |
#assoc_members(all_members, api_members, ignored_members) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/apinodes/api_node.rb', line 86 def assoc_members(all_members, api_members, ignored_members) api_mbrs=[] del_mbrs=[] api_members.each { |s| found=nil all_found=all_members.select { |str| str.basename == s.basename } if all_found.empty? EasySwig::Logger.log("WARNING: Member not found: #{s.to_str}") del_mbrs << s next end if all_found.size > 1 EasySwig::Logger.log("WARNING: Found several matching members for #{s.to_str}: "+all_found.join(" -- ")+" Only the first one will be matched") end found=all_found[0] s.assoc_with_node found api_mbrs.push found } api_members.reject! { |m| del_mbrs.include?(m) } ignored_members.push(*(all_members - api_mbrs)); end |
#assoc_with_node(node) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/apinodes/api_node.rb', line 51 def assoc_with_node(node) @wrapped_node = node EasySwig::Logger.log %Q{Associating target #{@node_type}: #{@target_name} with native node: #{name}} @basename = node.basename @target_name || @features.infer_target_name(self) self end |
#fullname ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/apinodes/api_node.rb', line 34 def fullname if @parent == nil return @basename else return @parent.fullname+"::"+@basename end end |
#to_str ⇒ Object
27 28 29 30 31 32 |
# File 'lib/apinodes/api_node.rb', line 27 def to_str if @fullname==nil @fullname=fullname end @node_type+"::"+@fullname end |