Merge pull request #21553 from VadimLevin:dev/vlevin/scope-for-classes-4x-port

4.x: submodule or a class scope for exported classes

* feature: submodule or a class scope for exported classes

All classes are registered in the scope that corresponds to C++
namespace or exported class.

Example:
`cv::ml::Boost` is exported as `cv.ml.Boost`
`cv::SimpleBlobDetector::Params` is exported as
`cv.SimpleBlobDetector.Params`

For backward compatibility all classes are registered in the global
module with their mangling name containing scope information.
Example:
`cv::ml::Boost` has `cv.ml_Boost` alias to `cv.ml.Boost` type

* refactor: remove redundant GAPI aliases

* fix: use explicit string literals in CVPY_TYPE macro

* fix: add handling for class aliases
This commit is contained in:
Vadim Levin
2022-02-25 01:17:43 +03:00
committed by GitHub
parent cd9edba26f
commit 119d8b3aca
6 changed files with 466 additions and 107 deletions
@@ -223,6 +223,53 @@ namespace nested {
CV_WRAP static inline bool testEchoBooleanFunction(bool flag) {
return flag;
}
class CV_EXPORTS_W CV_WRAP_AS(ExportClassName) OriginalClassName
{
public:
struct CV_EXPORTS_W_SIMPLE Params
{
CV_PROP_RW int int_value;
CV_PROP_RW float float_value;
CV_WRAP explicit Params(int int_param = 123, float float_param = 3.5f)
{
int_value = int_param;
float_value = float_param;
}
};
explicit OriginalClassName(const OriginalClassName::Params& params = OriginalClassName::Params())
{
params_ = params;
}
CV_WRAP int getIntParam() const
{
return params_.int_value;
}
CV_WRAP float getFloatParam() const
{
return params_.float_value;
}
CV_WRAP static std::string originalName()
{
return "OriginalClassName";
}
CV_WRAP static Ptr<OriginalClassName>
create(const OriginalClassName::Params& params = OriginalClassName::Params())
{
return makePtr<OriginalClassName>(params);
}
private:
OriginalClassName::Params params_;
};
typedef OriginalClassName::Params OriginalClassName_Params;
} // namespace nested
namespace fs {