Rename UUID
This commit is contained in:
+3
-3
@@ -16,9 +16,9 @@ struct UUID4 {
|
||||
};
|
||||
|
||||
wp_intern UUID4 generate_uuid4(void);
|
||||
wp_intern void uuid4_to_uuid(const UUID4* uuid4, WUUID *uuid);
|
||||
wp_intern void uuid4_to_uuid(const UUID4* uuid4, WpUuid *uuid);
|
||||
|
||||
WUUID *wapp_uuid_init_uuid4(WUUID *uuid) {
|
||||
WpUuid *wpUuidInitUuid4(WpUuid *uuid) {
|
||||
wpDebugAssert(uuid != NULL, "`uuid` should not be NULL");
|
||||
|
||||
UUID4 uuid4 = generate_uuid4();
|
||||
@@ -47,7 +47,7 @@ wp_intern UUID4 generate_uuid4(void) {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
wp_intern void uuid4_to_uuid(const UUID4* uuid4, WUUID *uuid) {
|
||||
wp_intern void uuid4_to_uuid(const UUID4* uuid4, WpUuid *uuid) {
|
||||
u64 group1 = uuid4->high >> 32;
|
||||
u64 group2 = (uuid4->high << 32) >> 48;
|
||||
u64 group3 = (uuid4->high << 48) >> 48;
|
||||
|
||||
+12
-12
@@ -11,37 +11,37 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define UUID_BUF_LENGTH 48
|
||||
#define WAPP_UUID_SPEC WAPP_STR8_SPEC
|
||||
#define wapp_uuid_varg(WUUID) wapp_str8_varg((WUUID).uuid)
|
||||
#define WP_UUID_BUF_LENGTH 48
|
||||
#define WP_UUID_SPEC WAPP_STR8_SPEC
|
||||
#define wpUuidVarg(WpUuid) wapp_str8_varg((WpUuid).uuid)
|
||||
|
||||
typedef struct WUUID WUUID;
|
||||
struct WUUID {
|
||||
typedef struct WpUuid WpUuid;
|
||||
struct WpUuid {
|
||||
Str8 uuid;
|
||||
};
|
||||
|
||||
// TODO (Abdelrahman): Update UUID implementation to work properly with C++ and tests for validation
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_uuid_gen_uuid4() ([&](){ \
|
||||
wp_persist WUUID uuid = wapp_uuid_create(); \
|
||||
return *(wapp_uuid_init_uuid4(&uuid)); \
|
||||
#define wpUuidGenUuid4() ([&](){ \
|
||||
wp_persist WpUuid uuid = wpUuidCreate(); \
|
||||
return *(wpUuidInitUuid4(&uuid)); \
|
||||
}())
|
||||
#else
|
||||
#define wapp_uuid_gen_uuid4() *(wapp_uuid_init_uuid4(&wapp_uuid_create()))
|
||||
#define wpUuidGenUuid4() *(wpUuidInitUuid4(&wpUuidCreate()))
|
||||
#endif
|
||||
|
||||
/* Low level UUID API */
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wapp_uuid_create() ([&](){ return WUUID{wapp_str8_buf(UUID_BUF_LENGTH)}; }())
|
||||
#define wpUuidCreate() ([&](){ return WpUuid{wapp_str8_buf(WP_UUID_BUF_LENGTH)}; }())
|
||||
#else
|
||||
#define wapp_uuid_create() ((WUUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)})
|
||||
#define wpUuidCreate() ((WpUuid){.uuid = wapp_str8_buf(WP_UUID_BUF_LENGTH)})
|
||||
#endif
|
||||
|
||||
// Just returns the same pointer that was passed in with the UUID initialised.
|
||||
// Fails when passed a NULL pointer.
|
||||
WUUID *wapp_uuid_init_uuid4(WUUID *uuid);
|
||||
WpUuid *wpUuidInitUuid4(WpUuid *uuid);
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
Reference in New Issue
Block a user