Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating constructors for pure abstract classes #69

Open
peremato opened this issue Nov 19, 2024 · 0 comments
Open

Generating constructors for pure abstract classes #69

peremato opened this issue Nov 19, 2024 · 0 comments

Comments

@peremato
Copy link
Contributor

With the lastest version constructors for intermediate abstract classes are generated. This is the case for G4BooleanSolid producing the following error:

n file included from /Users/mato/Development/Geant4.jl/gen/cpp/JlG4BooleanSolid.cxx:2:
In file included from /Users/mato/Development/Geant4.jl/gen/cpp/Wrapper.h:1:
In file included from /Users/mato/.julia/artifacts/eac17dc5e9612fcf8fb333c55469ecca63cc7fc6/include/jlcxx/jlcxx.hpp:15:
/Users/mato/.julia/artifacts/eac17dc5e9612fcf8fb333c55469ecca63cc7fc6/include/jlcxx/module.hpp:124:20: error: allocating an object of abstract class type 'G4BooleanSolid'
  124 |   T* cpp_obj = new T(std::forward<ArgsT>(args)...);
      |                    ^
/Users/mato/.julia/artifacts/eac17dc5e9612fcf8fb333c55469ecca63cc7fc6/include/jlcxx/module.hpp:624:114: note: in instantiation of function template specialization 'jlcxx::create<G4BooleanSolid, true, const G4String &, G4VSolid *&, G4VSolid *&>' requested here
  624 |     FunctionWrapperBase &new_wrapper = bool(extraData.finalize) ? add_lambda("dummy", [](ArgsT... args) { return create<T, true>(args...); }, std::move(extraData)) : add_lambda("dummy", [](ArgsT... args) { return create<T, false>(args...); }, std::move(extraData));
      |                                                                                                                  ^
/Users/mato/.julia/artifacts/eac17dc5e9612fcf8fb333c55469ecca63cc7fc6/include/jlcxx/module.hpp:1101:16: note: in instantiation of function template specialization 'jlcxx::Module::constructor<G4BooleanSolid, const G4String &, G4VSolid *, G4VSolid *, jlcxx::finalize_policy>' requested here
 1101 |       m_module.constructor<T, ArgsT...>(m_dt, extra...);
      |                ^
/Users/mato/Development/Geant4.jl/gen/cpp/JlG4BooleanSolid.cxx:33:7: note: in instantiation of function template specialization 'jlcxx::TypeWrapper<G4BooleanSolid>::constructor<const G4String &, G4VSolid *, G4VSolid *, jlcxx::finalize_policy>' requested here
   33 |     t.constructor<const G4String &, G4VSolid *, G4VSolid *>(/*finalize=*/jlcxx::finalize_policy::yes);
      |       ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:106:20: note: unimplemented pure virtual method 'CalculateExtent' in 'G4BooleanSolid'
  106 |     virtual G4bool CalculateExtent(const EAxis pAxis,
      |                    ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:114:21: note: unimplemented pure virtual method 'Inside' in 'G4BooleanSolid'
  114 |     virtual EInside Inside(const G4ThreeVector& p) const = 0;
      |                     ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:119:27: note: unimplemented pure virtual method 'SurfaceNormal' in 'G4BooleanSolid'
  119 |     virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const = 0;
      |                           ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:123:22: note: unimplemented pure virtual method 'DistanceToIn' in 'G4BooleanSolid'
  123 |     virtual G4double DistanceToIn(const G4ThreeVector& p,
      |                      ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:131:22: note: unimplemented pure virtual method 'DistanceToIn' in 'G4BooleanSolid'
  131 |     virtual G4double DistanceToIn(const G4ThreeVector& p) const = 0;
      |                      ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:135:22: note: unimplemented pure virtual method 'DistanceToOut' in 'G4BooleanSolid'
  135 |     virtual G4double DistanceToOut(const G4ThreeVector& p,
      |                      ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:156:22: note: unimplemented pure virtual method 'DistanceToOut' in 'G4BooleanSolid'
  156 |     virtual G4double DistanceToOut(const G4ThreeVector& p) const = 0;
      |                      ^
/Users/mato/.julia/artifacts/04a1f392c53fa9913a6e32dc79e45dcf6f1dd250/include/Geant4/G4VSolid.hh:201:18: note: unimplemented pure virtual method 'DescribeYourselfTo' in 'G4BooleanSolid'
  201 |     virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const = 0;

This was not the case with previous versions of WrapIt. The following class hierarchy can be used as a test:

#include <string>

struct G4ThreeVector 
{
    G4ThreeVector(double x, double y, double z) : x(x), y(y), z(z) {}
    double x, y, z;
};

struct G4VSolid   // Pure abstract class 
{
    G4VSolid(const std::string& name) { fshapeName = name; }
    virtual ~G4VSolid() {}
    virtual bool Inside(const G4ThreeVector& p) const = 0;
    std::string fshapeName;
};

struct G4BooleanSolid : public G4VSolid // also abstract class because it does to implement Inside()
{
    G4BooleanSolid( const std::string& pName, G4VSolid* pSolidA , G4VSolid* pSolidB) : G4VSolid(pName), fSolidA(pSolidA), fSolidB(pSolidB) {}
    virtual ~G4BooleanSolid() {}
    G4VSolid* fSolidA;
    G4VSolid* fSolidB;
};

struct G4UnionSolid : public G4BooleanSolid // concrete class
{
    G4UnionSolid( const std::string& pName, G4VSolid* pSolidA, G4VSolid* pSolidB) : G4BooleanSolid(pName, pSolidA, pSolidB) {}
    virtual ~G4UnionSolid() {}
    bool Inside(const G4ThreeVector& p) const override { return fSolidA->Inside(p) || fSolidB->Inside(p);}
};

struct G4Box : public G4VSolid  // concrete class
{
    G4Box(const std::string& name, double x, double y, double z) : G4VSolid(name), fX(x), fY(y), fZ(z) {}
    virtual ~G4Box() {}
    bool Inside(const G4ThreeVector& p) const override { return p.x < fX && p.y < fY && p.z < fZ; }
    double fX, fY, fZ;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant