rpm  5.4.10
Macros | Typedefs | Functions | Variables
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.

Macros

#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. More...
 
rpmruby rpmrubyLink (rpmruby ruby)
 References a Ruby interpreter instance. More...
 
rpmruby rpmrubyFree (rpmruby ruby)
 Destroys a Ruby interpreter instance. More...
 
rpmruby rpmrubyNew (char **av, uint32_t flags)
 Creates and initializes a Ruby interpreter. More...
 
rpmRC rpmrubyRun (rpmruby ruby, const char *str, const char **resultp)
 Evaluates Ruby code stored in a string. More...
 

Variables

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

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.

Macro Definition Documentation

§ rpmrubyFree

#define rpmrubyFree (   _ruby)
Value:
((rpmruby)rpmioFreePoolItem((rpmioItem)(_ruby), __FUNCTION__, \
__FILE__, __LINE__))
void * rpmioFreePoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Free a pool item.
Definition: rpmmalloc.c:187
struct rpmruby_s * rpmruby
Definition: rpmruby.h:32

Definition at line 117 of file rpmruby.h.

§ rpmrubyLink

#define rpmrubyLink (   _ruby)
Value:
((rpmruby)rpmioLinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, \
__FILE__, __LINE__))
rpmioItem rpmioLinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Increment a pool item refcount.
Definition: rpmmalloc.c:166
struct rpmruby_s * rpmruby
Definition: rpmruby.h:32

Definition at line 102 of file rpmruby.h.

§ rpmrubyUnlink

#define rpmrubyUnlink (   _ruby)
Value:
((rpmruby)rpmioUnlinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, \
__FILE__, __LINE__))
struct rpmruby_s * rpmruby
Definition: rpmruby.h:32
rpmioItem rpmioUnlinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Decrement a pool item refcount.
Definition: rpmmalloc.c:144

Definition at line 88 of file rpmruby.h.

Typedef Documentation

§ rpmruby

typedef struct rpmruby_s* rpmruby

Definition at line 32 of file rpmruby.h.

Function Documentation

§ rpmrubyFree()

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(), psmWait(), rpmcliFini(), and rpmioClean().

§ rpmrubyLink()

rpmruby rpmrubyLink ( rpmruby  ruby)

References a Ruby interpreter instance.

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

Referenced by rpmrubyNew().

§ 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 125 of file rpmruby.c.

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

Referenced by expandMacro(), psmWait(), and rpmrubyI().

§ rpmrubyRun()

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 163 of file rpmruby.c.

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

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

§ rpmrubyUnlink()

rpmruby rpmrubyUnlink ( rpmruby  ruby)

Dereferences a Ruby interpreter instance.

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

Variable Documentation

§ _rpmruby_debug

int _rpmruby_debug

Triggers printing of debugging information.

Definition at line 30 of file rpmruby.c.

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

§ _rpmrubyI

rpmruby _rpmrubyI

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 33 of file rpmruby.c.

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