glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places.

This eliminates a lot of boilerplate and should be 100% equivalent.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Kenneth Graunke
2013-09-18 14:05:36 -07:00
parent bfbad9d1a8
commit 81a3759bb5
5 changed files with 7 additions and 121 deletions

View File

@@ -49,24 +49,7 @@ struct YYLTYPE;
*/ */
class ast_node { class ast_node {
public: public:
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RZALLOC_CXX_OPERATORS(ast_node);
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *table)
{
ralloc_free(table);
}
/** /**
* Print an AST node in something approximating the original GLSL code * Print an AST node in something approximating the original GLSL code
@@ -363,24 +346,7 @@ enum {
}; };
struct ast_type_qualifier { struct ast_type_qualifier {
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RZALLOC_CXX_OPERATORS(ast_type_qualifier);
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *table)
{
ralloc_free(table);
}
union { union {
struct { struct {

View File

@@ -73,22 +73,7 @@ struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx); void *mem_ctx);
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *mem = rzalloc_size(ctx, size);
assert(mem != NULL);
return mem;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *mem)
{
ralloc_free(mem);
}
/** /**
* Generate a string representing the GLSL version currently being compiled * Generate a string representing the GLSL version currently being compiled

View File

@@ -26,20 +26,7 @@
class symbol_table_entry { class symbol_table_entry {
public: public:
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RALLOC_CXX_OPERATORS(symbol_table_entry);
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *entry = ralloc_size(ctx, size);
assert(entry != NULL);
return entry;
}
/* If the user *does* call delete, that's OK, we will just ralloc_free. */
static void operator delete(void *entry)
{
ralloc_free(entry);
}
bool add_interface(const glsl_type *i, enum ir_variable_mode mode) bool add_interface(const glsl_type *i, enum ir_variable_mode mode)
{ {

View File

@@ -139,25 +139,7 @@ public:
/* empty */ /* empty */
} }
DECLARE_RALLOC_CXX_OPERATORS(function)
/* Callers of this ralloc-based new need not call delete. It's
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *node)
{
ralloc_free(node);
}
ir_function_signature *sig; ir_function_signature *sig;

View File

@@ -76,24 +76,7 @@ struct exec_node {
struct exec_node *prev; struct exec_node *prev;
#ifdef __cplusplus #ifdef __cplusplus
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RALLOC_CXX_OPERATORS(exec_node)
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *node)
{
ralloc_free(node);
}
exec_node() : next(NULL), prev(NULL) exec_node() : next(NULL), prev(NULL)
{ {
@@ -285,24 +268,7 @@ struct exec_list {
struct exec_node *tail_pred; struct exec_node *tail_pred;
#ifdef __cplusplus #ifdef __cplusplus
/* Callers of this ralloc-based new need not call delete. It's DECLARE_RALLOC_CXX_OPERATORS(exec_list)
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = ralloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *node)
{
ralloc_free(node);
}
exec_list() exec_list()
{ {