File: class.c

package info (click to toggle)
kdevelop 4%3A24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 71,888 kB
  • sloc: cpp: 290,869; python: 3,626; javascript: 3,518; sh: 1,316; ansic: 703; xml: 401; php: 95; lisp: 66; makefile: 31; sed: 12
file content (99 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{% load kdev_filters %}
{% include "license_header_cpp.txt" %}


#include "{{ output_file_header }}"

{% with namespaces|join:"_"|default:"___"|add:"_"|cut:"____"|upper as uc_prefix %}
{% with namespaces|join:"_"|default:"___"|add:"_"|cut:"____"|lower as lc_prefix %}
{% with namespaces|join:"" as prefix %}
{% with prefix|add:name as full_name %}

/* 
 * forward definitions
 */
G_DEFINE_TYPE ({{ full_name }}, {{ lc_prefix }}{{ name|lower }}, G_TYPE_OBJECT);

/*
/* forward declarations of default virtual methods 
 */

{% for f in functions %}
{% if f.isVirtual %}
  {% with f.arguments as arguments %}
  {{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %});
  {% endwith %}
{% endif %}
{% endfor %}

static void
{{ lc_prefix }}{{ name|lower }}_dispose (GObject *gobject)
{
  {{ full_name }} *self = {{ uc_prefix }}{{ name|upper }} (gobject);


  /* 
   * In dispose, you are supposed to free all types referenced from this
   * object which might themselves hold a reference to self. Generally,
   * the most simple solution is to unref all members on which you own a 
   * reference.
   */


  /* Chain up to the parent class */
  G_OBJECT_CLASS ({{ lc_prefix }}{{ name|lower }}_parent_class)->dispose (gobject);
}


static void
{{ lc_prefix }}{{ name|lower }}_finalize (GObject *gobject)
{
  {{ full_name }} *self = {{ uc_prefix }}{{ name|upper }} (gobject);


  /* Chain up to the parent class */
  G_OBJECT_CLASS ({{ lc_prefix }}{{ name|lower }}_parent_class)->finalize (gobject);
}


static void
{{ lc_prefix }}{{ name|lower }}_init ({{ full_name }} *self)
{
  /* initialize all public and private members to reasonable default values. */

  
  /* Default implementations for virtual methods 
   * For pure-virtual functions, set these to NULL
   */
  {% for f in functions %}
  {% if f.isVirtual %}
    klass->{{ f.name }} = {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }};
  {% endif %}
  {% endfor %}
}

{% for f in functions %}
{% with f.arguments as arguments %}
{{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %})
{
    g_return_if_fail ({{ uc_prefix }}IS_{{ name|upper }} (self));
    
    {% if f.isVirtual %}
    {{ uc_prefix }}{{ name|upper }}_GET_CLASS (self)->{{ f.name }} (self{% if arguments %}, {% include "arguments_names.txt" %}{% endif %});
    {% endif %}
    
}

{% if f.isVirtual %}
{{ f.returnType|default:"void" }} {{ lc_prefix }}{{ name|lower }}_real_{{ f.name }}({{ full_name }}* self{% if arguments %}, {% include "arguments_types_names.txt" %}{% endif %})
{
    /* Default implementation for the virtual method {{ f.name }} */
}
{% endif %}
{% endwith %}
{% endfor %}

{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}