* Fixed warnings.

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32279 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-12 14:29:02 +00:00
parent 43da1b4f11
commit a5079edc04
2 changed files with 122 additions and 128 deletions

View File

@ -38,22 +38,20 @@ extern int yylineno;
struct field_t;
// Describes a data type.
struct type_t
{
struct type_t {
type_code code; // type code
char* name; // name of this type
const char* name; // name of this type
int32 count; // how many fields
field_t* fields; // field definitions
int32 def_id; // default resource ID
char* def_name; // default resource name
const char* def_name; // default resource name
};
// Used by the lexer and parser to pass around resource data. The rdef
// format allows string literals to contain embedded '\0' chars, so we
// can't use strlen() to find their length; instead we look at the size
// field for that (size includes the final '\0' too).
struct data_t
{
struct data_t {
type_t type; // data type
char* name; // name (only if this is a field)
size_t size; // byte size of data
@ -61,24 +59,21 @@ struct data_t
};
// Describes a data field in a user-defined type.
struct field_t
{
struct field_t {
type_t type; // data type
char* name; // name of this field
const char* name; // name of this field
size_t resize; // if not 0, data will be resized
data_t data; // default value
};
// Describes an array of data_t or field_t objects.
struct list_t
{
struct list_t {
int32 count;
void* items; // cast to data_t* or field_t*
};
// Used by the parser to pass around resource IDs.
struct res_id_t
{
struct res_id_t {
bool has_id;
bool has_name;
int32 id;
@ -86,9 +81,8 @@ struct res_id_t
};
// Describes a symbolic constant.
struct define_t
{
char* name;
struct define_t {
const char* name;
int32 value;
};
@ -109,7 +103,7 @@ void* alloc_mem(size_t size);
void free_mem(void* ptr);
// Returns the data type with the specified name.
type_t get_type(char* name);
type_t get_type(const char* name);
void abort_compile(status_t err, const char* format, ...);
void abort_compile();

View File

@ -37,39 +37,38 @@ using namespace std;
#define YYERROR_VERBOSE
static void yyerror(char*);
static void yyerror(const char*);
struct ident_compare_t { // allows the maps to compare identifier names
bool
operator()(char* s1, char* s2) const
operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
typedef std::map<char*, int32, ident_compare_t> sym_tab_t;
typedef std::map<const char*, int32, ident_compare_t> sym_tab_t;
typedef sym_tab_t::iterator sym_iter_t;
typedef std::map<const char*, type_t, ident_compare_t> type_tab_t;
typedef type_tab_t::iterator type_iter_t;
typedef std::map<const char*, define_t, ident_compare_t> define_tab_t;
typedef define_tab_t::iterator define_iter_t;
static sym_tab_t symbol_table; // symbol table for enums
static int32 enum_cnt; // counter for enum symbols without id
static void add_symbol(char*, int32);
static int32 get_symbol(char*);
typedef std::map<char*, type_t, ident_compare_t> type_tab_t;
typedef type_tab_t::iterator type_iter_t;
static type_tab_t type_table; // symbol table for data types
static void add_user_type(res_id_t, type_code, char*, list_t);
typedef std::map<char*, define_t, ident_compare_t> define_tab_t;
typedef define_tab_t::iterator define_iter_t;
static define_tab_t define_table; // symbol table for defines
static bool is_type(char* name);
static define_t get_define(char* name);
static void add_user_type(res_id_t, type_code, const char*, list_t);
static void add_symbol(const char*, int32);
static int32 get_symbol(const char*);
static bool is_type(const char* name);
static define_t get_define(const char* name);
static data_t make_data(size_t, type_t);
static data_t make_bool(bool);
@ -83,7 +82,7 @@ static BMessage* make_msg(list_t);
static data_t flatten_msg(BMessage*);
static data_t make_default(type_t);
static data_t make_type(char*, list_t);
static data_t make_type(char* name, list_t);
static list_t make_field_list(field_t);
static list_t concat_field_list(list_t, field_t);
@ -98,6 +97,7 @@ static data_t binary_expr(data_t, data_t, char);
static void add_resource(res_id_t, type_code, data_t);
//------------------------------------------------------------------------------
%}
@ -497,7 +497,7 @@ float
void
yyerror(char* msg)
yyerror(const char* msg)
{
// This function is called by the parser when it encounters
// an error, after which it aborts parsing and returns from
@ -511,7 +511,7 @@ yyerror(char* msg)
void
add_symbol(char* name, int32 id)
add_symbol(const char* name, int32 id)
{
if (symbol_table.find(name) != symbol_table.end())
abort_compile(RDEF_COMPILE_ERR, "duplicate symbol %s", name);
@ -521,7 +521,7 @@ add_symbol(char* name, int32 id)
int32
get_symbol(char* name)
get_symbol(const char* name)
{
sym_iter_t i = symbol_table.find(name);
@ -533,7 +533,7 @@ get_symbol(char* name)
static void
add_builtin_type(type_code code, char* name)
add_builtin_type(type_code code, const char* name)
{
type_t type;
type.code = code;
@ -548,7 +548,7 @@ add_builtin_type(type_code code, char* name)
void
add_user_type(res_id_t id, type_code code, char* name, list_t list)
add_user_type(res_id_t id, type_code code, const char* name, list_t list)
{
if (type_table.find(name) != type_table.end())
abort_compile(RDEF_COMPILE_ERR, "duplicate type %s", name);
@ -586,7 +586,7 @@ same_type(type_t type1, type_t type2)
type_t
get_type(char* name)
get_type(const char* name)
{
type_iter_t i = type_table.find(name);
@ -598,14 +598,14 @@ get_type(char* name)
bool
is_type(char* name)
is_type(const char* name)
{
return type_table.find(name) != type_table.end();
}
define_t
get_define(char* name)
get_define(const char* name)
{
define_iter_t i = define_table.find(name);
@ -1371,7 +1371,7 @@ add_resource(res_id_t id, type_code code, data_t data)
id.id = data.type.def_id;
if (!id.has_name)
id.name = data.type.def_name;
id.name = (char*)data.type.def_name;
if (!(flags & RDEF_MERGE_RESOURCES) && rsrc.HasResource(code, id.id))
abort_compile(RDEF_COMPILE_ERR, "duplicate resource");
@ -1681,7 +1681,7 @@ add_file_types()
static void
add_define(char* name, int32 value)
add_define(const char* name, int32 value)
{
define_t define;
define.name = name;