Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. /* This file defines an internal function for processing default arguments
  2. with proxy classes.
  3. There seems to be no straightforward way to write proxy functions
  4. involving default arguments. For example :
  5. def foo(arg1,arg2,*args):
  6. proxyc.foo(arg1,arg2,args)
  7. This fails because args is now a tuple and SWIG doesn't know what to
  8. do with it.
  9. This file allows a different approach :
  10. def foo(arg1,arg2,*args):
  11. proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args)
  12. Basically, we form a new tuple from the object, call this special
  13. __call_defarg method and it passes control to the real wrapper function.
  14. An ugly hack, but it works.
  15. */
  16. SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
  17. PyObject *func;
  18. PyObject *parms;
  19. if (!PyArg_ParseTuple(args,"OO",&func,&parms))
  20. return NULL;
  21. if (!PyCallable_Check(func)) {
  22. SWIG_PYTHON_THREAD_BEGIN_BLOCK;
  23. PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!");
  24. SWIG_PYTHON_THREAD_END_BLOCK;
  25. return NULL;
  26. }
  27. return PyEval_CallObject(func,parms);
  28. }