Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion crates/cli/src/subcommands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::io::Read;
pub fn cli() -> clap::Command {
clap::Command::new("generate")
.about("Generate client files for a spacetime module.")
.override_usage("spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR>]")
.override_usage("spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR> | --module-prefix <PREFIX>]")
.arg(
Arg::new("wasm_file")
.value_parser(clap::value_parser!(PathBuf))
Expand Down Expand Up @@ -93,6 +93,11 @@ pub fn cli() -> clap::Command {
.help("The module name that should be used for DLL export macros (required for lang unrealcpp)")
.required_if_eq("lang", "unrealcpp")
)
.arg(
Arg::new("module_prefix")
.long("module-prefix")
.help("The module prefix to use for generated types (only used with --lang unrealcpp)")
)
.arg(
Arg::new("lang")
.required(true)
Expand Down Expand Up @@ -135,6 +140,7 @@ pub async fn exec_ex(
let lang = *args.get_one::<Language>("lang").unwrap();
let namespace = args.get_one::<String>("namespace").unwrap();
let module_name = args.get_one::<String>("module_name");
let module_prefix = args.get_one::<String>("module_prefix");
let force = args.get_flag("force");
let build_options = args.get_one::<String>("build_options").unwrap();

Expand Down Expand Up @@ -186,6 +192,7 @@ pub async fn exec_ex(
unreal_cpp_lang = UnrealCpp {
module_name: module_name.as_ref().unwrap(),
uproject_dir: out_dir,
module_prefix: module_prefix.as_ref().map(|s| s.as_str()).unwrap_or(""),
};
&unreal_cpp_lang as &dyn Lang
}
Expand Down
1 change: 1 addition & 0 deletions crates/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spacetimedb-schema.workspace = true
anyhow.workspace = true
convert_case.workspace = true
itertools.workspace = true
serde_json.workspace = true

[dev-dependencies]
fs-err.workspace = true
Expand Down
1,402 changes: 967 additions & 435 deletions crates/codegen/src/unrealcpp.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct TESTCLIENT_API FTestClientOptionalInt32
bool bHasValue = false;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpacetimeDB", meta = (EditCondition = "bHasValue"))
int32 Value;
int32 Value = 0;

FTestClientOptionalInt32() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct TESTCLIENT_API FTestClientOptionalSimpleEnum
bool bHasValue = false;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpacetimeDB", meta = (EditCondition = "bHasValue"))
ESimpleEnumType Value;
ESimpleEnumType Value = static_cast<ESimpleEnumType>(0);

FTestClientOptionalSimpleEnum() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once
#include "CoreMinimal.h"
#include "BSATN/UESpacetimeDB.h"
#include "ModuleBindings/Optionals/TestClientOptionalInt32.g.h"
#include "TestClientOptionalVecOptionalInt32.g.generated.h"

USTRUCT(BlueprintType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ struct TESTCLIENT_API FDeleteLargeTableArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
uint8 A;
uint8 A = 0;

// NOTE: uint16 field not exposed to Blueprint due to non-blueprintable elements
uint16 B;
uint16 B = 0;

// NOTE: uint32 field not exposed to Blueprint due to non-blueprintable elements
uint32 C;
uint32 C = 0;

// NOTE: uint64 field not exposed to Blueprint due to non-blueprintable elements
uint64 D;
uint64 D = 0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
FSpacetimeDBUInt128 E;
Expand All @@ -39,16 +39,16 @@ struct TESTCLIENT_API FDeleteLargeTableArgs
FSpacetimeDBUInt256 F;

// NOTE: int8 field not exposed to Blueprint due to non-blueprintable elements
int8 G;
int8 G = 0;

// NOTE: int16 field not exposed to Blueprint due to non-blueprintable elements
int16 H;
int16 H = 0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 I;
int32 I = 0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int64 J;
int64 J = 0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
FSpacetimeDBInt128 K;
Expand All @@ -57,19 +57,19 @@ struct TESTCLIENT_API FDeleteLargeTableArgs
FSpacetimeDBInt256 L;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
bool M;
bool M = false;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
float N;
float N = 0.0f;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
double O;
double O = 0.0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
FString P;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
ESimpleEnumType Q;
ESimpleEnumType Q = static_cast<ESimpleEnumType>(0);

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
FEnumWithPayloadType R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkBoolArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
bool B;
bool B = false;

FDeletePkBoolArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkI16Args
GENERATED_BODY()

// NOTE: int16 field not exposed to Blueprint due to non-blueprintable elements
int16 N;
int16 N = 0;

FDeletePkI16Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkI32Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 N;
int32 N = 0;

FDeletePkI32Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkI64Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int64 N;
int64 N = 0;

FDeletePkI64Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkI8Args
GENERATED_BODY()

// NOTE: int8 field not exposed to Blueprint due to non-blueprintable elements
int8 N;
int8 N = 0;

FDeletePkI8Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkU16Args
GENERATED_BODY()

// NOTE: uint16 field not exposed to Blueprint due to non-blueprintable elements
uint16 N;
uint16 N = 0;

FDeletePkU16Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkU32Args
GENERATED_BODY()

// NOTE: uint32 field not exposed to Blueprint due to non-blueprintable elements
uint32 N;
uint32 N = 0;

FDeletePkU32Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ struct TESTCLIENT_API FDeletePkU32InsertPkU32TwoArgs
GENERATED_BODY()

// NOTE: uint32 field not exposed to Blueprint due to non-blueprintable elements
uint32 N;
uint32 N = 0;

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 Data;
int32 Data = 0;

FDeletePkU32InsertPkU32TwoArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkU32TwoArgs
GENERATED_BODY()

// NOTE: uint32 field not exposed to Blueprint due to non-blueprintable elements
uint32 N;
uint32 N = 0;

FDeletePkU32TwoArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkU64Args
GENERATED_BODY()

// NOTE: uint64 field not exposed to Blueprint due to non-blueprintable elements
uint64 N;
uint64 N = 0;

FDeletePkU64Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeletePkU8Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
uint8 N;
uint8 N = 0;

FDeletePkU8Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueBoolArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
bool B;
bool B = false;

FDeleteUniqueBoolArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueI16Args
GENERATED_BODY()

// NOTE: int16 field not exposed to Blueprint due to non-blueprintable elements
int16 N;
int16 N = 0;

FDeleteUniqueI16Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueI32Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 N;
int32 N = 0;

FDeleteUniqueI32Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueI64Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int64 N;
int64 N = 0;

FDeleteUniqueI64Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueI8Args
GENERATED_BODY()

// NOTE: int8 field not exposed to Blueprint due to non-blueprintable elements
int8 N;
int8 N = 0;

FDeleteUniqueI8Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueU16Args
GENERATED_BODY()

// NOTE: uint16 field not exposed to Blueprint due to non-blueprintable elements
uint16 N;
uint16 N = 0;

FDeleteUniqueU16Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueU32Args
GENERATED_BODY()

// NOTE: uint32 field not exposed to Blueprint due to non-blueprintable elements
uint32 N;
uint32 N = 0;

FDeleteUniqueU32Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueU64Args
GENERATED_BODY()

// NOTE: uint64 field not exposed to Blueprint due to non-blueprintable elements
uint64 N;
uint64 N = 0;

FDeleteUniqueU64Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FDeleteUniqueU8Args
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
uint8 N;
uint8 N = 0;

FDeleteUniqueU8Args() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FInsertCallerPkConnectionIdArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 Data;
int32 Data = 0;

FInsertCallerPkConnectionIdArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FInsertCallerPkIdentityArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 Data;
int32 Data = 0;

FInsertCallerPkIdentityArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FInsertCallerUniqueConnectionIdArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 Data;
int32 Data = 0;

FInsertCallerUniqueConnectionIdArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TESTCLIENT_API FInsertCallerUniqueIdentityArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
int32 Data;
int32 Data = 0;

FInsertCallerUniqueIdentityArgs() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct TESTCLIENT_API FInsertIntoIndexedSimpleEnumArgs
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
ESimpleEnumType N;
ESimpleEnumType N = static_cast<ESimpleEnumType>(0);

FInsertIntoIndexedSimpleEnumArgs() = default;

Expand Down
Loading
Loading