Added toNativeByPtr for RefEntity.