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());
}
printf("\n");
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.