Initial import
This commit is contained in:
parent
86875aadb3
commit
87aff3a4d9
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
|
def replaceAll(line, subst)
|
||||||
|
subst.each do |sub,rep|
|
||||||
|
line = line.gsub('{' + sub + '}', rep)
|
||||||
|
end
|
||||||
|
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
def degenerateCaps(text)
|
||||||
|
text = text.gsub(/[A-Z]+[a-z]+/) do |s|
|
||||||
|
s.downcase + '_'
|
||||||
|
end
|
||||||
|
|
||||||
|
return text[0..-2]
|
||||||
|
end
|
||||||
|
|
||||||
|
subst = {}
|
||||||
|
name = ARGV[0]
|
||||||
|
|
||||||
|
if (name == nil) then
|
||||||
|
print "Class name (capitalized): "
|
||||||
|
name = gets[0..-2]
|
||||||
|
end
|
||||||
|
|
||||||
|
subst['template_'] = degenerateCaps(name)
|
||||||
|
subst['template-'] = subst['template_'].sub('_', '-')
|
||||||
|
subst['TEMPLATE'] = subst['template_'].upcase
|
||||||
|
subst['Template'] = name
|
||||||
|
|
||||||
|
tc = IO.readlines("template.c")
|
||||||
|
th = IO.readlines("template.h")
|
||||||
|
|
||||||
|
f = File.open('gm-' + subst['template-'] + '.c', 'w')
|
||||||
|
tc.each do |line|
|
||||||
|
f.write(replaceAll(line, subst))
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
|
||||||
|
f = File.open('gm-' + subst['template-'] + '.h', 'w')
|
||||||
|
th.each do |line|
|
||||||
|
f.write(replaceAll(line, subst))
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
|
||||||
|
print "Done ...\n"
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include <gobject/gobject.h>
|
||||||
|
#include "gm-{template-}.h"
|
||||||
|
|
||||||
|
#define GM_{TEMPLATE}_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GM_TYPE_{TEMPLATE}, Gm{Template}Private))
|
||||||
|
|
||||||
|
struct _Gm{Template}Private {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Signals
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROTO
|
||||||
|
NUM_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint gm_{template_}_signals[NUM_SIGNALS] = {0};*/
|
||||||
|
|
||||||
|
G_DEFINE_TYPE(Gm{Template}, gm_{template_}, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_{template_}_finalize(GObject *object) {
|
||||||
|
//Gm{Template} *obj = GM_{TEMPLATE}(object);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS(gm_{template_}_parent_class)->finalize(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_{template_}_class_init(Gm{Template}Class *klass) {
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||||
|
|
||||||
|
object_class->finalize = gm_{template_}_finalize;
|
||||||
|
|
||||||
|
/*gm_{template_}_signals[PROTO] =
|
||||||
|
g_signal_new("proto",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(Gm{Template}Class, proto),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
0);*/
|
||||||
|
|
||||||
|
g_type_class_add_private(object_class, sizeof(Gm{Template}Private));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_{template_}_init(Gm{Template} *obj) {
|
||||||
|
obj->priv = GM_{TEMPLATE}_GET_PRIVATE(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gm{Template} *
|
||||||
|
gm_{template_}_new() {
|
||||||
|
Gm{Template} *obj = GM_{TEMPLATE}(g_object_new(GM_TYPE_{TEMPLATE}, NULL));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef __GM_{TEMPLATE}_H__
|
||||||
|
#define __GM_{TEMPLATE}_H__
|
||||||
|
|
||||||
|
#include <gobject/gobject.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Type checking and casting macros
|
||||||
|
*/
|
||||||
|
#define GM_TYPE_{TEMPLATE} (gm_{template_}_get_type())
|
||||||
|
#define GM_{TEMPLATE}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GM_TYPE_{TEMPLATE}, Gm{Template}))
|
||||||
|
#define GM_{TEMPLATE}_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GM_TYPE_{TEMPLATE}, Gm{Template} const))
|
||||||
|
#define GM_{TEMPLATE}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GM_TYPE_{TEMPLATE}, Gm{Template}Class))
|
||||||
|
#define GM_IS_{TEMPLATE}(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GM_TYPE_{TEMPLATE}))
|
||||||
|
#define GM_IS_{TEMPLATE}_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GM_TYPE_{TEMPLATE}))
|
||||||
|
#define GM_{TEMPLATE}_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GM_TYPE_{TEMPLATE}, Gm{Template}Class))
|
||||||
|
|
||||||
|
/* Private structure type */
|
||||||
|
typedef struct _Gm{Template}Private Gm{Template}Private;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main object structure
|
||||||
|
*/
|
||||||
|
typedef struct _Gm{Template} Gm{Template};
|
||||||
|
|
||||||
|
struct _Gm{Template} {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
/*< private > */
|
||||||
|
Gm{Template}Private *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class definition
|
||||||
|
*/
|
||||||
|
typedef struct _Gm{Template}Class Gm{Template}Class;
|
||||||
|
|
||||||
|
struct _Gm{Template}Class {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
/* Signals
|
||||||
|
void (* proto) (Gm{Template} *obj); */
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gm_{template_}_get_type(void) G_GNUC_CONST;
|
||||||
|
Gm{Template} *gm_{template_}_new(void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
#endif /* __GM_{TEMPLATE}_H__ */
|
Reference in New Issue