diff options
| author | ruki <[email protected]> | 2015-05-13 22:05:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-13 22:05:42 +0800 |
| commit | 74ece0defa314bab78262d95bee517bdc09df689 (patch) | |
| tree | 950684880d0193e60956a9b695cab50861208ff4 /core | |
| parent | 1f45e3bf9b41a413804305fc23810639b977a9f1 (diff) | |
add preprocessor and update tbox
Diffstat (limited to 'core')
| -rw-r--r-- | core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h | 2 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/memory/buffer.h | 90 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h | 40 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h | 44 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/network/cookies.h | 4 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/object/data.h | 4 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/object/string.h | 2 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/string/static_string.h | 75 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/string/string.h | 79 | ||||
| -rwxr-xr-x | core/src/xmake/machine.c | 58 | ||||
| -rwxr-xr-x | core/src/xmake/makefile | 3 | ||||
| -rwxr-xr-x | core/src/xmake/preprocessor/load_xproj.c | 133 | ||||
| -rw-r--r-- | core/src/xmake/preprocessor/prefix.h | 35 |
13 files changed, 372 insertions, 197 deletions
diff --git a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h index d05f235cd..22f02c45d 100644 --- a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h +++ b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h @@ -14,7 +14,7 @@ #define TB_CONFIG_VERSION_ALTER 8 // build version -#define TB_CONFIG_VERSION_BUILD 201505041915 +#define TB_CONFIG_VERSION_BUILD 201505132122 // small #define TB_CONFIG_SMALL (0) diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h index 0d0cee6c2..98c6f568e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h @@ -57,203 +57,203 @@ typedef struct __tb_buffer_t tb_byte_t buff[64]; #endif -}tb_buffer_t; +}tb_buffer_t, *tb_buffer_ref_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ -/*! init the scoped buffer +/*! init the buffer * - * @param buffer the scoped buffer + * @param buffer the buffer * * @return tb_true or tb_false */ -tb_bool_t tb_buffer_init(tb_buffer_t* buffer); +tb_bool_t tb_buffer_init(tb_buffer_ref_t buffer); -/*! exit the scoped buffer +/*! exit the buffer * - * @param buffer the scoped buffer + * @param buffer the buffer */ -tb_void_t tb_buffer_exit(tb_buffer_t* buffer); +tb_void_t tb_buffer_exit(tb_buffer_ref_t buffer); /*! the buffer data * - * @param buffer the scoped buffer + * @param buffer the buffer * * @return the buffer data address */ -tb_byte_t* tb_buffer_data(tb_buffer_t* buffer); +tb_byte_t* tb_buffer_data(tb_buffer_ref_t buffer); /*! the buffer data size * - * @param buffer the scoped buffer + * @param buffer the buffer * * @return the buffer data size */ -tb_size_t tb_buffer_size(tb_buffer_t const* buffer); +tb_size_t tb_buffer_size(tb_buffer_ref_t buffer); /*! the buffer data maxn * - * @param buffer the scoped buffer + * @param buffer the buffer * * @return the buffer data maxn */ -tb_size_t tb_buffer_maxn(tb_buffer_t const* buffer); +tb_size_t tb_buffer_maxn(tb_buffer_ref_t buffer); /*! clear the buffer * - * @param buffer the scoped buffer + * @param buffer the buffer */ -tb_void_t tb_buffer_clear(tb_buffer_t* buffer); +tb_void_t tb_buffer_clear(tb_buffer_ref_t buffer); /*! resize the buffer size * - * @param buffer the scoped buffer + * @param buffer the buffer * @param size the new buffer size * * @return the buffer data address */ -tb_byte_t* tb_buffer_resize(tb_buffer_t* buffer, tb_size_t size); +tb_byte_t* tb_buffer_resize(tb_buffer_ref_t buffer, tb_size_t size); /*! memset: b => 0 ... e * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the filled byte * * @return the buffer data address */ -tb_byte_t* tb_buffer_memset(tb_buffer_t* buffer, tb_byte_t b); +tb_byte_t* tb_buffer_memset(tb_buffer_ref_t buffer, tb_byte_t b); /*! memset: b => p ... e * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the start position * @param b the filled byte * * @return the buffer data address */ -tb_byte_t* tb_buffer_memsetp(tb_buffer_t* buffer, tb_size_t p, tb_byte_t b); +tb_byte_t* tb_buffer_memsetp(tb_buffer_ref_t buffer, tb_size_t p, tb_byte_t b); /*! memset: b => 0 ... n * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the filled byte * @param n the filled count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memnset(tb_buffer_t* buffer, tb_byte_t b, tb_size_t n); +tb_byte_t* tb_buffer_memnset(tb_buffer_ref_t buffer, tb_byte_t b, tb_size_t n); /*! memset: b => p ... n * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the start position * @param b the filled byte * @param n the filled count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memnsetp(tb_buffer_t* buffer, tb_size_t p, tb_byte_t b, tb_size_t n); +tb_byte_t* tb_buffer_memnsetp(tb_buffer_ref_t buffer, tb_size_t p, tb_byte_t b, tb_size_t n); /*! memcpy: b => 0 ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the copied buffer * * @return the buffer data address */ -tb_byte_t* tb_buffer_memcpy(tb_buffer_t* buffer, tb_buffer_t* b); +tb_byte_t* tb_buffer_memcpy(tb_buffer_ref_t buffer, tb_buffer_ref_t b); /*! memcpy: b => p ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the start position * @param b the copied buffer * * @return the buffer data address */ -tb_byte_t* tb_buffer_memcpyp(tb_buffer_t* buffer, tb_size_t p, tb_buffer_t* b); +tb_byte_t* tb_buffer_memcpyp(tb_buffer_ref_t buffer, tb_size_t p, tb_buffer_ref_t b); /*! memcpy: b ... n => 0 ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the copied buffer * @param n the copied count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memncpy(tb_buffer_t* buffer, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_buffer_memncpy(tb_buffer_ref_t buffer, tb_byte_t const* b, tb_size_t n); /*! memcpy: b ... n => p ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the start position * @param b the copied buffer * @param n the copied count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memncpyp(tb_buffer_t* buffer, tb_size_t p, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_buffer_memncpyp(tb_buffer_ref_t buffer, tb_size_t p, tb_byte_t const* b, tb_size_t n); /*! memmov: b ... e => 0 ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the moved start position * * @return the buffer data address */ -tb_byte_t* tb_buffer_memmov(tb_buffer_t* buffer, tb_size_t b); +tb_byte_t* tb_buffer_memmov(tb_buffer_ref_t buffer, tb_size_t b); /*! memmov: b ... e => p ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the moved destination position * @param b the moved start position * * @return the buffer data address */ -tb_byte_t* tb_buffer_memmovp(tb_buffer_t* buffer, tb_size_t p, tb_size_t b); +tb_byte_t* tb_buffer_memmovp(tb_buffer_ref_t buffer, tb_size_t p, tb_size_t b); /*! memmov: b ... n => 0 ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the moved start position * @param n the moved count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memnmov(tb_buffer_t* buffer, tb_size_t b, tb_size_t n); +tb_byte_t* tb_buffer_memnmov(tb_buffer_ref_t buffer, tb_size_t b, tb_size_t n); /*! memmov: b ... n => p ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param p the moved destination position * @param b the moved start position * @param n the moved count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memnmovp(tb_buffer_t* buffer, tb_size_t p, tb_size_t b, tb_size_t n); +tb_byte_t* tb_buffer_memnmovp(tb_buffer_ref_t buffer, tb_size_t p, tb_size_t b, tb_size_t n); /*! memcat: b +=> e ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the concated buffer * * @return the buffer data address */ -tb_byte_t* tb_buffer_memcat(tb_buffer_t* buffer, tb_buffer_t* b); +tb_byte_t* tb_buffer_memcat(tb_buffer_ref_t buffer, tb_buffer_ref_t b); /*! memcat: b ... n +=> e ... * - * @param buffer the scoped buffer + * @param buffer the buffer * @param b the concated buffer * @param n the concated count * * @return the buffer data address */ -tb_byte_t* tb_buffer_memncat(tb_buffer_t* buffer, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_buffer_memncat(tb_buffer_ref_t buffer, tb_byte_t const* b, tb_size_t n); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h index 8ba797f4f..cb4c18d4f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h @@ -53,7 +53,7 @@ typedef struct __tb_queue_buffer_t // the buffer maxn tb_size_t maxn; -}tb_queue_buffer_t; +}tb_queue_buffer_t, *tb_queue_buffer_ref_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -66,13 +66,13 @@ typedef struct __tb_queue_buffer_t * * @return tb_true or tb_false */ -tb_bool_t tb_queue_buffer_init(tb_queue_buffer_t* buffer, tb_size_t maxn); +tb_bool_t tb_queue_buffer_init(tb_queue_buffer_ref_t buffer, tb_size_t maxn); /*! exit buffer * * @param buffer the buffer */ -tb_void_t tb_queue_buffer_exit(tb_queue_buffer_t* buffer); +tb_void_t tb_queue_buffer_exit(tb_queue_buffer_ref_t buffer); /*! the buffer data * @@ -80,7 +80,7 @@ tb_void_t tb_queue_buffer_exit(tb_queue_buffer_t* buffer); * * @return the buffer data */ -tb_byte_t* tb_queue_buffer_data(tb_queue_buffer_t const* buffer); +tb_byte_t* tb_queue_buffer_data(tb_queue_buffer_ref_t buffer); /*! the buffer head * @@ -88,7 +88,7 @@ tb_byte_t* tb_queue_buffer_data(tb_queue_buffer_t const* buffer); * * @return the buffer head */ -tb_byte_t* tb_queue_buffer_head(tb_queue_buffer_t const* buffer); +tb_byte_t* tb_queue_buffer_head(tb_queue_buffer_ref_t buffer); /*! the buffer tail * @@ -96,7 +96,7 @@ tb_byte_t* tb_queue_buffer_head(tb_queue_buffer_t const* buffer); * * @return the buffer tail */ -tb_byte_t* tb_queue_buffer_tail(tb_queue_buffer_t const* buffer); +tb_byte_t* tb_queue_buffer_tail(tb_queue_buffer_ref_t buffer); /*! the buffer maxn * @@ -104,7 +104,7 @@ tb_byte_t* tb_queue_buffer_tail(tb_queue_buffer_t const* buffer); * * @return the buffer maxn */ -tb_size_t tb_queue_buffer_maxn(tb_queue_buffer_t const* buffer); +tb_size_t tb_queue_buffer_maxn(tb_queue_buffer_ref_t buffer); /*! the buffer size * @@ -112,7 +112,7 @@ tb_size_t tb_queue_buffer_maxn(tb_queue_buffer_t const* buffer); * * @return the buffer size */ -tb_size_t tb_queue_buffer_size(tb_queue_buffer_t const* buffer); +tb_size_t tb_queue_buffer_size(tb_queue_buffer_ref_t buffer); /*! the buffer left * @@ -120,7 +120,7 @@ tb_size_t tb_queue_buffer_size(tb_queue_buffer_t const* buffer); * * @return the buffer left */ -tb_size_t tb_queue_buffer_left(tb_queue_buffer_t const* buffer); +tb_size_t tb_queue_buffer_left(tb_queue_buffer_ref_t buffer); /*! the buffer full? * @@ -128,7 +128,7 @@ tb_size_t tb_queue_buffer_left(tb_queue_buffer_t const* buffer); * * @return tb_true or tb_false */ -tb_bool_t tb_queue_buffer_full(tb_queue_buffer_t const* buffer); +tb_bool_t tb_queue_buffer_full(tb_queue_buffer_ref_t buffer); /*! the buffer null? * @@ -136,13 +136,13 @@ tb_bool_t tb_queue_buffer_full(tb_queue_buffer_t const* buffer); * * @return tb_true or tb_false */ -tb_bool_t tb_queue_buffer_null(tb_queue_buffer_t const* buffer); +tb_bool_t tb_queue_buffer_null(tb_queue_buffer_ref_t buffer); /*! clear buffer * * @param buffer the buffer */ -tb_void_t tb_queue_buffer_clear(tb_queue_buffer_t* buffer); +tb_void_t tb_queue_buffer_clear(tb_queue_buffer_ref_t buffer); /*! resize buffer size * @@ -151,7 +151,7 @@ tb_void_t tb_queue_buffer_clear(tb_queue_buffer_t* buffer); * * @return the buffer data */ -tb_byte_t* tb_queue_buffer_resize(tb_queue_buffer_t* buffer, tb_size_t maxn); +tb_byte_t* tb_queue_buffer_resize(tb_queue_buffer_ref_t buffer, tb_size_t maxn); /*! skip buffer * @@ -160,7 +160,7 @@ tb_byte_t* tb_queue_buffer_resize(tb_queue_buffer_t* buffer, tb_size_t * * @return the real size */ -tb_long_t tb_queue_buffer_skip(tb_queue_buffer_t* buffer, tb_size_t size); +tb_long_t tb_queue_buffer_skip(tb_queue_buffer_ref_t buffer, tb_size_t size); /*! read buffer * @@ -170,7 +170,7 @@ tb_long_t tb_queue_buffer_skip(tb_queue_buffer_t* buffer, tb_size_t si * * @return the real size */ -tb_long_t tb_queue_buffer_read(tb_queue_buffer_t* buffer, tb_byte_t* data, tb_size_t size); +tb_long_t tb_queue_buffer_read(tb_queue_buffer_ref_t buffer, tb_byte_t* data, tb_size_t size); /*! writ buffer * @@ -180,7 +180,7 @@ tb_long_t tb_queue_buffer_read(tb_queue_buffer_t* buffer, tb_byte_t* d * * @return the real size */ -tb_long_t tb_queue_buffer_writ(tb_queue_buffer_t* buffer, tb_byte_t const* data, tb_size_t size); +tb_long_t tb_queue_buffer_writ(tb_queue_buffer_ref_t buffer, tb_byte_t const* data, tb_size_t size); /*! init pull buffer for reading * @@ -189,14 +189,14 @@ tb_long_t tb_queue_buffer_writ(tb_queue_buffer_t* buffer, tb_byte_t co * * @return the data */ -tb_byte_t* tb_queue_buffer_pull_init(tb_queue_buffer_t* buffer, tb_size_t* size); +tb_byte_t* tb_queue_buffer_pull_init(tb_queue_buffer_ref_t buffer, tb_size_t* size); /*! exit pull buffer for reading * * @param buffer the buffer * @param size the size */ -tb_void_t tb_queue_buffer_pull_exit(tb_queue_buffer_t* buffer, tb_size_t size); +tb_void_t tb_queue_buffer_pull_exit(tb_queue_buffer_ref_t buffer, tb_size_t size); /*! init push buffer for writing * @@ -205,14 +205,14 @@ tb_void_t tb_queue_buffer_pull_exit(tb_queue_buffer_t* buffer, tb_size * * @return the data */ -tb_byte_t* tb_queue_buffer_push_init(tb_queue_buffer_t* buffer, tb_size_t* size); +tb_byte_t* tb_queue_buffer_push_init(tb_queue_buffer_ref_t buffer, tb_size_t* size); /*! exit push buffer for writing * * @param buffer the buffer * @param size the size */ -tb_void_t tb_queue_buffer_push_exit(tb_queue_buffer_t* buffer, tb_size_t size); +tb_void_t tb_queue_buffer_push_exit(tb_queue_buffer_ref_t buffer, tb_size_t size); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h index 95d307551..daaa065fd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h @@ -50,7 +50,7 @@ typedef struct __tb_static_buffer_t // the buffer maxn tb_size_t maxn; -}tb_static_buffer_t; +}tb_static_buffer_t, *tb_static_buffer_ref_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -64,13 +64,13 @@ typedef struct __tb_static_buffer_t * * @return tb_true or tb_false */ -tb_bool_t tb_static_buffer_init(tb_static_buffer_t* buffer, tb_byte_t* data, tb_size_t maxn); +tb_bool_t tb_static_buffer_init(tb_static_buffer_ref_t buffer, tb_byte_t* data, tb_size_t maxn); /*! exit the static buffer * * @param buffer the static buffer */ -tb_void_t tb_static_buffer_exit(tb_static_buffer_t* buffer); +tb_void_t tb_static_buffer_exit(tb_static_buffer_ref_t buffer); /*! the buffer data * @@ -78,7 +78,7 @@ tb_void_t tb_static_buffer_exit(tb_static_buffer_t* buffer); * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_data(tb_static_buffer_t* buffer); +tb_byte_t* tb_static_buffer_data(tb_static_buffer_ref_t buffer); /*! the buffer data size * @@ -86,7 +86,7 @@ tb_byte_t* tb_static_buffer_data(tb_static_buffer_t* buffer); * * @return the buffer data size */ -tb_size_t tb_static_buffer_size(tb_static_buffer_t const* buffer); +tb_size_t tb_static_buffer_size(tb_static_buffer_ref_t buffer); /*! the buffer data maxn * @@ -94,13 +94,13 @@ tb_size_t tb_static_buffer_size(tb_static_buffer_t const* buffer); * * @return the buffer data maxn */ -tb_size_t tb_static_buffer_maxn(tb_static_buffer_t const* buffer); +tb_size_t tb_static_buffer_maxn(tb_static_buffer_ref_t buffer); /*! clear the buffer * * @param buffer the static buffer */ -tb_void_t tb_static_buffer_clear(tb_static_buffer_t* buffer); +tb_void_t tb_static_buffer_clear(tb_static_buffer_ref_t buffer); /*! resize the buffer size * @@ -109,7 +109,7 @@ tb_void_t tb_static_buffer_clear(tb_static_buffer_t* buffer); * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_resize(tb_static_buffer_t* buffer, tb_size_t size); +tb_byte_t* tb_static_buffer_resize(tb_static_buffer_ref_t buffer, tb_size_t size); /*! memset: b => 0 ... e * @@ -118,7 +118,7 @@ tb_byte_t* tb_static_buffer_resize(tb_static_buffer_t* buffer, tb_size_ * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memset(tb_static_buffer_t* buffer, tb_byte_t b); +tb_byte_t* tb_static_buffer_memset(tb_static_buffer_ref_t buffer, tb_byte_t b); /*! memset: b => p ... e * @@ -128,7 +128,7 @@ tb_byte_t* tb_static_buffer_memset(tb_static_buffer_t* buffer, tb_byte_ * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memsetp(tb_static_buffer_t* buffer, tb_size_t p, tb_byte_t b); +tb_byte_t* tb_static_buffer_memsetp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_byte_t b); /*! memset: b => 0 ... n * @@ -138,7 +138,7 @@ tb_byte_t* tb_static_buffer_memsetp(tb_static_buffer_t* buffer, tb_size * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memnset(tb_static_buffer_t* buffer, tb_byte_t b, tb_size_t n); +tb_byte_t* tb_static_buffer_memnset(tb_static_buffer_ref_t buffer, tb_byte_t b, tb_size_t n); /*! memset: b => p ... n * @@ -149,7 +149,7 @@ tb_byte_t* tb_static_buffer_memnset(tb_static_buffer_t* buffer, tb_byte * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memnsetp(tb_static_buffer_t* buffer, tb_size_t p, tb_byte_t b, tb_size_t n); +tb_byte_t* tb_static_buffer_memnsetp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_byte_t b, tb_size_t n); /*! memcpy: b => 0 ... * @@ -158,7 +158,7 @@ tb_byte_t* tb_static_buffer_memnsetp(tb_static_buffer_t* buffer, tb_siz * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memcpy(tb_static_buffer_t* buffer, tb_static_buffer_t* b); +tb_byte_t* tb_static_buffer_memcpy(tb_static_buffer_ref_t buffer, tb_static_buffer_ref_t b); /*! memcpy: b => p ... * @@ -168,7 +168,7 @@ tb_byte_t* tb_static_buffer_memcpy(tb_static_buffer_t* buffer, tb_stati * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memcpyp(tb_static_buffer_t* buffer, tb_size_t p, tb_static_buffer_t* b); +tb_byte_t* tb_static_buffer_memcpyp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_static_buffer_ref_t b); /*! memcpy: b ... n => 0 ... * @@ -178,7 +178,7 @@ tb_byte_t* tb_static_buffer_memcpyp(tb_static_buffer_t* buffer, tb_size * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memncpy(tb_static_buffer_t* buffer, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_static_buffer_memncpy(tb_static_buffer_ref_t buffer, tb_byte_t const* b, tb_size_t n); /*! memcpy: b ... n => p ... * @@ -189,7 +189,7 @@ tb_byte_t* tb_static_buffer_memncpy(tb_static_buffer_t* buffer, tb_byte * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memncpyp(tb_static_buffer_t* buffer, tb_size_t p, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_static_buffer_memncpyp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_byte_t const* b, tb_size_t n); /*! memmov: b ... e => 0 ... * @@ -198,7 +198,7 @@ tb_byte_t* tb_static_buffer_memncpyp(tb_static_buffer_t* buffer, tb_siz * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memmov(tb_static_buffer_t* buffer, tb_size_t b); +tb_byte_t* tb_static_buffer_memmov(tb_static_buffer_ref_t buffer, tb_size_t b); /*! memmov: b ... e => p ... * @@ -208,7 +208,7 @@ tb_byte_t* tb_static_buffer_memmov(tb_static_buffer_t* buffer, tb_size_ * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memmovp(tb_static_buffer_t* buffer, tb_size_t p, tb_size_t b); +tb_byte_t* tb_static_buffer_memmovp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_size_t b); /*! memmov: b ... n => 0 ... * @@ -218,7 +218,7 @@ tb_byte_t* tb_static_buffer_memmovp(tb_static_buffer_t* buffer, tb_size * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memnmov(tb_static_buffer_t* buffer, tb_size_t b, tb_size_t n); +tb_byte_t* tb_static_buffer_memnmov(tb_static_buffer_ref_t buffer, tb_size_t b, tb_size_t n); /*! memmov: b ... n => p ... * @@ -229,7 +229,7 @@ tb_byte_t* tb_static_buffer_memnmov(tb_static_buffer_t* buffer, tb_size * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memnmovp(tb_static_buffer_t* buffer, tb_size_t p, tb_size_t b, tb_size_t n); +tb_byte_t* tb_static_buffer_memnmovp(tb_static_buffer_ref_t buffer, tb_size_t p, tb_size_t b, tb_size_t n); /*! memcat: b +=> e ... * @@ -238,7 +238,7 @@ tb_byte_t* tb_static_buffer_memnmovp(tb_static_buffer_t* buffer, tb_siz * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memcat(tb_static_buffer_t* buffer, tb_static_buffer_t* b); +tb_byte_t* tb_static_buffer_memcat(tb_static_buffer_ref_t buffer, tb_static_buffer_ref_t b); /*! memcat: b ... n +=> e ... * @@ -248,7 +248,7 @@ tb_byte_t* tb_static_buffer_memcat(tb_static_buffer_t* buffer, tb_stati * * @return the buffer data address */ -tb_byte_t* tb_static_buffer_memncat(tb_static_buffer_t* buffer, tb_byte_t const* b, tb_size_t n); +tb_byte_t* tb_static_buffer_memncat(tb_static_buffer_ref_t buffer, tb_byte_t const* b, tb_size_t n); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h index 9178513f9..5d6438fe9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h @@ -262,7 +262,7 @@ tb_bool_t tb_cookies_set_from_url(tb_cookies_ref_t cookies, tb_char_t * * @return the cookies data */ -tb_char_t const* tb_cookies_get(tb_cookies_ref_t cookies, tb_char_t const* domain, tb_char_t const* path, tb_bool_t secure, tb_string_t* value); +tb_char_t const* tb_cookies_get(tb_cookies_ref_t cookies, tb_char_t const* domain, tb_char_t const* path, tb_bool_t secure, tb_string_ref_t value); /*! get cookies from the given url * @@ -272,7 +272,7 @@ tb_char_t const* tb_cookies_get(tb_cookies_ref_t cookies, tb_char_t const* do * * @return the cookies data */ -tb_char_t const* tb_cookies_get_from_url(tb_cookies_ref_t cookies, tb_char_t const* url, tb_string_t* value); +tb_char_t const* tb_cookies_get_from_url(tb_cookies_ref_t cookies, tb_char_t const* url, tb_string_ref_t value); /*! clear cookies * diff --git a/core/pkg/tbox.pkg/inc/tbox/object/data.h b/core/pkg/tbox.pkg/inc/tbox/object/data.h index 7cd8f870c..893f1568b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/data.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/data.h @@ -62,7 +62,7 @@ tb_object_ref_t tb_object_data_init_from_data(tb_pointer_t data, tb_size_t s * * @return the data object */ -tb_object_ref_t tb_object_data_init_from_buffer(tb_buffer_t* buffer); +tb_object_ref_t tb_object_data_init_from_buffer(tb_buffer_ref_t buffer); /*! get the data * @@ -96,7 +96,7 @@ tb_size_t tb_object_data_size(tb_object_ref_t data); * * @return the data buffer */ -tb_buffer_t* tb_object_data_buffer(tb_object_ref_t data); +tb_buffer_ref_t tb_object_data_buffer(tb_object_ref_t data); /*! writ data to url * diff --git a/core/pkg/tbox.pkg/inc/tbox/object/string.h b/core/pkg/tbox.pkg/inc/tbox/object/string.h index 915102ed0..a3721b777 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/string.h @@ -52,7 +52,7 @@ tb_object_ref_t tb_object_string_init_from_cstr(tb_char_t const* cstr); * * @return the string object */ -tb_object_ref_t tb_object_string_init_from_str(tb_string_t* str); +tb_object_ref_t tb_object_string_init_from_str(tb_string_ref_t str); /*! the c-string * diff --git a/core/pkg/tbox.pkg/inc/tbox/string/static_string.h b/core/pkg/tbox.pkg/inc/tbox/string/static_string.h index 8b76f37fd..4a8bcd0c9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/string/static_string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/static_string.h @@ -40,7 +40,10 @@ __tb_extern_c_enter__ */ /// the static string type -typedef tb_static_buffer_t tb_static_string_t; +typedef tb_static_buffer_t tb_static_string_t; + +/// the static string ref type +typedef tb_static_buffer_ref_t tb_static_string_ref_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -54,13 +57,13 @@ typedef tb_static_buffer_t tb_static_string_t; * * @return tb_true or tb_false */ -tb_bool_t tb_static_string_init(tb_static_string_t* string, tb_char_t* data, tb_size_t maxn); +tb_bool_t tb_static_string_init(tb_static_string_ref_t string, tb_char_t* data, tb_size_t maxn); /*! exit string * * @param string the string */ -tb_void_t tb_static_string_exit(tb_static_string_t* string); +tb_void_t tb_static_string_exit(tb_static_string_ref_t string); /*! the c-string pointer * @@ -68,7 +71,7 @@ tb_void_t tb_static_string_exit(tb_static_string_t* string); * * @return the c-string */ -tb_char_t const* tb_static_string_cstr(tb_static_string_t const* string); +tb_char_t const* tb_static_string_cstr(tb_static_string_ref_t string); /*! the string size * @@ -76,13 +79,13 @@ tb_char_t const* tb_static_string_cstr(tb_static_string_t const* string); * * @return the string size */ -tb_size_t tb_static_string_size(tb_static_string_t const* string); +tb_size_t tb_static_string_size(tb_static_string_ref_t string); /*! clear the string * * @param string the string */ -tb_void_t tb_static_string_clear(tb_static_string_t* string); +tb_void_t tb_static_string_clear(tb_static_string_ref_t string); /*! strip the string * @@ -91,7 +94,7 @@ tb_void_t tb_static_string_clear(tb_static_string_t* string); * * @return the c-string */ -tb_char_t const* tb_static_string_strip(tb_static_string_t* string, tb_size_t n); +tb_char_t const* tb_static_string_strip(tb_static_string_ref_t string, tb_size_t n); /*! trim the right spaces for string * @@ -99,7 +102,7 @@ tb_char_t const* tb_static_string_strip(tb_static_string_t* string, tb_si * * @return the c-string */ -tb_char_t const* tb_static_string_rtrim(tb_static_string_t* string); +tb_char_t const* tb_static_string_rtrim(tb_static_string_ref_t string); /*! find charactor position * @@ -109,7 +112,7 @@ tb_char_t const* tb_static_string_rtrim(tb_static_string_t* string); * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strchr(tb_static_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_static_string_strchr(tb_static_string_ref_t string, tb_size_t p, tb_char_t c); /*! find charactor position and ignore case * @@ -119,7 +122,7 @@ tb_long_t tb_static_string_strchr(tb_static_string_t const* string * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strichr(tb_static_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_static_string_strichr(tb_static_string_ref_t string, tb_size_t p, tb_char_t c); /*! reverse to find charactor position * @@ -129,7 +132,7 @@ tb_long_t tb_static_string_strichr(tb_static_string_t const* strin * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strrchr(tb_static_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_static_string_strrchr(tb_static_string_ref_t string, tb_size_t p, tb_char_t c); /*! reverse to find charactor position and ignore case * @@ -139,7 +142,7 @@ tb_long_t tb_static_string_strrchr(tb_static_string_t const* strin * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strirchr(tb_static_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_static_string_strirchr(tb_static_string_ref_t string, tb_size_t p, tb_char_t c); /*! find string position * @@ -149,7 +152,7 @@ tb_long_t tb_static_string_strirchr(tb_static_string_t const* stri * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strstr(tb_static_string_t const* string, tb_size_t p, tb_static_string_t const* s); +tb_long_t tb_static_string_strstr(tb_static_string_ref_t string, tb_size_t p, tb_static_string_ref_t s); /*! find string position and ignore case * @@ -159,7 +162,7 @@ tb_long_t tb_static_string_strstr(tb_static_string_t const* string * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_stristr(tb_static_string_t const* string, tb_size_t p, tb_static_string_t const* s); +tb_long_t tb_static_string_stristr(tb_static_string_ref_t string, tb_size_t p, tb_static_string_ref_t s); /*! find c-string position * @@ -169,7 +172,7 @@ tb_long_t tb_static_string_stristr(tb_static_string_t const* strin * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_cstrstr(tb_static_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_static_string_cstrstr(tb_static_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! find c-string position and ignore case * @@ -179,7 +182,7 @@ tb_long_t tb_static_string_cstrstr(tb_static_string_t const* strin * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_cstristr(tb_static_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_static_string_cstristr(tb_static_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! reverse to find string position * @@ -189,7 +192,7 @@ tb_long_t tb_static_string_cstristr(tb_static_string_t const* stri * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strrstr(tb_static_string_t const* string, tb_size_t p, tb_static_string_t const* s); +tb_long_t tb_static_string_strrstr(tb_static_string_ref_t string, tb_size_t p, tb_static_string_ref_t s); /*! reverse to find string position and ignore case * @@ -199,7 +202,7 @@ tb_long_t tb_static_string_strrstr(tb_static_string_t const* strin * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_strirstr(tb_static_string_t const* string, tb_size_t p, tb_static_string_t const* s); +tb_long_t tb_static_string_strirstr(tb_static_string_ref_t string, tb_size_t p, tb_static_string_ref_t s); /*! reverse to find c-string position * @@ -209,7 +212,7 @@ tb_long_t tb_static_string_strirstr(tb_static_string_t const* stri * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_cstrrstr(tb_static_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_static_string_cstrrstr(tb_static_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! reverse to find c-string position and ignore case * @@ -219,7 +222,7 @@ tb_long_t tb_static_string_cstrrstr(tb_static_string_t const* stri * * @return the real position, no find: -1 */ -tb_long_t tb_static_string_cstrirstr(tb_static_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_static_string_cstrirstr(tb_static_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! copy string * @@ -228,7 +231,7 @@ tb_long_t tb_static_string_cstrirstr(tb_static_string_t const* str * * @return the c-string */ -tb_char_t const* tb_static_string_strcpy(tb_static_string_t* string, tb_static_string_t const* s); +tb_char_t const* tb_static_string_strcpy(tb_static_string_ref_t string, tb_static_string_ref_t s); /*! copy c-string * @@ -237,7 +240,7 @@ tb_char_t const* tb_static_string_strcpy(tb_static_string_t* string, tb_s * * @return the c-string */ -tb_char_t const* tb_static_string_cstrcpy(tb_static_string_t* string, tb_char_t const* s); +tb_char_t const* tb_static_string_cstrcpy(tb_static_string_ref_t string, tb_char_t const* s); /*! copy c-string with the given size * @@ -247,7 +250,7 @@ tb_char_t const* tb_static_string_cstrcpy(tb_static_string_t* string, tb_ * * @return the c-string */ -tb_char_t const* tb_static_string_cstrncpy(tb_static_string_t* string, tb_char_t const* s, tb_size_t n); +tb_char_t const* tb_static_string_cstrncpy(tb_static_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! copy format c-string * @@ -256,7 +259,7 @@ tb_char_t const* tb_static_string_cstrncpy(tb_static_string_t* string, tb * * @return the c-string */ -tb_char_t const* tb_static_string_cstrfcpy(tb_static_string_t* string, tb_char_t const* fmt, ...); +tb_char_t const* tb_static_string_cstrfcpy(tb_static_string_ref_t string, tb_char_t const* fmt, ...); /*! append charactor * @@ -265,7 +268,7 @@ tb_char_t const* tb_static_string_cstrfcpy(tb_static_string_t* string, tb * * @return the c-string */ -tb_char_t const* tb_static_string_chrcat(tb_static_string_t* string, tb_char_t c); +tb_char_t const* tb_static_string_chrcat(tb_static_string_ref_t string, tb_char_t c); /*! append charactor with the given size * @@ -275,7 +278,7 @@ tb_char_t const* tb_static_string_chrcat(tb_static_string_t* string, tb_c * * @return the c-string */ -tb_char_t const* tb_static_string_chrncat(tb_static_string_t* string, tb_char_t c, tb_size_t n); +tb_char_t const* tb_static_string_chrncat(tb_static_string_ref_t string, tb_char_t c, tb_size_t n); /*! append string * @@ -284,7 +287,7 @@ tb_char_t const* tb_static_string_chrncat(tb_static_string_t* string, tb_ * * @return the c-string */ -tb_char_t const* tb_static_string_strcat(tb_static_string_t* string, tb_static_string_t const* s); +tb_char_t const* tb_static_string_strcat(tb_static_string_ref_t string, tb_static_string_ref_t s); /*! append c-string * @@ -293,7 +296,7 @@ tb_char_t const* tb_static_string_strcat(tb_static_string_t* string, tb_s * * @return the c-string */ -tb_char_t const* tb_static_string_cstrcat(tb_static_string_t* string, tb_char_t const* s); +tb_char_t const* tb_static_string_cstrcat(tb_static_string_ref_t string, tb_char_t const* s); /*! append c-string with the given size * @@ -303,7 +306,7 @@ tb_char_t const* tb_static_string_cstrcat(tb_static_string_t* string, tb_ * * @return the c-string */ -tb_char_t const* tb_static_string_cstrncat(tb_static_string_t* string, tb_char_t const* s, tb_size_t n); +tb_char_t const* tb_static_string_cstrncat(tb_static_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! append format c-string * @@ -312,7 +315,7 @@ tb_char_t const* tb_static_string_cstrncat(tb_static_string_t* string, tb * * @return the c-string */ -tb_char_t const* tb_static_string_cstrfcat(tb_static_string_t* string, tb_char_t const* fmt, ...); +tb_char_t const* tb_static_string_cstrfcat(tb_static_string_ref_t string, tb_char_t const* fmt, ...); /*! compare string * @@ -321,7 +324,7 @@ tb_char_t const* tb_static_string_cstrfcat(tb_static_string_t* string, tb * * @return equal: 0 */ -tb_long_t tb_static_string_strcmp(tb_static_string_t* string, tb_static_string_t const* s); +tb_long_t tb_static_string_strcmp(tb_static_string_ref_t string, tb_static_string_ref_t s); /*! compare string and ignore case * @@ -330,7 +333,7 @@ tb_long_t tb_static_string_strcmp(tb_static_string_t* string, tb_s * * @return equal: 0 */ -tb_long_t tb_static_string_strimp(tb_static_string_t* string, tb_static_string_t const* s); +tb_long_t tb_static_string_strimp(tb_static_string_ref_t string, tb_static_string_ref_t s); /*! compare c-string * @@ -339,7 +342,7 @@ tb_long_t tb_static_string_strimp(tb_static_string_t* string, tb_s * * @return equal: 0 */ -tb_long_t tb_static_string_cstrcmp(tb_static_string_t* string, tb_char_t const* s); +tb_long_t tb_static_string_cstrcmp(tb_static_string_ref_t string, tb_char_t const* s); /*! compare c-string and ignore case * @@ -348,7 +351,7 @@ tb_long_t tb_static_string_cstrcmp(tb_static_string_t* string, tb_ * * @return equal: 0 */ -tb_long_t tb_static_string_cstricmp(tb_static_string_t* string, tb_char_t const* s); +tb_long_t tb_static_string_cstricmp(tb_static_string_ref_t string, tb_char_t const* s); /*! compare c-string with given size * @@ -358,7 +361,7 @@ tb_long_t tb_static_string_cstricmp(tb_static_string_t* string, tb * * @return equal: 0 */ -tb_long_t tb_static_string_cstrncmp(tb_static_string_t* string, tb_char_t const* s, tb_size_t n); +tb_long_t tb_static_string_cstrncmp(tb_static_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! compare c-string with given size and ignore case * @@ -368,7 +371,7 @@ tb_long_t tb_static_string_cstrncmp(tb_static_string_t* string, tb * * @return equal: 0 */ -tb_long_t tb_static_string_cstrnicmp(tb_static_string_t* string, tb_char_t const* s, tb_size_t n); +tb_long_t tb_static_string_cstrnicmp(tb_static_string_ref_t string, tb_char_t const* s, tb_size_t n); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/string/string.h b/core/pkg/tbox.pkg/inc/tbox/string/string.h index 6aa8f4135..1380e62b6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/string/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/string.h @@ -21,8 +21,8 @@ * @ingroup string * */ -#ifndef TB_STRING_SCOPED_STRING_H -#define TB_STRING_SCOPED_STRING_H +#ifndef TB_STRING_H +#define TB_STRING_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -40,7 +40,10 @@ __tb_extern_c_enter__ */ /// the string type -typedef tb_buffer_t tb_string_t; +typedef tb_buffer_t tb_string_t; + +/// the string ref type +typedef tb_buffer_ref_t tb_string_ref_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -52,13 +55,13 @@ typedef tb_buffer_t tb_string_t; * * @return tb_true or tb_false */ -tb_bool_t tb_string_init(tb_string_t* string); +tb_bool_t tb_string_init(tb_string_ref_t string); /*! exit string * * @param string the string */ -tb_void_t tb_string_exit(tb_string_t* string); +tb_void_t tb_string_exit(tb_string_ref_t string); /*! the c-string pointer * @@ -66,7 +69,7 @@ tb_void_t tb_string_exit(tb_string_t* string); * * @return the c-string */ -tb_char_t const* tb_string_cstr(tb_string_t const* string); +tb_char_t const* tb_string_cstr(tb_string_ref_t string); /*! the string size * @@ -74,13 +77,13 @@ tb_char_t const* tb_string_cstr(tb_string_t const* string); * * @return the string size */ -tb_size_t tb_string_size(tb_string_t const* string); +tb_size_t tb_string_size(tb_string_ref_t string); /*! clear the string * * @param string the string */ -tb_void_t tb_string_clear(tb_string_t* string); +tb_void_t tb_string_clear(tb_string_ref_t string); /*! strip the string * @@ -89,7 +92,7 @@ tb_void_t tb_string_clear(tb_string_t* string); * * @return the c-string */ -tb_char_t const* tb_string_strip(tb_string_t* string, tb_size_t n); +tb_char_t const* tb_string_strip(tb_string_ref_t string, tb_size_t n); /*! trim the right spaces for string * @@ -97,7 +100,7 @@ tb_char_t const* tb_string_strip(tb_string_t* string, tb_size_t n); * * @return the c-string */ -tb_char_t const* tb_string_rtrim(tb_string_t* string); +tb_char_t const* tb_string_rtrim(tb_string_ref_t string); /*! find charactor position * @@ -107,7 +110,7 @@ tb_char_t const* tb_string_rtrim(tb_string_t* string); * * @return the real position, no find: -1 */ -tb_long_t tb_string_strchr(tb_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_string_strchr(tb_string_ref_t string, tb_size_t p, tb_char_t c); /*! find charactor position and ignore case * @@ -117,7 +120,7 @@ tb_long_t tb_string_strchr(tb_string_t const* string, tb_size_t p, * * @return the real position, no find: -1 */ -tb_long_t tb_string_strichr(tb_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_string_strichr(tb_string_ref_t string, tb_size_t p, tb_char_t c); /*! reverse to find charactor position * @@ -127,7 +130,7 @@ tb_long_t tb_string_strichr(tb_string_t const* string, tb_size_t p * * @return the real position, no find: -1 */ -tb_long_t tb_string_strrchr(tb_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_string_strrchr(tb_string_ref_t string, tb_size_t p, tb_char_t c); /*! reverse to find charactor position and ignore case * @@ -137,7 +140,7 @@ tb_long_t tb_string_strrchr(tb_string_t const* string, tb_size_t p * * @return the real position, no find: -1 */ -tb_long_t tb_string_strirchr(tb_string_t const* string, tb_size_t p, tb_char_t c); +tb_long_t tb_string_strirchr(tb_string_ref_t string, tb_size_t p, tb_char_t c); /*! find string position * @@ -147,7 +150,7 @@ tb_long_t tb_string_strirchr(tb_string_t const* string, tb_size_t * * @return the real position, no find: -1 */ -tb_long_t tb_string_strstr(tb_string_t const* string, tb_size_t p, tb_string_t const* s); +tb_long_t tb_string_strstr(tb_string_ref_t string, tb_size_t p, tb_string_ref_t s); /*! find string position and ignore case * @@ -157,7 +160,7 @@ tb_long_t tb_string_strstr(tb_string_t const* string, tb_size_t p, * * @return the real position, no find: -1 */ -tb_long_t tb_string_stristr(tb_string_t const* string, tb_size_t p, tb_string_t const* s); +tb_long_t tb_string_stristr(tb_string_ref_t string, tb_size_t p, tb_string_ref_t s); /*! find c-string position * @@ -167,7 +170,7 @@ tb_long_t tb_string_stristr(tb_string_t const* string, tb_size_t p * * @return the real position, no find: -1 */ -tb_long_t tb_string_cstrstr(tb_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_string_cstrstr(tb_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! find c-string position and ignore case * @@ -177,7 +180,7 @@ tb_long_t tb_string_cstrstr(tb_string_t const* string, tb_size_t p * * @return the real position, no find: -1 */ -tb_long_t tb_string_cstristr(tb_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_string_cstristr(tb_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! reverse to find string position * @@ -187,7 +190,7 @@ tb_long_t tb_string_cstristr(tb_string_t const* string, tb_size_t * * @return the real position, no find: -1 */ -tb_long_t tb_string_strrstr(tb_string_t const* string, tb_size_t p, tb_string_t const* s); +tb_long_t tb_string_strrstr(tb_string_ref_t string, tb_size_t p, tb_string_ref_t s); /*! reverse to find string position and ignore case * @@ -197,7 +200,7 @@ tb_long_t tb_string_strrstr(tb_string_t const* string, tb_size_t p * * @return the real position, no find: -1 */ -tb_long_t tb_string_strirstr(tb_string_t const* string, tb_size_t p, tb_string_t const* s); +tb_long_t tb_string_strirstr(tb_string_ref_t string, tb_size_t p, tb_string_ref_t s); /*! reverse to find c-string position * @@ -207,7 +210,7 @@ tb_long_t tb_string_strirstr(tb_string_t const* string, tb_size_t * * @return the real position, no find: -1 */ -tb_long_t tb_string_cstrrstr(tb_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_string_cstrrstr(tb_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! reverse to find c-string position and ignore case * @@ -217,7 +220,7 @@ tb_long_t tb_string_cstrrstr(tb_string_t const* string, tb_size_t * * @return the real position, no find: -1 */ -tb_long_t tb_string_cstrirstr(tb_string_t const* string, tb_size_t p, tb_char_t const* s); +tb_long_t tb_string_cstrirstr(tb_string_ref_t string, tb_size_t p, tb_char_t const* s); /*! copy string * @@ -226,7 +229,7 @@ tb_long_t tb_string_cstrirstr(tb_string_t const* string, tb_size_t * * @return the c-string */ -tb_char_t const* tb_string_strcpy(tb_string_t* string, tb_string_t const* s); +tb_char_t const* tb_string_strcpy(tb_string_ref_t string, tb_string_ref_t s); /*! copy c-string * @@ -235,7 +238,7 @@ tb_char_t const* tb_string_strcpy(tb_string_t* string, tb_string_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrcpy(tb_string_t* string, tb_char_t const* s); +tb_char_t const* tb_string_cstrcpy(tb_string_ref_t string, tb_char_t const* s); /*! copy c-string with the given size * @@ -245,7 +248,7 @@ tb_char_t const* tb_string_cstrcpy(tb_string_t* string, tb_char_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrncpy(tb_string_t* string, tb_char_t const* s, tb_size_t n); +tb_char_t const* tb_string_cstrncpy(tb_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! copy format c-string * @@ -254,7 +257,7 @@ tb_char_t const* tb_string_cstrncpy(tb_string_t* string, tb_char_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrfcpy(tb_string_t* string, tb_char_t const* fmt, ...); +tb_char_t const* tb_string_cstrfcpy(tb_string_ref_t string, tb_char_t const* fmt, ...); /*! append charactor * @@ -263,7 +266,7 @@ tb_char_t const* tb_string_cstrfcpy(tb_string_t* string, tb_char_t const* * * @return the c-string */ -tb_char_t const* tb_string_chrcat(tb_string_t* string, tb_char_t c); +tb_char_t const* tb_string_chrcat(tb_string_ref_t string, tb_char_t c); /*! append charactor with the given size * @@ -273,7 +276,7 @@ tb_char_t const* tb_string_chrcat(tb_string_t* string, tb_char_t c); * * @return the c-string */ -tb_char_t const* tb_string_chrncat(tb_string_t* string, tb_char_t c, tb_size_t n); +tb_char_t const* tb_string_chrncat(tb_string_ref_t string, tb_char_t c, tb_size_t n); /*! append string * @@ -282,7 +285,7 @@ tb_char_t const* tb_string_chrncat(tb_string_t* string, tb_char_t c, tb_s * * @return the c-string */ -tb_char_t const* tb_string_strcat(tb_string_t* string, tb_string_t const* s); +tb_char_t const* tb_string_strcat(tb_string_ref_t string, tb_string_ref_t s); /*! append c-string * @@ -291,7 +294,7 @@ tb_char_t const* tb_string_strcat(tb_string_t* string, tb_string_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrcat(tb_string_t* string, tb_char_t const* s); +tb_char_t const* tb_string_cstrcat(tb_string_ref_t string, tb_char_t const* s); /*! append c-string with the given size * @@ -301,7 +304,7 @@ tb_char_t const* tb_string_cstrcat(tb_string_t* string, tb_char_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrncat(tb_string_t* string, tb_char_t const* s, tb_size_t n); +tb_char_t const* tb_string_cstrncat(tb_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! append format c-string * @@ -310,7 +313,7 @@ tb_char_t const* tb_string_cstrncat(tb_string_t* string, tb_char_t const* * * @return the c-string */ -tb_char_t const* tb_string_cstrfcat(tb_string_t* string, tb_char_t const* fmt, ...); +tb_char_t const* tb_string_cstrfcat(tb_string_ref_t string, tb_char_t const* fmt, ...); /*! compare string * @@ -319,7 +322,7 @@ tb_char_t const* tb_string_cstrfcat(tb_string_t* string, tb_char_t const* * * @return equal: 0 */ -tb_long_t tb_string_strcmp(tb_string_t* string, tb_string_t const* s); +tb_long_t tb_string_strcmp(tb_string_ref_t string, tb_string_ref_t s); /*! compare string and ignore case * @@ -328,7 +331,7 @@ tb_long_t tb_string_strcmp(tb_string_t* string, tb_string_t const* * * @return equal: 0 */ -tb_long_t tb_string_strimp(tb_string_t* string, tb_string_t const* s); +tb_long_t tb_string_strimp(tb_string_ref_t string, tb_string_ref_t s); /*! compare c-string * @@ -337,7 +340,7 @@ tb_long_t tb_string_strimp(tb_string_t* string, tb_string_t const* * * @return equal: 0 */ -tb_long_t tb_string_cstrcmp(tb_string_t* string, tb_char_t const* s); +tb_long_t tb_string_cstrcmp(tb_string_ref_t string, tb_char_t const* s); /*! compare c-string and ignore case * @@ -346,7 +349,7 @@ tb_long_t tb_string_cstrcmp(tb_string_t* string, tb_char_t const* * * @return equal: 0 */ -tb_long_t tb_string_cstricmp(tb_string_t* string, tb_char_t const* s); +tb_long_t tb_string_cstricmp(tb_string_ref_t string, tb_char_t const* s); /*! compare c-string with given size * @@ -356,7 +359,7 @@ tb_long_t tb_string_cstricmp(tb_string_t* string, tb_char_t const* * * @return equal: 0 */ -tb_long_t tb_string_cstrncmp(tb_string_t* string, tb_char_t const* s, tb_size_t n); +tb_long_t tb_string_cstrncmp(tb_string_ref_t string, tb_char_t const* s, tb_size_t n); /*! compare c-string with given size and ignore case * @@ -366,7 +369,7 @@ tb_long_t tb_string_cstrncmp(tb_string_t* string, tb_char_t const* * * @return equal: 0 */ -tb_long_t tb_string_cstrnicmp(tb_string_t* string, tb_char_t const* s, tb_size_t n); +tb_long_t tb_string_cstrnicmp(tb_string_ref_t string, tb_char_t const* s, tb_size_t n); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index a1988203a..50b8984a4 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -43,9 +43,6 @@ typedef struct __xm_machine_impl_t // the lua lua_State* lua; - // print verbose info? - tb_bool_t verbose; - }xm_machine_impl_t; /* ////////////////////////////////////////////////////////////////////////////////////// @@ -60,6 +57,9 @@ tb_int_t xm_path_is_absolute(lua_State* lua); // the string functions tb_int_t xm_string_startswith(lua_State* lua); +// the preprocessor functions +tb_int_t xm_preprocessor_load_xproj(lua_State* lua); + /* ////////////////////////////////////////////////////////////////////////////////////// * globals */ @@ -76,8 +76,15 @@ static luaL_Reg const g_path_functions[] = // the string functions static luaL_Reg const g_string_functions[] = { - { "startswith", xm_string_startswith } -, { tb_null, tb_null } + { "startswith", xm_string_startswith } +, { tb_null, tb_null } +}; + +// the preprocessor functions +static luaL_Reg const g_preprocessor_functions[] = +{ + { "load_xproj", xm_preprocessor_load_xproj } +, { tb_null, tb_null } }; /* ////////////////////////////////////////////////////////////////////////////////////// @@ -95,10 +102,6 @@ static tb_bool_t xm_machine_main_save_arguments(xm_machine_impl_t* impl, tb_int_ tb_int_t i = 0; for (i = 1; i < argc; i++) { - // print verbose info - if (!tb_strcmp(argv[i], "-v") || !tb_strcmp(argv[i], "--verbose")) - impl->verbose = tb_true; - // table_new[table.getn(table_new) + 1] = argv[i] lua_pushstring(impl->lua, argv[i]); lua_rawseti(impl->lua, -2, luaL_getn(impl->lua, -2) + 1); @@ -123,8 +126,8 @@ static tb_bool_t xm_machine_main_get_program_directory(xm_machine_impl_t* impl, tb_char_t data[TB_PATH_MAXN] = {0}; if (!tb_environment_get_one("XMAKE_PROGRAM_DIR", data, sizeof(data))) { - // trace - if (impl->verbose) tb_trace_i("please set XMAKE_PROGRAM_DIR first!"); + // error + tb_printf("error: please set XMAKE_PROGRAM_DIR first!\n"); break; } @@ -177,7 +180,7 @@ static tb_bool_t xm_machine_main_get_project_directory(xm_machine_impl_t* impl, } while (0); // failed? - if (!ok && impl->verbose) tb_trace_i("not found the project directory!"); + if (!ok) tb_printf("error: not found the project directory!\n"); // ok? return ok; @@ -210,6 +213,9 @@ xm_machine_ref_t xm_machine_init() // bind string functions luaL_register(impl->lua, "string", g_string_functions); + // bind preprocessor functions + luaL_register(impl->lua, "preprocessor", g_preprocessor_functions); + // init host #if defined(TB_CONFIG_OS_WINDOWS) lua_pushstring(impl->lua, "windows"); @@ -242,9 +248,6 @@ xm_machine_ref_t xm_machine_init() lua_newtable(impl->lua); lua_setglobal(impl->lua, "xmake"); - // init verbose - impl->verbose = tb_false; - // ok ok = tb_true; @@ -295,8 +298,10 @@ tb_int_t xm_machine_main(xm_machine_ref_t machine, tb_int_t argc, tb_char_t** ar // exists this script? if (!tb_file_info(path, tb_null)) { - // trace - if (impl->verbose) tb_trace_i("not found main script: %s", path); + // error + tb_printf("not found main script: %s\n", path); + + // failed return -1; } @@ -306,28 +311,23 @@ tb_int_t xm_machine_main(xm_machine_ref_t machine, tb_int_t argc, tb_char_t** ar // load and execute the main script if (luaL_dofile(impl->lua, path)) { - // trace - if (impl->verbose) tb_trace_i("%s", lua_tostring(impl->lua, -1)); + // error + tb_printf("error: %s\n", lua_tostring(impl->lua, -1)); // failed return -1; } // set the error function - tb_int_t errfunc = 0; - if (impl->verbose) - { - lua_getglobal(impl->lua, "debug"); - lua_getfield(impl->lua, -1, "traceback"); - errfunc = -2; - } + lua_getglobal(impl->lua, "debug"); + lua_getfield(impl->lua, -1, "traceback"); // call the main function lua_getglobal(impl->lua, "_xmake_main"); - if (lua_pcall(impl->lua, 0, 1, errfunc)) + if (lua_pcall(impl->lua, 0, 1, -2)) { - // trace - if (impl->verbose) tb_trace_i("%s", lua_tostring(impl->lua, -1)); + // error + tb_printf("error: %s\n", lua_tostring(impl->lua, -1)); // failed return -1; diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index aaa94682e..20b4706e3 100755 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -17,7 +17,8 @@ xmake_C_FILES += \ path/absolute \ path/translate \ path/is_absolute \ - string/startswith + string/startswith \ + preprocessor/load_xproj # flags diff --git a/core/src/xmake/preprocessor/load_xproj.c b/core/src/xmake/preprocessor/load_xproj.c new file mode 100755 index 000000000..1c03d563a --- /dev/null +++ b/core/src/xmake/preprocessor/load_xproj.c @@ -0,0 +1,133 @@ +/*!The Automatic Cross-platform Build Tool + * + * XMake is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * XMake is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with XMake; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2015, ruki All rights reserved. + * + * @author ruki + * @file load_xproj.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "load_xproj" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * private implementation + */ +static tb_char_t const* xm_preprocessor_load_xproj_to_string(tb_stream_ref_t stream, tb_string_ref_t string) +{ + // check + tb_assert_and_check_return_val(stream && string, tb_null); + + // done + tb_bool_t is_values = tb_false; + while (!tb_stream_beof(stream)) + { + // read character + tb_char_t ch = (tb_char_t)tb_stream_bread_u8(stream); + if (ch) + { + // skip '{' + if (ch == '{') ; + // replace '}' to scopend + else if (ch == '}') tb_string_cstrcat(string, "scopend"); + // enter values? + else if (ch == ':') + { + // values now + is_values = tb_true; + } + // append it + else tb_string_chrcat(string, ch); + } + else + { + // end + break; + } + } + + // ok? + return tb_string_size(string)? tb_string_cstr(string) : tb_null; +} + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_preprocessor_load_xproj(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // get the xmake.xproj path + tb_char_t const* path = luaL_checkstring(lua, 1); + tb_check_return_val(path, 0); + + // done + tb_int_t ok = 0; + tb_stream_ref_t stream = tb_null; + tb_string_t string; + do + { + // init string + if (!tb_string_init(&string)) break; + + // init stream + stream = tb_stream_init_from_file(path, TB_FILE_MODE_RO); + tb_assert_and_check_break(stream); + + // open stream + if (!tb_stream_open(stream)) break; + + // load xmake.xproj to the string and preprocess it + tb_char_t const* xproj = xm_preprocessor_load_xproj_to_string(stream, &string); + tb_assert_and_check_break(xproj); + + tb_trace_i("%s", xproj); + + // load xmake.xproj string to script + if (luaL_loadstring(lua, xproj)) + { + // error + tb_printf("error: %s\n", lua_tostring(lua, -1)); + + // failed + break; + } + + // ok + ok = 1; + + } while (0); + + // exit stream + if (stream) tb_stream_exit(stream); + stream = tb_null; + + // exit string + tb_string_exit(&string); + + // ok? + return ok; +} diff --git a/core/src/xmake/preprocessor/prefix.h b/core/src/xmake/preprocessor/prefix.h new file mode 100644 index 000000000..443833645 --- /dev/null +++ b/core/src/xmake/preprocessor/prefix.h @@ -0,0 +1,35 @@ +/*!The Automatic Cross-platform Build Tool + * + * XMake is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * XMake is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with XMake; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef XM_PREPROCESSOR_PREFIX_H +#define XM_PREPROCESSOR_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "luajit/luajit.h" + + +#endif + + |
