aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 14:38:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 14:38:42 -0300
commit787a78f83e0484c9e9698189982e2f309808fae8 (patch)
tree0682eddf4ea5a49bf5078bac937a36f90057df57 /lauxlib.h
parent70c8a310925d6c41c3ef4f7feeae604a4c9a3a95 (diff)
downloadlua-787a78f83e0484c9e9698189982e2f309808fae8.tar.gz
lua-787a78f83e0484c9e9698189982e2f309808fae8.tar.bz2
lua-787a78f83e0484c9e9698189982e2f309808fae8.zip
new scheme for buffers
Diffstat (limited to 'lauxlib.h')
-rw-r--r--lauxlib.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/lauxlib.h b/lauxlib.h
index 8e3fea5c..de717da5 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.21 2000/08/29 20:43:28 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.22 2000/09/04 18:27:32 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -10,6 +10,7 @@
10 10
11 11
12#include <stddef.h> 12#include <stddef.h>
13#include <stdio.h>
13 14
14#include "lua.h" 15#include "lua.h"
15 16
@@ -34,18 +35,8 @@ void luaL_checktype (lua_State *L, int narg, const char *tname);
34void luaL_verror (lua_State *L, const char *fmt, ...); 35void luaL_verror (lua_State *L, const char *fmt, ...);
35int luaL_findstring (const char *name, const char *const list[]); 36int luaL_findstring (const char *name, const char *const list[]);
36void luaL_chunkid (char *out, const char *source, int len); 37void luaL_chunkid (char *out, const char *source, int len);
37void luaL_filesource (char *out, const char *filename, int len);
38 38
39 39
40char *luaL_openspace (lua_State *L, size_t size);
41void luaL_resetbuffer (lua_State *L);
42void luaL_addchar (lua_State *L, int c);
43size_t luaL_getsize (lua_State *L);
44void luaL_addsize (lua_State *L, size_t n);
45size_t luaL_newbuffer (lua_State *L, size_t size);
46void luaL_oldbuffer (lua_State *L, size_t old);
47char *luaL_buffer (lua_State *L);
48
49 40
50/* 41/*
51** =============================================================== 42** ===============================================================
@@ -64,5 +55,39 @@ char *luaL_buffer (lua_State *L);
64#define luaL_openl(L,a) luaL_openlib(L, a, (sizeof(a)/sizeof(a[0]))) 55#define luaL_openl(L,a) luaL_openlib(L, a, (sizeof(a)/sizeof(a[0])))
65 56
66 57
58/*
59** {======================================================
60** Generic Buffer manipulation
61** =======================================================
62*/
63
64
65#define LUAL_BUFFERSIZE BUFSIZ
66
67
68typedef struct luaL_Buffer {
69 char *p; /* current position in buffer */
70 int level;
71 lua_State *L;
72 char buffer[LUAL_BUFFERSIZE];
73} luaL_Buffer;
74
75#define luaL_putchar(B,c) \
76 ((void)((B)->p < &(B)->buffer[LUAL_BUFFERSIZE] || luaL_prepbuffer(B)), \
77 (*(B)->p++ = (char)(c)))
78
79#define luaL_addsize(B,n) ((B)->p += (n))
80
81void luaL_buffinit (lua_State *L, luaL_Buffer *B);
82char *luaL_prepbuffer (luaL_Buffer *B);
83void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
84void luaL_addvalue (luaL_Buffer *B);
85void luaL_pushresult (luaL_Buffer *B);
86
87
88/* }====================================================== */
89
90
67#endif 91#endif
68 92
93