Skip to content

Commit 7dc6b98

Browse files
committed
use definitions as-is in xlm-io.lua
1 parent f7c2465 commit 7dc6b98

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

xmlua/libxml2/tree.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ffi.cdef[[
44
typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
55
typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
66

7+
typedef struct _xmlOutputBuffer xmlOutputBuffer;
8+
typedef xmlOutputBuffer *xmlOutputBufferPtr;
9+
710
typedef struct _xmlParserInput xmlParserInput;
811
typedef xmlParserInput *xmlParserInputPtr;
912

@@ -96,6 +99,9 @@ struct _xmlBuffer {
9699
xmlChar *contentIO; /* in IO mode we may have a different base */
97100
};
98101

102+
typedef struct _xmlBuf xmlBuf;
103+
typedef xmlBuf *xmlBufPtr;
104+
99105
xmlBuffer *xmlBufferCreate(void);
100106
void xmlBufferFree(xmlBuffer *buf);
101107

xmlua/libxml2/xml-io.lua

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,49 @@ local ffi = require("ffi")
22

33
ffi.cdef[[
44

5-
typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer, int len);
5+
/**
6+
* xmlOutputWriteCallback:
7+
* @context: an Output context
8+
* @buffer: the buffer of data to write
9+
* @len: the length of the buffer in bytes
10+
*
11+
* Callback used in the I/O Output API to write to the resource
12+
*
13+
* Returns the number of bytes written or -1 in case of error
14+
*/
15+
typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
16+
int len);
17+
/**
18+
* xmlOutputCloseCallback:
19+
* @context: an Output context
20+
*
21+
* Callback used in the I/O Output API to close the resource
22+
*
23+
* Returns 0 or -1 in case of error
24+
*/
625
typedef int (*xmlOutputCloseCallback) (void * context);
726

827
struct _xmlOutputBuffer {
9-
void* context;
10-
xmlOutputWriteCallback writecallback;
11-
xmlOutputCloseCallback closecallback;
28+
void* context;
29+
xmlOutputWriteCallback writecallback;
30+
xmlOutputCloseCallback closecallback;
1231

13-
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
32+
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
1433

15-
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
16-
xmlBufferPtr conv; /* if encoder != NULL buffer for output */
17-
int written; /* total number of byte written */
18-
int error;
34+
xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
35+
xmlBufPtr conv; /* if encoder != NULL buffer for output */
36+
int written; /* total number of byte written */
37+
int error;
1938
};
2039

21-
typedef struct _xmlOutputBuffer xmlOutputBuffer;
22-
typedef xmlOutputBuffer *xmlOutputBufferPtr;
40+
xmlOutputBufferPtr
41+
xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
2342

24-
xmlOutputBufferPtr xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
25-
xmlOutputBufferPtr xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, xmlCharEncodingHandlerPtr encoder);
26-
int xmlOutputBufferClose (xmlOutputBufferPtr out);
43+
xmlOutputBufferPtr
44+
xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
45+
xmlCharEncodingHandlerPtr encoder);
46+
47+
int
48+
xmlOutputBufferClose (xmlOutputBufferPtr out);
2749

2850
]]

0 commit comments

Comments
 (0)