rpm  5.4.4
Defines | Typedefs | Functions | Variables
rpmio/rpmruby.h File Reference

Embedded Ruby interpreter. More...

#include <rpmiotypes.h>
#include <rpmio.h>
Include dependency graph for rpmruby.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define rpmrubyUnlink(_ruby)
#define rpmrubyLink(_ruby)
#define rpmrubyFree(_ruby)

Typedefs

typedef struct rpmruby_s * rpmruby

Functions

rpmruby rpmrubyUnlink (rpmruby ruby)
 Dereferences a Ruby interpreter instance.
rpmruby rpmrubyLink (rpmruby ruby)
 References a Ruby interpreter instance.
rpmruby rpmrubyFree (rpmruby ruby)
 Destroys a Ruby interpreter instance.
rpmruby rpmrubyNew (char **av, uint32_t flags)
 Creates and initializes a Ruby interpreter.
rpmRC rpmrubyRun (rpmruby ruby, const char *str, const char **resultp)
 Evaluates Ruby code stored in a string.

Variables

int _rpmruby_debug
 Triggers printing of debugging information.
rpmruby _rpmrubyI
 Current (global) interpreter instance.

Detailed Description

Embedded Ruby interpreter.

This allows the embedding of the Ruby interpreter into RPM5. It can be used, for example, for expanding in the fashion of %expand{ruby: ...}.

Currently (as of ruby-1.9.2), the Ruby interpreter allows only one instance of itself per process. As such, rpmio's pooling mechanism will also always contain only one rpmruby instance. Calling rpmrubyNew() will initialize a new interpreter, while rpmrubyFree() beds this instance. Make sure you keep things in order, that is, call rpmrubyNew() exactly once, and don't forget to call rpmrubyFree() when you're done. Repeatedly calling rpmrubyNew will have no effect while an interpreter is allocated.

You can use rpmrubyRun() to evaluate Ruby code and get the result back.

Definition in file rpmruby.h.


Define Documentation

#define rpmrubyFree (   _ruby)
Value:
((rpmruby)rpmioFreePoolItem((rpmioItem)(_ruby), __FUNCTION__, \
        __FILE__, __LINE__))

Definition at line 117 of file rpmruby.h.

#define rpmrubyLink (   _ruby)
Value:
((rpmruby)rpmioLinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, \
        __FILE__, __LINE__))

Definition at line 102 of file rpmruby.h.

#define rpmrubyUnlink (   _ruby)
Value:
((rpmruby)rpmioUnlinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, \
        __FILE__, __LINE__))

Definition at line 88 of file rpmruby.h.


Typedef Documentation

typedef struct rpmruby_s* rpmruby

Definition at line 32 of file rpmruby.h.


Function Documentation

rpmruby rpmrubyFree ( rpmruby  ruby)

Destroys a Ruby interpreter instance.

Parameters:
rubyThe Ruby interpreter to be destroyed
Returns:
NULL on last dereference
See also:
rpmioFreePoolItem

Referenced by expandMacro(), rpmcliFini(), and rpmioClean().

rpmruby rpmrubyLink ( rpmruby  ruby)

References a Ruby interpreter instance.

Parameters:
rubyRuby interpreter
Returns:
A new ruby interpreter reference
See also:
rpmioLinkPoolItem

Referenced by rpmrubyNew().

rpmruby rpmrubyNew ( char **  av,
uint32_t  flags 
)

Creates and initializes a Ruby interpreter.

Parameters:
avArguments to the Ruby interpreter (may be NULL)
flagsRuby interpreter flags: ((1<<31): use global interpreter)
Returns:
A new Ruby interpreter

Definition at line 111 of file rpmruby.c.

References _rpmrubyI, rpmrubyGetPool(), rpmrubyLink(), and rpmrubyRun().

Referenced by expandMacro(), and rpmrubyI().

rpmRC rpmrubyRun ( rpmruby  ruby,
const char *  str,
const char **  resultp 
)

Evaluates Ruby code stored in a string.

Parameters:
rubyThe Ruby interpreter that is to be used (NULL uses global interpreter)
strRuby code to evaluate (NULL forces return of RPMRC_FAIL)
*resultpResult of the evaluation
Returns:
RPMRC_OK on success

Definition at line 145 of file rpmruby.c.

References _rpmruby_debug, RPMRC_FAIL, RPMRC_OK, and rpmrubyI().

Referenced by expandMacro(), rpmrbLoadClasses(), rpmrbLoadFile(), and rpmrubyNew().

rpmruby rpmrubyUnlink ( rpmruby  ruby)

Dereferences a Ruby interpreter instance.

Parameters:
rubyRuby interpreter pool item
Returns:
NULL on last dereference
See also:
rpmUnlinkPoolItem

Variable Documentation

Triggers printing of debugging information.

Definition at line 31 of file rpmruby.c.

Referenced by main(), rpmrubyGetPool(), and rpmrubyRun().

Current (global) interpreter instance.

At the moment, this variable is merely a safeguard against initializing the Ruby interpreter over and over again. In the future, when there is Ruby support for multiple interpreter instances, a flag given to rpmrubyNew() will use this variable and return the global interpreter instance.

Definition at line 34 of file rpmruby.c.

Referenced by rpmcliFini(), rpmioClean(), rpmrbLoadClasses(), rpmrubyI(), and rpmrubyNew().