7#include "xfa/fxfa/parser/xfa_basic_data.h"
12#include "core/fxcrt/span.h"
13#include "fxjs/xfa/cjx_boolean.h"
14#include "fxjs/xfa/cjx_container.h"
15#include "fxjs/xfa/cjx_datawindow.h"
16#include "fxjs/xfa/cjx_delta.h"
17#include "fxjs/xfa/cjx_desc.h"
18#include "fxjs/xfa/cjx_draw.h"
19#include "fxjs/xfa/cjx_encrypt.h"
20#include "fxjs/xfa/cjx_eventpseudomodel.h"
21#include "fxjs/xfa/cjx_exclgroup.h"
22#include "fxjs/xfa/cjx_extras.h"
23#include "fxjs/xfa/cjx_field.h"
24#include "fxjs/xfa/cjx_form.h"
25#include "fxjs/xfa/cjx_handler.h"
26#include "fxjs/xfa/cjx_hostpseudomodel.h"
27#include "fxjs/xfa/cjx_instancemanager.h"
28#include "fxjs/xfa/cjx_layoutpseudomodel.h"
29#include "fxjs/xfa/cjx_logpseudomodel.h"
30#include "fxjs/xfa/cjx_manifest.h"
31#include "fxjs/xfa/cjx_model.h"
32#include "fxjs/xfa/cjx_node.h"
33#include "fxjs/xfa/cjx_occur.h"
34#include "fxjs/xfa/cjx_packet.h"
35#include "fxjs/xfa/cjx_script.h"
36#include "fxjs/xfa/cjx_signaturepseudomodel.h"
37#include "fxjs/xfa/cjx_source.h"
38#include "fxjs/xfa/cjx_subform.h"
39#include "fxjs/xfa/cjx_textnode.h"
40#include "fxjs/xfa/cjx_tree.h"
41#include "fxjs/xfa/cjx_treelist.h"
42#include "fxjs/xfa/cjx_wsdlconnection.h"
43#include "fxjs/xfa/cjx_xfa.h"
44#include "xfa/fxfa/fxfa_basic.h"
48struct PacketTableRecord {
53const PacketTableRecord kPacketTable[] = {
55#define PCKT____(a, b, c, d, e, f)
56 {a, {XFA_PacketType::c, XFA_PacketMatch::e, XFA_PacketSupport::f, b, d}},
57#include "xfa/fxfa/parser/packets.inc"
61constexpr pdfium::span<
const PacketTableRecord> kPacketSpan{kPacketTable};
71constexpr ElementRecord kElementRecords[] = {
73#define ELEM____(a, b, c, d) {a, XFA_Element::c, XFA_Element::d},
74#include "xfa/fxfa/parser/elements.inc"
78constexpr pdfium::span<
const ElementRecord> kElementRecordSpan{kElementRecords};
80constexpr const char* kElementNames[] = {
82#define ELEM____(a, b, c, d) b,
83#include "xfa/fxfa/parser/elements.inc"
87constexpr const pdfium::span<
const char*
const> kElementNameSpan{kElementNames};
89static_assert(
std::size(kElementRecords) ==
std::size(kElementNames),
92struct AttributeRecord {
100constexpr AttributeRecord kAttributeRecords[] = {
102#define ATTR____(a, b, c, d) {a, XFA_Attribute::c, XFA_ScriptType::d},
103#include "xfa/fxfa/parser/attributes.inc"
107constexpr pdfium::span<
const AttributeRecord> kAttributeRecordSpan{
110constexpr const char* kAttributeNames[] = {
112#define ATTR____(a, b, c, d) b,
113#include "xfa/fxfa/parser/attributes.inc"
117constexpr pdfium::span<
const char*
const> kAttributeNameSpan{kAttributeNames};
119static_assert(
std::size(kAttributeRecords) ==
std::size(kAttributeNames),
122struct AttributeValueRecord {
130constexpr AttributeValueRecord kAttributeValueRecords[] = {
132#define VALUE____(a, b, c) {a, XFA_AttributeValue::c},
133#include "xfa/fxfa/parser/attribute_values.inc"
137constexpr const char* kAttributeValueNames[] = {
139#define VALUE____(a, b, c) b,
140#include "xfa/fxfa/parser/attribute_values.inc"
144constexpr pdfium::span<
const char*
const> kAttributeValueNameSpan{
145 kAttributeValueNames};
147static_assert(
std::size(kAttributeValueRecords) ==
148 std::size(kAttributeValueNames),
151struct ElementAttributeRecord {
158constexpr ElementAttributeRecord kElementAttributeRecords[] = {
160#define ELEM_ATTR____(a, b, c) {XFA_Element::a, XFA_Attribute::b},
161#include "xfa/fxfa/parser/element_attributes.inc"
167#define ELEM_ATTR____(a, b, c) c##_static,
168#include "xfa/fxfa/parser/element_attributes.inc"
172constexpr pdfium::span<
const XFA_ATTRIBUTE_CALLBACK>
173 kElementAttributeCallbackSpan{kElementAttributeCallbacks};
175static_assert(
std::size(kElementAttributeRecords) ==
176 std::size(kElementAttributeCallbacks),
182 return kPacketSpan[
static_cast<uint8_t>(ePacket)].info;
186 uint32_t hash = FX_HashCode_GetW(wsName);
187 auto* elem =
std::lower_bound(
188 std::begin(kPacketTable),
std::end(kPacketTable), hash,
189 [](
const PacketTableRecord& a, uint32_t hash) {
return a.hash < hash; });
190 if (elem !=
std::end(kPacketTable) && wsName.EqualsASCII(elem->info.name))
196 return kElementNameSpan[
static_cast<size_t>(elem)];
200 uint32_t hash = FX_HashCode_GetW(name);
201 auto* elem =
std::lower_bound(
202 std::begin(kElementRecords),
std::end(kElementRecords), hash,
203 [](
const ElementRecord& a, uint32_t hash) {
return a.hash < hash; });
204 if (elem ==
std::end(kElementRecords))
207 size_t index =
std::distance(
std::begin(kElementRecords), elem);
208 return name.EqualsASCII(kElementNameSpan[index]) ? elem->element
213 return kAttributeNameSpan[
static_cast<size_t>(attr)];
217 uint32_t hash = FX_HashCode_GetW(name);
218 auto* elem =
std::lower_bound(
219 kAttributeRecordSpan.begin(), kAttributeRecordSpan.end(), hash,
220 [](
const AttributeRecord& a, uint32_t hash) {
return a.hash < hash; });
221 if (elem == kAttributeRecordSpan.end()) {
224 size_t index =
std::distance(kAttributeRecordSpan.begin(), elem);
225 if (!name.EqualsASCII(kAttributeNameSpan[index])) {
235 return kAttributeValueNameSpan[
static_cast<int32_t>(item)];
241 std::lower_bound(
std::begin(kAttributeValueRecords),
242 std::end(kAttributeValueRecords), FX_HashCode_GetW(name),
243 [](
const AttributeValueRecord& arg, uint32_t hash) {
244 return arg.uHash < hash;
246 if (it ==
std::end(kAttributeValueRecords))
249 size_t index =
std::distance(
std::begin(kAttributeValueRecords), it);
250 if (!name.EqualsASCII(kAttributeValueNameSpan[index])) {
261 XFA_GetAttributeByName(attribute_name);
262 if (!attr.has_value())
266 auto compound_key = std::make_pair(element, attr.value().attribute);
267 auto* it =
std::lower_bound(
268 std::begin(kElementAttributeRecords),
269 std::end(kElementAttributeRecords), compound_key,
270 [](
const ElementAttributeRecord& arg,
272 return std::make_pair(arg.element, arg.attribute) < key;
274 if (it != std::end(kElementAttributeRecords) &&
275 compound_key == std::make_pair(it->element, it->attribute)) {
279 size_t index =
std::distance(
std::begin(kElementAttributeRecords), it);
280 result
.callback = kElementAttributeCallbackSpan[index];
283 element = kElementRecordSpan[
static_cast<size_t>(element)].parent;
fxcrt::ByteStringView ByteStringView
fxcrt::WideStringView WideStringView
XFA_ScriptType eValueType
XFA_ScriptType eValueType
XFA_ATTRIBUTE_CALLBACK callback
XFA_Element XFA_GetElementByName(WideStringView name)
ByteStringView XFA_AttributeValueToName(XFA_AttributeValue item)
std::optional< XFA_SCRIPTATTRIBUTEINFO > XFA_GetScriptAttributeByName(XFA_Element eElement, WideStringView wsAttributeName)
std::optional< XFA_PACKETINFO > XFA_GetPacketByName(WideStringView wsName)
ByteStringView XFA_ElementToName(XFA_Element elem)
std::optional< XFA_AttributeValue > XFA_GetAttributeValueByName(WideStringView name)
void(*)(v8::Isolate *pIsolate, CJX_Object *pNode, v8::Local< v8::Value > *pValue, bool bSetting, XFA_Attribute eAttribute) XFA_ATTRIBUTE_CALLBACK
XFA_PACKETINFO XFA_GetPacketByIndex(XFA_PacketType ePacket)
ByteStringView XFA_AttributeToName(XFA_Attribute attr)
std::optional< XFA_ATTRIBUTEINFO > XFA_GetAttributeByName(WideStringView name)