resource-native: Re-add the mainloop object

This lets us deal with the return value as a pointer instead of
int