api_generator: move common code to RhoLib