4 if (my ($class, $super) = /boilerplate for ([a-zA-Z0-9_]+), a subclass of ([a-zA-Z0-9_]+)/) {
9 /* This boilerplate for ${class}, a subclass of ${super}, was
10 autogenerated by mk-class-boilerplate. */
13 #include <libpspp/cast.h>
15 extern const struct ${super}_class ${class}_class;
17 /* Returns true if SUPER is a ${class}, otherwise false. */
19 is_${class} (const struct ${super} *super)
21 return super->class == &${class}_class;
24 /* Returns SUPER converted to ${class}. SUPER must be a ${class}, as
25 reported by is_${class}. */
26 static inline struct ${class} *
27 to_${class} (const struct ${super} *super)
29 assert (is_${class} (super));
30 return UP_CAST (super, struct ${class}, ${super});
33 /* Returns INSTANCE converted to ${super}. */
34 static inline struct ${super} *
35 ${class}_super (const struct ${class} *instance)
37 return CONST_CAST (struct ${super} *, &instance->${super});
40 /* Increments INSTANCE's reference count and returns INSTANCE. */
41 static inline struct ${class} *
42 ${class}_ref (const struct ${class} *instance)
44 return to_${class} (${super}_ref (&instance->${super}));
47 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
48 the reference count is now zero. */
50 ${class}_unref (struct ${class} *instance)
52 ${super}_unref (&instance->${super});
55 /* Returns true if INSTANCE's reference count is greater than 1,
58 ${class}_is_shared (const struct ${class} *instance)
60 return ${super}_is_shared (&instance->${super});
64 if ($super ne 'output_item') {
67 ${class}_submit (struct ${class} *instance)
69 ${super}_submit (&instance->${super});
73 print "void ${class}_submit (struct ${class} *);\n";