Hello,

  I am new to the Inline module, I read the perlxs*, perlguts, perlapi
man pages and the Inline and Inline:CPP doc.

  I realised, there is a problemm, when I declare an array in the class:

use Inline (CPP => Config, DISABLE => CLEAN_AFTER_BUILD);
use Inline CPP => <<'END';

class TCfgData {
  public:
        bool                     verbose;
        //double                   initial_vector[4];
        double                   kappa;
        TCfgData();
        bool Get();
};

TCfgData::TCfgData() : verbose(false) {  }

bool TCfgData::Get() { return verbose; }

END

$_ = TCfgData->new();
print "Get:", $_->Get() ? "Y" : "N", "\n";

    This example works good for me. But when I don't comment the
declaration fo initial_vector, the Inline:CPP generates an correct XS
file, it does not recognised the class and does not generate
PACKAGE=main::TCfgData line but only PACKAGE=main.
Why? Where is a problem?


    I would like to have an C++ class with all data I need to transfer
between Perl ans C++, containing array of doubles or more complicated
array of structs. On the pere side I plan an hash containing names of
the class members as keys and volues for its volues, where the volue for
the vector would be reference to an perl's array or the more complicated
case, array of structs would be reference to an array containing
unpacked volues of struct in an array.

    Then I should programm two C++ functions, one that gets an hash or
ref to an hash and sets the class members, and another for the reverse
transfer. Or I would prefer to it in a typemap, so I can then write
something like

        $_ = TSolver->new(%hash);
        %cfg = TSolver->GetCfg();

where TSolver constructor and method is declaread in the class TSolver
this way:

        class TSolver {
                TCfgData * Cfg;
                TSolver(TCfgData &C) { Cfg = &C; }
                TCfgData & GetCfg() { return C; }
        };
This is the main goal.

   Can you give me some points, how to realise this in a typemap? Do I
need to go form c++ & references to "real" pointers?

        Thanks
                                        Hans Ginzel
--
You can find a Vim desktop calendar here: http://www.moolenaar.net/
Happy Vimming in 2003!

Reply via email to