PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Lib/d/dmemberfunctionpointers.swg

#
Unknown | 92 lines | 79 code | 13 blank | 0 comment | 0 complexity | cada307775cbaa8289b251d1599936c2 MD5 | raw file
 1/* -----------------------------------------------------------------------------
 2 * dmemberfunctionpointers.swg
 3 *
 4 * Typemaps for member function pointers.
 5 * ----------------------------------------------------------------------------- */
 6
 7
 8%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
 9%typemap(imtype) SWIGTYPE (CLASS::*) "char*"
10%typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname"
11
12%typecheck(SWIG_TYPECHECK_POINTER)
13  SWIGTYPE (CLASS::*)
14  ""
15
16
17/*
18 * Conversion generation typemaps.
19 */
20
21%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
22  SWIG_UnpackData($input, (void *)&$1, sizeof($1));
23%}
24%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
25  char buf[128];
26  char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
27  *data = '\0';
28  $result = SWIG_d_string_callback(buf);
29%}
30
31%typemap(directorin) SWIGTYPE (CLASS::*) "$input = (void *) $1;"
32%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
33  "$result = ($1_ltype)$input;"
34
35%typemap(ddirectorin) SWIGTYPE (CLASS::*)
36  "($winput is null) ? null : new $dclassname($winput, false)"
37%typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)"
38
39%typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)"
40%typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
41  char* cMemberPtr = $imcall;
42  $dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode
43  return ret;
44}
45
46
47/*
48 * Helper functions to pack/unpack arbitrary binary data (member function
49 * pointers in this case) into a string.
50 */
51
52%fragment("SWIG_PackData", "header") {
53/* Pack binary data into a string */
54SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
55  static const char hex[17] = "0123456789abcdef";
56  register const unsigned char *u = (unsigned char *) ptr;
57  register const unsigned char *eu =  u + sz;
58  for (; u != eu; ++u) {
59    register unsigned char uu = *u;
60    *(c++) = hex[(uu & 0xf0) >> 4];
61    *(c++) = hex[uu & 0xf];
62  }
63  return c;
64}
65}
66
67%fragment("SWIG_UnPackData", "header") {
68/* Unpack binary data from a string */
69SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
70  register unsigned char *u = (unsigned char *) ptr;
71  register const unsigned char *eu = u + sz;
72  for (; u != eu; ++u) {
73    register char d = *(c++);
74    register unsigned char uu;
75    if ((d >= '0') && (d <= '9'))
76      uu = ((d - '0') << 4);
77    else if ((d >= 'a') && (d <= 'f'))
78      uu = ((d - ('a'-10)) << 4);
79    else
80      return (char *) 0;
81    d = *(c++);
82    if ((d >= '0') && (d <= '9'))
83      uu |= (d - '0');
84    else if ((d >= 'a') && (d <= 'f'))
85      uu |= (d - ('a'-10));
86    else
87      return (char *) 0;
88    *u = uu;
89  }
90  return c;
91}
92}