Commit f004faff authored by T.J. Corona's avatar T.J. Corona

Update to the latest pybind11.

The most recent version of pybind11 does not explicitly include
FindPythonLibsNew.cmake, so that's nice.
parent 1f74d979
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::model::Operator > pybind11_init_smtk_model_AddAuxiliaryGeometry(py::module &m)
{
PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::model::Operator > instance(m, "AddAuxiliaryGeometry");
PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::model::Operator > instance(m, "AddAuxiliaryGeometry", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::AddAuxiliaryGeometry const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::CloseModel, smtk::model::Operator > pybind11_init_smtk_model_CloseModel(py::module &m)
{
PySharedPtrClass< smtk::model::CloseModel, smtk::model::Operator > instance(m, "CloseModel");
PySharedPtrClass< smtk::model::CloseModel, smtk::model::Operator > instance(m, "CloseModel", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::CloseModel const &>())
......
......@@ -24,7 +24,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > pybind11_init_smtk_model_DefaultSession(py::module &m)
{
PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > instance(m, "DefaultSession");
PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > instance(m, "DefaultSession", py::metaclass());
instance
.def(py::init<::smtk::model::DefaultSession const &>())
.def("deepcopy", (smtk::model::DefaultSession & (smtk::model::DefaultSession::*)(::smtk::model::DefaultSession const &)) &smtk::model::DefaultSession::operator=)
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::DeleteMesh, smtk::model::Operator > pybind11_init_smtk_model_DeleteMesh(py::module &m)
{
PySharedPtrClass< smtk::model::DeleteMesh, smtk::model::Operator > instance(m, "DeleteMesh");
PySharedPtrClass< smtk::model::DeleteMesh, smtk::model::Operator > instance(m, "DeleteMesh", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::DeleteMesh const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::ExportMesh, smtk::model::Operator > pybind11_init_smtk_model_ExportMesh(py::module &m)
{
PySharedPtrClass< smtk::model::ExportMesh, smtk::model::Operator > instance(m, "ExportMesh");
PySharedPtrClass< smtk::model::ExportMesh, smtk::model::Operator > instance(m, "ExportMesh", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::ExportMesh const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::ExportModelJSON, smtk::model::Operator > pybind11_init_smtk_model_ExportModelJSON(py::module &m)
{
PySharedPtrClass< smtk::model::ExportModelJSON, smtk::model::Operator > instance(m, "ExportModelJSON");
PySharedPtrClass< smtk::model::ExportModelJSON, smtk::model::Operator > instance(m, "ExportModelJSON", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::ExportModelJSON const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::ExportSMTKModel, smtk::model::Operator > pybind11_init_smtk_model_ExportSMTKModel(py::module &m)
{
PySharedPtrClass< smtk::model::ExportSMTKModel, smtk::model::Operator > instance(m, "ExportSMTKModel");
PySharedPtrClass< smtk::model::ExportSMTKModel, smtk::model::Operator > instance(m, "ExportSMTKModel", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::ExportSMTKModel const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::ImportSMTKModel, smtk::model::Operator > pybind11_init_smtk_model_ImportSMTKModel(py::module &m)
{
PySharedPtrClass< smtk::model::ImportSMTKModel, smtk::model::Operator > instance(m, "ImportSMTKModel");
PySharedPtrClass< smtk::model::ImportSMTKModel, smtk::model::Operator > instance(m, "ImportSMTKModel", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::ImportSMTKModel const &>())
......
......@@ -13,6 +13,8 @@
#include <pybind11/pybind11.h>
#include <type_traits>
#include "smtk/model/Operator.h"
#include "smtk/attribute/Attribute.h"
......@@ -50,6 +52,8 @@ void pybind11_init_smtk_model_OperatorOutcome(py::module &m)
PySharedPtrClass< smtk::model::Operator > pybind11_init_smtk_model_Operator(py::module &m)
{
typedef std::underlying_type<::smtk::attribute::SearchStyle>::type SearchStyleType;
PySharedPtrClass< smtk::model::Operator > instance(m, "Operator");
instance
.def("__lt__", (bool (smtk::model::Operator::*)(::smtk::model::Operator const &) const) &smtk::model::Operator::operator<)
......@@ -63,17 +67,28 @@ PySharedPtrClass< smtk::model::Operator > pybind11_init_smtk_model_Operator(py::
.def("disassociateEntity", &smtk::model::Operator::disassociateEntity, py::arg("entity"))
.def("ensureSpecification", &smtk::model::Operator::ensureSpecification)
.def("eraseResult", &smtk::model::Operator::eraseResult, py::arg("res"))
.def("findDirectory", &smtk::model::Operator::findDirectory, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findDouble", &smtk::model::Operator::findDouble, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findFile", &smtk::model::Operator::findFile, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findGroup", &smtk::model::Operator::findGroup, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findInt", &smtk::model::Operator::findInt, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findMesh", &smtk::model::Operator::findMesh, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findMeshSelection", &smtk::model::Operator::findMeshSelection, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findModelEntity", &smtk::model::Operator::findModelEntity, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findRef", &smtk::model::Operator::findRef, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findString", &smtk::model::Operator::findString, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findVoid", &smtk::model::Operator::findVoid, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::ALL_CHILDREN)
.def("findDirectory", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findDirectory(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findDouble", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findDouble(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findFile", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findFile(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findGroup", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findGroup(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findInt", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findInt(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findMesh", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findMesh(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findMeshSelection", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findMeshSelection(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findModelEntity", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findModelEntity(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findRef", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findRef(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findString", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findString(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("findVoid", [](smtk::model::Operator& o, const std::string& s, SearchStyleType i) { return o.findVoid(s, ::smtk::attribute::SearchStyle(i)); },
py::arg("name"), py::arg("style") = static_cast<SearchStyleType>(::smtk::attribute::SearchStyle::ALL_CHILDREN))
.def("log", &smtk::model::Operator::log)
.def("manager", &smtk::model::Operator::manager)
.def("meshManager", &smtk::model::Operator::meshManager)
......@@ -94,21 +109,21 @@ PySharedPtrClass< smtk::model::Operator > pybind11_init_smtk_model_Operator(py::
.def("unobserve", (void (smtk::model::Operator::*)(::smtk::model::OperatorEventType, ::smtk::model::BareOperatorCallback, void *)) &smtk::model::Operator::unobserve, py::arg("event"), py::arg("functionHandle"), py::arg("callData"))
.def("unobserve", (void (smtk::model::Operator::*)(::smtk::model::OperatorEventType, ::smtk::model::OperatorWithResultCallback, void *)) &smtk::model::Operator::unobserve, py::arg("event"), py::arg("functionHandle"), py::arg("callData"))
.def("findAsInt", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::IntItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::IntItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsDouble", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::DoubleItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::DoubleItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsString", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::StringItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::StringItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsFile", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::FileItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::FileItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsDirectory", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::DirectoryItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::DirectoryItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsGroup", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::GroupItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::GroupItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsRef", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::RefItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::RefItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
.def("findAsModelEntity", [](const smtk::model::Operator& o, const std::string& s) {
return o.specification()->findAs<smtk::attribute::ModelEntityItem>(s, smtk::attribute::ALL_CHILDREN); })
return o.specification()->findAs<smtk::attribute::ModelEntityItem>(s, smtk::attribute::SearchStyle::ALL_CHILDREN); })
;
py::enum_<smtk::model::Operator::ResultEntityOrigin>(instance, "ResultEntityOrigin")
.value("CREATED", smtk::model::Operator::ResultEntityOrigin::CREATED)
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::RemoteOperator, smtk::model::Operator > pybind11_init_smtk_model_RemoteOperator(py::module &m)
{
PySharedPtrClass< smtk::model::RemoteOperator, smtk::model::Operator > instance(m, "RemoteOperator");
PySharedPtrClass< smtk::model::RemoteOperator, smtk::model::Operator > instance(m, "RemoteOperator", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::RemoteOperator const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::SetProperty, smtk::model::Operator > pybind11_init_smtk_model_SetProperty(py::module &m)
{
PySharedPtrClass< smtk::model::SetProperty, smtk::model::Operator > instance(m, "SetProperty");
PySharedPtrClass< smtk::model::SetProperty, smtk::model::Operator > instance(m, "SetProperty", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::SetProperty const &>())
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
PySharedPtrClass< smtk::model::WriteMesh, smtk::model::Operator > pybind11_init_smtk_model_WriteMesh(py::module &m)
{
PySharedPtrClass< smtk::model::WriteMesh, smtk::model::Operator > instance(m, "WriteMesh");
PySharedPtrClass< smtk::model::WriteMesh, smtk::model::Operator > instance(m, "WriteMesh", py::metaclass());
instance
.def(py::init<>())
.def(py::init<::smtk::model::WriteMesh const &>())
......
......@@ -55,7 +55,7 @@ class TestExportImport(smtk.testing.TestCase):
ftmp = os.path.join(tempfile.mkdtemp(), 'test.json')
# Export to ftmp
exp = sess.op('export smtk model')
SetVectorValue(exp.findFile('filename', smtk.attribute.ACTIVE_CHILDREN), [ftmp,])
SetVectorValue(exp.findFile('filename', int(smtk.attribute.SearchStyle.ACTIVE_CHILDREN)), [ftmp,])
SetVectorValue(exp.specification().associations(), models)
result = exp.operate()
PrintResultLog(result)
......@@ -66,7 +66,7 @@ class TestExportImport(smtk.testing.TestCase):
SetActiveSession(se2)
# Import from ftmp
imp = se2.op('import smtk model')
SetVectorValue(imp.findFile('filename', smtk.attribute.ACTIVE_CHILDREN), [ftmp,])
SetVectorValue(imp.findFile('filename', int(smtk.attribute.ACTIVE_CHILDREN)), [ftmp,])
result = imp.operate()
PrintResultLog(result)
self.assertEqual(result.findInt('outcome').value(0), smtk.model.OPERATION_SUCCEEDED, 'Could not import model')
......
......@@ -298,7 +298,7 @@ def Delete(ents, **kwargs):
op = sess.op('delete')
SetVectorValue(op.specification().associations(), ents)
if 'delete_dependents' in kwargs and kwargs['delete_dependents']:
op.findVoid('delete dependents', smtk.attribute.ALL_CHILDREN).setIsEnabled()
op.findVoid('delete dependents', int(smtk.attribute.ALL_CHILDREN)).setIsEnabled()
res = op.operate()
SetLastResult(res)
PrintResultLog(res)
......@@ -310,7 +310,7 @@ def ImportSMTKModel(filename):
"""Import an SMTK model into the active session."""
sess = GetActiveSession()
op = sess.op('import smtk model')
fname = op.findFile('filename', smtk.attribute.ALL_CHILDREN)
fname = op.findFile('filename', int(smtk.attribute.ALL_CHILDREN))
fname.setValue(filename)
res = op.operate()
SetLastResult(res)
......@@ -391,7 +391,7 @@ def Subtract(workpiece, tool, **args):
# Convert tool to a list
if type(tool) != type([]):
tool = [tool,]
SetVectorValue(op.findModelEntity('tools',smtk.attribute.ALL_CHILDREN), tool)
SetVectorValue(op.findModelEntity('tools',int(smtk.attribute.ALL_CHILDREN)), tool)
res = op.operate()
SetLastResult(res)
......
Subproject commit 2b92a49115657712c7dd924248df2286e6143b8d
Subproject commit 05920e363edfd5d8dc6b4608820d749af5217b5f
......@@ -362,6 +362,24 @@ def parse_free_function(func, overloaded, stream):
stream("}")
return init_function_name
def has_static(class_):
for member in class_.public_members:
if member.parent.name != class_.name:
continue
if member.__class__.__name__ != "member_function_t":
continue
if member.has_static:
return True
for variable in class_.variables(allow_empty = True):
if variable.parent.name != class_.name:
continue
if variable.access_type == "public" \
and variable.type_qualifiers.has_static:
return True
return False
def parse_class(class_, stream, top_level = True):
"""
Write bindings for a class
......@@ -371,18 +389,24 @@ def parse_class(class_, stream, top_level = True):
init_function_name = "pybind11_init_" + mangled_name(class_)
metaclass = ""
if has_static(class_):
metaclass = ", py::metaclass()"
if top_level:
stream("%s %s(py::module &m)" % (bind_class_name(class_),
init_function_name))
init_function_name))
stream("{")
stream(" %s instance(m, \"%s\");" % \
stream(" %s instance(m, \"%s\"%s);" % \
(bind_class_name(class_),
class_.name.replace('<','_').replace('>','_').replace('::','_')))
class_.name.replace('<','_').replace('>','_').replace('::','_'),
metaclass))
stream(" instance")
else:
stream(" %s(instance, \"%s\")" % \
stream(" %s(instance, \"%s\"%s)" % \
(bind_class_name(class_),
class_.name.replace('<','_').replace('>','_').replace('::','_')))
class_.name.replace('<','_').replace('>','_').replace('::','_'),
metaclass))
if not class_.is_abstract:
for constructor in class_.constructors():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment