diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
| commit | e1d072571ec6f9d830e575a2ecdc95fd43428e53 (patch) | |
| tree | 830fab7f2acb9adaee2d63073d339cc9557a5437 /lobject.h | |
| parent | 7651a5c6b2ee6ec59cadec6199319d482071f176 (diff) | |
| download | lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.gz lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.bz2 lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.zip | |
better syntax for type casts
Diffstat (limited to 'lobject.h')
| -rw-r--r-- | lobject.h | 12 |
1 files changed, 8 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 1.109 2001/06/28 14:56:25 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.110 2001/08/27 15:16:28 roberto Exp $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -22,6 +22,10 @@ | |||
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | #ifndef cast | ||
| 26 | #define cast(t, exp) ((t)(exp)) | ||
| 27 | #endif | ||
| 28 | |||
| 25 | 29 | ||
| 26 | /* tags for values visible from Lua == first user-created tag */ | 30 | /* tags for values visible from Lua == first user-created tag */ |
| 27 | #define NUM_TAGS 6 | 31 | #define NUM_TAGS 6 |
| @@ -96,7 +100,7 @@ typedef union TString { | |||
| 96 | } TString; | 100 | } TString; |
| 97 | 101 | ||
| 98 | 102 | ||
| 99 | #define getstr(ts) ((l_char *)((ts) + 1)) | 103 | #define getstr(ts) cast(l_char *, (ts) + 1) |
| 100 | #define svalue(o) getstr(tsvalue(o)) | 104 | #define svalue(o) getstr(tsvalue(o)) |
| 101 | 105 | ||
| 102 | 106 | ||
| @@ -196,7 +200,7 @@ typedef struct Hash { | |||
| 196 | /* | 200 | /* |
| 197 | ** `module' operation for hashing (size is always a power of 2) | 201 | ** `module' operation for hashing (size is always a power of 2) |
| 198 | */ | 202 | */ |
| 199 | #define lmod(s,size) ((int)((s) & ((size)-1))) | 203 | #define lmod(s,size) (cast(int, (s) & ((size)-1))) |
| 200 | 204 | ||
| 201 | 205 | ||
| 202 | /* | 206 | /* |
| @@ -217,7 +221,7 @@ typedef struct CallInfo { | |||
| 217 | extern const TObject luaO_nilobject; | 221 | extern const TObject luaO_nilobject; |
| 218 | 222 | ||
| 219 | 223 | ||
| 220 | #define luaO_openspace(L,n,t) ((t *)luaO_openspaceaux(L,(n)*sizeof(t))) | 224 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) |
| 221 | void *luaO_openspaceaux (lua_State *L, size_t n); | 225 | void *luaO_openspaceaux (lua_State *L, size_t n); |
| 222 | 226 | ||
| 223 | int luaO_equalObj (const TObject *t1, const TObject *t2); | 227 | int luaO_equalObj (const TObject *t1, const TObject *t2); |
