diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-11 14:38:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-11 14:38:42 -0300 |
commit | 787a78f83e0484c9e9698189982e2f309808fae8 (patch) | |
tree | 0682eddf4ea5a49bf5078bac937a36f90057df57 /lauxlib.h | |
parent | 70c8a310925d6c41c3ef4f7feeae604a4c9a3a95 (diff) | |
download | lua-787a78f83e0484c9e9698189982e2f309808fae8.tar.gz lua-787a78f83e0484c9e9698189982e2f309808fae8.tar.bz2 lua-787a78f83e0484c9e9698189982e2f309808fae8.zip |
new scheme for buffers
Diffstat (limited to 'lauxlib.h')
-rw-r--r-- | lauxlib.h | 47 |
1 files changed, 36 insertions, 11 deletions
@@ -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); | |||
34 | void luaL_verror (lua_State *L, const char *fmt, ...); | 35 | void luaL_verror (lua_State *L, const char *fmt, ...); |
35 | int luaL_findstring (const char *name, const char *const list[]); | 36 | int luaL_findstring (const char *name, const char *const list[]); |
36 | void luaL_chunkid (char *out, const char *source, int len); | 37 | void luaL_chunkid (char *out, const char *source, int len); |
37 | void luaL_filesource (char *out, const char *filename, int len); | ||
38 | 38 | ||
39 | 39 | ||
40 | char *luaL_openspace (lua_State *L, size_t size); | ||
41 | void luaL_resetbuffer (lua_State *L); | ||
42 | void luaL_addchar (lua_State *L, int c); | ||
43 | size_t luaL_getsize (lua_State *L); | ||
44 | void luaL_addsize (lua_State *L, size_t n); | ||
45 | size_t luaL_newbuffer (lua_State *L, size_t size); | ||
46 | void luaL_oldbuffer (lua_State *L, size_t old); | ||
47 | char *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 | |||
68 | typedef 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 | |||
81 | void luaL_buffinit (lua_State *L, luaL_Buffer *B); | ||
82 | char *luaL_prepbuffer (luaL_Buffer *B); | ||
83 | void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l); | ||
84 | void luaL_addvalue (luaL_Buffer *B); | ||
85 | void luaL_pushresult (luaL_Buffer *B); | ||
86 | |||
87 | |||
88 | /* }====================================================== */ | ||
89 | |||
90 | |||
67 | #endif | 91 | #endif |
68 | 92 | ||
93 | |||