MCPcopy Create free account
hub / github.com/bab2min/tomotopy / init

Method init

src/python/handler/PyUtils.h:1842–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1840 }
1841
1842 static int init(Derived* self, PyObject* args, PyObject* kwargs)
1843 {
1844 return handleExc([&]() -> int
1845 {
1846 using InitArgs = typename Derived::_InitArgs;
1847 if constexpr (std::tuple_size_v<InitArgs> == 0)
1848 {
1849 if (args && PyTuple_Size(args) != 0)
1850 {
1851 throw TypeError{ "function takes " + std::to_string(std::tuple_size_v<InitArgs>) + " arguments (" + std::to_string(PyTuple_Size(args)) + " given)" };
1852 }
1853 }
1854
1855 if (std::tuple_size_v<InitArgs> != PyTuple_Size(args))
1856 {
1857 throw TypeError{ "function takes " + std::to_string(std::tuple_size_v<InitArgs>) + " arguments (" + std::to_string(PyTuple_Size(args)) + " given)" };
1858 }
1859 if (kwargs)
1860 {
1861 throw TypeError{ "function takes positional arguments only" };
1862 }
1863
1864 auto temp = self->ob_base;
1865 initFromPython<InitArgs>(self, args, std::make_index_sequence<std::tuple_size_v<InitArgs>>{});
1866 self->ob_base = temp;
1867 return 0;
1868 });
1869 }
1870
1871 friend class TypeWrapper<Derived>;
1872 };

Callers

nothing calls this directly

Calls 1

handleExcFunction · 0.85

Tested by

no test coverage detected