Bug 1883861 - Part 1: Move visitMemoryBarrier into the common CodeGenerator file...
[gecko.git] / layout / style / ServoBindings.h
blob6f1900651299fc60953ef079ce11a368da5d5b69
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* FFI functions for Gecko to call into Servo */
9 #ifndef mozilla_ServoBindings_h
10 #define mozilla_ServoBindings_h
12 #include "mozilla/ServoStyleConsts.h"
14 // These functions are defined via macros in Rust, so cbindgen doesn't see them.
16 namespace mozilla {
18 // The clang we use on windows complains about returning StyleStrong<> and
19 // StyleOwned<>, since the template parameters are incomplete.
21 // But they only contain pointers so it is ok. Also, this warning hilariously
22 // doesn't exist in GCC.
24 // A solution for this is to explicitly instantiate the template, but duplicate
25 // instantiations are an error.
27 // https://github.com/eqrion/cbindgen/issues/402 tracks an improvement to
28 // cbindgen that would allow it to autogenerate the template instantiations on
29 // its own.
30 #pragma GCC diagnostic push
31 #ifdef __clang__
32 # pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
33 #endif
35 extern "C" {
37 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, prefix_) \
38 void Servo_##type_##_Debug(const mozilla::Style##prefix_##type_*, \
39 nsACString* result); \
40 void Servo_##type_##_GetCssText(const mozilla::Style##prefix_##type_*, \
41 nsACString* result);
43 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(type_) \
44 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, Locked)
45 #define BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED(type_) \
46 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_, )
48 #define BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
49 StyleStrong<mozilla::Style##prefix_##type_##Rule> \
50 Servo_CssRules_Get##type_##RuleAt(const StyleLockedCssRules* rules, \
51 uint32_t index, uint32_t* line, \
52 uint32_t* column); \
53 void Servo_StyleSet_##type_##RuleChanged( \
54 const StylePerDocumentStyleData*, const Style##prefix_##type_##Rule*, \
55 const StyleDomStyleSheet*, StyleRuleChangeKind); \
56 BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX(type_##Rule, prefix_)
58 #define BASIC_RULE_FUNCS_LOCKED(type_) \
59 BASIC_RULE_FUNCS_WITH_PREFIX(type_, Locked)
61 #define BASIC_RULE_FUNCS_UNLOCKED(type_) BASIC_RULE_FUNCS_WITH_PREFIX(type_, )
63 #define GROUP_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
64 BASIC_RULE_FUNCS_WITH_PREFIX(type_, prefix_) \
65 StyleStrong<mozilla::StyleLockedCssRules> Servo_##type_##Rule_GetRules( \
66 const mozilla::Style##prefix_##type_##Rule* rule);
68 #define GROUP_RULE_FUNCS_LOCKED(type_) \
69 GROUP_RULE_FUNCS_WITH_PREFIX(type_, Locked)
71 #define GROUP_RULE_FUNCS_UNLOCKED(type_) GROUP_RULE_FUNCS_WITH_PREFIX(type_, )
73 BASIC_RULE_FUNCS_LOCKED(Style)
74 BASIC_RULE_FUNCS_LOCKED(Import)
75 BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED(Keyframe)
76 BASIC_RULE_FUNCS_LOCKED(Keyframes)
77 GROUP_RULE_FUNCS_UNLOCKED(Media)
78 GROUP_RULE_FUNCS_UNLOCKED(Document)
79 BASIC_RULE_FUNCS_UNLOCKED(Namespace)
80 BASIC_RULE_FUNCS_LOCKED(Page)
81 BASIC_RULE_FUNCS_UNLOCKED(Property)
82 GROUP_RULE_FUNCS_UNLOCKED(Supports)
83 GROUP_RULE_FUNCS_UNLOCKED(LayerBlock)
84 BASIC_RULE_FUNCS_UNLOCKED(LayerStatement)
85 BASIC_RULE_FUNCS_UNLOCKED(FontFeatureValues)
86 BASIC_RULE_FUNCS_UNLOCKED(FontPaletteValues)
87 BASIC_RULE_FUNCS_LOCKED(FontFace)
88 BASIC_RULE_FUNCS_LOCKED(CounterStyle)
89 GROUP_RULE_FUNCS_UNLOCKED(Container)
91 #undef GROUP_RULE_FUNCS_LOCKED
92 #undef GROUP_RULE_FUNCS_UNLOCKED
93 #undef GROUP_RULE_FUNCS_WITH_PREFIX
94 #undef BASIC_RULE_FUNCS_LOCKED
95 #undef BASIC_RULE_FUNCS_UNLOCKED
96 #undef BASIC_RULE_FUNCS_WITH_PREFIX
97 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_LOCKED
98 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_UNLOCKED
99 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER_WITH_PREFIX
101 #define BASIC_SERDE_FUNCS(type_) \
102 bool Servo_##type_##_Deserialize(mozilla::ipc::ByteBuf* input, type_* v); \
103 bool Servo_##type_##_Serialize(const type_* v, mozilla::ipc::ByteBuf* output);
105 BASIC_SERDE_FUNCS(LengthPercentage)
106 BASIC_SERDE_FUNCS(StyleRotate)
107 BASIC_SERDE_FUNCS(StyleScale)
108 BASIC_SERDE_FUNCS(StyleTranslate)
109 BASIC_SERDE_FUNCS(StyleTransform)
110 BASIC_SERDE_FUNCS(StyleOffsetPath)
111 BASIC_SERDE_FUNCS(StyleOffsetRotate)
112 BASIC_SERDE_FUNCS(StylePositionOrAuto)
113 BASIC_SERDE_FUNCS(StyleOffsetPosition)
114 BASIC_SERDE_FUNCS(StyleComputedTimingFunction)
116 #undef BASIC_SERDE_FUNCS
118 void Servo_CounterStyleRule_GetDescriptorCssText(
119 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
120 nsACString* result);
122 bool Servo_CounterStyleRule_SetDescriptor(
123 const StyleLockedCounterStyleRule* rule, nsCSSCounterDesc desc,
124 const nsACString* value);
126 } // extern "C"
128 #pragma GCC diagnostic pop
130 } // namespace mozilla
132 #endif // mozilla_ServoBindings_h