File indexing completed on 2024-05-12 04:37:33

0001 {% load kdev_filters %}
0002 {% include "license_header_cpp.txt" %}
0003 
0004 
0005 #include "{{ output_file_header }}"
0006 
0007 
0008 {% with namespaces|join:"_"|default:"___"|add:"_"|cut:"____"|upper as uc_prefix %}
0009 {% with namespaces|join:"_"|default:"___"|add:"_"|cut:"____"|lower as lc_prefix %}
0010 {% with namespaces|join:"" as prefix %}
0011 {% with prefix|add:name as full_name %}
0012 
0013 
0014 #define {{ uc_prefix }}{{ name|upper }}_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), {{ uc_prefix }}TYPE_{{ name|upper }}, {{ full_name }}Private))
0015 
0016 
0017 struct _{{ full_name }}Private
0018 {
0019     /* private members */
0020 };
0021 
0022 
0023 
0024 
0025 /* 
0026  * forward definitions
0027  */
0028 G_DEFINE_TYPE ({{ full_name }}, {{ lc_prefix }}{{ name|lower }}, G_TYPE_OBJECT);
0029 
0030 
0031 /*
0032 /* forward declarations of default virtual methods 
0033  */
0034 
0035 
0036 {% for f in functions %}
0037 {% if f.isVirtual %}
0038   {% with f.arguments as arguments %}
0039   {{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %});
0040   {% endwith %}
0041 {% endif %}
0042 {% endfor %}
0043 
0044 
0045 static void {{ lc_prefix }}{{ name|lower }}_class_init ({{ full_name }}Class *klass)
0046 {
0047   g_type_class_add_private (klass, sizeof ({{ full_name }}Private));
0048 }
0049 
0050 
0051 static void
0052 {{ lc_prefix }}{{ name|lower }}_dispose (GObject *gobject)
0053 {
0054   {{ full_name }} *self = {{ uc_prefix }}{{ name|upper }} (gobject);
0055 
0056 
0057   /* 
0058    * In dispose, you are supposed to free all types referenced from this
0059    * object which might themselves hold a reference to self. Generally,
0060    * the most simple solution is to unref all members on which you own a 
0061    * reference.
0062    */
0063 
0064 
0065   /* Chain up to the parent class */
0066   G_OBJECT_CLASS ({{ lc_prefix }}{{ name|lower }}_parent_class)->dispose (gobject);
0067 }
0068 
0069 
0070 static void
0071 {{ lc_prefix }}{{ name|lower }}_finalize (GObject *gobject)
0072 {
0073   {{ full_name }} *self = {{ uc_prefix }}{{ name|upper }} (gobject);
0074 
0075 
0076   /* Chain up to the parent class */
0077   G_OBJECT_CLASS ({{ lc_prefix }}{{ name|lower }}_parent_class)->finalize (gobject);
0078 }
0079 
0080 
0081 static void
0082 {{ lc_prefix }}{{ name|lower }}_init ({{ full_name }} *self)
0083 {
0084   self->priv = {{ uc_prefix }}{{ name|upper }}_GET_PRIVATE (self);
0085 
0086 
0087   /* initialize all public and private members to reasonable default values. */
0088 
0089 
0090   /*
0091    * Default implementations for virtual methods 
0092    * For pure-virtual functions, set these to NULL
0093    */
0094   {% for f in functions %}
0095   {% if f.isVirtual %}
0096     klass->{{ f.name }} = {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }};
0097   {% endif %}
0098   {% endfor %}
0099 }
0100 
0101 {% for f in functions %}
0102 {% with f.arguments as arguments %}
0103 {{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %})
0104 {
0105     g_return_if_fail ({{ uc_prefix }}IS_{{ name|upper }} (self));
0106 
0107     {% if f.isVirtual %}
0108 
0109     {{ uc_prefix }}{{ name|upper }}_GET_CLASS (self)->{{ f.name }} (self{% if arguments %}, {% include "arguments_names.txt" %}{% endif %});
0110     {% endif %}
0111 }
0112 
0113 {% if f.isVirtual %}
0114 {{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %})
0115 {
0116     /* Default implementation for the virtual method {{ f.name }} */
0117 }
0118 {% endif %}
0119 {% endwith %}
0120 {% endfor %}
0121 
0122 {% endwith %}
0123 {% endwith %}
0124 {% endwith %}
0125 {% endwith %}