danlooo / dggrid-julia

Julia bindings for the DGGRID library
GNU Affero General Public License v3.0
1 stars 1 forks source link

Add constructor of class TransformParam #1

Open danlooo opened 1 year ago

danlooo commented 1 year ago

In order to call function doTransform, an object of type TransformParam must be created. This failes, because the constructor is missing and was not generated by wrapit:

julia> p = Main.DGGRID_jll.DgParamList()
Main.DGGRID_jll.DgParamListAllocated(Ptr{Nothing} @0x00000000029f20f0)

julia> Main.DGGRID_jll.TransformParam(p)
ERROR: MethodError: no constructors have been defined for Main.DGGRID_jll.TransformParam
Stacktrace:
 [1] top-level scope
   @ REPL[35]:1

❯ cat jlDGGRID.cxx | grep constructor
  t1.constructor<DgParamList &>();
  t3.constructor<DgParamList &>();
  t4.constructor<DgParamList &>();
  t5.constructor<DgParamList &>();
  t6.constructor<DgParamList &>();
  t2.constructor<>();
danlooo commented 1 year ago

Its there but called auto t6:

  DEBUG_MSG("Adding wrapper for void TransformParam::TransformParam(DgParamList &) (" __HERE__ ")");
  // defined in DGGRID/src/apps/dggrid/dggrid.h:336:7
  t6.constructor<DgParamList &>();

  // defined in DGGRID/src/apps/dggrid/dggrid.h:332:7
  auto t6 = types.add_type<TransformParam>("TransformParam", jlcxx::julia_base_type<MainParam>());
danlooo commented 1 year ago

This constructor works in Julia, because it does expect no argument:

julia> Main.DGGRID_jll.DgGridPList()
Main.DGGRID_jll.DgGridPListAllocated(Ptr{Nothing} @0x0000000003352770)

class DgGridPList : public DgParamList {

   public:

      DgGridPList (void);
danlooo commented 1 year ago

TransformParam is being constructed using an DgParamList

class TransformParam : public MainParam {

   public:

      TransformParam (DgParamList& plist);

TransformParam::TransformParam (DgParamList& plist)
      : MainParam(plist), inSeqNum (0), outSeqNum (false), inputDelimiter (' '),
        outputDelimiter (' '), nDensify (1)
danlooo commented 1 year ago

Adding DgLIntParam.h to input of the wrapit config returns in lots of ambigious binding definition. Maybe due to templates, see https://github.com/grasph/wrapit/issues/5. One can remove duplictaed lines in the generated cxx file resulting in another error:

/workspace/srcdir/dggrid-julia/src/jlDGGRID.cxx:23:42: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct jlcxx::SuperType’
   23 |   template<> struct SuperType<DgParameter> { typedef DgAssoc type; };
      |                                          ^
/workspace/srcdir/dggrid-julia/src/jlDGGRID.cxx:23:42: note:   expected a type, got ‘DgParameter’

Another way is to utilize a veto header for wrapit, e.g. with regex /DgDoubleParam/;. However, this regex will remove all bindings and not just duplicates.

danlooo commented 1 year ago

During `julia src/build_tarballs.jl --deploy="local" --debug``:

/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/jlcxx/module.hpp:123:16: error: call of overloaded ‘DgDoubleParam(const std::basic_string<char>&, long double&, long double&)’ is ambiguous
  123 |   T* cpp_obj = new T(std::forward<ArgsT>(args)...);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /workspace/srcdir/dggrid-julia/src/DGGRID/src/lib/dglib/lib/DgParamList.cpp:29,
                 from /workspace/srcdir/dggrid-julia/src/jlDGGRID.h:1,
                 from /workspace/srcdir/dggrid-julia/src/jlDGGRID.cxx:9:
/workspace/srcdir/dggrid-julia/src/DGGRID/src/lib/dglib/include/dglib/DgParamList.h:538:7: note: candidate: ‘DgDoubleParam::DgDoubleParam(const string&, const long double&, const long double&, const long double&, bool)’
  538 |       DgDoubleParam (const string& nameIn, const long double& valIn,
      |       ^~~~~~~~~~~~~
/workspace/srcdir/dggrid-julia/src/DGGRID/src/lib/dglib/include/dglib/DgParamList.h:534:7: note: candidate: ‘DgDoubleParam::DgDoubleParam(const string&, long double, long double)’
  534 |       DgDoubleParam (const string& nameIn, long double minIn = LDBL_MIN,
      |       ^~~~~~~~~~~~~
In file included from /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/jlcxx/jlcxx.hpp:15,
                 from /workspace/srcdir/dggrid-julia/src/jlDGGRID.cxx:5:
danlooo commented 1 year ago

Error of wrong type:

/workspace/srcdir/dggrid-julia/src/jlDGGRID.cxx:195:88: error: no match for ‘operator=’ (operand types are ‘std::vector<DgAssoc*>’ and ‘int’)

Wrapit assumed int but DgAssoc is an empty class:

DgAssoc::~DgAssoc (void)
{
   // does nothing

} // DgAssoc::~DgAssoc

See d3efbd17e5951519879e8aee3209063eaa79314e