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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/autoc/box.rb', line 36
def render_interface(stream)
if public?
stream << %{
/**
#{defgroup}
@brief Value type wrapper of the C union
*/
}
stream << %{
/**
#{ingroup}
@brief Box tag set
Use @ref #{identifier(:tag)} to query current box contents. Empty box is always tagged as 0.
@since 2.0
*/
}
else
stream << PRIVATE
end
stream << 'typedef enum {'
i = 0; stream << (variants.collect { |name, type| "#{identifier(name)} = #{i+=1}" }).join(',')
stream << "} #{tag_};"
if public?
stream << %{
/**
#{ingroup}
@brief Opaque struct holding state of the box
@since 2.0
*/
}
else
stream << PRIVATE
end
stream << 'typedef struct {union {'
variants.each { |name, type| stream << field_declaration(type, name) }
stream << "} variant; /**< @private */ #{tag_} tag; /**< @private */} #{signature};"
end
|