Class: SwiftPropertyType

Inherits:
Object
  • Object
show all
Defined in:
lib/swift_generator/code_generation/swift_types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(swift_type_symbol, serialized_json_type, auto_bridged: false, swift_kind: :primitive, test_value: lambda{|num| 'undefined' }, unmarshal_method: nil) ⇒ SwiftPropertyType

Returns a new instance of SwiftPropertyType.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/swift_generator/code_generation/swift_types.rb', line 20

def initialize( swift_type_symbol, serialized_json_type, auto_bridged:false, swift_kind: :primitive,
				test_value:lambda{|num| 'undefined' }, unmarshal_method: nil)
	@swift_type_symbol = swift_type_symbol
	@swift_type_name = swift_type_symbol.to_s
	@serialized_json_type = serialized_json_type
	@auto_bridged = auto_bridged
	@swift_kind = swift_kind
	@test_value_lambda = test_value
	@custom_equality_test = nil
	@hashable_value_lambda = nil
	@unmarshal_method_lambda = unmarshal_method
end

Instance Attribute Details

#auto_bridgedObject

Returns the value of attribute auto_bridged.



12
13
14
# File 'lib/swift_generator/code_generation/swift_types.rb', line 12

def auto_bridged
  @auto_bridged
end

#custom_equality_testObject

Returns the value of attribute custom_equality_test.



17
18
19
# File 'lib/swift_generator/code_generation/swift_types.rb', line 17

def custom_equality_test
  @custom_equality_test
end

#custom_marshalingObject

Returns the value of attribute custom_marshaling.



15
16
17
# File 'lib/swift_generator/code_generation/swift_types.rb', line 15

def custom_marshaling
  @custom_marshaling
end

#custom_unmarshalingObject

Returns the value of attribute custom_unmarshaling.



16
17
18
# File 'lib/swift_generator/code_generation/swift_types.rb', line 16

def custom_unmarshaling
  @custom_unmarshaling
end

#hashable_value_lambdaObject

Returns the value of attribute hashable_value_lambda.



18
19
20
# File 'lib/swift_generator/code_generation/swift_types.rb', line 18

def hashable_value_lambda
  @hashable_value_lambda
end

#serialized_json_typeObject

Returns the value of attribute serialized_json_type.



11
12
13
# File 'lib/swift_generator/code_generation/swift_types.rb', line 11

def serialized_json_type
  @serialized_json_type
end

#swift_kindObject

Returns the value of attribute swift_kind.



13
14
15
# File 'lib/swift_generator/code_generation/swift_types.rb', line 13

def swift_kind
  @swift_kind
end

#swift_type_nameObject

Returns the value of attribute swift_type_name.



10
11
12
# File 'lib/swift_generator/code_generation/swift_types.rb', line 10

def swift_type_name
  @swift_type_name
end

#swift_type_symbolObject

Returns the value of attribute swift_type_symbol.



9
10
11
# File 'lib/swift_generator/code_generation/swift_types.rb', line 9

def swift_type_symbol
  @swift_type_symbol
end

#test_value_lambdaObject

Returns the value of attribute test_value_lambda.



14
15
16
# File 'lib/swift_generator/code_generation/swift_types.rb', line 14

def test_value_lambda
  @test_value_lambda
end

Class Method Details

.all_swift_kindsObject



33
34
35
36
37
38
39
40
# File 'lib/swift_generator/code_generation/swift_types.rb', line 33

def self.all_swift_kinds
	{
		primitive:	'Swift primitive, e.g. Int, String',
		class:		'Swift Class',
		struct:		'Swift Struct',
		enum: 		'Swift Enum'
	}
end

Instance Method Details

#hashable_value(var_name, is_optional) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/swift_generator/code_generation/swift_types.rb', line 46

def hashable_value( var_name, is_optional)
	if @hashable_value_lambda.nil?
		return var_name
	else
		return @hashable_value_lambda.call( var_name, is_optional )
	end
end

#make_test_value(index) ⇒ Object



42
43
44
# File 'lib/swift_generator/code_generation/swift_types.rb', line 42

def make_test_value( index )
	@test_value_lambda.call( index )
end