Hi Andi,

Many many thanks for your answer, using the u'A' worked perfectly! I wouldn't 
have figured that out myself.

Big thanks.

Regards
/Petrus






On Jan 28, 2012, at 11:05 PM, Andi Vajda wrote:

> 
> Hi Petrus,
> 
> On Sat, 28 Jan 2012, Petrus Hyvönen wrote:
> 
>> Thanks for the prompt reply,
>> 
>> Yes, no difference, it treats it as an int in that case.
>> 
>> "InvalidArgsError: (<type 'TLE'>, '__init__', (5555, 65, 2000, 1, 'A', 0, 
>> 1,..."
>> 
>> In the error message, it seems like int,float,string are printed
>> without a type but others are printed with a <type>?
> 
> According to the source code of _parseArgs in functions.cpp, a char must be 
> passed with one-character unicode string:
> 
>          case 'C':           /* char */
>          {
>              if (array)
>              {
>                  if (arg == Py_None)
>                      break;
>                  if (PyObject_TypeCheck(arg, PY_TYPE(JArrayChar)))
>                      break;
>              }
>              else if (PyUnicode_Check(arg) && PyUnicode_GET_SIZE(arg) == 1)
>                  break;
>              return -1;
>          }
> 
> Please, try passing u'A' instead of just 'A' to see if that works.
> 
> I can't think of a reason right now why this was written that way but it was 
> intentional as the part that extracts the character also expects a 
> one-character unicode string and has no code to support a plain string.
> 
> The reasoning was probably that a jchar is a unicode character and thus a 
> unicode string must be required but I don't see why it couldn't be extended 
> to supporting also a one-character byte string (a plain str in python 2.x).
> 
> Andi..
> 
> 
>> 
>> Regards
>> /Petrus
>> 
>> 
>> On Sat, Jan 28, 2012 at 6:26 PM, Andi Vajda <va...@apache.org> wrote:
>>> 
>>> On Jan 28, 2012, at 9:15, Petrus Hyvönen <petrus.hyvo...@gmail.com> wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> I have a problem which I think is due to typecasting,
>>>> 
>>>> I have wrapped a function that has following input types:
>>>> 
>>>> TLE(jint, jchar, jint, jint, const ::java::lang::String &, jint, jint,
>>>> const ::org::orekit::time::AbsoluteDate &, jdouble, jdouble, jdouble,
>>>> jdouble, jdouble, jdouble, jdouble, jdouble, jint, jdouble);
>>>> 
>>>> I have been trying all kind of stuff to call it from python, but get
>>>> 
>>>> InvalidArgsError: (<type 'TLE'>, '__init__', (5555, JArray<char>u'U',
>>>> 2000, 1, 'A', 0, 1, <AbsoluteDate: 2012-01-26T11:00:00.000>,
>>>> 0.0011421088155377755, 1.5670255537196003e-12, 0.0, 0.0,
>>>> 0.7059490305174144, 5.583519461969352, 4.184206970170655,
>>>> 0.7002697291314248, 0, 0.0007279))
>>>> 
>>>> (in different kind of fashion depending on how far my tests has gone)
>>>> 
>>>> My feeling now is that there is something with the input type jchar
>>>> and java String. Both are actually single characters that I want to
>>>> send, but in python I use (as a start) 'A' syntax for both. Do I need
>>>> to typecast it to a jchar? I tried in the example above to cast it
>>>> using JArray_char but no success.
>>>> 
>>>> How does JCC differ between when i want to send 'A' as a char and as a
>>>> string? or does it try it as both?
>>> 
>>> Have you tried sending 'A' as 65, its ascii code ? ord('A').
>>> 
>>> Andi..
>>> 
>>>> 
>>>> Many thanks for any comment,
>>>> Best regards
>>>> /Petrus
>> 
>> 
>> 
>> -- 
>> _____________________________________________
>> Petrus Hyvönen, Uppsala, Sweden
>> Mobile Phone/SMS:+46 73 803 19 00

_____________________________________________
Petrus Hyvönen, Space Engineer, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 1900



Reply via email to