php_vm 1.3.8 → 1.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/php_vm/php_vm.c +114 -52
- data/ext/php_vm/php_vm.h +4 -6
- data/ext/php_vm/php_vm_z2v.c +1 -1
- metadata +2 -2
data/ext/php_vm/php_vm.c
CHANGED
@@ -32,7 +32,7 @@ static int php_embed_output_handler(const char *str, unsigned int str_length TSR
|
|
32
32
|
return str_length;
|
33
33
|
}
|
34
34
|
|
35
|
-
static void php_embed_error_handler(char *message)
|
35
|
+
static void php_embed_error_handler(char *message TSRMLS_DC)
|
36
36
|
{
|
37
37
|
VALUE proc = rb_cv_get(rb_mPHPVM, "@@error_handler");
|
38
38
|
VALUE report = rb_exc_new2(rb_ePHPErrorReporting, message);
|
@@ -77,9 +77,10 @@ void php_eval_string(char *code, int code_len TSRMLS_DC)
|
|
77
77
|
}
|
78
78
|
|
79
79
|
// exception
|
80
|
-
if (
|
81
|
-
VALUE exception = zval_to_value(
|
82
|
-
|
80
|
+
if (g_exception) {
|
81
|
+
VALUE exception = zval_to_value(g_exception);
|
82
|
+
zval_ptr_dtor(&g_exception);
|
83
|
+
g_exception = NULL;
|
83
84
|
rb_exc_raise(exception);
|
84
85
|
}
|
85
86
|
|
@@ -92,7 +93,7 @@ void php_eval_string(char *code, int code_len TSRMLS_DC)
|
|
92
93
|
}
|
93
94
|
}
|
94
95
|
|
95
|
-
void find_zend_class_entry(char *name, int name_len, zend_class_entry ***ce)
|
96
|
+
void find_zend_class_entry(char *name, int name_len, zend_class_entry ***ce TSRMLS_DC)
|
96
97
|
{
|
97
98
|
// lowercase
|
98
99
|
char *lcname = malloc(name_len+1);
|
@@ -115,7 +116,7 @@ void find_zend_class_entry(char *name, int name_len, zend_class_entry ***ce)
|
|
115
116
|
|
116
117
|
int is_exception_zend_class_entry(zend_class_entry *ce TSRMLS_DC)
|
117
118
|
{
|
118
|
-
return instanceof_function(ce, zend_exception_get_default() TSRMLS_CC);
|
119
|
+
return instanceof_function(ce, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);
|
119
120
|
}
|
120
121
|
|
121
122
|
int is_exception_zval(zval *z TSRMLS_DC)
|
@@ -123,7 +124,7 @@ int is_exception_zval(zval *z TSRMLS_DC)
|
|
123
124
|
return is_exception_zend_class_entry(Z_OBJCE_P(z) TSRMLS_CC);
|
124
125
|
}
|
125
126
|
|
126
|
-
void find_zend_function(zend_class_entry *ce, char *name, int name_len, zend_function **mptr)
|
127
|
+
void find_zend_function(zend_class_entry *ce, char *name, int name_len, zend_function **mptr TSRMLS_DC)
|
127
128
|
{
|
128
129
|
// function_table
|
129
130
|
HashTable *function_table = NULL;
|
@@ -152,20 +153,11 @@ void find_zend_function(zend_class_entry *ce, char *name, int name_len, zend_fun
|
|
152
153
|
free(lcname);
|
153
154
|
}
|
154
155
|
|
155
|
-
int
|
156
|
-
{
|
157
|
-
zend_function *mptr;
|
158
|
-
find_zend_function(ce, RSTRING_PTR(method_name), RSTRING_LEN(method_name), &mptr);
|
159
|
-
return mptr!=NULL;
|
160
|
-
}
|
161
|
-
|
162
|
-
int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval)
|
156
|
+
int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval TSRMLS_DC)
|
163
157
|
{
|
164
158
|
int result = FAILURE;
|
165
159
|
|
166
160
|
if (ce->constructor) {
|
167
|
-
TSRMLS_FETCH();
|
168
|
-
|
169
161
|
// defined constructor
|
170
162
|
/*
|
171
163
|
if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
|
@@ -177,12 +169,13 @@ int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval)
|
|
177
169
|
object_init_ex(retval, ce);
|
178
170
|
|
179
171
|
// call constructor
|
180
|
-
|
172
|
+
result = call_php_method(ce, retval, ce->constructor, RARRAY_LEN(v_args), RARRAY_PTR(v_args), &retval TSRMLS_CC);
|
181
173
|
|
182
174
|
// exception
|
183
175
|
if (result==FAILURE) {
|
184
176
|
if (g_exception) {
|
185
177
|
VALUE exception = zval_to_value(g_exception);
|
178
|
+
zval_ptr_dtor(&g_exception);
|
186
179
|
g_exception = NULL;
|
187
180
|
rb_exc_raise(exception);
|
188
181
|
} else {
|
@@ -190,6 +183,8 @@ int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval)
|
|
190
183
|
}
|
191
184
|
}
|
192
185
|
|
186
|
+
zval_ptr_dtor(&retval);
|
187
|
+
|
193
188
|
} else if (!RARRAY_LEN(v_args)) {
|
194
189
|
// undefined constructor, hasnt args
|
195
190
|
object_init_ex(retval, ce);
|
@@ -368,7 +363,7 @@ int call_php_method(zend_class_entry *ce, zval *obj, zend_function *mptr, int ar
|
|
368
363
|
zend_hash_next_index_insert(Z_ARRVAL_P(z_args), &new_var, sizeof(zval *), NULL);
|
369
364
|
}
|
370
365
|
|
371
|
-
zend_fcall_info_args(&fci, z_args);
|
366
|
+
zend_fcall_info_args(&fci, z_args TSRMLS_CC);
|
372
367
|
|
373
368
|
zend_try {
|
374
369
|
// call method
|
@@ -391,10 +386,8 @@ int call_php_method(zend_class_entry *ce, zval *obj, zend_function *mptr, int ar
|
|
391
386
|
} zend_end_try();
|
392
387
|
|
393
388
|
// release
|
394
|
-
for (i=0; i<fci.param_count; i++) {
|
395
|
-
zval_ptr_dtor(fci.params[i]);
|
396
|
-
}
|
397
389
|
zend_fcall_info_args_clear(&fci, 1);
|
390
|
+
zval_ptr_dtor(&z_args);
|
398
391
|
|
399
392
|
// result
|
400
393
|
if (g_exception) {
|
@@ -424,6 +417,8 @@ VALUE get_callee_name()
|
|
424
417
|
|
425
418
|
VALUE call_php_method_bridge(zend_class_entry *ce, zval *obj, zend_function *mptr, int argc, VALUE *argv)
|
426
419
|
{
|
420
|
+
TSRMLS_FETCH();
|
421
|
+
|
427
422
|
// call
|
428
423
|
zval *z_val;
|
429
424
|
int result = call_php_method(ce, obj, mptr, argc, argv, &z_val TSRMLS_CC);
|
@@ -432,6 +427,7 @@ VALUE call_php_method_bridge(zend_class_entry *ce, zval *obj, zend_function *mpt
|
|
432
427
|
if (result==FAILURE) {
|
433
428
|
if (g_exception) {
|
434
429
|
VALUE exception = zval_to_value(g_exception);
|
430
|
+
zval_ptr_dtor(&g_exception);
|
435
431
|
g_exception = NULL;
|
436
432
|
rb_exc_raise(exception);
|
437
433
|
} else {
|
@@ -439,7 +435,9 @@ VALUE call_php_method_bridge(zend_class_entry *ce, zval *obj, zend_function *mpt
|
|
439
435
|
}
|
440
436
|
}
|
441
437
|
|
442
|
-
|
438
|
+
VALUE v_retval = zval_to_value(z_val);
|
439
|
+
zval_ptr_dtor(&z_val);
|
440
|
+
return v_retval;
|
443
441
|
}
|
444
442
|
|
445
443
|
VALUE call_php_method_name_bridge(zend_class_entry *ce, zval *obj, VALUE callee, int argc, VALUE *argv)
|
@@ -453,7 +451,7 @@ VALUE call_php_method_name_bridge(zend_class_entry *ce, zval *obj, VALUE callee,
|
|
453
451
|
|
454
452
|
// method
|
455
453
|
zend_function *mptr;
|
456
|
-
find_zend_function(ce, RSTRING_PTR(callee), RSTRING_LEN(callee), &mptr);
|
454
|
+
find_zend_function(ce, RSTRING_PTR(callee), RSTRING_LEN(callee), &mptr TSRMLS_CC);
|
457
455
|
|
458
456
|
// call
|
459
457
|
if (mptr) {
|
@@ -602,7 +600,7 @@ VALUE rb_php_vm_set_error_handler(VALUE cls, VALUE proc)
|
|
602
600
|
return Qnil;
|
603
601
|
}
|
604
602
|
|
605
|
-
void php_vm_require(char *token, VALUE filepath)
|
603
|
+
void php_vm_require(char *token, VALUE filepath TSRMLS_DC)
|
606
604
|
{
|
607
605
|
StringValue(filepath);
|
608
606
|
filepath = rb_funcall(filepath, rb_intern("gsub"), 2, rb_str_new2("\\"), rb_str_new2("\\\\"));
|
@@ -613,30 +611,34 @@ void php_vm_require(char *token, VALUE filepath)
|
|
613
611
|
rb_str_cat(code, RSTRING_PTR(filepath), RSTRING_LEN(filepath));
|
614
612
|
rb_str_cat2(code, "\";");
|
615
613
|
|
616
|
-
php_eval_string(RSTRING_PTR(code), RSTRING_LEN(code));
|
614
|
+
php_eval_string(RSTRING_PTR(code), RSTRING_LEN(code) TSRMLS_CC);
|
617
615
|
}
|
618
616
|
|
619
617
|
VALUE rb_php_vm_require(VALUE cls, VALUE filepath)
|
620
618
|
{
|
621
|
-
|
619
|
+
TSRMLS_FETCH();
|
620
|
+
php_vm_require("require", filepath TSRMLS_CC);
|
622
621
|
return Qtrue;
|
623
622
|
}
|
624
623
|
|
625
624
|
VALUE rb_php_vm_require_once(VALUE cls, VALUE filepath)
|
626
625
|
{
|
627
|
-
|
626
|
+
TSRMLS_FETCH();
|
627
|
+
php_vm_require("require_once", filepath TSRMLS_CC);
|
628
628
|
return Qtrue;
|
629
629
|
}
|
630
630
|
|
631
631
|
VALUE rb_php_vm_include(VALUE cls, VALUE filepath)
|
632
632
|
{
|
633
|
-
|
633
|
+
TSRMLS_FETCH();
|
634
|
+
php_vm_require("include", filepath TSRMLS_CC);
|
634
635
|
return Qnil;
|
635
636
|
}
|
636
637
|
|
637
638
|
VALUE rb_php_vm_include_once(VALUE cls, VALUE filepath)
|
638
639
|
{
|
639
|
-
|
640
|
+
TSRMLS_FETCH();
|
641
|
+
php_vm_require("include_once", filepath TSRMLS_CC);
|
640
642
|
return Qnil;
|
641
643
|
}
|
642
644
|
|
@@ -658,7 +660,7 @@ VALUE define_global_constants()
|
|
658
660
|
|
659
661
|
// method
|
660
662
|
zend_function *mptr;
|
661
|
-
find_zend_function(NULL, "get_defined_constants", strlen("get_defined_constants"), &mptr);
|
663
|
+
find_zend_function(NULL, "get_defined_constants", strlen("get_defined_constants"), &mptr TSRMLS_CC);
|
662
664
|
if (!mptr) {
|
663
665
|
return Qfalse;
|
664
666
|
}
|
@@ -667,7 +669,10 @@ VALUE define_global_constants()
|
|
667
669
|
zval *z_val;
|
668
670
|
int result = call_php_method(NULL, NULL, mptr, 0, NULL, &z_val TSRMLS_CC);
|
669
671
|
if (result==FAILURE) {
|
670
|
-
g_exception
|
672
|
+
if (g_exception) {
|
673
|
+
zval_ptr_dtor(&g_exception);
|
674
|
+
g_exception = NULL;
|
675
|
+
}
|
671
676
|
return Qfalse;
|
672
677
|
}
|
673
678
|
|
@@ -703,6 +708,7 @@ VALUE define_global_constants()
|
|
703
708
|
|
704
709
|
zend_hash_move_forward_ex(ht, &pos);
|
705
710
|
}
|
711
|
+
zval_ptr_dtor(&z_val);
|
706
712
|
return Qtrue;
|
707
713
|
}
|
708
714
|
|
@@ -712,7 +718,7 @@ VALUE define_global_functions()
|
|
712
718
|
|
713
719
|
// method
|
714
720
|
zend_function *mptr;
|
715
|
-
find_zend_function(NULL, "get_defined_functions", strlen("get_defined_functions"), &mptr);
|
721
|
+
find_zend_function(NULL, "get_defined_functions", strlen("get_defined_functions"), &mptr TSRMLS_CC);
|
716
722
|
if (!mptr) {
|
717
723
|
return Qfalse;
|
718
724
|
}
|
@@ -721,7 +727,10 @@ VALUE define_global_functions()
|
|
721
727
|
zval *z_val;
|
722
728
|
int result = call_php_method(NULL, NULL, mptr, 0, NULL, &z_val TSRMLS_CC);
|
723
729
|
if (result==FAILURE) {
|
724
|
-
g_exception
|
730
|
+
if (g_exception) {
|
731
|
+
zval_ptr_dtor(&g_exception);
|
732
|
+
g_exception = NULL;
|
733
|
+
}
|
725
734
|
return Qfalse;
|
726
735
|
}
|
727
736
|
|
@@ -743,6 +752,7 @@ VALUE define_global_functions()
|
|
743
752
|
|
744
753
|
zend_hash_move_forward_ex(ht, &pos);
|
745
754
|
}
|
755
|
+
zval_ptr_dtor(&z_val);
|
746
756
|
return Qtrue;
|
747
757
|
}
|
748
758
|
|
@@ -752,7 +762,7 @@ VALUE define_global_classes()
|
|
752
762
|
|
753
763
|
// method
|
754
764
|
zend_function *mptr;
|
755
|
-
find_zend_function(NULL, "get_declared_classes", strlen("get_declared_classes"), &mptr);
|
765
|
+
find_zend_function(NULL, "get_declared_classes", strlen("get_declared_classes"), &mptr TSRMLS_CC);
|
756
766
|
if (!mptr) {
|
757
767
|
return Qfalse;
|
758
768
|
}
|
@@ -761,7 +771,10 @@ VALUE define_global_classes()
|
|
761
771
|
zval *z_val;
|
762
772
|
int result = call_php_method(NULL, NULL, mptr, 0, NULL, &z_val TSRMLS_CC);
|
763
773
|
if (result==FAILURE) {
|
764
|
-
g_exception
|
774
|
+
if (g_exception) {
|
775
|
+
zval_ptr_dtor(&g_exception);
|
776
|
+
g_exception = NULL;
|
777
|
+
}
|
765
778
|
return Qfalse;
|
766
779
|
}
|
767
780
|
|
@@ -785,6 +798,7 @@ VALUE define_global_classes()
|
|
785
798
|
}
|
786
799
|
zend_hash_move_forward_ex(ht, &pos);
|
787
800
|
}
|
801
|
+
zval_ptr_dtor(&z_val);
|
788
802
|
return Qtrue;
|
789
803
|
}
|
790
804
|
|
@@ -813,7 +827,8 @@ VALUE rb_php_global_class_call(VALUE self)
|
|
813
827
|
|
814
828
|
static VALUE php_global_require_b_proc(RequireArgs *args)
|
815
829
|
{
|
816
|
-
|
830
|
+
TSRMLS_FETCH();
|
831
|
+
php_vm_require(args->token, args->filepath TSRMLS_CC);
|
817
832
|
return Qnil;
|
818
833
|
}
|
819
834
|
|
@@ -915,11 +930,13 @@ VALUE rb_php_class_get(VALUE cls, VALUE v_name)
|
|
915
930
|
|
916
931
|
VALUE rb_php_class_initialize(VALUE self, VALUE v_name)
|
917
932
|
{
|
933
|
+
TSRMLS_FETCH();
|
934
|
+
|
918
935
|
rb_iv_set(self, "name", v_name);
|
919
936
|
|
920
937
|
// find zend class
|
921
938
|
zend_class_entry **ce = NULL;
|
922
|
-
find_zend_class_entry(RSTRING_PTR(v_name), RSTRING_LEN(v_name), &ce);
|
939
|
+
find_zend_class_entry(RSTRING_PTR(v_name), RSTRING_LEN(v_name), &ce TSRMLS_CC);
|
923
940
|
|
924
941
|
// class not found
|
925
942
|
if (!ce) {
|
@@ -948,13 +965,15 @@ VALUE rb_php_class_name(VALUE self)
|
|
948
965
|
|
949
966
|
VALUE rb_php_class_new(int argc, VALUE *argv, VALUE self)
|
950
967
|
{
|
968
|
+
TSRMLS_FETCH();
|
969
|
+
|
951
970
|
VALUE args;
|
952
971
|
rb_scan_args(argc, argv, "*", &args);
|
953
972
|
|
954
973
|
// alloc
|
955
974
|
VALUE obj = Qnil;
|
956
975
|
zend_class_entry *ce = get_zend_class_entry(self);
|
957
|
-
if (is_exception_zend_class_entry(ce)) {
|
976
|
+
if (is_exception_zend_class_entry(ce TSRMLS_CC)) {
|
958
977
|
obj = rb_obj_alloc(rb_ePHPExceptionObject);
|
959
978
|
} else {
|
960
979
|
obj = rb_obj_alloc(rb_cPHPObject);
|
@@ -1010,6 +1029,8 @@ VALUE rb_php_class_call_method_missing(int argc, VALUE *argv, VALUE self)
|
|
1010
1029
|
|
1011
1030
|
VALUE rb_php_object_initialize(VALUE self, VALUE class, VALUE args)
|
1012
1031
|
{
|
1032
|
+
TSRMLS_FETCH();
|
1033
|
+
|
1013
1034
|
// set class
|
1014
1035
|
rb_iv_set(self, "php_class", class);
|
1015
1036
|
|
@@ -1017,7 +1038,7 @@ VALUE rb_php_object_initialize(VALUE self, VALUE class, VALUE args)
|
|
1017
1038
|
zend_class_entry *ce = get_zend_class_entry(class);
|
1018
1039
|
zval *z_obj;
|
1019
1040
|
ALLOC_INIT_ZVAL(z_obj);
|
1020
|
-
new_php_object(ce, args, z_obj);
|
1041
|
+
new_php_object(ce, args, z_obj TSRMLS_CC);
|
1021
1042
|
|
1022
1043
|
// set resource
|
1023
1044
|
PHPNativeResource *p = ALLOC(PHPNativeResource);
|
@@ -1080,6 +1101,13 @@ VALUE rb_php_object_call_magic_clone(VALUE self)
|
|
1080
1101
|
Z_SET_REFCOUNT_P(retval, 0);
|
1081
1102
|
Z_SET_ISREF_P(retval);
|
1082
1103
|
|
1104
|
+
if (g_exception) {
|
1105
|
+
VALUE exception = zval_to_value(g_exception);
|
1106
|
+
zval_ptr_dtor(&g_exception);
|
1107
|
+
g_exception = NULL;
|
1108
|
+
rb_exc_raise(exception);
|
1109
|
+
}
|
1110
|
+
|
1083
1111
|
return zval_to_value(retval);
|
1084
1112
|
}
|
1085
1113
|
|
@@ -1101,6 +1129,14 @@ VALUE rb_php_object_call_magic___get(VALUE self, VALUE name)
|
|
1101
1129
|
retval = handler(zobj, member, BP_VAR_IS, NULL TSRMLS_CC);
|
1102
1130
|
|
1103
1131
|
zval_ptr_dtor(&member);
|
1132
|
+
|
1133
|
+
if (g_exception) {
|
1134
|
+
VALUE exception = zval_to_value(g_exception);
|
1135
|
+
zval_ptr_dtor(&g_exception);
|
1136
|
+
g_exception = NULL;
|
1137
|
+
rb_exc_raise(exception);
|
1138
|
+
}
|
1139
|
+
|
1104
1140
|
return zval_to_value(retval);
|
1105
1141
|
}
|
1106
1142
|
|
@@ -1125,6 +1161,14 @@ VALUE rb_php_object_call_magic___set(VALUE self, VALUE name, VALUE arg)
|
|
1125
1161
|
|
1126
1162
|
zval_ptr_dtor(&member);
|
1127
1163
|
zval_ptr_dtor(&z_arg);
|
1164
|
+
|
1165
|
+
if (g_exception) {
|
1166
|
+
VALUE exception = zval_to_value(g_exception);
|
1167
|
+
zval_ptr_dtor(&g_exception);
|
1168
|
+
g_exception = NULL;
|
1169
|
+
rb_exc_raise(exception);
|
1170
|
+
}
|
1171
|
+
|
1128
1172
|
return Qnil;
|
1129
1173
|
}
|
1130
1174
|
|
@@ -1145,6 +1189,14 @@ VALUE rb_php_object_call_magic___unset(VALUE self, VALUE name)
|
|
1145
1189
|
handler(zobj, member, NULL TSRMLS_CC);
|
1146
1190
|
|
1147
1191
|
zval_ptr_dtor(&member);
|
1192
|
+
|
1193
|
+
if (g_exception) {
|
1194
|
+
VALUE exception = zval_to_value(g_exception);
|
1195
|
+
zval_ptr_dtor(&g_exception);
|
1196
|
+
g_exception = NULL;
|
1197
|
+
rb_exc_raise(exception);
|
1198
|
+
}
|
1199
|
+
|
1148
1200
|
return Qnil;
|
1149
1201
|
}
|
1150
1202
|
|
@@ -1166,6 +1218,14 @@ VALUE rb_php_object_call_magic___isset(VALUE self, VALUE name)
|
|
1166
1218
|
has = handler(zobj, member, 0, NULL TSRMLS_CC);
|
1167
1219
|
|
1168
1220
|
zval_ptr_dtor(&member);
|
1221
|
+
|
1222
|
+
if (g_exception) {
|
1223
|
+
VALUE exception = zval_to_value(g_exception);
|
1224
|
+
zval_ptr_dtor(&g_exception);
|
1225
|
+
g_exception = NULL;
|
1226
|
+
rb_exc_raise(exception);
|
1227
|
+
}
|
1228
|
+
|
1169
1229
|
return has ? Qtrue : Qfalse;
|
1170
1230
|
}
|
1171
1231
|
|
@@ -1291,15 +1351,6 @@ VALUE rb_php_error_reporting_line(VALUE self)
|
|
1291
1351
|
|
1292
1352
|
// module
|
1293
1353
|
|
1294
|
-
void php_vm_module_init()
|
1295
|
-
{
|
1296
|
-
TSRMLS_FETCH();
|
1297
|
-
int argc = 1;
|
1298
|
-
char *argv[2] = {"php_vm", NULL};
|
1299
|
-
php_embed_init(argc, argv PTSRMLS_CC);
|
1300
|
-
EG(bailout) = NULL;
|
1301
|
-
}
|
1302
|
-
|
1303
1354
|
void php_vm_module_exit()
|
1304
1355
|
{
|
1305
1356
|
TSRMLS_FETCH();
|
@@ -1308,13 +1359,24 @@ void php_vm_module_exit()
|
|
1308
1359
|
|
1309
1360
|
void Init_php_vm()
|
1310
1361
|
{
|
1311
|
-
|
1362
|
+
#ifdef ZTS
|
1363
|
+
void ***tsrm_ls;
|
1364
|
+
#endif
|
1365
|
+
|
1366
|
+
// set php_embed callback function
|
1312
1367
|
php_embed_module.ub_write = php_embed_output_handler;
|
1313
1368
|
php_embed_module.log_message = php_embed_error_handler;
|
1314
1369
|
|
1315
|
-
|
1370
|
+
// initialize php_embed
|
1371
|
+
int init_argc = 1;
|
1372
|
+
char *init_argv[2] = {"php_vm", NULL};
|
1373
|
+
php_embed_init(init_argc, init_argv PTSRMLS_CC);
|
1374
|
+
EG(bailout) = NULL;
|
1375
|
+
|
1376
|
+
// set exit php_vm callback function
|
1316
1377
|
atexit(php_vm_module_exit);
|
1317
1378
|
|
1379
|
+
// set php_embed hook function
|
1318
1380
|
zend_throw_exception_hook = php_vm_exception_hook;
|
1319
1381
|
|
1320
1382
|
// ini
|
@@ -1341,7 +1403,7 @@ void Init_php_vm()
|
|
1341
1403
|
rb_define_singleton_method(rb_mPHPVM, "get_class", rb_php_vm_get_class, 1);
|
1342
1404
|
rb_define_singleton_method(rb_mPHPVM, "define_global", rb_php_vm_define_global, 0);
|
1343
1405
|
|
1344
|
-
rb_define_const(rb_mPHPVM, "VERSION", rb_str_new2("1.3.
|
1406
|
+
rb_define_const(rb_mPHPVM, "VERSION", rb_str_new2("1.3.9"));
|
1345
1407
|
|
1346
1408
|
rb_cv_set(rb_mPHPVM, "@@output_handler", Qnil);
|
1347
1409
|
rb_cv_set(rb_mPHPVM, "@@error_handler", Qnil);
|
data/ext/php_vm/php_vm.h
CHANGED
@@ -27,12 +27,11 @@ typedef struct {
|
|
27
27
|
|
28
28
|
// PHP
|
29
29
|
extern void php_eval_string(char *code, int code_len TSRMLS_DC);
|
30
|
-
extern void find_zend_class_entry(char *name, int name_len, zend_class_entry ***ce);
|
30
|
+
extern void find_zend_class_entry(char *name, int name_len, zend_class_entry ***ce TSRMLS_DC);
|
31
31
|
extern int is_exception_zend_class_entry(zend_class_entry *ce TSRMLS_DC);
|
32
32
|
extern int is_exception_zval(zval *z TSRMLS_DC);
|
33
|
-
extern void find_zend_function(zend_class_entry *ce, char *name, int name_len, zend_function **mptr);
|
34
|
-
extern int
|
35
|
-
extern int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval);
|
33
|
+
extern void find_zend_function(zend_class_entry *ce, char *name, int name_len, zend_function **mptr TSRMLS_DC);
|
34
|
+
extern int new_php_object(zend_class_entry *ce, VALUE v_args, zval *retval TSRMLS_DC);
|
36
35
|
extern void define_php_properties(VALUE v_obj, zend_class_entry *ce, int is_static);
|
37
36
|
extern void define_php_methods(VALUE v_obj, zend_class_entry *ce, int is_static);
|
38
37
|
extern void define_php_magic_method(VALUE v_obj, zend_class_entry *ce, zval *zobj);
|
@@ -54,7 +53,7 @@ extern VALUE rb_php_vm_get_output_handler(VALUE cls);
|
|
54
53
|
extern VALUE rb_php_vm_set_output_handler(VALUE cls, VALUE proc);
|
55
54
|
extern VALUE rb_php_vm_get_error_handler(VALUE cls);
|
56
55
|
extern VALUE rb_php_vm_set_error_handler(VALUE cls, VALUE proc);
|
57
|
-
extern void php_vm_require(char *token, VALUE filepath);
|
56
|
+
extern void php_vm_require(char *token, VALUE filepath TSRMLS_DC);
|
58
57
|
extern VALUE rb_php_vm_require(VALUE cls, VALUE filepath);
|
59
58
|
extern VALUE rb_php_vm_require_once(VALUE cls, VALUE filepath);
|
60
59
|
extern VALUE rb_php_vm_include(VALUE cls, VALUE filepath);
|
@@ -113,7 +112,6 @@ extern VALUE rb_php_error_reporting_file(VALUE self);
|
|
113
112
|
extern VALUE rb_php_error_reporting_line(VALUE self);
|
114
113
|
|
115
114
|
// module
|
116
|
-
extern void php_vm_module_init();
|
117
115
|
extern void php_vm_module_exit();
|
118
116
|
extern void Init_php_vm();
|
119
117
|
|
data/ext/php_vm/php_vm_z2v.c
CHANGED
@@ -91,7 +91,7 @@ static VALUE zval_to_value_object(zval *z)
|
|
91
91
|
|
92
92
|
// object
|
93
93
|
VALUE obj = Qnil;
|
94
|
-
if (is_exception_zval(z)) {
|
94
|
+
if (is_exception_zval(z TSRMLS_CC)) {
|
95
95
|
// exception object
|
96
96
|
zval *z_message = zend_read_property(zend_exception_get_default(TSRMLS_C), z, "message", sizeof("message")-1, 0 TSRMLS_CC);
|
97
97
|
obj = rb_exc_new2(rb_ePHPExceptionObject, Z_STRVAL_P(z_message));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: php_vm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: php_vm is a native bridge between Ruby and PHP.
|
15
15
|
email:
|