1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 import mozpack
.path
as mozpath
13 SERVO_BASE
= mozpath
.join(buildconfig
.topsrcdir
, "servo")
14 SERVO_PROP_BASE
= mozpath
.join(SERVO_BASE
, "components", "style", "properties")
17 def generate_data(output
, template
):
18 output
.write("# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT\n\n")
20 subprocess
.check_output(
23 mozpath
.join(SERVO_PROP_BASE
, "build.py"),
28 universal_newlines
=True,
32 # Add all relevant files into the dependencies of the generated file.
33 DEP_EXTS
= [".py", ".rs", ".zip"]
35 for path
, dirs
, files
in os
.walk(SERVO_PROP_BASE
):
37 if os
.path
.splitext(file)[1] in DEP_EXTS
:
38 deps
.add(mozpath
.join(path
, file))
42 def generate_header(output
, data
):
43 data
= runpy
.run_path(data
)["data"]
46 """/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
48 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
49 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
50 /* This Source Code Form is subject to the terms of the Mozilla Public
51 * License, v. 2.0. If a copy of the MPL was not distributed with this
52 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
54 #define CSS_PROP_DOMPROP_PREFIXED(name_) \\
55 CSS_PROP_PUBLIC_OR_PRIVATE(Moz ## name_, name_)
57 #ifndef CSS_PROP_LONGHAND
58 #define CSS_PROP_LONGHAND(name_, id_, method_, flags_, pref_) /* nothing */
59 #define DEFINED_CSS_PROP_LONGHAND
62 #ifndef CSS_PROP_SHORTHAND
63 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) /* nothing */
64 #define DEFINED_CSS_PROP_SHORTHAND
67 #ifndef CSS_PROP_ALIAS
68 #define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, flags_, pref_) /* nothing */
69 #define DEFINED_CSS_PROP_ALIAS
75 # Some flags are only used for code generation, so we don't need to
76 # expose them to runtime.
77 COMPILE_TIME_FLAGS
= {"ExposedOnGetCS"}
80 "longhand": "CSS_PROP_LONGHAND",
81 "shorthand": "CSS_PROP_SHORTHAND",
82 "alias": "CSS_PROP_ALIAS",
84 for prop
in data
.values():
85 is_internal
= "Internal" in prop
.flags
87 "CSSPropFlags::{}".format(flag
)
88 for flag
in prop
.flags
89 if flag
not in COMPILE_TIME_FLAGS
92 flags
= "CSSPropFlags(0)"
93 pref
= '"' + prop
.pref
+ '"'
95 if prop
.type() == "alias":
96 params
= [prop
.name
, prop
.alias_id
, prop
.prop_id
, method
, flags
, pref
]
98 if method
== "CssFloat":
99 method
= "CSS_PROP_PUBLIC_OR_PRIVATE(CssFloat, Float)"
100 elif method
.startswith("Moz"):
101 method
= "CSS_PROP_DOMPROP_PREFIXED({})".format(method
[3:])
102 params
= [prop
.name
, prop
.id, method
, flags
, pref
]
105 excludes
.append("CSS_PROP_LIST_EXCLUDE_INTERNAL")
106 if "Style" not in prop
.rules
:
107 excludes
.append("CSS_PROP_LIST_EXCLUDE_NOT_IN_STYLE")
112 " || ".join("!defined " + exclude
for exclude
in excludes
)
115 output
.write("{}({})\n".format(MACRO_NAMES
[prop
.type()], ", ".join(params
)))
117 output
.write("#endif\n")
121 #ifdef DEFINED_CSS_PROP_ALIAS
122 #undef CSS_PROP_ALIAS
123 #undef DEFINED_CSS_PROP_ALIAS
126 #ifdef DEFINED_CSS_PROP_SHORTHAND
127 #undef CSS_PROP_SHORTHAND
128 #undef DEFINED_CSS_PROP_SHORTHAND
131 #ifdef DEFINED_CSS_PROP_LONGHAND
132 #undef CSS_PROP_LONGHAND
133 #undef DEFINED_CSS_PROP_LONGHAND
136 #undef CSS_PROP_DOMPROP_PREFIXED