Skip to content

Commit 39f9487

Browse files
author
Andi Gutmans
committed
-Tiny patches
1 parent 76ceb9a commit 39f9487

8 files changed

+76
-14
lines changed

Zend/config.w32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef unsigned int uint;
1717
#undef inline
1818
#endif
1919

20-
#define ZEND_DEBUG 1
20+
#define ZEND_DEBUG 0
2121

2222
#define zend_sprintf sprintf
2323

Zend/libzend.dsp

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend-scanner.l

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,28 @@ inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
170170
}
171171

172172

173-
zend_op_array *compile_files(int mark_as_ref CLS_DC, int file_count, ...)
173+
174+
ZEND_API zend_op_array *compile_files(int mark_as_ref ELS_DC, int file_count, ...)
175+
{
176+
va_list files;
177+
zend_op_array *op_array;
178+
179+
va_start(files, file_count);
180+
op_array = v_compile_files(mark_as_ref ELS_CC, file_count, files);
181+
va_end(files);
182+
return op_array;
183+
}
184+
185+
186+
ZEND_API zend_op_array *v_compile_files(int mark_as_ref ELS_DC, int file_count, va_list files)
174187
{
175188
zend_lex_state original_lex_state;
176189
zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
177190
zend_op_array *original_active_op_array = CG(active_op_array);
178191
zend_op_array *retval=NULL;
179192
zend_file_handle *file_handle;
180-
va_list files;
181193
int i;
182194

183-
va_start(files, file_count);
184-
185195
init_op_array(op_array, INITIAL_OP_ARRAY_SIZE);
186196
save_lexical_state(&original_lex_state CLS_CC);
187197

@@ -215,7 +225,6 @@ zend_op_array *compile_files(int mark_as_ref CLS_DC, int file_count, ...)
215225
pass_include_eval(op_array);
216226
}
217227
}
218-
va_end(files);
219228
return retval;
220229
}
221230

Zend/zend_API.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,51 @@ int getParametersArray(int ht, int param_count, zval **argument_array)
103103
}
104104

105105

106+
107+
108+
/* Zend-optimized Extended functions */
109+
/* this function doesn't check for too many parameters */
110+
int getParametersEx(int param_count,...)
111+
{
112+
void **p = EG(argument_stack).top_element-1;
113+
int arg_count = (ulong) *p;
114+
va_list ptr;
115+
zval ***param;
116+
ELS_FETCH();
117+
118+
if (param_count>arg_count) {
119+
return FAILURE;
120+
}
121+
122+
va_start(ptr, param_count);
123+
while (param_count>0) {
124+
param = va_arg(ptr, zval ***);
125+
*param = (zval **) p-(param_count--);
126+
}
127+
va_end(ptr);
128+
129+
return SUCCESS;
130+
}
131+
132+
133+
int getParametersArrayEx(int param_count, zval ***argument_array)
134+
{
135+
void **p = EG(argument_stack).top_element-1;
136+
int arg_count = (ulong) *p;
137+
ELS_FETCH();
138+
139+
if (param_count>arg_count) {
140+
return FAILURE;
141+
}
142+
143+
while (param_count>0) {
144+
*(argument_array++) = (zval **) p-(param_count--);
145+
}
146+
147+
return SUCCESS;
148+
}
149+
150+
106151
int getThis(zval **this)
107152
{
108153
/* NEEDS TO BE IMPLEMENTED FOR ZEND */

Zend/zend_API.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ int zend_next_free_module(void);
2525

2626
int getParameters(int ht, int param_count,...);
2727
int getParametersArray(int ht, int param_count, zval **argument_array);
28+
int getParametersEx(int param_count,...);
29+
int getParametersArrayEx(int param_count, zval ***argument_array);
30+
2831
int getThis(zval **this);
32+
33+
2934
int ParameterPassedByReference(int ht, uint n);
3035
int register_functions(function_entry *functions);
3136
void unregister_functions(function_entry *functions, int count);

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "zend_operators.h"
2323

2424

25-
zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
25+
ZEND_API zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
2626

2727

2828
#ifndef ZTS

Zend/zend_compile.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ typedef struct {
150150
} list_llist_element;
151151

152152

153-
typedef struct {
153+
typedef struct _zend_file_handle {
154154
int type;
155155
char *filename;
156156
union {
@@ -176,7 +176,7 @@ typedef struct {
176176
void init_compiler(CLS_D ELS_DC);
177177
void shutdown_compiler(CLS_D);
178178

179-
extern zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
179+
extern ZEND_API zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
180180

181181
int lex_scan(zval *zendlval CLS_DC);
182182
void reset_scanner(CLS_D);
@@ -315,6 +315,7 @@ void do_extended_fcall_end(CLS_D);
315315
ZEND_API int require_file(zend_file_handle *file_handle CLS_DC);
316316
ZEND_API int require_filename(char *filename CLS_DC);
317317
ZEND_API zend_op_array *compile_files(int mark_as_ref CLS_DC, int file_count, ...);
318+
ZEND_API zend_op_array *v_compile_files(int mark_as_ref ELS_DC, int file_count, va_list files);
318319
ZEND_API zend_op_array *compile_string(zval *source_string CLS_DC);
319320
ZEND_API zend_op_array *compile_filename(zval *filename CLS_DC);
320321
inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC);
@@ -325,8 +326,8 @@ inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC);
325326
ZEND_API void init_op_array(zend_op_array *op_array, int initial_ops_size);
326327
ZEND_API void destroy_op_array(zend_op_array *op_array);
327328

328-
void destroy_zend_function(zend_function *function);
329-
void destroy_zend_class(zend_class_entry *ce);
329+
ZEND_API void destroy_zend_function(zend_function *function);
330+
ZEND_API void destroy_zend_class(zend_class_entry *ce);
330331
zend_op *get_next_op(zend_op_array *op_array CLS_DC);
331332
int get_next_op_number(zend_op_array *op_array);
332333
int print_class(zend_class_entry *class_entry);

Zend/zend_opcode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void init_op_array(zend_op_array *op_array, int initial_ops_size)
9696
}
9797

9898

99-
void destroy_zend_function(zend_function *function)
99+
ZEND_API void destroy_zend_function(zend_function *function)
100100
{
101101
switch (function->type) {
102102
case ZEND_USER_FUNCTION:
@@ -108,7 +108,8 @@ void destroy_zend_function(zend_function *function)
108108
}
109109
}
110110

111-
void destroy_zend_class(zend_class_entry *ce)
111+
112+
ZEND_API void destroy_zend_class(zend_class_entry *ce)
112113
{
113114
switch (ce->type) {
114115
case ZEND_USER_CLASS:

0 commit comments

Comments
 (0)