Clean up pre-processor mess for context bindings

This commit is contained in:
Alex Palaistras 2016-05-03 18:00:03 +01:00
parent 4688362c1b
commit 6c0669dd67
5 changed files with 22 additions and 10 deletions

View File

@ -95,7 +95,7 @@ void *context_eval(engine_context *context, char *script) {
void context_bind(engine_context *context, char *name, void *value) {
engine_value *v = (engine_value *) value;
CONTEXT_VALUE_BIND(name, v->internal);
context_bind_zval(name, v->internal);
}
void context_destroy(engine_context *context) {
@ -103,4 +103,6 @@ void context_destroy(engine_context *context) {
SG(server_context) = NULL;
free(context);
}
}
#include "_context.c"

View File

@ -5,9 +5,7 @@
#ifndef ___CONTEXT_H___
#define ___CONTEXT_H___
#define CONTEXT_VALUE_BIND(n, v) do { \
ZEND_SET_SYMBOL(EG(active_symbol_table), n, v); \
} while (0)
static void context_bind_zval(char *name, zval *value);
#define CONTEXT_EXECUTE(o, v) do { \
zend_op_array *oparr = EG(active_op_array); \
@ -44,4 +42,4 @@
EG(return_value_ptr_ptr) = retvalptr; \
} while (0)
#endif
#endif

View File

@ -5,9 +5,7 @@
#ifndef ___CONTEXT_H___
#define ___CONTEXT_H___
#define CONTEXT_VALUE_BIND(n, v) do { \
zend_hash_str_update(&EG(symbol_table), n, strlen(n), v); \
} while (0)
static void context_bind_zval(char *name, zval *value);
#define CONTEXT_EXECUTE(o, v) do { \
EG(no_extensions) = 1; \
@ -24,4 +22,4 @@
EG(no_extensions) = 0; \
} while (0)
#endif
#endif

View File

@ -0,0 +1,7 @@
// Copyright 2016 Alexander Palaistras. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
static void context_bind_zval(char *name, zval *value) {
ZEND_SET_SYMBOL(EG(active_symbol_table), name, value);
}

View File

@ -0,0 +1,7 @@
// Copyright 2016 Alexander Palaistras. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
static void context_bind_zval(char *name, zval *value) {
zend_hash_str_update(&EG(symbol_table), name, strlen(name), value);
}