Ejemplo n.º 1
0
	
			#ifdef USE_WXPHP_DEBUG
			php_printf("Deleting object by calling destroy and delete\n");
			#endif
			
			custom_object->native_object->Destroy();
			delete custom_object->native_object;
<?php 
        } else {
            ?>
			#ifdef USE_WXPHP_DEBUG
			php_printf("Deleting pointer with delete\n");
			#endif
			
<?php 
            if (class_has_properties($class_name)) {
                ?>
			custom_object->native_object->UninitProperties();
<?php 
            }
            ?>
       
            delete custom_object->native_object;
<?php 
        }
        ?>
			
			custom_object->native_object = NULL;
		}
		
		#ifdef USE_WXPHP_DEBUG
Ejemplo n.º 2
0
/**
 * This function generates the code that ensures that the object
 * calling the function is casted to the appropiate type
 */
function class_method_return_call($class_name, $method_name, $parameters_string, $required_parameters, $standard_return_type, $method_return_type)
{
    global $defIni;
    $call_code = "";
    $first_call = true;
    $derivations = array();
    //Amount of indentation for inner elements
    $t = 4;
    //Skip derivations type checking if this class implements a constructor
    if (!isset($defIni[$class_name][$class_name]) || methods_compatible($class_name)) {
        $derivations = derivationsOfClass($class_name);
        //Since type checking code is generated add 1 indenting place
        $t += 1;
    }
    //Append this class to the parent_rsrc_type checking code
    $derivations[$class_name] = true;
    foreach ($derivations as $derivation_class_name => $dummy) {
        if ($derivation_class_name != $class_name) {
            //Skip methods that already have a seperate implementation
            if (isset($defIni[$derivation_class_name][$method_name])) {
                continue;
            }
            //Skip classes that dont inherit the method from this class but another base class
            if (!inherits_method_from_class($method_name, $class_name, $derivation_class_name)) {
                continue;
            }
        }
        //Skip derivations type checking code if this class implements a constructor
        if (!isset($defIni[$class_name][$class_name]) || methods_compatible($class_name)) {
            if ($first_call) {
                $call_code .= tabs(4) . "if(";
                $first_call = false;
            } else {
                $call_code .= tabs(4) . "else if(";
            }
            $call_code .= "current_object_type == PHP_" . strtoupper($derivation_class_name) . "_TYPE";
            $call_code .= ")\n";
            $call_code .= tabs(4) . "{\n";
        }
        $return_modifier = type_modifier($method_return_type);
        $return_type = str_replace(array("const ", "&", "*"), "", $method_return_type);
        switch ($standard_return_type) {
            case "bool":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "ZVAL_BOOL(return_value, *((({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string})));\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "ZVAL_BOOL(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "ZVAL_BOOL(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                }
                break;
            case "integer":
            case "class_enum":
            case "global_enum":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "ZVAL_LONG(return_value, *((({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string})));\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "ZVAL_LONG(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "ZVAL_LONG(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                }
                break;
            case "float":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "ZVAL_DOUBLE(return_value, *((({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string})));\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "ZVAL_DOUBLE(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "ZVAL_DOUBLE(return_value, (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}));\n";
                        break;
                }
                break;
            case "characters":
                switch ($return_modifier) {
                    case "const_pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (char*) (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "char value_to_return_temp{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = &value_to_return_temp{$required_parameters};\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "char value_to_return_temp{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = &value_to_return_temp{$required_parameters};\n";
                        break;
                }
                break;
            case "void":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "ZVAL_STRING(return_value, (char*) (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}), 1);\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "(({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                }
                break;
            case "date":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string})->GetTicks();\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}).GetTicks();\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string}).GetTicks();\n";
                        break;
                }
                break;
            case "string":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                }
                break;
            case "strings_array":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                    case "const_none":
                    case "none":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        break;
                }
                break;
            case "object":
                switch ($return_modifier) {
                    case "const_pointer":
                    case "pointer":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = ({$return_type}_php*) (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n\n";
                        break;
                    case "const_reference":
                    case "reference":
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = ({$return_type}_php*) &(({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n\n";
                        break;
                    case "const_none":
                    case "none":
                        $return_type = str_replace(array("const", " "), "", $method_return_type);
                        $call_code .= tabs($t) . "value_to_return{$required_parameters} = (({$derivation_class_name}_php*)native_object)->{$method_name}({$parameters_string});\n";
                        if (inherits_from_class("wxObject", $return_type)) {
                            $call_code .= tabs($t) . "((wxRefCounter *) value_to_return{$required_parameters}.GetRefData())->IncRef();\n";
                        }
                        $call_code .= tabs($t) . "void* ptr = safe_emalloc(1, sizeof({$return_type}_php), 0);\n";
                        $call_code .= tabs($t) . "memcpy(ptr, (void*) &value_to_return{$required_parameters}, sizeof({$return_type}));\n";
                        $call_code .= tabs($t) . "object_init_ex(return_value, php_{$return_type}_entry);\n";
                        $call_code .= tabs($t) . "(({$return_type}_php*)ptr)->phpObj = return_value;\n";
                        if (class_has_properties($return_type)) {
                            $call_code .= tabs($t) . "(({$return_type}_php*)ptr)->InitProperties();\n";
                        }
                        $call_code .= tabs($t) . "zo_{$return_type}* zo{$required_parameters} = (zo_{$return_type}*) zend_object_store_get_object(return_value TSRMLS_CC);\n";
                        $call_code .= tabs($t) . "zo{$required_parameters}->native_object = ({$return_type}_php*) ptr;\n";
                        break;
                }
                break;
        }
        //Skip derivations type checking code if this class implements a constructor
        if (!isset($defIni[$class_name][$class_name]) || methods_compatible($class_name)) {
            $call_code .= tabs(4) . "}\n";
        }
    }
    //Skip derivations type checking code if this class implements a constructor
    if (!isset($defIni[$class_name][$class_name]) || methods_compatible($class_name)) {
        $return_called_overload .= tabs(5) . "else{zend_error(E_ERROR, \"The object type that called the method '{$method_name}' couldn't be determined.\");}\n";
    }
    return $call_code;
}
Ejemplo n.º 3
0
?>
)
);

object_init_ex(return_value, php_<?php 
echo $overload_object->return_type->type;
?>
_ce);

((<?php 
echo $overload_object->return_type->type;
?>
_php*)ptr)->phpObj = return_value;

<?php 
if (class_has_properties($return_type)) {
    ?>
((<?php 
    echo $overload_object->return_type->type;
    ?>
_php*)ptr)->InitProperties();
<?php 
}
?>

php_<?php 
echo $overload_object->return_type->type;
?>
_zo* zo_<?php 
echo $overload;
?>