Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding associated enums #28

Merged
merged 7 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add rondpoint test
Signed-off-by: Martynas Gurskas <[email protected]>
Lipt0nas committed Feb 29, 2024

Verified

This commit was signed with the committer’s verified signature.
Lipt0nas Martynas Gurskas
commit 0769a44ef024bda120d12abdf8131cc18126a86d
2 changes: 1 addition & 1 deletion cpp-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ scaffolding_test_case(fixture_callbacks)
scaffolding_test_case(chronological)
# scaffolding_test_case(custom_types)
scaffolding_test_case(geometry)
# scaffolding_test_case(rondpoint)
scaffolding_test_case(rondpoint)
scaffolding_test_case(sprites)
scaffolding_test_case(todolist)
scaffolding_test_case(traits)
233 changes: 233 additions & 0 deletions cpp-tests/scaffolding_tests/rondpoint/lib_rondpoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#include "lib_rondpoint.hpp"

int8_t rondpoint::Retourneur::identique_i8(int8_t value) {
return value;
}

uint8_t rondpoint::Retourneur::identique_u8(uint8_t value) {
return value;
}

int16_t rondpoint::Retourneur::identique_i16(int16_t value) {
return value;
}

uint16_t rondpoint::Retourneur::identique_u16(uint16_t value) {
return value;
}

int32_t rondpoint::Retourneur::identique_i32(int32_t value) {
return value;
}

uint32_t rondpoint::Retourneur::identique_u32(uint32_t value) {
return value;
}

int64_t rondpoint::Retourneur::identique_i64(int64_t value) {
return value;
}

uint64_t rondpoint::Retourneur::identique_u64(uint64_t value) {
return value;
}

float rondpoint::Retourneur::identique_float(float value) {
return value;
}

double rondpoint::Retourneur::identique_double(double value) {
return value;
}

bool rondpoint::Retourneur::identique_boolean(bool value) {
return value;
}

std::string rondpoint::Retourneur::identique_string(std::string value) {
return value;
}

rondpoint::DictionnaireNombresSignes rondpoint::Retourneur::identique_nombres_signes(DictionnaireNombresSignes value) {
return value;
}

rondpoint::DictionnaireNombres rondpoint::Retourneur::identique_nombres(DictionnaireNombres value) {
return value;
}

rondpoint::OptionneurDictionnaire rondpoint::Retourneur::identique_optionneur_dictionnaire(OptionneurDictionnaire value) {
return value;
}


std::string rondpoint::Stringifier::well_known_string(std::string value) {
return "uniffi 💚 " + value + "!";
}

std::string rondpoint::Stringifier::to_string_i8(int8_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_u8(uint8_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_i16(int16_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_u16(uint16_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_i32(int32_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_u32(uint32_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_i64(int64_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_u64(uint64_t value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_float(float value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_double(double value) {
return std::to_string(value);
}

std::string rondpoint::Stringifier::to_string_boolean(bool value) {
return value ? "true" : "false";
}


bool rondpoint::Optionneur::sinon_boolean(bool value) {
return value;
}

std::string rondpoint::Optionneur::sinon_string(std::string value) {
return value;
}

std::vector<std::string> rondpoint::Optionneur::sinon_sequence(std::vector<std::string> value) {
return value;
}

std::optional<std::string> rondpoint::Optionneur::sinon_null(std::optional<std::string> value) {
return value;
}

std::optional<int32_t> rondpoint::Optionneur::sinon_zero(std::optional<int32_t> value) {
return value;
}

uint8_t rondpoint::Optionneur::sinon_u8_dec(uint8_t value) {
return value;
}

int8_t rondpoint::Optionneur::sinon_i8_dec(int8_t value) {
return value;
}

uint16_t rondpoint::Optionneur::sinon_u16_dec(uint16_t value) {
return value;
}

int16_t rondpoint::Optionneur::sinon_i16_dec(int16_t value) {
return value;
}

uint32_t rondpoint::Optionneur::sinon_u32_dec(uint32_t value) {
return value;
}

int32_t rondpoint::Optionneur::sinon_i32_dec(int32_t value) {
return value;
}

uint64_t rondpoint::Optionneur::sinon_u64_dec(uint64_t value) {
return value;
}

int64_t rondpoint::Optionneur::sinon_i64_dec(int64_t value) {
return value;
}

uint8_t rondpoint::Optionneur::sinon_u8_hex(uint8_t value) {
return value;
}

int8_t rondpoint::Optionneur::sinon_i8_hex(int8_t value) {
return value;
}

uint16_t rondpoint::Optionneur::sinon_u16_hex(uint16_t value) {
return value;
}

int16_t rondpoint::Optionneur::sinon_i16_hex(int16_t value) {
return value;
}

uint32_t rondpoint::Optionneur::sinon_u32_hex(uint32_t value) {
return value;
}

int32_t rondpoint::Optionneur::sinon_i32_hex(int32_t value) {
return value;
}

uint64_t rondpoint::Optionneur::sinon_u64_hex(uint64_t value) {
return value;
}

int64_t rondpoint::Optionneur::sinon_i64_hex(int64_t value) {
return value;
}

uint32_t rondpoint::Optionneur::sinon_u32_oct(uint32_t value) {
return value;
}

float rondpoint::Optionneur::sinon_f32(float value) {
return value;
}

double rondpoint::Optionneur::sinon_f64(double value) {
return value;
}

rondpoint::Enumeration rondpoint::Optionneur::sinon_enum(Enumeration value) {
return value;
}

rondpoint::Dictionnaire rondpoint::copie_dictionnaire(Dictionnaire d) {
return d;
}

rondpoint::Enumeration rondpoint::copie_enumeration(Enumeration e) {
return e;
}

std::vector<rondpoint::Enumeration> rondpoint::copie_enumerations(std::vector<Enumeration> e) {
return e;
}

std::unordered_map<std::string, rondpoint::EnumerationAvecDonnees> rondpoint::copie_carte(std::unordered_map<std::string, EnumerationAvecDonnees> c) {
return c;
}

bool rondpoint::switcheroo(bool b) {
return !b;
}

#include <rondpoint_cpp_scaffolding.cpp>
192 changes: 192 additions & 0 deletions cpp-tests/scaffolding_tests/rondpoint/lib_rondpoint.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#include <string>
#include <cstdint>
#include <vector>
#include <optional>
#include <variant>
#include <unordered_map>

namespace {
namespace rondpoint {
struct MinusculeMajusculeDict {
bool minuscule_majuscule_field;
};

enum class MinusculeMajusculeEnum {
MINUSCULE_MAJUSCULE_VARIANT
};

enum class Enumeration {
UN,
DEUX,
TROIS
};

class EnumerationAvecDonnees {
public:
struct ZERO {};
struct UN {
uint32_t premier;
};
struct DEUX {
uint32_t premier;
std::string second;
};

EnumerationAvecDonnees(EnumerationAvecDonnees::ZERO variant) { this->variant = variant; }
EnumerationAvecDonnees(EnumerationAvecDonnees::UN variant) { this->variant = variant; }
EnumerationAvecDonnees(EnumerationAvecDonnees::DEUX variant) { this->variant = variant; }


std::variant<ZERO, UN, DEUX> variant;
};

struct Dictionnaire {
Enumeration un;
bool deux;
uint8_t petit_nombre;
uint64_t gros_nombre;
};

struct DictionnaireNombres {
uint8_t petit_nombre;
uint16_t court_nombre;
uint32_t nombre_simple;
uint64_t gros_nombre;
};

struct DictionnaireNombresSignes {
int8_t petit_nombre;
int16_t court_nombre;
int32_t nombre_simple;
int64_t gros_nombre;
};

struct OptionneurDictionnaire {
int8_t i8_var = -8;
uint8_t u8_var = 8;

int16_t i16_var = -0x10;
uint16_t u16_var = 0x10;

int32_t i32_var = -32;
uint32_t u32_var = 32;

int64_t i64_var = -64;
uint64_t u64_var = 64;

float float_var = 4.0f;
double double_var = 8.0;

bool boolean_var = true;

std::string string_var = "default";
std::vector<std::string> list_var = {};

Enumeration enumeration_var = Enumeration::DEUX;
std::optional<MinusculeMajusculeEnum> dictionnaire_var = std::nullopt;
};

class Retourneur {
public:
Retourneur() = default;

int8_t identique_i8(int8_t value);
uint8_t identique_u8(uint8_t value);

int16_t identique_i16(int16_t value);
uint16_t identique_u16(uint16_t value);

int32_t identique_i32(int32_t value);
uint32_t identique_u32(uint32_t value);

int64_t identique_i64(int64_t value);
uint64_t identique_u64(uint64_t value);

float identique_float(float value);
double identique_double(double value);

bool identique_boolean(bool value);

std::string identique_string(std::string value);

DictionnaireNombresSignes identique_nombres_signes(DictionnaireNombresSignes value);
DictionnaireNombres identique_nombres(DictionnaireNombres value);
OptionneurDictionnaire identique_optionneur_dictionnaire(OptionneurDictionnaire value);
};

class Stringifier {
public:
Stringifier() = default;

std::string well_known_string(std::string value);

std::string to_string_i8(int8_t value);
std::string to_string_u8(uint8_t value);

std::string to_string_i16(int16_t value);
std::string to_string_u16(uint16_t value);

std::string to_string_i32(int32_t value);
std::string to_string_u32(uint32_t value);

std::string to_string_i64(int64_t value);
std::string to_string_u64(uint64_t value);

std::string to_string_float(float value);
std::string to_string_double(double value);
std::string to_string_boolean(bool value);
};

class Optionneur {
public:
Optionneur() = default;

bool sinon_boolean(bool value);
std::string sinon_string(std::string value);

std::vector<std::string> sinon_sequence(std::vector<std::string> value);

std::optional<std::string> sinon_null(std::optional<std::string> value);
std::optional<int32_t> sinon_zero(std::optional<int32_t> value);

uint8_t sinon_u8_dec(uint8_t value);
int8_t sinon_i8_dec(int8_t value);

uint16_t sinon_u16_dec(uint16_t value);
int16_t sinon_i16_dec(int16_t value);

uint32_t sinon_u32_dec(uint32_t value);
int32_t sinon_i32_dec(int32_t value);

uint64_t sinon_u64_dec(uint64_t value);
int64_t sinon_i64_dec(int64_t value);

uint8_t sinon_u8_hex(uint8_t value);
int8_t sinon_i8_hex(int8_t value);

uint16_t sinon_u16_hex(uint16_t value);
int16_t sinon_i16_hex(int16_t value);

uint32_t sinon_u32_hex(uint32_t value);
int32_t sinon_i32_hex(int32_t value);

uint64_t sinon_u64_hex(uint64_t value);
int64_t sinon_i64_hex(int64_t value);

uint32_t sinon_u32_oct(uint32_t value);

float sinon_f32(float value);
double sinon_f64(double value);

Enumeration sinon_enum(Enumeration value);
};

Dictionnaire copie_dictionnaire(Dictionnaire d);
Enumeration copie_enumeration(Enumeration e);

std::vector<Enumeration> copie_enumerations(std::vector<Enumeration> e);
std::unordered_map<std::string, EnumerationAvecDonnees> copie_carte(std::unordered_map<std::string, EnumerationAvecDonnees> c);

bool switcheroo(bool b);
}
}