Skip to content

Commit 9e29f40

Browse files
committed
All classes must be specified in .yml file now
- This is because the generator will need to know that a trampoline is potentially being generated only by parsing pyproject.toml/autogen yaml
1 parent ecfa0eb commit 9e29f40

36 files changed

+303
-15
lines changed

examples/demo/gen/demo.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
functions:
4+
add2:
5+
classes:
6+
DemoClass:
7+
methods:
8+
setX:
9+
getX:

robotpy_build/autowrap/cxxparser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,15 @@ def on_class_start(self, state: AWClassBlockState) -> typing.Optional[bool]:
587587
return False
588588

589589
cls_key, cls_name, cls_namespace, parent_ctx = cls_name_result
590-
class_data = self.gendata.get_class_data(cls_key)
590+
class_data, missing = self.gendata.get_class_data(cls_key)
591591

592-
# Ignore explicitly ignored classes
592+
# Ignore explicitly ignored classes (including default-ignore)
593593
if class_data.ignore:
594594
return False
595595

596+
if missing and not self.report_only:
597+
raise ValueError(f"'{cls_key}' must be in {self.gendata.data_fname}")
598+
596599
for typename in class_data.force_type_casters:
597600
self._add_user_type_caster(typename)
598601

robotpy_build/autowrap/generator_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ class GeneratorData:
6666

6767
data: AutowrapConfigYaml
6868

69-
def __init__(self, data: AutowrapConfigYaml):
69+
def __init__(self, data: AutowrapConfigYaml, data_fname: str):
7070
self.data = data
71+
self.data_fname = data_fname
7172

7273
default_ignore = self.data.defaults.ignore
7374
self._default_enum_data = EnumData(ignore=default_ignore)
@@ -82,7 +83,7 @@ def __init__(self, data: AutowrapConfigYaml):
8283
self.enums: EnumMissingData = {}
8384
self.attributes: AttrMissingData = {}
8485

85-
def get_class_data(self, name: str) -> ClassData:
86+
def get_class_data(self, name: str) -> Tuple[ClassData, bool]:
8687
"""
8788
The 'name' is namespace::[parent_class::]class_name
8889
"""
@@ -92,7 +93,7 @@ def get_class_data(self, name: str) -> ClassData:
9293
data = self._default_class_data
9394

9495
self.classes[name] = ClsReportData(missing=missing)
95-
return data
96+
return data, missing
9697

9798
def get_cls_enum_data(
9899
self, name: str, cls_key: str, cls_data: ClassData

robotpy_build/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def on_build_gen(
694694
)
695695
)
696696

697-
gendata = GeneratorData(data)
697+
gendata = GeneratorData(data, data_fname)
698698

699699
try:
700700
hctx = parse_header(

tests/cpp/gen/ft/IBase.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
classes:
4+
inheritance::IBase:
5+
methods:
6+
IBase:
7+
baseOnly:
8+
baseAndGrandchild:
9+
baseAndChild:
10+
baseAndPyChild:
11+
baseAndChildFinal:
12+
getBaseOnly:
13+
getBaseAndGrandchild:
14+
getBaseAndChild:
15+
getBaseAndPyChild:
16+
getBaseAndChildFinal:
17+
protectedMethod:
18+
protectedOutMethod:

tests/cpp/gen/ft/IChild.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
classes:
4+
inheritance::IChild:
5+
attributes:
6+
i:
7+
methods:
8+
IChild:
9+
baseAndChild:
10+
baseAndChildFinal:
11+
getI:
12+
inheritance::IFinal:

tests/cpp/gen/ft/IGChild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
classes:
4+
inheritance::IGrandChild:
5+
methods:
6+
baseAndGrandchild:

tests/cpp/gen/ft/IMChild.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
3+
classes:
4+
inheritance::IMOther:
5+
inheritance::IMChild:
6+
methods:
7+
baseAndChild:
8+
baseAndChildFinal:

tests/cpp/gen/ft/Overloaded.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
functions:
4+
OBinitOB:
5+
OCinitOB:
6+
OCinitOC:
7+
OGinitOC:
8+
classes:
9+
overloaded_inheritance::OBInitializer:
10+
methods:
11+
doInit:
12+
overloaded_inheritance::OB:
13+
methods:
14+
Init:
15+
overloaded_inheritance::OCInitializer:
16+
methods:
17+
doInit:
18+
overloaded_inheritance::OC:
19+
methods:
20+
Init:
21+
overloads:
22+
OBInitializer&:
23+
OCInitializer&:
24+
overloaded_inheritance::OG:
25+
methods:
26+
Init:

tests/cpp/gen/ft/PBase.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
classes:
4+
PBase:
5+
methods:
6+
getChannel:
7+
privateFinalTestC:
8+
privateFinalTestGC:
9+
privateOverrideTestC:
10+
setChannel:

0 commit comments

Comments
 (0)