Look at the package_create_* procs and somewhere there you will find bits and pieces that acutally create the rel_name_rel__new functions.