PageRenderTime 21ms CodeModel.GetById 19ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/tcl/tclstrings.swg

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