GObject Builder 介绍
来源:互联网 发布:暴走淘宝店 编辑:程序博客网 时间:2024/06/08 17:35
GObject Builder 介绍
GOB (GOB2 anyway) is a preprocessor for making GObjects with inline C code sothat generated files are not edited. Syntax is inspired by Java and Yacc orLex. The implementation is intentionally kept simple, and no C actual codeparsing is done.
Reasons:
- C is a perfect (well mostly) language, no need for another language
- Writing a fully featured GObject is a hassle
- GObject has little type safety, GOB improves on it.
- Need for a generator that doesn't require changes to generated code
- I like how Java writes method code directly into the class definition.
/* * This file is a basic example of how a .gob file would be constructed, * how to add data members, properties and methods */requires 2.0.0%{#include <time.h>#include "my-person.h"#include "my-person-private.h"%}class My:Person from G:Object { /* the name of the person */ private char *name = {g_strdup(_("Nobody"))} destroywith g_free; property STRING name (nick = _("Name"), blurb = _("Name of the person"), default_value = _("Nobody"), /* Export get/set functions for this property */ export, /* link to the data memeber 'name' */ link); /* date of birth as a time_t */ private long dob = 0; property LONG dob (nick = _("Date of birth"), blurb = _("Date of birth of the person"), minimum = 0, maximum = LONG_MAX, default_value = 0, export) /* We could use 'link' as above, but the code below * shows how to do this without linking */ set { self->_priv->dob = g_value_get_long (VAL); } get { g_value_set_long (VAL, self->_priv->dob); }; /* date of death as a time_t */ private long dod = 0; property LONG dod (nick = _("Date of death"), blurb = _("Date of death of the person"), minimum = 0, maximum = LONG_MAX, default_value = 0, export, link); /* number of rounds in our shotgun */ private int rounds_in_shotgun = 0; /* when the person gets born, sends out a signal, the caller of the signal should provide the date of birth */ signal last NONE (LONG) void birth (self, long dob) { g_object_set (G_OBJECT (self), "dob", dob); } /* when the person dies, sends out a signal, the caller of the signal should provide the date of death */ signal last NONE (LONG) void death (self, long dod) { g_object_set (G_OBJECT (self), "dod", dod); } public void load_shotgun (self) { /* add a round to our shotgun */ self->_priv->rounds_in_shotgun++; } public void shoot_oneself_in_the_head (self) { if (self->_priv->rounds_in_shotgun == 0) { g_warning (_("No rounds in the shotgun!")); return; } /* one round was fired */ self->_priv->rounds_in_shotgun--; /* death is imminent if we shoot oneself in the head */ death (self, (long)time (NULL)); } public GObject * new (void) { return (GObject *)GET_NEW; }}
- GObject Builder 介绍
- GObject Introspection(GI)介绍
- GObject
- GObject
- gobject
- gobject
- GObject
- GObject
- PyGobject(八十五)GObject介绍(自定义对象与信号)
- Flex Builder Debug介绍
- ios--IB介绍(Interface Builder)
- gobject instantiation
- GObject Tutorial
- 学习GObject
- 学习GObject
- gobject初探
- GObject Tutorial
- GObject教程
- SUN到底是怎么想的?一个空格给我过了个愚人节!
- 不争万年,只珍朝夕------我对编程的态度
- 什么是glibc
- Android学习笔记(16)————Android的XML解析之pull方式
- MFC连接MySQL数据库_编辑框出现中文乱码解决
- GObject Builder 介绍
- C# 5 新特性深入浅出:详解异步编程
- Maxent Source code reading experience
- QT收费吗?
- sigaction与signal 简单用法
- oracle 安装要用到的内存相关参数详解
- 不借助第三個變數,實現兩個數的交換(按位異或)
- CRF++ Source code reading experience
- 差分约束系统_bellman_ford_poj 1201 Intervals