Skip to content

Commit ee4363d

Browse files
committed
APL-CORE: December 2022 Release of APL 2022.2 compilant core engine (2022.2.2)
For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
1 parent 5c43a0b commit ee4363d

File tree

328 files changed

+13655
-4968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+13655
-4968
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

3-
## [2022.2]
3+
## [2022.2.1]
4+
5+
### Changed
6+
7+
- Bug fixes.
8+
- Performance improvements.
9+
- Build improvements.
10+
11+
## [2022.2.0]
412

513
This release adds support for version 2022.2 of the APL specification.
614

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# on older systems
1616
include(FetchContent OPTIONAL RESULT_VARIABLE HAS_FETCH_CONTENT)
1717

18-
cmake_minimum_required(VERSION 3.5)
18+
cmake_minimum_required(VERSION 3.11)
1919
set(CMAKE_CXX_STANDARD 11)
2020
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2121

aplcore/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
1818
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
1919
endif()
2020

21+
# Disable what needs to be disabled
22+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions")
23+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
24+
2125
include(target_sources_local.cmake)
2226

2327
# Check for the presence of GIT
@@ -179,6 +183,10 @@ if (USE_PROVIDED_YOGA_AS_LIB)
179183
# We built the bundled yoga lib, install it
180184
install(FILES ${YOGA_LIB}
181185
DESTINATION lib)
186+
install(DIRECTORY ${YOGA_INCLUDE}/yoga
187+
DESTINATION include
188+
FILES_MATCHING PATTERN "*.h")
189+
set(YOGA_EXTERNAL_LIB ${YOGA_LIB}) # used by aplcoreConfig.cmake.in
182190
endif()
183191

184192
if (NOT USE_PROVIDED_YOGA_INLINE)

aplcore/aplcoreConfig.cmake.in

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ else()
1313

1414
endif()
1515

16+
set(ENABLE_ALEXAEXTENSIONS @ENABLE_ALEXAEXTENSIONS@)
1617
set(USE_INTERNAL_ALEXAEXT @BUILD_ALEXAEXTENSIONS@)
1718

18-
if(NOT USE_INTERNAL_ALEXAEXT)
19-
find_package(alexaext REQUIRED)
20-
endif()
19+
if(ENABLE_ALEXAEXTENSIONS)
20+
if(NOT USE_INTERNAL_ALEXAEXT)
21+
find_package(alexaext REQUIRED)
22+
endif()
23+
endif(ENABLE_ALEXAEXTENSIONS)
2124

2225
include("${CMAKE_CURRENT_LIST_DIR}/aplcoreTargets.cmake")
2326

aplcore/include/apl/animation/easing.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef _APL_EASING_H
1818
#define _APL_EASING_H
1919

20-
#include "apl/primitives/objectdata.h"
20+
#include "apl/primitives/objecttype.h"
2121

2222
namespace apl {
2323

@@ -67,6 +67,19 @@ class Easing : public ObjectData {
6767
virtual bool operator==(const Easing& other) const = 0;
6868
virtual bool operator==(const CoreEasing& other) const = 0;
6969
virtual ~Easing() noexcept;
70+
71+
class ObjectType final : public PointerHolderObjectType<Easing> {
72+
public:
73+
bool isCallable() const override { return true; }
74+
75+
bool equals(const Object::DataHolder& lhs, const Object::DataHolder& rhs) const override {
76+
return *lhs.data == *rhs.data;
77+
}
78+
79+
Object call(const Object::DataHolder& dataHolder, const ObjectArray& args) const override {
80+
return dataHolder.data->call(args);
81+
}
82+
};
7083
};
7184

7285
} // namespace apl

aplcore/include/apl/animation/easinggrammar.h

+68-38
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
#ifndef _APL_EASING_GRAMMAR_H
1717
#define _APL_EASING_GRAMMAR_H
1818

19-
#include <tao/pegtl.hpp>
20-
#include <tao/pegtl/contrib/abnf.hpp>
21-
2219
#include "apl/animation/coreeasing.h"
20+
#include "apl/datagrammar/grammarpolyfill.h"
2321
#include "apl/utils/log.h"
2422
#include "apl/utils/stringfunctions.h"
2523

@@ -86,7 +84,7 @@ struct action
8684
: nothing< Rule > {
8785
};
8886

89-
struct easing_state
87+
struct easing_state : fail_state
9088
{
9189
float lastTime = 0;
9290
size_t startIndex = 0;
@@ -118,14 +116,18 @@ template<> struct action< path >
118116
template< typename Input >
119117
static void apply(const Input& in, easing_state& state) {
120118
auto argCount = state.args.size() - state.startIndex;
121-
if (argCount % 2 == 1)
122-
throw parse_error("Path easing function needs an even number of arguments", in);
119+
if (argCount % 2 == 1) {
120+
state.fail("Path easing function needs an even number of arguments", in);
121+
return;
122+
}
123123

124124
// Push each linear segment. Check to ensure time is incrementing
125125
for (auto offset = state.startIndex ; offset < state.args.size() ; offset += 2) {
126126
auto time = state.args.at(offset);
127-
if (time <= state.lastTime || time >= 1)
128-
throw parse_error("Path easing function needs ordered array of segments", in);
127+
if (time <= state.lastTime || time >= 1) {
128+
state.fail("Path easing function needs ordered array of segments", in);
129+
return;
130+
}
129131
state.lastTime = time;
130132
state.segments.emplace_back(EasingSegment(kLinearSegment, offset));
131133
}
@@ -153,8 +155,10 @@ template<> struct action< cubicbezier >
153155
template< typename Input >
154156
static void apply(const Input& in, easing_state& state) {
155157
auto argCount = state.args.size() - state.startIndex;
156-
if (argCount != 4)
157-
throw parse_error("Cubic-bezier easing function requires 4 arguments", in);
158+
if (argCount != 4) {
159+
state.fail("Cubic-bezier easing function requires 4 arguments", in);
160+
return;
161+
}
158162

159163
// Add a final segment at (1,1)
160164
state.segments.emplace_back(EasingSegment(kEndSegment, state.args.size()));
@@ -176,12 +180,16 @@ template<> struct action< end >
176180
template< typename Input >
177181
static void apply(const Input& in, easing_state& state) {
178182
auto argCount = state.args.size() - state.startIndex;
179-
if (argCount != 2)
180-
throw parse_error("End easing function segment requires 2 arguments", in);
183+
if (argCount != 2) {
184+
state.fail("End easing function segment requires 2 arguments", in);
185+
return;
186+
}
181187

182188
auto time = state.args.at(state.startIndex);
183-
if (time <= state.lastTime && state.startIndex > 0)
184-
throw parse_error("End easing function segment cannot start at this time", in);
189+
if (time <= state.lastTime && state.startIndex > 0) {
190+
state.fail("End easing function segment cannot start at this time", in);
191+
return;
192+
}
185193

186194
state.lastTime = time;
187195
state.segments.emplace_back(EasingSegment(kEndSegment, state.startIndex));
@@ -201,12 +209,16 @@ template<> struct action< line >
201209
template< typename Input >
202210
static void apply(const Input& in, easing_state& state) {
203211
auto argCount = state.args.size() - state.startIndex;
204-
if (argCount != 2)
205-
throw parse_error("Line easing function segment requires 2 arguments", in);
212+
if (argCount != 2) {
213+
state.fail("Line easing function segment requires 2 arguments", in);
214+
return;
215+
}
206216

207217
auto time = state.args.at(state.startIndex);
208-
if (time <= state.lastTime && state.startIndex > 0)
209-
throw parse_error("Line easing function segment cannot start at this time", in);
218+
if (time <= state.lastTime && state.startIndex > 0) {
219+
state.fail("Line easing function segment cannot start at this time", in);
220+
return;
221+
}
210222

211223
state.lastTime = time;
212224
state.segments.emplace_back(EasingSegment(kLinearSegment, state.startIndex));
@@ -226,12 +238,16 @@ template<> struct action< curve >
226238
template< typename Input >
227239
static void apply(const Input& in, easing_state& state) {
228240
auto argCount = state.args.size() - state.startIndex;
229-
if (argCount != 6)
230-
throw parse_error("Curve easing function segment requires 6 arguments", in);
241+
if (argCount != 6) {
242+
state.fail("Curve easing function segment requires 6 arguments", in);
243+
return;
244+
}
231245

232246
auto time = state.args.at(state.startIndex);
233-
if (time <= state.lastTime && state.startIndex > 0)
234-
throw parse_error("Curve easing function segment cannot start at this time", in);
247+
if (time <= state.lastTime && state.startIndex > 0) {
248+
state.fail("Curve easing function segment cannot start at this time", in);
249+
return;
250+
}
235251

236252
state.lastTime = time;
237253
state.segments.emplace_back(EasingSegment(kCurveSegment, state.startIndex));
@@ -246,16 +262,22 @@ template<> struct action< spatial >
246262
assert(state.startIndex == 0);
247263

248264
auto argCount = state.args.size();
249-
if (argCount != 2)
250-
throw parse_error("Wrong number of arguments to spatial", in);
265+
if (argCount != 2) {
266+
state.fail("Wrong number of arguments to spatial", in);
267+
return;
268+
}
251269

252270
auto dof = static_cast<int>(state.args.at(0));
253-
if (dof < 2)
254-
throw parse_error("invalid number of indices in spatial segment", in);
271+
if (dof < 2) {
272+
state.fail("invalid number of indices in spatial segment", in);
273+
return;
274+
}
255275

256276
auto index = static_cast<int>(state.args.at(1));
257-
if (index < 0 || index >= dof)
258-
throw parse_error("select index out of range in spatial segment", in);
277+
if (index < 0 || index >= dof) {
278+
state.fail("select index out of range in spatial segment", in);
279+
return;
280+
}
259281
}
260282
};
261283

@@ -274,13 +296,17 @@ template<> struct action< send >
274296
auto argCount = state.args.size() - state.startIndex;
275297

276298
// Time, pcount for value
277-
auto dof = ::abs(static_cast<int>(state.args[0]));
278-
if (argCount != 1 + dof)
279-
throw parse_error("Wrong number of arguments to send", in);
299+
auto dof = std::abs(static_cast<int>(state.args[0]));
300+
if (argCount != 1 + dof) {
301+
state.fail("Wrong number of arguments to send", in);
302+
return;
303+
}
280304

281305
auto time = state.args.at(state.startIndex);
282-
if (time <= state.lastTime && !state.segments.empty())
283-
throw parse_error("send easing function segment cannot start at this time", in);
306+
if (time <= state.lastTime && !state.segments.empty()) {
307+
state.fail("send easing function segment cannot start at this time", in);
308+
return;
309+
}
284310

285311
state.lastTime = time;
286312
state.segments.emplace_back(EasingSegment(kSEndSegment, state.startIndex));
@@ -302,13 +328,17 @@ template<> struct action< scurve >
302328
auto argCount = state.args.size() - state.startIndex;
303329

304330
// Time, pcount * 3 for value, tin, tout, 4 for the time curve =
305-
auto dof = ::abs(static_cast<int>(state.args[0]));
306-
if (argCount != 5 + dof * 3)
307-
throw parse_error("Wrong number of arguments to scurve", in);
331+
auto dof = std::abs(static_cast<int>(state.args[0]));
332+
if (argCount != 5 + dof * 3) {
333+
state.fail("Wrong number of arguments to scurve", in);
334+
return;
335+
}
308336

309337
auto time = state.args.at(state.startIndex);
310-
if (time <= state.lastTime && !state.segments.empty())
311-
throw parse_error("scurve easing function segment cannot start at this time", in);
338+
if (time <= state.lastTime && !state.segments.empty()) {
339+
state.fail("scurve easing function segment cannot start at this time", in);
340+
return;
341+
}
312342

313343
state.lastTime = time;
314344
state.segments.emplace_back(EasingSegment(kSCurveSegment, state.startIndex));

aplcore/include/apl/apl.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "apl/primitives/range.h"
6868
#include "apl/primitives/roundedrect.h"
6969
#include "apl/primitives/styledtext.h"
70+
#include "apl/primitives/transform2d.h"
7071
#include "apl/scaling/metricstransform.h"
7172
#ifdef SCENEGRAPH
7273
#include "apl/scenegraph/accessibility.h"

0 commit comments

Comments
 (0)