Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: short interface declaration in generated ${protocol_name}-procotol.cpp #74

Open
twaik opened this issue Jan 20, 2023 · 0 comments

Comments

@twaik
Copy link

twaik commented Jan 20, 2023

Hi. Your code is generating sources like this

code
const wl_interface* buffer_interface_destroy_request_server[0] = {
};

const wl_interface* buffer_interface_release_event_server[0] = {
};

const wl_message buffer_interface_requests_server[1] = {
  {
    "destroy",
    "",
    buffer_interface_destroy_request_server,
  },
};

const wl_message buffer_interface_events_server[1] = {
  {
    "release",
    "",
    buffer_interface_release_event_server,
  },
};

const wl_interface wayland::server::detail::buffer_interface =
  {
    "wl_buffer",
    1,
    1,
    buffer_interface_requests_server,
    1,
    buffer_interface_events_server,
  };
But it could be much shorter, like this
code
const wl_interface wayland::server::detail::buffer_interface = {
	"wl_buffer", 1,
	1, new const wl_message[] { 
		{ "destroy", "", new const wl_interface*[] {} }
	},
	1, new const wl_message[] {
		{ "release", "", new const wl_interface*[] {} }
	}
};
Also it can be oneliner because it is machine generated code and nobody reads it carefully.
code
const wl_interface wayland::server::detail::buffer_interface = {"wl_buffer", 1, 1, new const wl_message[] {{ "destroy", "", new const wl_interface*[] {} }}, 1, new const wl_message[] {{ "release", "", new const wl_interface*[] {} }}};

I failed to make it constexpr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant