Module: WSDL::SOAP::ClassDefCreatorSupport

Overview

requires @defined_const, @simpletypes, @name_creator

Instance Method Summary collapse

Methods included from XSD::CodeGen::GenSupport

capitalize, constant?, #format, keyword?, safeconstname, safeconstname?, safemethodname, safemethodname?, safevarname, safevarname?, uncapitalize

Instance Method Details

#assign_const(value, prefix = '') ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 88

def assign_const(value, prefix = '')
  return if value.nil? or @defined_const.key?(value)
  name = value.scan(/[^:\/]+\/?\z/)[0] || 'C'
  tag = prefix + safeconstname(name)
  if @defined_const.value?(tag)
    idx = 0
    while true
      tag = prefix + safeconstname(name + "_#{idx}")
      break unless @defined_const.value?(tag)
      idx += 1
      raise RuntimeError.new("too much similar names") if idx > 100
    end
  end
  @defined_const[value] = tag
end

#basetype_mapped_class(name) ⇒ Object



33
34
35
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 33

def basetype_mapped_class(name)
  ::SOAP::TypeMap[name]
end

#create_type_name(modulepath, element) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 104

def create_type_name(modulepath, element)
  if element.type == XSD::AnyTypeName
    # nil means anyType.
    nil
  elsif simpletype = @simpletypes[element.type]
    #MODIFICATO PER RESTRICTION NON GESTITE
    if simpletype.restriction #and simpletype.restriction.enumeration?
      mapped_class_name(element.type, modulepath)
    else
      nil
    end
  elsif klass = element_basetype(element)
    klass.name
  elsif element.type
    mapped_class_name(element.type, modulepath)
  elsif element.ref
    mapped_class_name(element.ref, modulepath)
  elsif element.anonymous_type?
    # inner class
    mapped_class_name(element.name, modulepath)
  else
    nil
  end
end

#dq(ele) ⇒ Object



64
65
66
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 64

def dq(ele)
  ele.dump
end

#dqname(qname) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 80

def dqname(qname)
  if @defined_const.key?(qname.namespace)
    qname.dump(@defined_const[qname.namespace])
  else
    qname.dump
  end
end

#dump_method_signature(name, operation, element_definitions) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 37

def dump_method_signature(name, operation, element_definitions)
  methodname = safemethodname(name)
  input = operation.input
  output = operation.output
  fault = operation.fault
  signature = "#{methodname}#{dump_inputparam(input)}"
  str = <<__EOD__
# SYNOPSIS
#   #{methodname}#{dump_inputparam(input)}
#
# ARGS
#{dump_inout_type(input, element_definitions).chomp}
#
# RETURNS
#{dump_inout_type(output, element_definitions).chomp}
#
__EOD__
  unless fault.empty?
    str += <<__EOD__
# RAISES
#{dump_fault_type(fault, element_definitions)}
#
__EOD__
  end
  str
end

#mapped_class_basename(qname, modulepath) ⇒ Object



28
29
30
31
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 28

def mapped_class_basename(qname, modulepath)
  classname = @name_creator.assign_name(qname, modulepath)
  classname.sub(/\A.*:/, '')
end

#mapped_class_name(qname, modulepath) ⇒ Object



24
25
26
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 24

def mapped_class_name(qname, modulepath)
  @name_creator.assign_name(qname, modulepath)
end

#ndq(ele) ⇒ Object



68
69
70
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 68

def ndq(ele)
  ele.nil? ? 'nil' : dq(ele)
end

#nsym(ele) ⇒ Object



76
77
78
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 76

def nsym(ele)
  ele.nil? ? 'nil' : sym(ele)
end

#sym(ele) ⇒ Object



72
73
74
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 72

def sym(ele)
  ':' + ele.id2name
end