Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1914

Show
Ignore:
Timestamp:
08/05/07 15:19:03 (1 year ago)
Author:
nahi
Message:
  • extracted common part from classDefCreator.rb and mappingRegistryCreatorSupport.rb
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/wsdl/soap/classDefCreator.rb

    r1911 r1914  
    327327  end 
    328328 
    329   def element_basetype(ele) 
    330     if klass = basetype_class(ele.type) 
    331       klass 
    332     elsif ele.local_simpletype 
    333       basetype_class(ele.local_simpletype.base) 
    334     else 
    335       nil 
    336     end 
    337   end 
    338  
    339   def attribute_basetype(attr) 
    340     if klass = basetype_class(attr.type) 
    341       klass 
    342     elsif attr.local_simpletype 
    343       basetype_class(attr.local_simpletype.base) 
    344     else 
    345       nil 
    346     end 
    347   end 
    348  
    349   def basetype_class(type) 
    350     return nil if type.nil? 
    351     if simpletype = @simpletypes[type] 
    352       basetype_mapped_class(simpletype.base) 
    353     else 
    354       basetype_mapped_class(type) 
    355     end 
    356   end 
    357  
    358329  def define_attribute(c, attributes) 
    359330    const = {} 
     
    385356  end 
    386357 
    387   def name_element(element) 
    388     return element.name if element.name  
    389     return element.ref if element.ref 
    390     raise RuntimeError.new("cannot define name of #{element}") 
    391   end 
    392  
    393   def name_attribute(attribute) 
    394     return attribute.name if attribute.name  
    395     return attribute.ref if attribute.ref 
    396     raise RuntimeError.new("cannot define name of #{attribute}") 
    397   end 
    398  
    399358  def dump_arraydef(qname, complextype) 
    400359    classname = create_class_name(qname) 
     
    403362    c.comment = "#{qname}" 
    404363    c.dump 
    405   end 
    406  
    407   def check_classname(classname) 
    408     if @modulepath.nil? and Object.constants.include?(classname) 
    409       warn("created definition re-opens an existing toplevel class: #{classname}") 
    410     end 
    411364  end 
    412365 
  • trunk/lib/wsdl/soap/classDefCreatorSupport.rb

    r1911 r1914  
    1717 
    1818 
    19 # requires @defined_const and @modulepath 
     19# requires @defined_const, @simpletypes, and @modulepath 
    2020module ClassDefCreatorSupport 
    2121  include XSD::CodeGen::GenSupport 
     
    192192    }.join("\n") 
    193193  end 
     194 
     195  def element_basetype(ele) 
     196    if klass = basetype_class(ele.type) 
     197      klass 
     198    elsif ele.local_simpletype 
     199      basetype_class(ele.local_simpletype.base) 
     200    else 
     201      nil 
     202    end 
     203  end 
     204 
     205  def attribute_basetype(attr) 
     206    if klass = basetype_class(attr.type) 
     207      klass 
     208    elsif attr.local_simpletype 
     209      basetype_class(attr.local_simpletype.base) 
     210    else 
     211      nil 
     212    end 
     213  end 
     214 
     215  def basetype_class(type) 
     216    return nil if type.nil? 
     217    if simpletype = @simpletypes[type] 
     218      basetype_mapped_class(simpletype.base) 
     219    else 
     220      basetype_mapped_class(type) 
     221    end 
     222  end 
     223 
     224  def name_element(element) 
     225    return element.name if element.name  
     226    return element.ref if element.ref 
     227    raise RuntimeError.new("cannot define name of #{element}") 
     228  end 
     229 
     230  def name_attribute(attribute) 
     231    return attribute.name if attribute.name  
     232    return attribute.ref if attribute.ref 
     233    raise RuntimeError.new("cannot define name of #{attribute}") 
     234  end 
     235 
     236  def check_classname(classname) 
     237    if @modulepath.nil? and Object.constants.include?(classname) 
     238      warn("created definition re-opens an existing toplevel class: #{classname}") 
     239    end 
     240  end 
    194241end 
    195242 
  • trunk/lib/wsdl/soap/mappingRegistryCreatorSupport.rb

    r1911 r1914  
    118118  end 
    119119 
    120   def element_basetype(ele) 
    121     if klass = basetype_class(ele.type) 
    122       klass 
    123     elsif ele.local_simpletype 
    124       basetype_class(ele.local_simpletype.base) 
    125     else 
    126       nil 
    127     end 
    128   end 
    129  
    130   def attribute_basetype(attr) 
    131     if klass = basetype_class(attr.type) 
    132       klass 
    133     elsif attr.local_simpletype 
    134       basetype_class(attr.local_simpletype.base) 
    135     else 
    136       nil 
    137     end 
    138   end 
    139  
    140   def basetype_class(type) 
    141     return nil if type.nil? 
    142     if simpletype = @simpletypes[type] 
    143       basetype_mapped_class(simpletype.base) 
    144     else 
    145       basetype_mapped_class(type) 
    146     end 
    147   end 
    148  
    149120  def define_attribute(attributes) 
    150121    schema_attribute = [] 
     
    165136      }.join(",\n    ") + 
    166137    "\n  }" 
    167   end 
    168  
    169   def name_element(element) 
    170     return element.name if element.name  
    171     return element.ref if element.ref 
    172     raise RuntimeError.new("cannot define name of #{element}") 
    173   end 
    174  
    175   def name_attribute(attribute) 
    176     return attribute.name if attribute.name  
    177     return attribute.ref if attribute.ref 
    178     raise RuntimeError.new("cannot define name of #{attribute}") 
    179138  end 
    180139