Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Update generator to blacklist internal structs and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisDevDane committed Aug 18, 2020
1 parent 9d0f09a commit 588e7d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 56 deletions.
12 changes: 8 additions & 4 deletions generator_v2/function_output.odin
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,8 @@ gather_foreign_proc_groups :: proc(groups : ^[dynamic]Foreign_Func_Group, obj: j

for ov in overloads {
ov_obj := ov.value.(json.Object);
// if is_nonUDT(ov_obj) do continue;
if is_vector(ov_obj) do continue;
if is_pool(ov_obj) do continue;
if is_chunk_stream(ov_obj) do continue;
if is_bit_vector(ov_obj) do continue;
if is_internal(ov_obj) do continue;
if is_ctor_dtor(ov_obj) do continue;

f, ok := convert_json_to_foreign_func(ov_obj);
Expand Down Expand Up @@ -399,6 +396,13 @@ is_nonUDT :: proc(obj: json.Object) -> bool {
return ok == true;
}

@(private="file")
is_internal :: proc(obj: json.Object) -> bool {
v, ok := obj["location"];
if ok == false do return false;
return get_value_string(v) == "internal";
}

@(private="file")
convert_json_to_foreign_func :: proc(ov_obj: json.Object) -> (Foreign_Func, bool) {
f := Foreign_Func{};
Expand Down
9 changes: 9 additions & 0 deletions generator_v2/main.odin
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,17 @@ output_structs :: proc(json_path: string, output_path: string, predefined_entite

{ // Gather
obj := js.value.(json.Object);
blacklist : map[string]bool;
for k, v in obj["locations"].value.(json.Object) {
location := get_value_string(v);
if location == "internal" do blacklist[k] = true;
}

for k, v in obj["structs"].value.(json.Object) {
def := Struct_Definition{};

if _, ok := blacklist[k]; ok do continue;

def.name = k;

for x in v.value.(json.Array) {
Expand Down
63 changes: 11 additions & 52 deletions generator_v2/predefined/imgui_predefined.odin
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ package predefined;

// ///////////////////////////
// // Predefined structs

@output_copy
Im_Chunk_Stream :: struct(T : typeid) {
buf: Im_Vector(T),
}
Draw_List_Shared_Data :: opaque struct {};
@output_copy
Context :: opaque struct {};

@output_copy
Im_Vector :: struct(T : typeid) {
Expand All @@ -34,48 +35,6 @@ Im_Vector :: struct(T : typeid) {
data: ^T,
}

@output_copy
Im_Pool :: struct(T : typeid) {
buf: Im_Vector(T),
map_: Storage,
free_idx: i32,
}

@output_copy
STB_Textedit_State :: struct {
cursor: i32,
select_start: i32,
select_end: i32,
insert_mode: u8,
cursor_at_end_of_line: u8,
initialized: u8,
has_preferred_x: u8,
single_line: u8,
padding1: u8,
padding2: u8,
padding3: u8,
preferred_x: f32,
undo_state: STB_Undo_State,
}

@output_copy
STB_Undo_State :: struct {
undo_rec: [99]STB_Undo_Record,
undo_char: [999]Wchar,
undo_point: i16,
redo_point: i16,
undo_char_point: i32,
redo_char_point: i32,
}

@output_copy
STB_Undo_Record :: struct {
where_: i32,
insert_length: i32,
delete_length: i32,
char_storage: i32,
}

@(struct_overwrite="ImGuiStyleMod")
Style_Mod :: struct {
var_idx: Style_Var,
Expand Down Expand Up @@ -220,13 +179,13 @@ wrapper_combo_str_arr :: proc(label: string, current_item: ^i32, items: []string
return igComboStr_arr(l, current_item, &data[0], i32(len(items)), popup_max_height_in_items);
}

@(wrapper="igTextEx")
wrapper_text_ex :: proc(text: string, flags := Text_Flags(0)) {
t := strings.clone_to_cstring(text, context.temp_allocator);
ptr := transmute(^u8)t;
end_ptr := mem.ptr_offset(ptr, len(t));
igTextEx(cstring(ptr), cstring(end_ptr), flags);
}
// @(wrapper="igTextEx")
// wrapper_text_ex :: proc(text: string, flags := Text_Flags(0)) {
// t := strings.clone_to_cstring(text, context.temp_allocator);
// ptr := transmute(^u8)t;
// end_ptr := mem.ptr_offset(ptr, len(t));
// igTextEx(cstring(ptr), cstring(end_ptr), flags);
// }

@(wrapper="igTextWrapped")
wrapper_text_wrapped :: proc(fmt_: string, args: ..any) {
Expand Down

0 comments on commit 588e7d5

Please sign in to comment.