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.

31 lines
793 B

  1. /* ------------------------------------------------------------
  2. * utility methods for char strings
  3. * ------------------------------------------------------------ */
  4. %fragment("SWIG_AsCharPtrAndSize","header") {
  5. SWIGINTERN int
  6. SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc)
  7. {
  8. int len = 0;
  9. char *cstr = Tcl_GetStringFromObj(obj, &len);
  10. if (cstr) {
  11. if (cptr) *cptr = cstr;
  12. if (psize) *psize = len + 1;
  13. if (alloc) *alloc = SWIG_OLDOBJ;
  14. return SWIG_OK;
  15. }
  16. return SWIG_TypeError;
  17. }
  18. }
  19. %fragment("SWIG_FromCharPtrAndSize","header",
  20. fragment="<limits.h>") {
  21. SWIGINTERNINLINE Tcl_Obj *
  22. SWIG_FromCharPtrAndSize(const char* carray, size_t size)
  23. {
  24. return (size < INT_MAX) ? Tcl_NewStringObj(carray, %numeric_cast(size,int)) : NULL;
  25. }
  26. }