Dehydra API: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
m (Reverted edits by Firefoxer2011 (Talk) to last revision by Tglek)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This is an attempt to document the functions for writing scripts for [[Dehydra GCC]]. It is incomplete, as is dehydra-gcc itself, so things are in constant flux.
#REDIRECT [[MDC:Dehydra_Manual]]
 
== Callback Functions ==
 
Dehydra works by calling functions in your Javascript for elements of the source code file. You are not required to have any of these functions in your script: if a function is not there, Dehydra will know and will not try to call it. Here are the functions Dehydra will call:
 
=== process_class(cls) ===
 
Dehydra calls this for each class/struct. process_class is called ''after'' process_function is called for all the member functions. <var>cls</var> is a JS object representing the class, with the following properties:
 
<dl>
<dt>.kind
<dd>"class" or "struct"
 
<dt>.bases
<dd>An array representing the base classes of this class.
 
<dt>.members
<dd>An array of member variables and functions.
</dl>
 
=== process_function(func) ===
 
Dehydra calls this for each top-level function or class member function. func is a JS object with the function name, type, location, and isStatic property.
 
=== process_var(decl) ===
 
decl is a JS object representing a variable declaration.
 
=== process_tree(func, body) ===
 
func is a function declaration. body is a JS object representing the AST for a function body. NOT YET FULLY IMPLEMENTED
 
=== input_end() ===
 
Called once at the end of the C++ source file.
 
== Type objects ==
 
Dehydra provides detailed type objects. A Dehydra type object can represent a primitive type (with name attribute), a class type (with name, members attributes, etc.), a pointer type (with isPointer=true and a type attribute), a reference type (with isReference=true and a type attribute), or a function pointer type (with parameters attribute, etc).
 
== Builtin functions ==
 
The following functions are provided by dehydra and may be called by the user:
 
=== warning(msg, ...) ===
 
Print one or more warning messages using the GCC warning mechanism. If -Werror is specified this will cause compilation to fail.
 
=== error(msg, ...) ===
 
Print one or more error messages using the GCC error mechanism. This will cause compilation to fail.
 
=== print(msg) ===
 
Print a string to stdout (or stderr if the compiler is piping output). If the current callback is associated with a particular location, the location will be printed first.
 
=== _print(msg, ...) ===
 
Like <tt>print()</tt> but the location will not be printed.
 
=== read_file(filename) ===
 
Read a file a return it as a string.
 
=== write_file(filename, data) ===
 
Write a string to a file.

Latest revision as of 21:53, 13 May 2010

Redirect to: