Next: , Previous: , Up: Top   [Contents]

10 Configuration methods

The configuration object is intended for future extensions. These may allow the application to override Libmarpa’s memory allocation and fatal error handling without resorting to global variables, and therefore in a thread-safe way. Currently, the only function of the Marpa_Config class is to give marpa_g_new() a place to put its error code.

Marpa_Config is Libmarpa’s only “major” class which is not a time class. There is no constructor or destructor, although Marpa_Config objects do need to be initialized before use. Aside from its own accessor, Marpa_Config objects are only used by marpa_g_new and no reference to their location is not kept in any of Libmarpa’s time objects. The intent is to that it be convenient to have them in memory that might be deallocated soon after marpa_g_new returns. For example, they could be put on the stack.

Function: int marpa_c_init ( Marpa_Config* config)

Initialize the config information to “safe” default values. Unspecified behavior will result if an initialized configuration is used to create a grammar.

Return value: A non-negative value. Always succeeds.

Function: Marpa_Error_Code marpa_c_error ( Marpa_Config* config, const char** p_error_string )

Error codes are usually kept in the base grammar, which leaves marpa_g_new() no place to put its error code on failure. Objects of the Marpa_Config class provide such a place. p_error_string is reserved for use by the internals. Applications should set it to NULL.

Return value: The error code in config. Always succeeds.