Skip to content

Commit 22a6b32

Browse files
committed
remove unused helper in code generator + rename FlecsComponent to Component
1 parent 395eea4 commit 22a6b32

5 files changed

Lines changed: 5 additions & 37 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Flecs-Java uses Java 25's Foreign Function & Memory API for direct C interop:
137137

138138
### Component System
139139

140-
Components are defined as Java records with the `@FlecsComponent` annotation. An annotation processor generates the necessary memory layouts and accessor code at compile time.
140+
Components are defined as Java records with the `@Component` annotation. An annotation processor generates the necessary memory layouts and accessor code at compile time.
141141

142142
## Building
143143

src/main/java/com/github/elebras1/flecs/ComponentRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private <T> Component<T> getComponentInstance(Class<T> componentClass) {
8383
Component<T> component = ComponentMap.getInstance(componentClass);
8484

8585
if (component == null) {
86-
throw new IllegalStateException("Component not found for " + componentClass.getName() + ". Make sure the record is annotated with @FlecsComponent and annotation processing is enabled.");
86+
throw new IllegalStateException("Component not found for " + componentClass.getName() + ". Make sure the record is annotated with @Component and annotation processing is enabled.");
8787
}
8888

8989
return component;

src/main/java/com/github/elebras1/flecs/processor/ComponentCodeGenerator.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -170,38 +170,6 @@ private MethodSpec createReadMethod(String packageName, String recordName, List<
170170
return method.build();
171171
}
172172

173-
private MethodSpec createWriteFixedStringHelper() {
174-
return MethodSpec.methodBuilder("writeFixedString")
175-
.addModifiers(Modifier.PRIVATE)
176-
.addParameter(MemorySegment.class, "structPtr")
177-
.addParameter(long.class, "offset")
178-
.addParameter(String.class, "value")
179-
.addParameter(int.class, "capacity")
180-
.addCode(CodeBlock.builder()
181-
.addStatement("$T slice = structPtr.asSlice(offset, capacity)", MemorySegment.class)
182-
.beginControlFlow("if (value == null || value.isEmpty())")
183-
.addStatement("slice.set($T.JAVA_BYTE, 0, (byte) 0)", ValueLayout.class)
184-
.addStatement("return")
185-
.endControlFlow()
186-
.addStatement("byte[] bytes = value.getBytes($T.UTF_8)", StandardCharsets.class)
187-
.addStatement("int len = Math.min(bytes.length, capacity - 1)")
188-
.addStatement("$T.copy(bytes, 0, slice, $T.JAVA_BYTE, 0, len)", MemorySegment.class, ValueLayout.class)
189-
.addStatement("slice.set($T.JAVA_BYTE, len, (byte) 0)", ValueLayout.class)
190-
.build())
191-
.build();
192-
}
193-
194-
private MethodSpec createReadFixedStringHelper() {
195-
return MethodSpec.methodBuilder("readFixedString")
196-
.addModifiers(Modifier.PRIVATE)
197-
.returns(String.class)
198-
.addParameter(MemorySegment.class, "structPtr")
199-
.addParameter(long.class, "offset")
200-
.addParameter(int.class, "capacity")
201-
.addStatement("return structPtr.asSlice(offset, capacity).getString(0)")
202-
.build();
203-
}
204-
205173
private MethodSpec createFactoryMethod(String packageName, String recordName) {
206174
MethodSpec.Builder method = MethodSpec.methodBuilder("create")
207175
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)

src/main/java/com/github/elebras1/flecs/processor/ComponentMapGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public JavaFile generateComponentMap(List<TypeElement> components) {
2525
.addMethod(this.createGetInstanceMethod());
2626

2727
return JavaFile.builder(MAP_PACKAGE, mapClass.build())
28-
.addFileComment("Generated by FlecsComponentProcessor")
28+
.addFileComment("Generated by ComponentMapGenerator.")
2929
.indent(" ")
3030
.build();
3131
}

src/main/java/com/github/elebras1/flecs/processor/ComponentProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
4848
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
4949

5050
if (element.getKind() != ElementKind.RECORD) {
51-
this.messager.printMessage(Diagnostic.Kind.ERROR, "@FlecsComponent can only be applied to records", element);
51+
this.messager.printMessage(Diagnostic.Kind.ERROR, "@Component can only be applied to records", element);
5252
continue;
5353
}
5454

@@ -57,7 +57,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
5757
this.processRecord(recordElement);
5858
this.processedComponents.add(recordElement);
5959
} catch (Exception e) {
60-
this.messager.printMessage(Diagnostic.Kind.ERROR, "Failed to process @FlecsComponent: " + e.getMessage(), element);
60+
this.messager.printMessage(Diagnostic.Kind.ERROR, "Failed to process @Component: " + e.getMessage(), element);
6161
}
6262
}
6363
}

0 commit comments

Comments
 (0)