Override Syntax

Override files can be used to override specific behaviours of the RbgTool definition/code generator. It can for instance be used to override a specific method implementation, add code to the initialization of a specific type, require the needed module to inform RbgTool of the available types or specify the namespace of the generated bindings.

The override file is interpreted as ERB (embedded ruby). All ruby code therefore needs to be between <% %> (see Example). Besides usual ruby constructs, the following ruby methods can be used in override files:

include(str)include another override file (relative to the current file)
namespace(str)the namespace that should be used (this is used to find out the bind names of classes, enums, flags etc)
module_name(str)the module name of the generated code. This is currently used to generated the function name that actually initializes the ruby classes etc.
ignore(*regexes)add one or more regular expressions which are used to filter out methods/types that should be ignored during code generation
override(function[, options]) blockoverrides a function implementation. function is the actual C function that needs to be overriden. Options currently is either Override::NONE or Override::VARGS specifying that the ruby method should receive a variable number of ruby VALUE arguments. In the block the actual implementation of the method should be returned, this is very easily done with the use of ERB (simply close the ruby context, write code and open the context again, see Example)
auto_rubynames(true|false)specifies whether rubyish aliases should be automatically generated for methods like get_a -> a, is_a -> a?, true by default
header blockspecify custom code to be inserted at the top of the generated code. This can be used to include custom headers, or write helper functions. The actual code should be returned in the block as with override
after_initialize(type) blockused to specify additional code after initialization of a type (class/boxed/enum/flag)
override_initialize(type) blockused to override the initialization of a specific type

Example

<% 

include 'general.override'

require 'gtk2'
module_name 'sourceview'

header do %>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourceview-typebuiltins.h>
#include <rbgtk.h>

<% end %>