Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Add const to query functions for cmd_ln_t and logmath_t #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions include/sphinxbase/cmd_ln.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ cmd_ln_t *cmd_ln_parse_file_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous comma
* Access the generic type union for a command line argument.
*/
SPHINXBASE_EXPORT
anytype_t *cmd_ln_access_r(cmd_ln_t *cmdln, char const *name);
anytype_t *cmd_ln_access_r(cmd_ln_t const *cmdln, char const *name);

/**
* Retrieve a string from a command-line object.
Expand All @@ -281,7 +281,7 @@ anytype_t *cmd_ln_access_r(cmd_ln_t *cmdln, char const *name);
* is unknown.
*/
SPHINXBASE_EXPORT
char const *cmd_ln_str_r(cmd_ln_t *cmdln, char const *name);
char const *cmd_ln_str_r(cmd_ln_t const *cmdln, char const *name);

/**
* Retrieve an array of strings from a command-line object.
Expand All @@ -298,7 +298,7 @@ char const *cmd_ln_str_r(cmd_ln_t *cmdln, char const *name);
* is unknown.
*/
SPHINXBASE_EXPORT
char const **cmd_ln_str_list_r(cmd_ln_t *cmdln, char const *name);
char const **cmd_ln_str_list_r(cmd_ln_t const *cmdln, char const *name);

/**
* Retrieve an integer from a command-line object.
Expand All @@ -312,7 +312,7 @@ char const **cmd_ln_str_list_r(cmd_ln_t *cmdln, char const *name);
* is unknown.
*/
SPHINXBASE_EXPORT
long cmd_ln_int_r(cmd_ln_t *cmdln, char const *name);
long cmd_ln_int_r(cmd_ln_t const *cmdln, char const *name);

/**
* Retrieve a floating-point number from a command-line object.
Expand All @@ -326,7 +326,7 @@ long cmd_ln_int_r(cmd_ln_t *cmdln, char const *name);
* is unknown.
*/
SPHINXBASE_EXPORT
double cmd_ln_float_r(cmd_ln_t *cmdln, char const *name);
double cmd_ln_float_r(cmd_ln_t const *cmdln, char const *name);

/**
* Retrieve a boolean value from a command-line object.
Expand Down Expand Up @@ -399,7 +399,7 @@ void cmd_ln_set_float_r(cmd_ln_t *cmdln, char const *name, double fv);
* was one of the arguments defined in the call to cmd_ln_parse_r().
*/
SPHINXBASE_EXPORT
int cmd_ln_exists_r(cmd_ln_t *cmdln, char const *name);
int cmd_ln_exists_r(cmd_ln_t const *cmdln, char const *name);

/**
* Print a help message listing the valid argument names, and the associated
Expand All @@ -410,7 +410,7 @@ int cmd_ln_exists_r(cmd_ln_t *cmdln, char const *name);
* @param defn array of argument name definitions.
*/
SPHINXBASE_EXPORT
void cmd_ln_print_help_r (cmd_ln_t *cmdln, FILE *fp, const arg_t *defn);
void cmd_ln_print_help_r (cmd_ln_t const *cmdln, FILE *fp, const arg_t *defn);

/**
* Print current configuration values and defaults.
Expand All @@ -420,7 +420,7 @@ void cmd_ln_print_help_r (cmd_ln_t *cmdln, FILE *fp, const arg_t *defn);
* @param defn array of argument name definitions.
*/
SPHINXBASE_EXPORT
void cmd_ln_print_values_r (cmd_ln_t *cmdln, FILE *fp, const arg_t *defn);
void cmd_ln_print_values_r (cmd_ln_t const *cmdln, FILE *fp, const arg_t *defn);

/**
* Non-reentrant version of cmd_ln_parse().
Expand Down
32 changes: 16 additions & 16 deletions include/sphinxbase/logmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,38 +132,38 @@ logmath_t *logmath_read(const char *filename);
* Write a log table to a file.
*/
SPHINXBASE_EXPORT
int32 logmath_write(logmath_t *lmath, const char *filename);
int32 logmath_write(logmath_t const *lmath, const char *filename);

/**
* Get the log table size and dimensions.
*/
SPHINXBASE_EXPORT
int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size,
int32 logmath_get_table_shape(logmath_t const *lmath, uint32 *out_size,
uint32 *out_width, uint32 *out_shift);

/**
* Get the log base.
*/
SPHINXBASE_EXPORT
float64 logmath_get_base(logmath_t *lmath);
float64 logmath_get_base(logmath_t const *lmath);

/**
* Get the smallest possible value represented in this base.
*/
SPHINXBASE_EXPORT
int logmath_get_zero(logmath_t *lmath);
int logmath_get_zero(logmath_t const *lmath);

/**
* Get the width of the values in a log table.
*/
SPHINXBASE_EXPORT
int logmath_get_width(logmath_t *lmath);
int logmath_get_width(logmath_t const *lmath);

/**
* Get the shift of the values in a log table.
*/
SPHINXBASE_EXPORT
int logmath_get_shift(logmath_t *lmath);
int logmath_get_shift(logmath_t const *lmath);

/**
* Retain ownership of a log table.
Expand All @@ -185,61 +185,61 @@ int logmath_free(logmath_t *lmath);
* Add two values in log space exactly and slowly (without using add table).
*/
SPHINXBASE_EXPORT
int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q);
int logmath_add_exact(logmath_t const *lmath, int logb_p, int logb_q);

/**
* Add two values in log space (i.e. return log(exp(p)+exp(q)))
*/
SPHINXBASE_EXPORT
int logmath_add(logmath_t *lmath, int logb_p, int logb_q);
int logmath_add(logmath_t const *lmath, int logb_p, int logb_q);

/**
* Convert linear floating point number to integer log in base B.
*/
SPHINXBASE_EXPORT
int logmath_log(logmath_t *lmath, float64 p);
int logmath_log(logmath_t const *lmath, float64 p);

/**
* Convert integer log in base B to linear floating point.
*/
SPHINXBASE_EXPORT
float64 logmath_exp(logmath_t *lmath, int logb_p);
float64 logmath_exp(logmath_t const *lmath, int logb_p);

/**
* Convert natural log (in floating point) to integer log in base B.
*/
SPHINXBASE_EXPORT
int logmath_ln_to_log(logmath_t *lmath, float64 log_p);
int logmath_ln_to_log(logmath_t const *lmath, float64 log_p);

/**
* Convert integer log in base B to natural log (in floating point).
*/
SPHINXBASE_EXPORT
float64 logmath_log_to_ln(logmath_t *lmath, int logb_p);
float64 logmath_log_to_ln(logmath_t const *lmath, int logb_p);

/**
* Convert base 10 log (in floating point) to integer log in base B.
*/
SPHINXBASE_EXPORT
int logmath_log10_to_log(logmath_t *lmath, float64 log_p);
int logmath_log10_to_log(logmath_t const *lmath, float64 log_p);

/**
* Convert base 10 log (in floating point) to float log in base B.
*/
SPHINXBASE_EXPORT
float logmath_log10_to_log_float(logmath_t *lmath, float64 log_p);
float logmath_log10_to_log_float(logmath_t const *lmath, float64 log_p);

/**
* Convert integer log in base B to base 10 log (in floating point).
*/
SPHINXBASE_EXPORT
float64 logmath_log_to_log10(logmath_t *lmath, int logb_p);
float64 logmath_log_to_log10(logmath_t const *lmath, int logb_p);

/**
* Convert float log in base B to base 10 log.
*/
SPHINXBASE_EXPORT
float64 logmath_log_float_to_log10(logmath_t *lmath, float log_p);
float64 logmath_log_float_to_log10(logmath_t const *lmath, float log_p);

#ifdef __cplusplus
}
Expand Down
20 changes: 10 additions & 10 deletions src/libsphinxbase/util/cmd_ln.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct cmd_ln_s {
cmd_ln_t *global_cmdln;

static void
arg_dump_r(cmd_ln_t *, FILE *, arg_t const *, int32);
arg_dump_r(cmd_ln_t const *, FILE *, arg_t const *, int32);

static cmd_ln_t *
parse_options(cmd_ln_t *, const arg_t *, int32, char* [], int32);
Expand Down Expand Up @@ -239,7 +239,7 @@ arg_resolve_env(const char *str)
}

static void
arg_dump_r(cmd_ln_t *cmdln, FILE *fp, const arg_t * defn, int32 doc)
arg_dump_r(cmd_ln_t const *cmdln, FILE *fp, const arg_t * defn, int32 doc)
{
arg_t const **pos;
int32 i, n;
Expand Down Expand Up @@ -908,7 +908,7 @@ cmd_ln_parse_file(const arg_t * defn, const char *filename, int32 strict)
}

void
cmd_ln_print_help_r(cmd_ln_t *cmdln, FILE *fp, arg_t const* defn)
cmd_ln_print_help_r(cmd_ln_t const *cmdln, FILE *fp, arg_t const* defn)
{
if (defn == NULL)
return;
Expand All @@ -917,7 +917,7 @@ cmd_ln_print_help_r(cmd_ln_t *cmdln, FILE *fp, arg_t const* defn)
}

void
cmd_ln_print_values_r(cmd_ln_t *cmdln, FILE *fp, arg_t const* defn)
cmd_ln_print_values_r(cmd_ln_t const *cmdln, FILE *fp, arg_t const* defn)
{
if (defn == NULL)
return;
Expand All @@ -926,7 +926,7 @@ cmd_ln_print_values_r(cmd_ln_t *cmdln, FILE *fp, arg_t const* defn)
}

int
cmd_ln_exists_r(cmd_ln_t *cmdln, const char *name)
cmd_ln_exists_r(cmd_ln_t const *cmdln, const char *name)
{
void *val;
if (cmdln == NULL)
Expand All @@ -935,7 +935,7 @@ cmd_ln_exists_r(cmd_ln_t *cmdln, const char *name)
}

anytype_t *
cmd_ln_access_r(cmd_ln_t *cmdln, const char *name)
cmd_ln_access_r(cmd_ln_t const *cmdln, const char *name)
{
void *val;
if (hash_table_lookup(cmdln->ht, name, &val) < 0) {
Expand All @@ -946,7 +946,7 @@ cmd_ln_access_r(cmd_ln_t *cmdln, const char *name)
}

char const *
cmd_ln_str_r(cmd_ln_t *cmdln, char const *name)
cmd_ln_str_r(cmd_ln_t const *cmdln, char const *name)
{
anytype_t *val;
val = cmd_ln_access_r(cmdln, name);
Expand All @@ -956,7 +956,7 @@ cmd_ln_str_r(cmd_ln_t *cmdln, char const *name)
}

char const **
cmd_ln_str_list_r(cmd_ln_t *cmdln, char const *name)
cmd_ln_str_list_r(cmd_ln_t const *cmdln, char const *name)
{
anytype_t *val;
val = cmd_ln_access_r(cmdln, name);
Expand All @@ -966,7 +966,7 @@ cmd_ln_str_list_r(cmd_ln_t *cmdln, char const *name)
}

long
cmd_ln_int_r(cmd_ln_t *cmdln, char const *name)
cmd_ln_int_r(cmd_ln_t const *cmdln, char const *name)
{
anytype_t *val;
val = cmd_ln_access_r(cmdln, name);
Expand All @@ -976,7 +976,7 @@ cmd_ln_int_r(cmd_ln_t *cmdln, char const *name)
}

double
cmd_ln_float_r(cmd_ln_t *cmdln, char const *name)
cmd_ln_float_r(cmd_ln_t const *cmdln, char const *name)
{
anytype_t *val;
val = cmd_ln_access_r(cmdln, name);
Expand Down
Loading