diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-03 15:39:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-03 15:39:14 -0300 |
commit | fa075b79530af1cbc977349f2e467d69ce01202c (patch) | |
tree | 300e10cd086a9812331b954d46552dbf420b0a8a /lobject.h | |
parent | 08a077d673b25cf1fbfe21794f240f4ff4999667 (diff) | |
parent | 7923dbbf72da303ca1cca17efd24725668992f15 (diff) | |
download | lua-fa075b79530af1cbc977349f2e467d69ce01202c.tar.gz lua-fa075b79530af1cbc977349f2e467d69ce01202c.tar.bz2 lua-fa075b79530af1cbc977349f2e467d69ce01202c.zip |
Merge branch 'master' into newarray
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -388,7 +388,7 @@ typedef struct GCObject { | |||
388 | typedef struct TString { | 388 | typedef struct TString { |
389 | CommonHeader; | 389 | CommonHeader; |
390 | lu_byte extra; /* reserved words for short strings; "has hash" for longs */ | 390 | lu_byte extra; /* reserved words for short strings; "has hash" for longs */ |
391 | lu_byte shrlen; /* length for short strings */ | 391 | lu_byte shrlen; /* length for short strings, 0xFF for long strings */ |
392 | unsigned int hash; | 392 | unsigned int hash; |
393 | union { | 393 | union { |
394 | size_t lnglen; /* length for long strings */ | 394 | size_t lnglen; /* length for long strings */ |
@@ -400,19 +400,17 @@ typedef struct TString { | |||
400 | 400 | ||
401 | 401 | ||
402 | /* | 402 | /* |
403 | ** Get the actual string (array of bytes) from a 'TString'. | 403 | ** Get the actual string (array of bytes) from a 'TString'. (Generic |
404 | ** version and specialized versions for long and short strings.) | ||
404 | */ | 405 | */ |
405 | #define getstr(ts) ((ts)->contents) | 406 | #define getstr(ts) ((ts)->contents) |
407 | #define getlngstr(ts) check_exp((ts)->shrlen == 0xFF, (ts)->contents) | ||
408 | #define getshrstr(ts) check_exp((ts)->shrlen != 0xFF, (ts)->contents) | ||
406 | 409 | ||
407 | 410 | ||
408 | /* get the actual string (array of bytes) from a Lua value */ | ||
409 | #define svalue(o) getstr(tsvalue(o)) | ||
410 | |||
411 | /* get string length from 'TString *s' */ | 411 | /* get string length from 'TString *s' */ |
412 | #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) | 412 | #define tsslen(s) \ |
413 | 413 | ((s)->shrlen != 0xFF ? (s)->shrlen : (s)->u.lnglen) | |
414 | /* get string length from 'TValue *o' */ | ||
415 | #define vslen(o) tsslen(tsvalue(o)) | ||
416 | 414 | ||
417 | /* }================================================================== */ | 415 | /* }================================================================== */ |
418 | 416 | ||