mikepaul-LuaJIT/src/lj_str.h

44 lines
1.4 KiB
C
Raw Normal View History

2009-12-08 18:46:35 +00:00
/*
** String handling.
2013-02-11 11:54:48 +00:00
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
2009-12-08 18:46:35 +00:00
*/
#ifndef _LJ_STR_H
#define _LJ_STR_H
#include <stdarg.h>
#include "lj_obj.h"
/* String interning. */
LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b);
2009-12-08 18:46:35 +00:00
LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask);
LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len);
LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s);
#define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s)))
#define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1))
/* Type conversions. */
2013-03-18 16:08:37 +00:00
LJ_FUNC MSize LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o);
2013-03-20 21:45:52 +00:00
LJ_FUNC MSize LJ_FASTCALL lj_str_bufptr(char *p, const void *v);
2013-03-18 16:08:37 +00:00
LJ_FUNC const char *lj_str_buftv(char *buf, cTValue *o, MSize *lenp);
LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np);
LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k);
LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o);
2011-02-16 23:44:14 +00:00
#define LJ_STR_INTBUF (1+10)
#define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR
2013-03-18 16:08:37 +00:00
#define LJ_STR_NUMBERBUF LUAI_MAXNUMBER2STR
2013-03-20 21:45:52 +00:00
#define LJ_STR_PTRBUF (2*sizeof(ptrdiff_t)+2)
2009-12-08 18:46:35 +00:00
/* String formatting. */
LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp);
LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...)
#if defined(__GNUC__)
__attribute__ ((format (printf, 2, 3)))
#endif
;
#endif