Archived

This forum has been archived. Please start a new discussion on GitHub.

about icephp

error log in apache with icephp.

my ice slice:
module test1{
module test2{
module test3{
struct st1
{
long n0;
long n1;
};

dictionary<st1,long> dict1;
}
}
}



php -r "ice_loadprofile();ice_dumpprofile();"
PHP Warning: PHP Startup: skipping dictionary ::test1::test2::test3::dict1- unsupported key type in Unknown on line 0
(and if i want to use "st1", i should write "test1_test2_test3_st1". am i right?)


so i want to know if icephp support this kind of dictionary definition.

and another question is about "long" (64bits)type in icephp. what i should do if i want to use "long"(using string type in my php code?)

Comments

  • mes
    mes California
    fanson wrote: »
    so i want to know if icephp support this kind of dictionary definition.
    No, you can't use a structure as a dictionary key in IcePHP. Here's a quote from the Ice manual:

    Slice dictionaries map to native PHP associative arrays. The PHP mapping does not currently support all Slice dictionary types, however, because native PHP associative arrays support only integer and string key types.

    We may add a solution for this limitation in some future release, but so far there has been no demand for it.
    and another question is about "long" (64bits)type in icephp. what i should do if i want to use "long"(using string type in my php code?)
    If a value exceeds the range of PHP's native integer type, you will have to pass it as a string to Ice. The Ice run time will convert it to a 64-bit integer when the value goes "over the wire". Likewise, if an Ice invocation returns a 64-bit integer that cannot be represented by a PHP integer, your script will receive it as a string.

    Hope that helps,
    - Mark
  • thanks.

    another question about long in IcePHP

    if i want to receive user input "long" type (exceeds the range of PHP's native integer type) as a parameter of some ICE function, what should i do?

    i have to use a string type in php to receive the user input. then, i get a proxy,and pass the string to the function like this, prx->myfunc(userstring).

    but in the slice file, the definition of myfunc is like this, ... myfunc (Ice::Long)...

    so apache server (with IcePHP) will raise error like this,"PHP Fatal error ... invalid long value..."

    i am confused.
  • and what about if myfunc(...) need a parameter like a struct st1.

    struct st1
    {
    long n0;
    long n1;
    };

    how do i initialize st1 and pass st1 as a parameter of prx->myfunc(...)
  • mes
    mes California
    Hi,
    fanson wrote: »
    the definition of myfunc is like this, ... myfunc (Ice::Long)...

    so apache server (with IcePHP) will raise error like this,"PHP Fatal error ... invalid long value..."
    You can pass a string whenever the Slice type long is expected. The IcePHP test suite exercises this capability, so it is known to work. If you obtain a value from user input, you should verify that it is a valid integer value before using it in an Ice invocation.
    and what about if myfunc(...) need a parameter like a struct st1.

    struct st1
    {
    long n0;
    long n1;
    };

    how do i initialize st1 and pass st1 as a parameter of prx->myfunc(...)
    As described in the IcePHP chapter of the manual, a Slice structure is mapped to a PHP class:
    $mystruct = new mymodule_st1;
    $mystruct->n0 = ...
    $mystruct->n1 = ...
    $prx->myfunc($mystruct);
    
    Take care,
    - Mark
  • i do as you suggest in my code like this:

    slice definition
    module mymodule
    {
        struct st
        {
            long n0;
            long n1;
        }
    
        struct st1
        {
            int key;
            struct st myst;
        }
    }
    

    my PHP program
    ...
    function getValue(...)
    {
        $mystruct = new mymodule_st1;
        $mystruct->key = 1;
        // n0,n1 just give some example values here for demonstration....
        $mystruct->myst->n0 = gmp_strval(gmp_init("0xEFCDAB8967452301"));
        $mystruct->myst->n1 = gmp_strval(gmp_init("0xEFCDAB8967452301"));
        return mymodule_st1;
    }
    ...
    
    $val = getValue(...);
    $prx->myfunc($val);
    
    

    when i use var_dump to see the variable mymodule_st1 in getValue().
    object(mymodule_st1)#2 (2) { ["key"]=> int(1) ["myst"]=> object(mymodule_st)#4 (2) { ["n0"]=> string(20) "17279655951921914625" ["n1"]=> string(20) "17279655951921914625" } }
    

    it seems ok after
    $val = getValue(...);
    

    but when it comes to the next line of code , some error occurs
    PHP Fatal error:  Ice_ObjectPrx::myfunc() [<a href='function.Ice-ObjectPrx-myfunc'>function.Ice-ObjectPrx-myfunc</a>]: invalid long value `17279655951921914625' in /home/apache/test.php on line 91, referer: http://192.168.1.1/test.php
    
  • mes
    mes California
    The maximum value of a 64-bit signed integer is 9,223,372,036,854,775,807, and your program is attempting to use 17,279,655,951,921,914,625.

    Take care,
    - Mark
  • thanks, it works.

    but complement should be used to present a 64-bits long long (signed) in my testcase.( CentOS .6.9-55.3.ELsmp x86_64+ apache2.0.52 + php 5.1.4)