Module: PHPVM::PHPGlobal
- Defined in:
- ext/php_vm/php_vm.c
Class Method Summary collapse
- .array(*args) ⇒ Object
- .echo(*args) ⇒ Object
- .print(arg) ⇒ Object
- .require(filepath) ⇒ Object
- .require_once(filepath) ⇒ Object
Class Method Details
.array(*args) ⇒ Object
884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'ext/php_vm/php_vm.c', line 884
VALUE rb_php_global_array(int argc, VALUE *argv, VALUE cls)
{
VALUE result;
if (argc==1 && TYPE(argv[0])==T_HASH) {
// hash
result = argv[0];
} else {
// argv
rb_scan_args(argc, argv, "*", &result);
}
return result;
}
|
.echo(*args) ⇒ Object
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
# File 'ext/php_vm/php_vm.c', line 847
VALUE rb_php_global_echo(int argc, VALUE *argv, VALUE cls)
{
int i;
if (argc==0) {
VALUE exception = rb_exc_new2(rb_eArgError, "Too few arguments");
rb_exc_raise(exception);
}
// format
char *format = malloc(argc*2+1);
for (i=0; i<argc; i++) {
format[i*2] = '%';
format[i*2+1] = 's';
}
format[i*2] = '\0';
// argv
VALUE *argv2 = malloc(sizeof(VALUE)*(argc+1));
argv2[0] = rb_str_new2(format);
for (i=0; i<argc; i++) {
argv2[i+1] = argv[i];
}
call_php_method_name_bridge(NULL, NULL, rb_str_new2("printf"), argc+1, argv2);
// release
free(format);
free(argv2);
return Qnil;
}
|
.print(arg) ⇒ Object
879 880 881 882 |
# File 'ext/php_vm/php_vm.c', line 879
VALUE rb_php_global_print(VALUE cls, VALUE arg)
{
return rb_php_global_echo(1, &arg, cls);
}
|
.require(filepath) ⇒ Object
835 836 837 838 839 |
# File 'ext/php_vm/php_vm.c', line 835
VALUE rb_php_global_require(VALUE cls, VALUE filepath)
{
php_global_require("require", filepath);
return Qtrue;
}
|
.require_once(filepath) ⇒ Object
841 842 843 844 845 |
# File 'ext/php_vm/php_vm.c', line 841
VALUE rb_php_global_require_once(VALUE cls, VALUE filepath)
{
php_global_require("require_once", filepath);
return Qtrue;
}
|