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



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

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



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

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

#create_type_name(modulepath, element) ⇒ Object



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

def create_type_name(modulepath, element)
  if element.type == XSD::AnyTypeName
    # nil means anyType.
    nil
  elsif simpletype = @simpletypes[element.type]
    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



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

def dq(ele)
  ele.dump
end

#dqname(qname) ⇒ Object



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

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

#dump_method_signature(operation, element_definitions) ⇒ Object



36
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
# File 'lib/wsdl/soap/classDefCreatorSupport.rb', line 36

def dump_method_signature(operation, element_definitions)
  name = operation.name
  input = operation.input
  output = operation.output
  fault = operation.fault
  signature = "#{ name }#{ dump_inputparam(input) }"
  str = <<__EOD__
# SYNOPSIS
#   #{name}#{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



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

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

#mapped_class_name(qname, modulepath) ⇒ Object



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

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

#ndq(ele) ⇒ Object



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

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

#nsym(ele) ⇒ Object



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

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

#sym(ele) ⇒ Object



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

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