The C++ Widget classes like the Button.cpp mentioned have their base class in Widget.cpp which creates any widget based on a string argument. Also, any widget properties are effectively set through through string arguments.
my_button = new NativeUI::Widget("button")
my_button->setProperty("text", "OK");
MoSync implements an "IDL" interface for Native UI widgets in WidgetFunctions.idl:
typedef int MAWidgetHandle;
MAWidgetHandle maWidgetCreate(in MAString widgetType);
int maWidgetSetProperty(in MAWidgetHandle widget, in MAString property, in MAString value);
This is a language-independent description of the functions which get called from the NativeUI::Widget through a C call interface:
handle = maWidgetCreate("button");
maWidgetSetProperty(handle,"text","OK");
Until here we are on the MoSync C/C++ layer, which is kind of a VM with a system call interface. From here it is translated to the languages of the other platforms (Java, C#, etc.) by different methods:
It can use Java Native Interface (JNI) to call the corresponding functions in the Android runtime in MoSyncNativeUI.java:
public int maWidgetCreate(String type)
public int maWidgetSetProperty(int widgetHandle, String key, String value)
Or it is compiled into the intermediate "PIPE language", a pseudo assembler dialect, this language is then translated into Visual Studio C# for Windows Phone 7, or into an XCode project for iOS.
All platforms implement an UI engine in the "runtime" which is bundled with every app package. This runtime is prebuilt in the corresponding SDK and implements those Native UI calls.