Skip to content

Commit

Permalink
yomm11_class::base_list -> type_list
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Jun 27, 2015
1 parent 499e641 commit 4dd0e80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/yorel/methods/extern_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef YOMM11_CLASS

#define YOMM11_CLASS(CLASS, BASES...) \
using _yomm11_base_list = ::yorel::methods::detail::yomm11_class::base_list<BASES>; \
using _yomm11_base_list = ::yorel::methods::detail::type_list<BASES>; \
const char* _yomm11_class_name_(CLASS*) { return #CLASS; } \
virtual void _yomm11_init_class_()

Expand Down
8 changes: 4 additions & 4 deletions include/yorel/methods/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

#undef MM_CLASS
#define MM_CLASS(CLASS, ...) \
using _yomm11_base_list = ::yorel::methods::detail::yomm11_class::base_list<__VA_ARGS__>; \
using _yomm11_base_list = ::yorel::methods::detail::type_list<__VA_ARGS__>; \
YOMM11_TRACE(friend const char* _yomm11_name_(CLASS*) { return #CLASS; }) \
virtual void _yomm11_init_class_() { &::yorel::methods::detail::yomm11_class::initializer<CLASS, ::yorel::methods::detail::yomm11_class::base_list<__VA_ARGS__>>::the; }
virtual void _yomm11_init_class_() { &::yorel::methods::detail::yomm11_class::initializer<CLASS, ::yorel::methods::detail::type_list<__VA_ARGS__>>::the; }

#undef MM_EXTERN_CLASS
#define MM_EXTERN_CLASS(CLASS)

#define MM_FOREIGN_CLASS(CLASS, ...) \
static_assert(::yorel::methods::detail::check_bases<CLASS, ::yorel::methods::detail::yomm11_class::base_list<__VA_ARGS__>>::value, "error in MM_FOREIGN_CLASS(): not a base in base list"); \
static_assert(::yorel::methods::detail::check_bases<CLASS, ::yorel::methods::detail::type_list<__VA_ARGS__>>::value, "error in MM_FOREIGN_CLASS(): not a base in base list"); \
static_assert(std::is_polymorphic<CLASS>::value, "error: class must be polymorphic"); \
YOMM11_TRACE(const char* _yomm11_name_(CLASS*) { return #CLASS; }) \
namespace { ::yorel::methods::detail::yomm11_class::initializer<CLASS, ::yorel::methods::detail::yomm11_class::base_list<__VA_ARGS__>> _yomm11_add_class_ ## CLASS; }
namespace { ::yorel::methods::detail::yomm11_class::initializer<CLASS, ::yorel::methods::detail::type_list<__VA_ARGS__>> _yomm11_add_class_ ## CLASS; }

#define MM_INIT() \
::yorel::methods::detail::init_ptr<_yomm11_base_list>::init(this)
Expand Down
23 changes: 13 additions & 10 deletions include/yorel/methods/no_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ class bitvec {

std::ostream& operator <<(std::ostream& os, const bitvec& v);

template<typename... T>
struct type_list;

struct yomm11_class {
struct method_param {
method_base* method;
Expand Down Expand Up @@ -313,7 +316,7 @@ struct yomm11_class {
struct initializer;

template<class Class, class... Bases>
struct initializer<Class, base_list<Bases...>> {
struct initializer<Class, type_list<Bases...>> {
initializer();
static initializer the;
};
Expand Down Expand Up @@ -534,10 +537,10 @@ template<class... X>
struct init_ptr;

template<class... Bases>
struct init_ptr<yomm11_class::base_list<Bases...>> : init_ptr<Bases...> { };
struct init_ptr<type_list<Bases...>> : init_ptr<Bases...> { };

template<>
struct init_ptr<yomm11_class::base_list<>> {
struct init_ptr<type_list<>> {
template<class This> static void init(This* p) {
p->selector::_yomm11_ptbl = &yomm11_class::of<This>::pc->mmt;
}
Expand Down Expand Up @@ -577,20 +580,20 @@ template<class Class, class Bases>
struct check_bases;

template<class Class, class Base, class... Bases>
struct check_bases<Class, yomm11_class::base_list<Base, Bases...>> {
static const bool value = std::is_base_of<Base, Class>::value && check_bases<Class, yomm11_class::base_list<Bases...>>::value;
struct check_bases<Class, type_list<Base, Bases...>> {
static const bool value = std::is_base_of<Base, Class>::value && check_bases<Class, type_list<Bases...>>::value;
};

template<class Class>
struct check_bases<Class, yomm11_class::base_list<>> {
struct check_bases<Class, type_list<>> {
static const bool value = true;
};

template<class Class, class... Bases>
struct has_nonvirtual_bases;

template<class... Classes>
struct has_nonvirtual_bases<yomm11_class::base_list<Classes...>> : has_nonvirtual_bases<Classes...>{};
struct has_nonvirtual_bases<type_list<Classes...>> : has_nonvirtual_bases<Classes...>{};

template<class Class, class Base, class... More>
struct has_nonvirtual_bases<Class, Base, More...> {
Expand Down Expand Up @@ -848,9 +851,9 @@ std::ostream& operator <<(std::ostream& os, virtuals<Class...> v){
#endif

template<class Class, class... Bases>
yomm11_class::initializer<Class, yomm11_class::base_list<Bases...>>::initializer() {
yomm11_class::initializer<Class, type_list<Bases...>>::initializer() {
static_assert(
detail::check_bases<Class, yomm11_class::base_list<Bases...>>::value,
detail::check_bases<Class, type_list<Bases...>>::value,
"Error in YOMM11_CLASS(): not a base in base list");
yomm11_class& pc = yomm11_class::of<Class>::the();
pc.abstract = std::is_abstract<Class>::value;
Expand All @@ -865,7 +868,7 @@ yomm11_class::initializer<Class, yomm11_class::base_list<Bases...>>::initializer
}

template<class Class, class... Bases>
yomm11_class::initializer<Class, yomm11_class::base_list<Bases...>> yomm11_class::initializer<Class, yomm11_class::base_list<Bases...>>::the;
yomm11_class::initializer<Class, type_list<Bases...>> yomm11_class::initializer<Class, type_list<Bases...>>::the;

template<template<typename Sig> class Method, typename R, typename... P>
struct method<Method, R(P...)> {
Expand Down

0 comments on commit 4dd0e80

Please sign in to comment.