@@ -847,34 +847,27 @@ public void enableRest(short port) {
847847 flecs_h .FlecsStatsImport (this .worldSeg );
848848 flecs_h .FlecsMetricsImport (this .worldSeg );
849849
850- try (Arena arena = Arena .ofConfined ()) {
851- MemorySegment restCompName = arena .allocateFrom ("flecs.rest.Rest" );
852- long restCompId = flecs_h .ecs_lookup (this .worldSeg , restCompName );
853-
854- if (restCompId == 0 ) {
855- throw new IllegalStateException ("Failed to find flecs.rest.Rest component." );
856- }
857-
858- MemorySegment restDataSeg = arena .allocate (32 );
859- restDataSeg .set (JAVA_SHORT , 0 , port );
850+ long restCompId = flecs_h .FLECS_IDEcsRestID_ ();
851+ if ( restCompId == 0 ) {
852+ throw new IllegalStateException ("Failed to find EcsRest component." );
853+ }
860854
861- flecs_h .ecs_set_id (this .worldSeg , restCompId , restCompId , 32 , restDataSeg );
855+ try (Arena arena = Arena .ofConfined ()) {
856+ MemorySegment restDataSeg = EcsRest .allocate (arena );
857+ EcsRest .port (restDataSeg , port );
858+ flecs_h .ecs_set_id (this .worldSeg , restCompId , restCompId , EcsRest .sizeof (), restDataSeg );
862859 }
863860 }
864861
865862 public void disableRest () {
866863 this .checkDestroyed ();
867864
868- try (Arena arena = Arena .ofConfined ()) {
869- MemorySegment restCompNameSeg = arena .allocateFrom ("flecs.rest.Rest" );
870- long restCompId = flecs_h .ecs_lookup (this .worldSeg , restCompNameSeg );
871-
872- if ( restCompId == 0 ) {
873- throw new IllegalStateException ("Failed to find flecs.rest.Rest component. Make sure FlecsRest module is imported." );
874- }
875-
876- flecs_h .ecs_remove_id (this .worldSeg , restCompId , restCompId );
865+ long restCompId = flecs_h .FLECS_IDEcsRestID_ ();
866+ if ( restCompId == 0 ) {
867+ throw new IllegalStateException ("Failed to find EcsRest component." );
877868 }
869+
870+ flecs_h .ecs_remove_id (this .worldSeg , restCompId , restCompId );
878871 }
879872
880873 public void destroy () {
@@ -906,3 +899,4 @@ public String toString() {
906899 }
907900}
908901
902+
0 commit comments