RPNXCortado
C++23 JVM class-file, bytecode, validation, and JAR toolkit
Loading...
Searching...
No Matches
descriptors.hpp
Go to the documentation of this file.
1// AI Generated 2026 Ryan P. Nicholl <rnicholl@protonmail.com>
2// SPDX-License-Identifier: Apache-2.0
3
7
8#ifndef RPNX_CORTADO_DESCRIPTORS_HPP
9#define RPNX_CORTADO_DESCRIPTORS_HPP
10
11#include <cstddef>
12#include <cstdint>
13#include <rpnx/macros.hpp>
14#include <rpnx/variant.hpp>
15#include <string>
16#include <string_view>
17#include <vector>
18
19namespace rpnx::cortado
20{
22 enum class primitive_descriptor_kind : std::uint8_t { byte = 'B', character = 'C', double_precision = 'D', floating_point = 'F', integer = 'I', long_integer = 'J', short_integer = 'S', boolean = 'Z' };
23
26 {
27 primitive_descriptor_kind kind{primitive_descriptor_kind::integer};
28 RPNX_MEMBER_METADATA(primitive_type_descriptor, kind);
29 };
30
33 {
34 std::string internal_name;
35 RPNX_MEMBER_METADATA(object_type_descriptor, internal_name);
36 };
37
39
41 using field_type_descriptor = rpnx::variant< primitive_type_descriptor, object_type_descriptor, array_type_descriptor >;
42
49
52 {
53 RPNX_EMPTY_METADATA(void_type_descriptor);
54 };
55
57 using return_type_descriptor = rpnx::variant< void_type_descriptor, field_type_descriptor >;
58
61 {
62 std::vector< field_type_descriptor > parameters;
64 RPNX_MEMBER_METADATA(method_descriptor, parameters, return_type);
65 };
66
72 [[nodiscard]] field_type_descriptor parse_field_descriptor(std::string_view text);
73
79 [[nodiscard]] method_descriptor parse_method_descriptor(std::string_view text);
80
86 [[nodiscard]] std::string serialize_field_descriptor(field_type_descriptor const& descriptor);
87
93 [[nodiscard]] std::string serialize_method_descriptor(method_descriptor const& descriptor);
94
99 [[nodiscard]] std::size_t descriptor_slot_count(field_type_descriptor const& descriptor) noexcept;
100} // namespace rpnx::cortado
101
102#endif // RPNX_CORTADO_DESCRIPTORS_HPP
JVM class-file, bytecode, validation, generation, and JAR APIs.
primitive_descriptor_kind
Primitive field-descriptor kinds.
method_descriptor parse_method_descriptor(std::string_view text)
Parses exactly one method descriptor and enforces the 255-slot parameter limit.
std::string serialize_field_descriptor(field_type_descriptor const &descriptor)
Encodes one field descriptor.
field_type_descriptor parse_field_descriptor(std::string_view text)
Parses exactly one field descriptor.
std::size_t descriptor_slot_count(field_type_descriptor const &descriptor) noexcept
Returns the number of JVM local/operand slots occupied by a field descriptor.
rpnx::variant< void_type_descriptor, field_type_descriptor > return_type_descriptor
A JVM method return descriptor.
std::string serialize_method_descriptor(method_descriptor const &descriptor)
Encodes one method descriptor.
rpnx::variant< primitive_type_descriptor, object_type_descriptor, array_type_descriptor > field_type_descriptor
Any JVM field descriptor.
An array JVM field descriptor.
field_type_descriptor component
Immediate component type; nested arrays represent additional dimensions.
A parsed JVM method descriptor.
return_type_descriptor return_type
Field type or the explicit void alternative.
std::vector< field_type_descriptor > parameters
Parameters in invocation order.
An object JVM field descriptor.
std::string internal_name
Slash-separated, nonempty JVM internal class name without L or ;.
A primitive JVM field descriptor.
primitive_descriptor_kind kind
Primitive represented by this descriptor.
The void return descriptor.