diff options
author | Jose <pepone@users.noreply.github.com> | 2023-08-09 09:27:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 09:27:00 +0200 |
commit | badafe8b848181a720ab96b48da6abc170fd918c (patch) | |
tree | 4b24dbf02f578cb6c68a43fa45a71b4cb8f2405b /cpp/src/slice2objc/ObjCUtil.cpp | |
parent | Fix GCC13 build failure - #1489 (#1490) (diff) | |
download | ice-badafe8b848181a720ab96b48da6abc170fd918c.tar.bz2 ice-badafe8b848181a720ab96b48da6abc170fd918c.tar.xz ice-badafe8b848181a720ab96b48da6abc170fd918c.zip |
Fix Objective-C build failures (#1496)
Diffstat (limited to 'cpp/src/slice2objc/ObjCUtil.cpp')
-rw-r--r-- | cpp/src/slice2objc/ObjCUtil.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cpp/src/slice2objc/ObjCUtil.cpp b/cpp/src/slice2objc/ObjCUtil.cpp index 1848cbcbf4d..cf7e34fd5f0 100644 --- a/cpp/src/slice2objc/ObjCUtil.cpp +++ b/cpp/src/slice2objc/ObjCUtil.cpp @@ -427,6 +427,46 @@ Slice::ObjCGenerator::typeToObjCTypeString(const TypePtr& type) } } +string +Slice::ObjCGenerator::defaultValue(const TypePtr& type, bool isOptional) +{ + if(isValueType(type) && !isOptional) + { + if(EnumPtr::dynamicCast(type)) + { + return "0"; + } + BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); + if(builtin) + { + switch(builtin->kind()) + { + case Builtin::KindBool: + return "NO"; + case Builtin::KindByte: + case Builtin::KindShort: + case Builtin::KindInt: + case Builtin::KindLong: + return "0"; + case Builtin::KindFloat: + case Builtin::KindDouble: + return "0.0"; + default: + { + assert(false); + return "???"; + } + } + } + assert(false); + return "???"; + } + else + { + return "nil"; + } +} + bool Slice::ObjCGenerator::isValueType(const TypePtr& type) { |