int->enum.

SVN revision: 52591
This commit is contained in:
Carsten Haitzler 2010-09-22 14:13:03 +00:00
parent 737556b8bb
commit f9d3eff9b3
2 changed files with 10 additions and 9 deletions

View File

@ -45,7 +45,7 @@ extern "C" {
EAPI extern Embryo_Version *embryo_version; EAPI extern Embryo_Version *embryo_version;
/* potentioal error values */ /* potentioal error values */
enum typedef enum _Embryo_Error
{ {
EMBRYO_ERROR_NONE, EMBRYO_ERROR_NONE,
/* reserve the first 15 error codes for exit codes of the abstract machine */ /* reserve the first 15 error codes for exit codes of the abstract machine */
@ -73,7 +73,7 @@ extern "C" {
EMBRYO_ERROR_INIT_JIT, /** Cannot initialize the JIT */ EMBRYO_ERROR_INIT_JIT, /** Cannot initialize the JIT */
EMBRYO_ERROR_PARAMS, /** Parameter error */ EMBRYO_ERROR_PARAMS, /** Parameter error */
EMBRYO_ERROR_DOMAIN, /** Domain error, expression result does not fit in range */ EMBRYO_ERROR_DOMAIN, /** Domain error, expression result does not fit in range */
}; } Embryo_Error;
/* possible function type values that are enumerated */ /* possible function type values that are enumerated */
#define EMBRYO_FUNCTION_NONE 0x7fffffff /* An invalid/non existent function */ #define EMBRYO_FUNCTION_NONE 0x7fffffff /* An invalid/non existent function */
@ -128,11 +128,11 @@ extern "C" {
EAPI Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, const char *name); EAPI Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, const char *name);
EAPI int embryo_program_variable_count_get(Embryo_Program *ep); EAPI int embryo_program_variable_count_get(Embryo_Program *ep);
EAPI Embryo_Cell embryo_program_variable_get(Embryo_Program *ep, int num); EAPI Embryo_Cell embryo_program_variable_get(Embryo_Program *ep, int num);
EAPI void embryo_program_error_set(Embryo_Program *ep, int error); EAPI void embryo_program_error_set(Embryo_Program *ep, Embryo_Error error);
EAPI int embryo_program_error_get(Embryo_Program *ep); EAPI Embryo_Error embryo_program_error_get(Embryo_Program *ep);
EAPI void embryo_program_data_set(Embryo_Program *ep, void *data); EAPI void embryo_program_data_set(Embryo_Program *ep, void *data);
EAPI void *embryo_program_data_get(Embryo_Program *ep); EAPI void *embryo_program_data_get(Embryo_Program *ep);
EAPI const char *embryo_error_string_get(int error); EAPI const char *embryo_error_string_get(Embryo_Error error);
EAPI int embryo_data_string_length_get(Embryo_Program *ep, Embryo_Cell *str_cell); EAPI int embryo_data_string_length_get(Embryo_Program *ep, Embryo_Cell *str_cell);
EAPI void embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst); EAPI void embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst);
EAPI void embryo_data_string_set(Embryo_Program *ep, const char *src, Embryo_Cell *str_cell); EAPI void embryo_data_string_set(Embryo_Program *ep, const char *src, Embryo_Cell *str_cell);

View File

@ -709,7 +709,7 @@ embryo_program_variable_get(Embryo_Program *ep, int num)
* @ingroup Embryo_Error_Group * @ingroup Embryo_Error_Group
*/ */
EAPI void EAPI void
embryo_program_error_set(Embryo_Program *ep, int error) embryo_program_error_set(Embryo_Program *ep, Embryo_Error error)
{ {
if (!ep) return; if (!ep) return;
ep->error = error; ep->error = error;
@ -721,7 +721,7 @@ embryo_program_error_set(Embryo_Program *ep, int error)
* @return The current error code. * @return The current error code.
* @ingroup Embryo_Error_Group * @ingroup Embryo_Error_Group
*/ */
EAPI int EAPI Embryo_Error
embryo_program_error_get(Embryo_Program *ep) embryo_program_error_get(Embryo_Program *ep)
{ {
if (!ep) return EMBRYO_ERROR_NONE; if (!ep) return EMBRYO_ERROR_NONE;
@ -768,7 +768,7 @@ embryo_program_data_get(Embryo_Program *ep)
* @ingroup Embryo_Error_Group * @ingroup Embryo_Error_Group
*/ */
EAPI const char * EAPI const char *
embryo_error_string_get(int error) embryo_error_string_get(Embryo_Error error)
{ {
const char *messages[] = const char *messages[] =
{ {
@ -799,7 +799,8 @@ embryo_error_string_get(int error)
/* EMBRYO_ERROR_INIT_JIT */ "Cannot initialize the JIT", /* EMBRYO_ERROR_INIT_JIT */ "Cannot initialize the JIT",
/* EMBRYO_ERROR_PARAMS */ "Parameter error", /* EMBRYO_ERROR_PARAMS */ "Parameter error",
}; };
if ((error < 0) || (error >= (int)(sizeof(messages) / sizeof(messages[0])))) if (((int)error < 0) ||
((int)error >= (int)(sizeof(messages) / sizeof(messages[0]))))
return (const char *)"(unknown)"; return (const char *)"(unknown)";
return messages[error]; return messages[error];
} }