7#include "xfa/fxfa/parser/xfa_basic_data.h"
12#include "fxjs/xfa/cjx_boolean.h"
13#include "fxjs/xfa/cjx_container.h"
14#include "fxjs/xfa/cjx_datawindow.h"
15#include "fxjs/xfa/cjx_delta.h"
16#include "fxjs/xfa/cjx_desc.h"
17#include "fxjs/xfa/cjx_draw.h"
18#include "fxjs/xfa/cjx_encrypt.h"
19#include "fxjs/xfa/cjx_eventpseudomodel.h"
20#include "fxjs/xfa/cjx_exclgroup.h"
21#include "fxjs/xfa/cjx_extras.h"
22#include "fxjs/xfa/cjx_field.h"
23#include "fxjs/xfa/cjx_form.h"
24#include "fxjs/xfa/cjx_handler.h"
25#include "fxjs/xfa/cjx_hostpseudomodel.h"
26#include "fxjs/xfa/cjx_instancemanager.h"
27#include "fxjs/xfa/cjx_layoutpseudomodel.h"
28#include "fxjs/xfa/cjx_logpseudomodel.h"
29#include "fxjs/xfa/cjx_manifest.h"
30#include "fxjs/xfa/cjx_model.h"
31#include "fxjs/xfa/cjx_node.h"
32#include "fxjs/xfa/cjx_occur.h"
33#include "fxjs/xfa/cjx_packet.h"
34#include "fxjs/xfa/cjx_script.h"
35#include "fxjs/xfa/cjx_signaturepseudomodel.h"
36#include "fxjs/xfa/cjx_source.h"
37#include "fxjs/xfa/cjx_subform.h"
38#include "fxjs/xfa/cjx_textnode.h"
39#include "fxjs/xfa/cjx_tree.h"
40#include "fxjs/xfa/cjx_treelist.h"
41#include "fxjs/xfa/cjx_wsdlconnection.h"
42#include "fxjs/xfa/cjx_xfa.h"
43#include "xfa/fxfa/fxfa_basic.h"
47struct PacketTableRecord {
52const PacketTableRecord kPacketTable[] = {
54#define PCKT____(a, b, c, d, e, f)
55 {a, {XFA_PacketType::c, XFA_PacketMatch::e, XFA_PacketSupport::f, b, d}},
56#include "xfa/fxfa/parser/packets.inc"
68constexpr ElementRecord kElementRecords[] = {
70#define ELEM____(a, b, c, d) {a, XFA_Element::c, XFA_Element::d},
71#include "xfa/fxfa/parser/elements.inc"
75constexpr const char* kElementNames[] = {
77#define ELEM____(a, b, c, d) b,
78#include "xfa/fxfa/parser/elements.inc"
82static_assert(
std::size(kElementRecords) ==
std::size(kElementNames),
85struct AttributeRecord {
93constexpr AttributeRecord kAttributeRecords[] = {
95#define ATTR____(a, b, c, d) {a, XFA_Attribute::c, XFA_ScriptType::d},
96#include "xfa/fxfa/parser/attributes.inc"
100constexpr const char* kAttributeNames[] = {
102#define ATTR____(a, b, c, d) b,
103#include "xfa/fxfa/parser/attributes.inc"
107static_assert(
std::size(kAttributeRecords) ==
std::size(kAttributeNames),
110struct AttributeValueRecord {
118constexpr AttributeValueRecord kAttributeValueRecords[] = {
120#define VALUE____(a, b, c) {a, XFA_AttributeValue::c},
121#include "xfa/fxfa/parser/attribute_values.inc"
125constexpr const char* kAttributeValueNames[] = {
127#define VALUE____(a, b, c) b,
128#include "xfa/fxfa/parser/attribute_values.inc"
132static_assert(
std::size(kAttributeValueRecords) ==
133 std::size(kAttributeValueNames),
136struct ElementAttributeRecord {
143constexpr ElementAttributeRecord kElementAttributeRecords[] = {
145#define ELEM_ATTR____(a, b, c) {XFA_Element::a, XFA_Attribute::b},
146#include "xfa/fxfa/parser/element_attributes.inc"
150constexpr XFA_ATTRIBUTE_CALLBACK kElementAttributeCallbacks[] = {
152#define ELEM_ATTR____(a, b, c) c##_static,
153#include "xfa/fxfa/parser/element_attributes.inc"
157static_assert(
std::size(kElementAttributeRecords) ==
158 std::size(kElementAttributeCallbacks),
164 return kPacketTable[
static_cast<uint8_t>(ePacket)].info;
168 uint32_t hash = FX_HashCode_GetW(wsName);
169 auto* elem =
std::lower_bound(
170 std::begin(kPacketTable),
std::end(kPacketTable), hash,
171 [](
const PacketTableRecord& a, uint32_t hash) {
return a.hash < hash; });
172 if (elem !=
std::end(kPacketTable) && wsName.EqualsASCII(elem->info.name))
174 return absl::nullopt;
178 return kElementNames[
static_cast<size_t>(elem)];
182 uint32_t hash = FX_HashCode_GetW(name);
183 auto* elem =
std::lower_bound(
184 std::begin(kElementRecords),
std::end(kElementRecords), hash,
185 [](
const ElementRecord& a, uint32_t hash) {
return a.hash < hash; });
186 if (elem ==
std::end(kElementRecords))
189 size_t index = std::distance(std::begin(kElementRecords), elem);
190 return name.EqualsASCII(kElementNames[index]) ? elem->element
195 return kAttributeNames[
static_cast<size_t>(attr)];
199 uint32_t hash = FX_HashCode_GetW(name);
200 auto* elem =
std::lower_bound(
201 std::begin(kAttributeRecords),
std::end(kAttributeRecords), hash,
202 [](
const AttributeRecord& a, uint32_t hash) {
return a.hash < hash; });
203 if (elem == std::end(kAttributeRecords))
204 return absl::nullopt;
206 size_t index = std::distance(std::begin(kAttributeRecords), elem);
207 if (!name.EqualsASCII(kAttributeNames[index]))
208 return absl::nullopt;
217 return kAttributeValueNames[
static_cast<int32_t>(item)];
221 WideStringView name) {
223 std::lower_bound(
std::begin(kAttributeValueRecords),
224 std::end(kAttributeValueRecords), FX_HashCode_GetW(name),
225 [](
const AttributeValueRecord& arg, uint32_t hash) {
226 return arg.uHash < hash;
228 if (it == std::end(kAttributeValueRecords))
229 return absl::nullopt;
231 size_t index = std::distance(std::begin(kAttributeValueRecords), it);
232 if (!name.EqualsASCII(kAttributeValueNames[index]))
233 return absl::nullopt;
240 WideStringView attribute_name) {
241 absl::optional<XFA_ATTRIBUTEINFO> attr =
242 XFA_GetAttributeByName(attribute_name);
243 if (!attr.has_value())
244 return absl::nullopt;
247 auto compound_key = std::make_pair(element, attr.value().attribute);
248 auto* it =
std::lower_bound(
249 std::begin(kElementAttributeRecords),
250 std::end(kElementAttributeRecords), compound_key,
251 [](
const ElementAttributeRecord& arg,
253 return std::make_pair(arg.element, arg.attribute) < key;
255 if (it != std::end(kElementAttributeRecords) &&
256 compound_key == std::make_pair(it->element, it->attribute)) {
258 result.attribute = attr.value().attribute;
259 result.eValueType = attr.value().eValueType;
260 size_t index = std::distance(std::begin(kElementAttributeRecords), it);
261 result
.callback = kElementAttributeCallbacks[index];
264 element = kElementRecords[
static_cast<size_t>(element)].parent;
266 return absl::nullopt;
XFA_ScriptType eValueType
XFA_ATTRIBUTE_CALLBACK callback
XFA_Element XFA_GetElementByName(WideStringView name)
ByteStringView XFA_AttributeValueToName(XFA_AttributeValue item)
absl::optional< XFA_AttributeValue > XFA_GetAttributeValueByName(WideStringView name)
ByteStringView XFA_ElementToName(XFA_Element elem)
absl::optional< XFA_SCRIPTATTRIBUTEINFO > XFA_GetScriptAttributeByName(XFA_Element eElement, WideStringView wsAttributeName)
absl::optional< XFA_PACKETINFO > XFA_GetPacketByName(WideStringView wsName)
absl::optional< XFA_ATTRIBUTEINFO > XFA_GetAttributeByName(WideStringView name)
XFA_PACKETINFO XFA_GetPacketByIndex(XFA_PacketType ePacket)
ByteStringView XFA_AttributeToName(XFA_Attribute attr)