From e75919476c3f0c5b18ad56ac17d05a47c3a9cce1 Mon Sep 17 00:00:00 2001 From: tqfx Date: Tue, 3 Sep 2024 12:35:26 +0800 Subject: [PATCH] rename a_version.alpha to a_version.alpha_ --- include/a/version.h | 10 +++++----- java/src/version.c | 6 +++--- javascript/src/liba.cc | 12 ++++++------ lua/src/version.c | 10 +++++----- python/src/a/version.pxd | 2 +- python/src/liba.pyx | 2 +- quickjs/src/version.c | 4 ++-- src/version.c | 18 +++++++++--------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/a/version.h b/include/a/version.h index 7695f20..6286d64 100644 --- a/include/a/version.h +++ b/include/a/version.h @@ -189,15 +189,15 @@ struct a_version unsigned int minor; //!< minor number unsigned int third; //!< third number unsigned int extra; //!< extra number - char alpha[4]; //!< alphabet + char alpha_[4]; //!< alphabet #if defined(__cplusplus) - A_INLINE void set_alpha(char const *str) + A_INLINE void alpha(char str[5]) const { - a_version_set_alpha(this, str); + a_version_alpha(this, str); } - A_INLINE void get_alpha(char str[5]) const + A_INLINE void set_alpha(char const *str) { - a_version_alpha(this, str); + a_version_set_alpha(this, str); } A_INLINE unsigned int parse(char const *ver) { diff --git a/java/src/version.c b/java/src/version.c index 639b25f..369e50e 100644 --- a/java/src/version.c +++ b/java/src/version.c @@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_liba_version_init__Ljava_lang_String_2(JNIEnv *Env, jobject Ctx = (*Env)->CallObjectMethod(Env, Obj, L.New, (jint)sizeof(a_version)); a_version *ctx = (a_version *)(*Env)->GetDirectBufferAddress(Env, Ctx); char const *ver = (*Env)->GetStringUTFChars(Env, Ver, NULL); - ctx->alpha[0] = '.'; + ctx->alpha_[0] = '.'; a_version_parse(ctx, ver); (*Env)->ReleaseStringUTFChars(Env, Ver, ver); } @@ -40,7 +40,7 @@ JNIEXPORT void JNICALL Java_liba_version_init__IIII(JNIEnv *Env, jobject Obj, ji ctx->minor = (unsigned int)minor; ctx->third = (unsigned int)third; ctx->extra = (unsigned int)extra; - ctx->alpha[0] = '.'; + ctx->alpha_[0] = '.'; } JNIEXPORT jint JNICALL Java_liba_version_check(JNIEnv *Env, jclass Cls, jint major, jint minor, jint patch) @@ -121,7 +121,7 @@ JNIEXPORT jstring JNICALL Java_liba_version_alpha__(JNIEnv *Env, jobject Obj) { jobject Ctx = (*Env)->GetObjectField(Env, Obj, L.ctx); a_version *ctx = (a_version *)(*Env)->GetDirectBufferAddress(Env, Ctx); - char alpha[sizeof(ctx->alpha) + 1]; + char alpha[sizeof(ctx->alpha_) + 1]; a_version_alpha(ctx, alpha); return (*Env)->NewStringUTF(Env, alpha); } diff --git a/javascript/src/liba.cc b/javascript/src/liba.cc index c6aa332..02cc2d8 100644 --- a/javascript/src/liba.cc +++ b/javascript/src/liba.cc @@ -863,10 +863,10 @@ struct version: public a_version minor = minor_; third = third_; extra = extra_; - alpha[0] = '.'; - alpha[1] = 0; - alpha[2] = 0; - alpha[3] = 0; + alpha_[0] = '.'; + alpha_[1] = 0; + alpha_[2] = 0; + alpha_[3] = 0; } A_INLINE void major_w(unsigned int major_) { major = major_; } A_INLINE unsigned int major_r() const { return major; } @@ -882,8 +882,8 @@ struct version: public a_version } A_INLINE std::string alpha_r() const { - char str[sizeof(alpha) + 1]; - a_version::get_alpha(str); + char str[sizeof(alpha_) + 1]; + a_version::alpha(str); return std::string(str); } static unsigned int const MAJOR; diff --git a/lua/src/version.c b/lua/src/version.c index 3766271..8fa6ed1 100644 --- a/lua/src/version.c +++ b/lua/src/version.c @@ -21,10 +21,10 @@ static int liba_version_tostring(lua_State *L) static int liba_version_init_(lua_State *L, a_version *ctx, int arg, int top) { - ctx->alpha[0] = '.'; - ctx->alpha[1] = 0; - ctx->alpha[2] = 0; - ctx->alpha[3] = 0; + ctx->alpha_[0] = '.'; + ctx->alpha_[1] = 0; + ctx->alpha_[2] = 0; + ctx->alpha_[3] = 0; switch (top) { default: @@ -276,7 +276,7 @@ static int liba_version_get(lua_State *L) break; case 0xB5485B9E: // alpha { - char alpha[sizeof(ctx->alpha) + 1]; + char alpha[sizeof(ctx->alpha_) + 1]; a_version_alpha(ctx, alpha); lua_pushstring(L, alpha); break; diff --git a/python/src/a/version.pxd b/python/src/a/version.pxd index 1ba19d6..6a06198 100644 --- a/python/src/a/version.pxd +++ b/python/src/a/version.pxd @@ -11,7 +11,7 @@ cdef extern from "a/version.h": unsigned int minor unsigned int third unsigned int extra - char[4] alpha + char[4] alpha_ int a_version_check(unsigned int major, unsigned int minor, unsigned int patch) unsigned int a_version_tostr(const a_version *ctx, void *pdata, a_size nbyte) unsigned int a_version_parse(a_version *ctx, const char *ver) diff --git a/python/src/liba.pyx b/python/src/liba.pyx index 6d69321..0e58b8b 100644 --- a/python/src/liba.pyx +++ b/python/src/liba.pyx @@ -1340,7 +1340,7 @@ cdef class version: self.ctx.minor = minor self.ctx.third = third self.ctx.extra = extra - self.ctx.alpha[0] = 46 + self.ctx.alpha_[0] = 46 def __repr__(self): cdef char[48] str a_version_tostr(&self.ctx, str, sizeof(str)) diff --git a/quickjs/src/version.c b/quickjs/src/version.c index e55548e..f82b34d 100644 --- a/quickjs/src/version.c +++ b/quickjs/src/version.c @@ -30,7 +30,7 @@ static JSValue liba_version_ctor(JSContext *ctx, JSValueConst new_target, int ar goto fail; } } - self->alpha[0] = '.'; + self->alpha_[0] = '.'; if (ver) { a_version_parse(self, ver); @@ -176,7 +176,7 @@ static JSValue liba_version_get(JSContext *ctx, JSValueConst this_val, int magic if (!self) { return JS_EXCEPTION; } if (magic == self_alpha) { - char alpha[sizeof(self->alpha) + 1]; + char alpha[sizeof(self->alpha_) + 1]; a_version_alpha(self, alpha); return JS_NewString(ctx, alpha); } diff --git a/src/version.c b/src/version.c index 01dd5f6..28a8d82 100644 --- a/src/version.c +++ b/src/version.c @@ -90,18 +90,18 @@ a_bool a_version_ne(a_version const *lhs, a_version const *rhs) static A_INLINE char const *a_version_set_alpha_(a_version *ctx, char const *alpha) { unsigned int c = 1; - ctx->alpha[0] = *alpha; + ctx->alpha_[0] = *alpha; for (++alpha; isalpha((a_byte)*alpha); ++alpha) { - if (c < sizeof(ctx->alpha)) { ctx->alpha[c++] = *alpha; } + if (c < sizeof(ctx->alpha_)) { ctx->alpha_[c++] = *alpha; } } if (*alpha == '.') { - if (c < sizeof(ctx->alpha)) { ctx->alpha[c++] = *alpha; } - else { ctx->alpha[c - 1] = *alpha; } + if (c < sizeof(ctx->alpha_)) { ctx->alpha_[c++] = *alpha; } + else { ctx->alpha_[c - 1] = *alpha; } ++alpha; } - while (c < sizeof(ctx->alpha)) { ctx->alpha[c++] = 0; } + while (c < sizeof(ctx->alpha_)) { ctx->alpha_[c++] = 0; } return alpha; } @@ -152,9 +152,9 @@ extra: void a_version_alpha(a_version const *ctx, char alpha[5]) { unsigned int c; - for (c = 0; c < sizeof(ctx->alpha) && ctx->alpha[c]; ++c) + for (c = 0; c < sizeof(ctx->alpha_) && ctx->alpha_[c]; ++c) { - alpha[c] = ctx->alpha[c]; + alpha[c] = ctx->alpha_[c]; } alpha[c] = 0; } @@ -163,8 +163,8 @@ unsigned int a_version_tostr(a_version const *ctx, void *pdata, a_size nbyte) { int n; char *p = (char *)pdata; - char alpha[sizeof(ctx->alpha) + 1]; - if (ctx->extra || isalpha((a_byte)ctx->alpha[0]) || isalpha((a_byte)ctx->alpha[1])) + char alpha[sizeof(ctx->alpha_) + 1]; + if (ctx->extra || isalpha((a_byte)ctx->alpha_[0]) || isalpha((a_byte)ctx->alpha_[1])) { a_version_alpha(ctx, alpha); n = snprintf(p, nbyte, "%u.%u.%u%s%u", -- 2.11.4.GIT