Skip to content

Commit

Permalink
codegen: add testdata with a minimalistic working setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Dec 22, 2024
1 parent 14c865e commit d053079
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/codegen/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all:
mkdir -p output
cd output; \
go run ../.. --verbose --package mypkg --include header.h --preset ..//preset.json -lng -lg -d ../deffinitions.json -e ../structs_and_enums.json -t ../typedefs_dict.json
21 changes: 21 additions & 0 deletions cmd/codegen/testdata/deffinitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"FuncName": {
"ov_cimguiname": "Foo",
"original_func_name": "OrgFoo",
"args": "(A a)",
"argsT": [
{
"name": "a",
"type": "A",
"custom_type": ""
}
],
"defaults": {
"a": "1"
},
"nonUDT": 0,
"comment": "function comment (optional)",
"location": 15
}
}

11 changes: 11 additions & 0 deletions cmd/codegen/testdata/output/callbacks.go

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

14 changes: 14 additions & 0 deletions cmd/codegen/testdata/output/enums.go

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

39 changes: 39 additions & 0 deletions cmd/codegen/testdata/output/funcs.go

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

12 changes: 12 additions & 0 deletions cmd/codegen/testdata/output/structs_accessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.


#include <string.h>
#include "wrapper.h"
#include "structs_accessor.h"

void wrap_B_SetField1(B *BPtr, int v) { BPtr->Field1 = v; }
int wrap_B_GetField1(B *self) { return self->Field1; }
void wrap_B_SetField2(B *BPtr, A v) { BPtr->Field2 = v; }
A wrap_B_GetField2(B *self) { return self->Field2; }
19 changes: 19 additions & 0 deletions cmd/codegen/testdata/output/structs_accessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.

#pragma once

#include "wrapper.h"

#ifdef __cplusplus
extern "C" {
#endif

extern void wrap_B_SetField1(B *BPtr, int v);
extern int wrap_B_GetField1(B *self);
extern void wrap_B_SetField2(B *BPtr, A v);
extern A wrap_B_GetField2(B *self);

#ifdef __cplusplus
}
#endif
6 changes: 6 additions & 0 deletions cmd/codegen/testdata/output/typedefs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.


#include "typedefs.h"
#include "header.h"
37 changes: 37 additions & 0 deletions cmd/codegen/testdata/output/typedefs.go

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

15 changes: 15 additions & 0 deletions cmd/codegen/testdata/output/typedefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.


#pragma once

#include "header.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif
6 changes: 6 additions & 0 deletions cmd/codegen/testdata/output/wrapper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.

#include "wrapper.h"
#include "header.h"

15 changes: 15 additions & 0 deletions cmd/codegen/testdata/output/wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Code generated by cmd/codegen from https://github.com/AllenDang/cimgui-go.
// DO NOT EDIT.

#pragma once

#include "header.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif
13 changes: 13 additions & 0 deletions cmd/codegen/testdata/preset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"PackagePath": "example.com/mypkg",
"TypedefsPoolSize": 32,
"DefaultArgReplace": {
"nullptr": "0",
"NULL": "0",
"((void*)0)": "0"
},
"DefaultArgArbitraryValue": {
"text_end": "0",
"text_end_": "0"
}
}
39 changes: 39 additions & 0 deletions cmd/codegen/testdata/structs_and_enums.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"structs":{
"B":[
{
"name": "Field1",
"type": "int"
},
{
"name": "Field2",
"type": "A"
}
]
},
"struct_comments": {
"B": {
"above": "// this is an example struct"
}
},
"enums": {
"A_": [
{
"calc_value": 0,
"comment": "// A default value of A",
"name": "A_Default",
"value": "0"
},
{
"calc_value": 1,
"name": "A_One",
"value": "1 << 0"
}
]
},
"enum_comments": {
"A_": {
"above": "// this is an example enum"
}
}
}
4 changes: 4 additions & 0 deletions cmd/codegen/testdata/typedefs_dict.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"A": "int",
"B": "struct B"
}

0 comments on commit d053079

Please sign in to comment.