oniksan / godobuf

A Google Protobuf implementation for Godot / GDScript
BSD 3-Clause "New" or "Revised" License
261 stars 36 forks source link

Namespaced nested imports not being found #27

Closed thoraxe closed 2 years ago

thoraxe commented 2 years ago

All protobuf files are here: https://github.com/OpenShiftDemos/srt-godot-test/tree/main/proto

Snippet: DualStickRawInputCommandBuffer.proto

syntax = "proto2";
package redhatgamedev.srt;

import "box2d.proto";

message DualStickRawInputCommandBuffer
{
    required box2d.PbVec2 pbv2Move = 1;
    required box2d.PbVec2 pbv2Shoot = 2;
}

box2d.proto

syntax = "proto2";
package box2d;

message PbVec2 {
  required float x = 1;
  required float y = 2;
}

Results in compilation error:

/home/thoraxe/Red_Hat/openshift/srt-godot-test/proto/DualStickRawInputCommandBuffer.proto: analysis.
/home/thoraxe/Red_Hat/openshift/srt-godot-test/proto/DualStickRawInputCommandBuffer.proto:9:5: error: Type 'box2d.PbVec2' of the 'pbv2Move' field undefined
/home/thoraxe/Red_Hat/openshift/srt-godot-test/proto/DualStickRawInputCommandBuffer.proto:10:5: error: Type 'box2d.PbVec2' of the 'pbv2Shoot' field undefined
/home/thoraxe/Red_Hat/openshift/srt-godot-test/proto/DualStickRawInputCommandBuffer.proto: analysis error.

It appears that import parsing may not be working correctly. PbVec2 is defined in box2d.proto which is imported by DualStickRawInputCommandBuffer.proto.

thoraxe commented 2 years ago

This appears to be a namespacing type issue.

godobuf doesn't namespace items imported. So, because box2d.proto definesPbVec2 and not box2d.PbVec2, it's not found.

If I change the required statements:

{
    required PbVec2 pbv2Move = 1;
    required PbVec2 pbv2Shoot = 2;
}

This successfully compiles.

I'm not sure if this is a Godobuf bug, a feature, or something bad about our implementation of Protobuf definitions.

oniksan commented 2 years ago

Hi, Erik. Packages is not supported (see readme.md). Maybe this is the problem?