X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flibcore%2Flc_opts.h;h=cf825eeae722cc6fbed67697ec21a6c74b12a995;hb=b8dd50e584e9747da3d0bdc83dff71e13e9deb08;hp=aaea5cc7484863bcab7917f05387543e0902977c;hpb=ce6161a7e42a48f7422b7babcc64d8ace18e2687;p=libfirm diff --git a/ir/libcore/lc_opts.h b/ir/libcore/lc_opts.h index aaea5cc74..cf825eeae 100644 --- a/ir/libcore/lc_opts.h +++ b/ir/libcore/lc_opts.h @@ -80,55 +80,54 @@ typedef int (lc_opt_dump_vals_t)(char *buf, size_t n, const char *name, lc_opt_t typedef int (lc_opt_error_handler_t)(const char *prefix, const lc_opt_err_info_t *err); typedef struct { - const char *name; /**< The name of the option. */ - const char *desc; /**< A description for the option. */ - lc_opt_type_t type; /**< The type of the option (see enum). */ - void *value; /**< A pointer to the area, where the value - of the option shall be put to. May be NULL. */ + const char *name; /**< The name of the option. */ + const char *desc; /**< A description for the option. */ + lc_opt_type_t type; /**< The type of the option (see enum). */ + void *value; /**< A pointer to the area, where the value + of the option shall be put to. May be + NULL. */ - size_t len; /**< The amount of bytes available at the - location value points to. */ - lc_opt_callback_t *cb; /**< A callback that is called, when the option is set. - This may never be NULL. */ + size_t len; /**< The amount of bytes available at the + location value points to. */ + lc_opt_callback_t *cb; /**< A callback that is called, when the + option is set. This may never be NULL. */ - lc_opt_dump_t *dump; /**< A function which is able to format the options value - into a string. May be NULL. */ + lc_opt_dump_t *dump; /**< A function which is able to format the + options value into a string. May be + NULL. */ - lc_opt_dump_vals_t *dump_vals; /**< A function which is able to format the possible values - for this option into a string. May be NULL. */ + lc_opt_dump_vals_t *dump_vals; /**< A function which is able to format the possible values + for this option into a string. May be NULL. */ } lc_opt_table_entry_t; -#define _LC_OPT_ENT(name, desc, type, value, len, cb, dump, dump_vals) \ - { name, desc, type, value, len, cb, dump, dump_vals } +#define _LC_OPT_ENT(name, desc, type, val_type, value, len, cb, dump, dump_vals) \ + { name, desc, type, 1 ? (value) : (val_type*)0 /* Produces a warning, if var has wrong type. */, len, cb, dump, dump_vals } #define LC_OPT_ENT_INT(name, desc, addr) \ - _LC_OPT_ENT(name, desc, lc_opt_type_int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, NULL) + _LC_OPT_ENT(name, desc, lc_opt_type_int, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, NULL) #define LC_OPT_ENT_DBL(name, desc, addr) \ - _LC_OPT_ENT(name, desc, lc_opt_type_double, addr, 0, lc_opt_std_cb, lc_opt_std_dump, NULL) + _LC_OPT_ENT(name, desc, lc_opt_type_double, double, addr, 0, lc_opt_std_cb, lc_opt_std_dump, NULL) #define LC_OPT_ENT_BIT(name, desc, addr, mask) \ - _LC_OPT_ENT(name, desc, lc_opt_type_bit, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL) + _LC_OPT_ENT(name, desc, lc_opt_type_bit, unsigned, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL) #define LC_OPT_ENT_NEGBIT(name, desc, addr, mask) \ - _LC_OPT_ENT(name, desc, lc_opt_type_negbit, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL) + _LC_OPT_ENT(name, desc, lc_opt_type_negbit, unsigned, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL) #define LC_OPT_ENT_BOOL(name, desc, addr) \ - _LC_OPT_ENT(name, desc, lc_opt_type_boolean, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals) + _LC_OPT_ENT(name, desc, lc_opt_type_boolean, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals) #define LC_OPT_ENT_NEGBOOL(name, desc, addr) \ - _LC_OPT_ENT(name, desc, lc_opt_type_negboolean, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals) + _LC_OPT_ENT(name, desc, lc_opt_type_negboolean, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals) -#define LC_OPT_ENT_STR(name, desc, buf, len) \ - _LC_OPT_ENT(name, desc, lc_opt_type_string, buf, len, lc_opt_std_cb, lc_opt_std_dump, NULL) - -#define LC_OPT_ENT_CB(name, desc, type, data, len, cb, dump, dump_vals) \ - _LC_OPT_ENT(name, desc, type, data, len, cb, dump, dump_vals) +#define LC_OPT_ENT_STR(name, desc, buf) \ + _LC_OPT_ENT(name, desc, lc_opt_type_string, char, buf, sizeof(buf), lc_opt_std_cb, lc_opt_std_dump, NULL) #define LC_OPT_LAST \ - _LC_OPT_ENT(NULL, NULL, lc_opt_type_invalid, NULL, 0, NULL, NULL, NULL) + _LC_OPT_ENT(NULL, NULL, lc_opt_type_invalid, void, NULL, 0, NULL, NULL, NULL) /** * Get the root option group. @@ -159,7 +158,7 @@ lc_opt_entry_t *lc_opt_get_grp(lc_opt_entry_t *parent, const char *name); * @param desc A description of the option. * @param type The data type of the option (see lc_opt_type_*) * @param value A pointer to the memory, where the value shall be stored. - * (May be NULL). + * (May be NULL). * @param length Amount of bytes available at the memory location * indicated by @p value. * @param cb A callback function to be called, as the option's value @@ -168,14 +167,14 @@ lc_opt_entry_t *lc_opt_get_grp(lc_opt_entry_t *parent, const char *name); * @return The handle for the option. */ lc_opt_entry_t *lc_opt_add_opt(lc_opt_entry_t *grp, - const char *name, - const char *desc, - lc_opt_type_t type, - void *value, size_t length, - lc_opt_callback_t *cb, - lc_opt_dump_t *dump, - lc_opt_dump_vals_t *dump_vals, - lc_opt_err_info_t *err); + const char *name, + const char *desc, + lc_opt_type_t type, + void *value, size_t length, + lc_opt_callback_t *cb, + lc_opt_dump_t *dump, + lc_opt_dump_vals_t *dump_vals, + lc_opt_err_info_t *err); int lc_opt_std_cb(const char *name, lc_opt_type_t type, void *data, size_t length, ...); @@ -278,48 +277,36 @@ void lc_opt_print_tree(lc_opt_entry_t *ent, FILE *f); int lc_opt_add_table(lc_opt_entry_t *grp, const lc_opt_table_entry_t *table); -void lc_opt_from_file(const char *filenmame, FILE *f, lc_opt_error_handler_t *handler); - /** * The same as lc_opt_from_single_arg() only for an array of arguments. */ int lc_opt_from_argv(const lc_opt_entry_t *root, - const char *opt_prefix, - int argc, const char *argv[], - lc_opt_error_handler_t *handler); + const char *opt_prefix, + int argc, const char *argv[], + lc_opt_error_handler_t *handler); /** * Set options from a single (command line) argument. - * @param root The root group we start resolving from. - * @param opt_prefix The option prefix which shall be stripped of (mostly --). - * @param arg The command line argument itself. + * @param root The root group we start resolving from. + * @param opt_prefix The option prefix which shall be stripped of (mostly --). + * @param arg The command line argument itself. * @param handler An error handler. * @return 1, if the argument was set, 0 if not. */ int lc_opt_from_single_arg(const lc_opt_entry_t *grp, - const char *opt_prefix, - const char *arg, - lc_opt_error_handler_t *handler); + const char *opt_prefix, + const char *arg, + lc_opt_error_handler_t *handler); /** * Get printf environment for the option module. * Currently implemented options are: - * %{opt:value} (%V) Value of an option. - * %{opt:type} (%T) Type of an option. - * %{opt:name} (%O) Name of an option. - * %{opt:desc} (%D) Description of an option. + * %{opt:value} (%V) Value of an option. + * %{opt:type} (%T) Type of an option. + * %{opt:name} (%O) Name of an option. + * %{opt:desc} (%D) Description of an option. * @return The option printf environment. */ const lc_arg_env_t *lc_opt_get_arg_env(void); -/** - * This function tries to open a ini file in the user's homedir - * (On win32 this is \Documents and Settings\Application Data) - * which is called .rc (on win32 .ini) - * - * and an ini file in the current directory which is called .ini on - * both systems. - */ -void lc_opt_default_configs(const char *init_name); - #endif