Class: PHPVM::PHPClass

Inherits:
Object
  • Object
show all
Defined in:
ext/php_vm/php_vm.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(v_name) ⇒ Object

class PHPVM::PHPClass



900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
# File 'ext/php_vm/php_vm.c', line 900

VALUE rb_php_class_get(VALUE cls, VALUE v_name)
{
	// find
	VALUE name_sym = rb_str_intern(v_name);
	VALUE classes = rb_cv_get(cls, "@@classes");
	VALUE class = rb_hash_lookup(classes, name_sym);

	if (class==Qnil) {
		// create
		class = rb_obj_alloc(rb_cPHPClass);
		rb_php_class_initialize(class, v_name);
		rb_hash_aset(classes, name_sym, class);
	}

	return class;
}

Instance Method Details

#nameObject



949
950
951
952
# File 'ext/php_vm/php_vm.c', line 949

VALUE rb_php_class_name(VALUE self)
{
	return rb_iv_get(self, "name");
}

#new(*args) ⇒ Object



954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
# File 'ext/php_vm/php_vm.c', line 954

VALUE rb_php_class_new(int argc, VALUE *argv, VALUE self)
{
	VALUE args;
	rb_scan_args(argc, argv, "*", &args);

	// alloc
	VALUE obj = Qnil;
	zend_class_entry *ce = get_zend_class_entry(self);
	if (is_exception_zend_class_entry(ce)) {
		obj = rb_obj_alloc(rb_ePHPExceptionObject);
	} else {
		obj = rb_obj_alloc(rb_cPHPObject);
	}
	rb_php_object_initialize(obj, self, args);

	// define php instance properties and methods
	define_php_properties(obj, ce, 0);
	define_php_methods(obj, ce, 0);
	define_php_magic_method(obj, ce, 0);

	return obj;
}