| 8658 | } |
| 8659 | |
| 8660 | std::string GeneratorKotlin::ConvertConstant(const std::string& domain, const std::string& package, const std::string& type, const std::string& value, bool optional) |
| 8661 | { |
| 8662 | if (value == "true") |
| 8663 | return "true"; |
| 8664 | else if (value == "false") |
| 8665 | return "false"; |
| 8666 | else if (value == "null") |
| 8667 | return "null"; |
| 8668 | else if (value == "min") |
| 8669 | { |
| 8670 | if (type == "byte") |
| 8671 | return ConvertConstantPrefix(type) + "0" + ConvertConstantSuffix(type); |
| 8672 | else if (type == "int8") |
| 8673 | return "Byte.MIN_VALUE"; |
| 8674 | else if (type == "uint8") |
| 8675 | return "UByte.MIN_VALUE"; |
| 8676 | else if (type == "int16") |
| 8677 | return "Short.MIN_VALUE"; |
| 8678 | else if (type == "uint16") |
| 8679 | return "UShort.MIN_VALUE"; |
| 8680 | else if (type == "int32") |
| 8681 | return "Int.MIN_VALUE"; |
| 8682 | else if (type == "uint32") |
| 8683 | return "UInt.MIN_VALUE"; |
| 8684 | else if (type == "int64") |
| 8685 | return "Long.MIN_VALUE"; |
| 8686 | else if (type == "uint64") |
| 8687 | return "ULong.MIN_VALUE"; |
| 8688 | |
| 8689 | yyerror("Unsupported type " + type + " for 'min' constant"); |
| 8690 | return ""; |
| 8691 | } |
| 8692 | else if (value == "max") |
| 8693 | { |
| 8694 | if (type == "byte") |
| 8695 | return ConvertConstantPrefix(type) + "0xFF" + ConvertConstantSuffix(type); |
| 8696 | else if (type == "int8") |
| 8697 | return "Byte.MAX_VALUE"; |
| 8698 | else if (type == "uint8") |
| 8699 | return "UByte.MAX_VALUE"; |
| 8700 | else if (type == "int16") |
| 8701 | return "Short.MAX_VALUE"; |
| 8702 | else if (type == "uint16") |
| 8703 | return "UShort.MAX_VALUE"; |
| 8704 | else if (type == "int32") |
| 8705 | return "Int.MAX_VALUE"; |
| 8706 | else if (type == "uint32") |
| 8707 | return "UInt.MAX_VALUE"; |
| 8708 | else if (type == "int64") |
| 8709 | return "Long.MAX_VALUE"; |
| 8710 | else if (type == "uint64") |
| 8711 | return "ULong.MAX_VALUE"; |
| 8712 | |
| 8713 | yyerror("Unsupported type " + type + " for 'max' constant"); |
| 8714 | return ""; |
| 8715 | } |
| 8716 | else if (value == "epoch") |
| 8717 | return ((Version() < 8) ? "java.util.Date(0)" : "java.time.Instant.EPOCH"); |