mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #29262 from Haris-bin-shakeel:fix-objc-volumetype-5x
objc: Fix VolumeType enum name clash on MacOS #29262 ### Pull Request Readiness Checklist - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable - [ ] The feature is well documented and sample code can be built with the project CMake **Problem** When the ObjC wrapper is generated, the global enum `cv::VolumeType` from the ptcloud module is emitted as `typedef NS_ENUM(int, VolumeType)`. macOS defines `typedef OSType VolumeType` in CoreServices, which leads to a typedef-redefinition error during the framework build. **Fix** `add_enum()` in `gen_objc.py` now handles namespace-global enums by falling back to a module-level lookup (`self.Module`) when the enum has no enclosing class. A new `gen_dict.json` entry maps `VolumeType` -> `PtcloudVolumeType`, and the import generation automatically uses the renamed enum. Fixes #29260
This commit is contained in:
@@ -847,9 +847,14 @@ class ObjectiveCWrapperGenerator(object):
|
||||
objc_type = enumType.rsplit(".", 1)[-1]
|
||||
if objc_type in enum_ignore_list:
|
||||
return
|
||||
if constinfo.classname in enum_fix:
|
||||
original_objc_type = objc_type
|
||||
if not constinfo.classname or constinfo.classname == objc_type:
|
||||
module_fix = enum_fix.get(self.Module, {})
|
||||
objc_type = module_fix.get(objc_type, objc_type)
|
||||
objc_type = enum_fix.get(objc_type, objc_type)
|
||||
elif constinfo.classname in enum_fix:
|
||||
objc_type = enum_fix[constinfo.classname].get(objc_type, objc_type)
|
||||
import_module = constinfo.classname if constinfo.classname and constinfo.classname != objc_type else self.Module
|
||||
import_module = constinfo.classname if constinfo.classname and constinfo.classname != original_objc_type else self.Module
|
||||
type_dict[ctype] = { "cast_from" : "int",
|
||||
"cast_to" : get_cname(enumType),
|
||||
"objc_type" : objc_type,
|
||||
|
||||
Reference in New Issue
Block a user