Method: AutoC::Record#render_interface

Defined in:
lib/autoc/record.rb

#render_interface(stream) ⇒ Object



33
34
35
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/record.rb', line 33

def render_interface(stream)
  if public?
    stream << %{
      /**
        #{defgroup}

        @brief Value type wrapper of the C struct

        @since 2.0
      */
    }
    if @opaque
      stream << %{
        /**
          #{ingroup}

          @brief Opaque struct holding state of the record

          @since 2.0
        */
      }
    else
      stream << %{
        /**
          #{ingroup}

          @brief Open struct holding state of the record

          The struct's fields are directly acessible.
          However, care must be taken when modifying the struct's contents directly
          as it may break the contract(s) of certain (namely, hash- and tree-based) containers.

          For the safety reasons these fields should be generally treated read-only.

          @since 2.0
        */
      }
    end
  else
    stream << PRIVATE
  end
  stream << 'typedef struct {'
    fields.each { |name, type| stream << field_declaration(type, name) }
  stream << "} #{signature};"
end