Hi,

        Sorry for the slow response.  You have quite a few good questions
here...


Konstantina Panagiotopoulou <kwno...@hotmail.com> wrote on 04/01/2014
05:51:58 AM:
>
> I have a first version of the binding (constructors, arithmetic
> functions etc..)
>  but I am trying to pass the mpz_class types as args to/return from
functions
> From the compilation errors I see  calls to RTT and
> serializer,deserializer...
> but I am not sure how other types, like double or Int implement
> these (or what interfaces they implement) in order to be
> used as formal parameters.
> This came up as I was trying to make mpz_class implement the
> Reducible interface.
> Could you give a hint of the classes dependency tree to make it work
> as argument?

        To make a @NativeRep struct really "fit in" like the other core
numeric structs (Int, Double, Complex, etc), you unfortunately need to know
a bit about the implementation level object model and the conventions of
the generated code.   In general, if you look for files in
x10.runtime/src-cpp/x10aux and x10.runtime/src-cpp/x10/* that mention
x10_complex you should be able to find where you need to make extensions
(but pick up a fix I just committed first --- x10_complex needed to be
added to Arithmetic.cc/.h which I just did).

        The key files are:
                x10aux/basic_functions.h  (equals, toString, etc)
                x10aux/RTT.cc and RTT.h  (provide RuntimeType for the primitive
types)
                x10aux/serialization_buffer.h and deserialization_buffer.h
(provide functions to allow primitives to be copied between Places)

                x10/lang/IBox.c IBox.h  (support for boxing the primitives into
a heap allocated object)

        If you want your type to implement useful interfaces like Arithmetic
[T], then you need to provide some additional code.  For Arithmetic,
Ordered, Comparable, and Bitwise this is done by editing specialized
interface dispatch files (eg x10/lang/Arithmetic.h).  For other interfaces,
you'll need to provide more elaborate support.
        The way I usually do this is to write a normal (not @NativeRep
struct) that implements the set of interfaces I want, compile it with x10c+
+, then pull out the generated code for itables (interface tables) into
your implementation class.  This code is fairly stylized, so I usually find
it easier to get the X10 compiler to generate it for me, then update it as
needed.
        I'd probably leave this as a last step (get the basics working like
==, toString, and serialization/deserialization.  Then add additional
interfaces).

>
> Also, I am trying to implement a toString method. In
> basic_functions.h I see for example that complex.h file is
> imported and some functionality for complex is added.
> Will there be any effect if I just add some lines for mpz_class to
> this file (basic_functions.h) or do I have to rebuild?

You'll need to add the lines to this file.  It would be safest to rebuild
X10 after doing so, but sometimes it works without the rebuild (but a
rebuild should only be a few minutes).

>
> Also, is there any workaround to convert x10.lang.String to C++
> string&(not char* ).?
>

We haven't looked at using std::string.   Probably the simplest thing is to
go x10.lang.String ==> char* ==> std::string.

hope this helps.  Sorry again for being slow to answer.

--dave
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to