Hello,

I am a little confused about this while working on my extension. I've
compiled PHP with --enable-debug and this only produces a fatal error
when used with that flag, without debug it runs fine.

"Fatal error: Arginfo / zpp mismatch during call of
raylib\Vector3::__construct()"

Here is the c code snippet of my code that produces the error:

ZEND_BEGIN_ARG_INFO_EX(arginfo_vector3__construct, 0, 0, 0)
    ZEND_ARG_TYPE_MASK(0, x, IS_DOUBLE, "0")
    ZEND_ARG_TYPE_MASK(0, y, IS_DOUBLE, "0")
    ZEND_ARG_TYPE_MASK(0, z, IS_DOUBLE, "0")
ZEND_END_ARG_INFO()
PHP_METHOD(Vector3, __construct)
{
    double x;
    bool x_is_null = 1;

    double y;
    bool y_is_null = 1;

    double z;
    bool z_is_null = 1;

    ZEND_PARSE_PARAMETERS_START(0, 3)
        Z_PARAM_OPTIONAL
        Z_PARAM_DOUBLE_OR_NULL(x, x_is_null)
        Z_PARAM_DOUBLE_OR_NULL(y, y_is_null)
        Z_PARAM_DOUBLE_OR_NULL(z, z_is_null)
    ZEND_PARSE_PARAMETERS_END();

    php_raylib_vector3_object *intern = Z_VECTOR3_OBJ_P(ZEND_THIS);

    if (x_is_null) {
        x = 0.0f;
    }

    if (y_is_null) {
        y = 0.0f;
    }

    if (z_is_null) {
        z = 0.0f;
    }

    intern->vector3->data = (Vector3) {
        .x = (float) x,
        .y = (float) y,
        .z = (float) z
    };
}

Then the line of PHP code:
$position = new Vector3(4.0, 2.0, 4.0);

I am confused because these are all optional parameters, and it should
work? If I exclude the parameters in my PHP code it works fine.

If I swap the following:

ZEND_BEGIN_ARG_INFO_EX(arginfo_vector3__construct, 0, 0, 0)
    ZEND_ARG_TYPE_MASK(0, x, IS_DOUBLE, "0")
    ZEND_ARG_TYPE_MASK(0, y, IS_DOUBLE, "0")
    ZEND_ARG_TYPE_MASK(0, z, IS_DOUBLE, "0")
ZEND_END_ARG_INFO()

For the following:

ZEND_BEGIN_ARG_INFO_EX(arginfo_vector3__construct, 0, 0, 0)
    ZEND_ARG_INFO(0, x)
    ZEND_ARG_INFO(0, y)
    ZEND_ARG_INFO(0, z)
ZEND_END_ARG_INFO()

Then it works fine. Can I not use ZEND_ARG_TYPE_MASK in this context?
I only put the type mask with the default value so it works better
with PHP's built-in reflection, so is this not possible? I've seen
similar uses with Tidy and Soap extensions so I'm a little baffled on
why it's an issue here. I think the only difference is that where the
ARG_INFO is, is in the header files versus the C files of those
extensions.

Thanks,
Joseph Montanez

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to