Arwalk / zig-protobuf

a protobuf 3 implementation for zig.
MIT License
229 stars 27 forks source link

WIP: Add support for protos without package name #58

Open osztenkurden opened 2 months ago

osztenkurden commented 2 months ago

There is still formatting to do, but beside that it works. One thing that needs to be taken care of, is that import "networkbasetypes.proto"; does not generate proper @import clause

Also haven't tested if it breaks something, hence very much WIP, I'll try to finish it this week

Arwalk commented 2 months ago

So far this is breaking the import of other packages. If you run zig build test you'll see that it makes the generator fail to generate import directives.

But no sweat, thanks for your support ;)

osztenkurden commented 2 months ago

Fixed the imports, another quirk (I'll create another issue / pr for that) is that nameless packages seem to bring the message names into the namespace of the protobuf, as this part is considered valid by other engines:

syntax = "proto2";

import "networkbasetypes.proto";

enum EBaseGameEvents {
    GE_VDebugGameSessionIDEvent = 200;
    GE_PlaceDecalEvent = 201;
    GE_ClearWorldDecalsEvent = 202;
    GE_ClearEntityDecalsEvent = 203;
    GE_ClearDecalsForSkeletonInstanceEvent = 204;
    GE_Source1LegacyGameEventList = 205;
    GE_Source1LegacyListenEvents = 206;
    GE_Source1LegacyGameEvent = 207;
    GE_SosStartSoundEvent = 208;
    GE_SosStopSoundEvent = 209;
    GE_SosSetSoundEventParams = 210;
    GE_SosSetLibraryStackFields = 211;
    GE_SosStopSoundEventHash = 212;
}

message CMsgVDebugGameSessionIDEvent {
    optional int32 clientid = 1;
    optional string gamesessionid = 2;
}

message CMsgPlaceDecalEvent {
    optional .CMsgVector position = 1;
    optional .CMsgVector normal = 2;
    optional .CMsgVector saxis = 3;
    optional uint32 decalmaterialindex = 4;
    optional uint32 flags = 5;
    optional fixed32 color = 6;
    optional float width = 7;
    optional float height = 8;
    optional float depth = 9;
    optional uint32 entityhandleindex = 10;
    optional fixed32 skeletoninstancehash = 11;
    optional int32 boneindex = 12;
    optional bool translucenthit = 13;
    optional bool is_adjacent = 14;
}

where CMsgVector is being imported from the networkbasetypes.proto which also doesn't have package name. Can't find any info on that in spec, so if you know how it's supposed to work I can try and add that as well

EDIT: I'll actually just continue on this PR

Arwalk commented 1 month ago

Hey there @osztenkurden , where are you on this? Do you have any plan? Please do not force yourself to finish this, if you want to leave the subject it's your call and would be reasonable. Thanks again for your work and interest already.

osztenkurden commented 1 month ago

Hey, I've been on vacations for 2 weeks, I shall be back with it soon. Ill try to have it done next week, as I also need it for my project ;D