#include <string>
#include <type_traits>
#include <vector>
#include "src/mapping/convert_js.h"
#include "src/mapping/js_wrappers.h"
#include "src/mapping/names.h"
Go to the source code of this file.
§ CONVERT_ENUM_AS_NUMBER
#define CONVERT_ENUM_AS_NUMBER |
( |
|
ns, |
|
|
|
type |
|
) |
| |
Value:template <> \
struct ::shaka::TypeName<ns::type, void> { \
static std::string
name() { \
} \
}; \
template <> \
struct ::shaka::impl::ConvertHelper<ns::type> \
This file defines how to convert C++ enums. There are two kinds of (conceptual) enums: numbers and strings. Many browser API standards define JavaScript enums as possible string choices. The macros below allow defining the mapping between JavaScript values and the C++ enum values. Note that all these macros must be placed at the global namespace.
To indicate an enum should just be treated as numbers, simply add the following:
To define an enum as string choices, add the following. Note that the macro defines |Enum| as an alias of the enum type:
AddMapping(Enum::ENUM, "string");
AddMapping(Enum::OTHER, "any-valid-string");
}
Definition at line 52 of file enum.h.
§ DEFINE_ENUM_MAPPING
#define DEFINE_ENUM_MAPPING |
( |
|
ns, |
|
|
|
type |
|
) |
| |
Value:template <> \
struct ::shaka::TypeName<ns::type, void> { \
static std::string
name() { \
} \
}; \
template <> \
class ::shaka::impl::EnumConverter<ns::type> \
: public ::shaka::impl::StringEnumConverter<ns::type> { \
public: \
EnumConverter(); \
}; \
template <> \
struct ::shaka::impl::ConvertHelper<ns::type> { \
return conv.FromJsValue(source, dest); \
} \
return conv.ToJsValue(source); \
} \
}; \
inline ::shaka::impl::EnumConverter<ns::type>::EnumConverter()
bool FromJsValue(Handle< JsValue > source, T *dest)
ReturnVal< JsValue > ToJsValue(T &&source)
Definition at line 63 of file enum.h.