@@ -747,6 +747,21 @@ static int tpp_setuseffi(CPPOverload*, PyObject*, void*)
747747 return 0 ; // dummy (__useffi__ unused)
748748}
749749
750+ // -----------------------------------------------------------------------------
751+ static PyObject* tpp_gettemplateargs (TemplateProxy* self, void *) {
752+ if (!self->fTemplateArgs ) {
753+ Py_RETURN_NONE;
754+ }
755+
756+ Py_INCREF (self->fTemplateArgs );
757+ return self->fTemplateArgs ;
758+ }
759+
760+ // -----------------------------------------------------------------------------
761+ static int tpp_settemplateargs (TemplateProxy*, PyObject*, void *) {
762+ PyErr_SetString (PyExc_AttributeError, " __template_args__ is read-only" );
763+ return -1 ;
764+ }
750765
751766// ----------------------------------------------------------------------------
752767static PyMappingMethods tpp_as_mapping = {
@@ -757,7 +772,9 @@ static PyGetSetDef tpp_getset[] = {
757772 {(char *)" __doc__" , (getter)tpp_doc, (setter)tpp_doc_set, nullptr , nullptr },
758773 {(char *)" __useffi__" , (getter)tpp_getuseffi, (setter)tpp_setuseffi,
759774 (char *)" unused" , nullptr },
760- {(char *)nullptr , nullptr , nullptr , nullptr , nullptr }
775+ {(char *)" __template_args__" , (getter)tpp_gettemplateargs, (setter)tpp_settemplateargs,
776+ (char *)" the template arguments for this method" , nullptr },
777+ {(char *)nullptr , nullptr , nullptr , nullptr , nullptr },
761778};
762779
763780
@@ -788,6 +805,7 @@ static PyObject* tpp_overload(TemplateProxy* pytmpl, PyObject* args)
788805{
789806// Select and call a specific C++ overload, based on its signature.
790807 const char * sigarg = nullptr ;
808+ const char * tmplarg = nullptr ;
791809 PyObject* sigarg_tuple = nullptr ;
792810 int want_const = -1 ;
793811
@@ -818,6 +836,11 @@ static PyObject* tpp_overload(TemplateProxy* pytmpl, PyObject* args)
818836 scope = ((CPPClass*)pytmpl->fTI ->fPyClass )->fCppType ;
819837 cppmeth = Cppyy::GetMethodTemplate (
820838 scope, pytmpl->fTI ->fCppName , proto.substr (1 , proto.size ()-2 ));
839+ } else if (PyArg_ParseTuple (args, const_cast <char *>(" ss:__overload__" ), &sigarg, &tmplarg)) {
840+ scope = ((CPPClass*)pytmpl->fTI ->fPyClass )->fCppType ;
841+ std::string full_name = std::string (pytmpl->fTI ->fCppName ) + " <" + tmplarg + " >" ;
842+
843+ cppmeth = Cppyy::GetMethodTemplate (scope, full_name, sigarg);
821844 } else if (PyArg_ParseTuple (args, const_cast <char *>(" O|i:__overload__" ), &sigarg_tuple, &want_const)) {
822845 PyErr_Clear ();
823846 want_const = PyTuple_GET_SIZE (args) == 1 ? -1 : want_const;
0 commit comments