Simplifying scripting usage

Current scripting API requires a lot of code when using it. I am experimenting to reduce amount of code required for scripting. I write some proxy classes that dramatically reduce code size and improve readability:

BApplicationProxy app("application/x-vnd.Haiku-StyledEdit");
BMenuProxy menu = app.Window[1].MenuBar;
printf("Items count: %d\n", menu.MenuItem.CountItems()); // outputs 4
for (int32 i = 0; i < menu.MenuItem.CountItems(); i++) {
	if (i > 0) printf(", ");
	BString label = menu.MenuItem[i].Label;
	printf("%s", label.String());
menu.Menu["File"].MenuItem["New"](); // Calls File -> New menu item

This classes are written by hand and incomplete. I think that it should be possible to generate proxy classes code from property_info table. BHandler::BMessageReceived code (I call it dispatcher) for scripting can be also automatically generated.


Isn’t it what Binder/OpenBinder was meant to solve? (not in a backward-compatible way, however)

I never used Binder so I don’t know. It seems to solve a bit different problem. I can’t find Binder usage samples similar to my sample code.

I think that it is possible to generate proxy/dispatcher pair while keeping binary compatibility. property_info table can be extended by adding version field if needed, but current version already supports most required features including function arguments declaration with types, see