Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1425)

Unified Diff: swig/Lib/cdata.i

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « swig/Lib/carrays.i ('k') | swig/Lib/cmalloc.i » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: swig/Lib/cdata.i
===================================================================
--- swig/Lib/cdata.i (revision 0)
+++ swig/Lib/cdata.i (revision 0)
@@ -0,0 +1,83 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cdata.i
+ *
+ * SWIG library file containing macros for manipulating raw C data as strings.
+ * ----------------------------------------------------------------------------- */
+
+%{
+typedef struct SWIGCDATA {
+ char *data;
+ int len;
+} SWIGCDATA;
+%}
+
+/* -----------------------------------------------------------------------------
+ * Typemaps for returning binary data
+ * ----------------------------------------------------------------------------- */
+
+#if SWIGGUILE
+%typemap(out) SWIGCDATA {
+ $result = gh_str2scm($1.data,$1.len);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#elif SWIGCHICKEN
+%typemap(out) SWIGCDATA {
+ C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len));
+ $result = C_string(&string_space, $1.len, $1.data);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#elif SWIGPHP
+%typemap(out) SWIGCDATA {
+ ZVAL_STRINGL($result, $1.data, $1.len, 1);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#else
+%echo "cdata.i module not supported."
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * %cdata(TYPE [, NAME])
+ *
+ * Convert raw C data to a binary string.
+ * ----------------------------------------------------------------------------- */
+
+%define %cdata(TYPE,NAME...)
+
+%insert("header") {
+#if #NAME == ""
+static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) {
+#else
+static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) {
+#endif
+ SWIGCDATA d;
+ d.data = (char *) ptr;
+#if #TYPE != "void"
+ d.len = nelements*sizeof(TYPE);
+#else
+ d.len = nelements;
+#endif
+ return d;
+}
+}
+
+%typemap(default) int nelements "$1 = 1;"
+
+#if #NAME == ""
+SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements);
+#else
+SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
+#endif
+%enddef
+
+%typemap(default) int nelements;
+
+%rename(cdata) ::cdata_void(void *ptr, int nelements);
+
+%cdata(void);
+
+/* Memory move function */
+void memmove(void *data, const void *indata, int inlen);
« no previous file with comments | « swig/Lib/carrays.i ('k') | swig/Lib/cmalloc.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698