fixes for running GasaGen more than once in editor
This commit is contained in:
parent
c895772cff
commit
3109ea4641
@ -7,7 +7,6 @@ USTRUCT()
|
|||||||
struct GASA_API FGasaDevOptionsCache
|
struct GASA_API FGasaDevOptionsCache
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TArray<UObject*> AttributeSets;
|
TArray<UObject*> AttributeSets;
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
@ -30,14 +30,7 @@ void Execute_GasaModule_Codegen()
|
|||||||
{
|
{
|
||||||
Gasa::LogEditor("Executing: Gasa Module code generation.");
|
Gasa::LogEditor("Executing: Gasa Module code generation.");
|
||||||
|
|
||||||
if (gen_ctx.Allocator_Temp.Proc) {
|
gen::init( & gen_ctx);
|
||||||
gen::reset(& gen_ctx);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gen::init( & gen_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
|
FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
|
||||||
FPaths::NormalizeDirectoryName(ue_project_path);
|
FPaths::NormalizeDirectoryName(ue_project_path);
|
||||||
char const* ue_ansi_project_path = TCHAR_TO_ANSI(*ue_project_path);
|
char const* ue_ansi_project_path = TCHAR_TO_ANSI(*ue_project_path);
|
||||||
@ -137,6 +130,8 @@ void Execute_GasaModule_Codegen()
|
|||||||
// generate_HostWidgetController();
|
// generate_HostWidgetController();
|
||||||
change_SBlueprintActionMenu_Construct();
|
change_SBlueprintActionMenu_Construct();
|
||||||
change_EditorContentList();
|
change_EditorContentList();
|
||||||
|
|
||||||
|
gen::deinit( & gen_ctx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3401,6 +3401,9 @@ void deinit(Context* ctx)
|
|||||||
if (_ctx == ctx)
|
if (_ctx == ctx)
|
||||||
_ctx = nullptr;
|
_ctx = nullptr;
|
||||||
-- context_counter;
|
-- context_counter;
|
||||||
|
|
||||||
|
Context wipe = {};
|
||||||
|
* ctx = wipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context* get_context() {
|
Context* get_context() {
|
||||||
@ -12940,9 +12943,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
char const* buf_begin = buf;
|
char const* buf_begin = buf;
|
||||||
ssize remaining = buf_size;
|
ssize remaining = buf_size;
|
||||||
|
|
||||||
local_persist StringTable tok_map;
|
if (_ctx->token_fmt_map.Hashes == nullptr) {
|
||||||
do_once() {
|
_ctx->token_fmt_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
||||||
tok_map = hashtable_init(Str, _ctx->Allocator_DyanmicContainers );
|
|
||||||
}
|
}
|
||||||
// Populate token pairs
|
// Populate token pairs
|
||||||
{
|
{
|
||||||
@ -12954,7 +12956,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
Str value = va_arg( va, Str );
|
Str value = va_arg( va, Str );
|
||||||
|
|
||||||
u32 key = crc32( token, c_str_len(token) );
|
u32 key = crc32( token, c_str_len(token) );
|
||||||
hashtable_set( tok_map, key, value );
|
hashtable_set( _ctx->token_fmt_map, key, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12989,8 +12991,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
|
|
||||||
char const* token = fmt + 1;
|
char const* token = fmt + 1;
|
||||||
|
|
||||||
u32 key = crc32( token, tok_len );
|
u32 key = crc32( token, tok_len );
|
||||||
Str* value = hashtable_get(tok_map, key );
|
Str* value = hashtable_get(_ctx->token_fmt_map, key );
|
||||||
|
|
||||||
if ( value )
|
if ( value )
|
||||||
{
|
{
|
||||||
@ -13019,7 +13021,7 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va )
|
|||||||
current = * fmt;
|
current = * fmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hashtable_clear(tok_map);
|
hashtable_clear(_ctx->token_fmt_map);
|
||||||
ssize result = buf_size - remaining;
|
ssize result = buf_size - remaining;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -267,13 +267,15 @@ GEN_NS_BEGIN
|
|||||||
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define src_line_str stringize( __LINE__ )
|
||||||
|
|
||||||
#ifndef do_once
|
#ifndef do_once
|
||||||
#define do_once() \
|
#define do_once() \
|
||||||
static int __do_once_counter_##__LINE__ = 0; \
|
static int __do_once_counter_##src_line_str = 0; \
|
||||||
for ( ; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1 )
|
for ( ; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1 )
|
||||||
#define do_once_defer( expression ) \
|
#define do_once_defer( expression ) \
|
||||||
static int __do_once_counter_##__LINE__ = 0; \
|
static int __do_once_counter_##src_line_str = 0; \
|
||||||
for ( ; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1, ( expression ) )
|
for ( ; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1, ( expression ) )
|
||||||
#define do_once_start \
|
#define do_once_start \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
@ -3968,6 +3968,8 @@ struct Context
|
|||||||
u32 InitSize_Fallback_Allocator_Bucket_Size;
|
u32 InitSize_Fallback_Allocator_Bucket_Size;
|
||||||
Array(Arena) Fallback_AllocatorBuckets;
|
Array(Arena) Fallback_AllocatorBuckets;
|
||||||
|
|
||||||
|
StringTable token_fmt_map;
|
||||||
|
|
||||||
// Array(Token) LexerTokens;
|
// Array(Token) LexerTokens;
|
||||||
|
|
||||||
Array(Pool) CodePools;
|
Array(Pool) CodePools;
|
||||||
@ -4270,12 +4272,20 @@ GEN_API Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... );
|
|||||||
#ifndef name
|
#ifndef name
|
||||||
// Convienence for defining any name used with the gen api.
|
// Convienence for defining any name used with the gen api.
|
||||||
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
||||||
#define name( Id_ ) { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
# if GEN_COMPILER_C
|
||||||
|
# define name( Id_ ) (Str){ stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
||||||
|
# else
|
||||||
|
# define name( Id_ ) Str { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef code
|
#ifndef code
|
||||||
// Same as name just used to indicate intention of literal for code instead of names.
|
// Same as name just used to indicate intention of literal for code instead of names.
|
||||||
#define code( ... ) { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
# if GEN_COMPILER_C
|
||||||
|
# define code( ... ) (Str){ stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
||||||
|
# else
|
||||||
|
# define code( ... ) Str { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef args
|
#ifndef args
|
||||||
|
Loading…
Reference in New Issue
Block a user