Skip to content

Commit

Permalink
Identifiers/names now return IdReturn to improve usability.
Browse files Browse the repository at this point in the history
- Fix for issue #60.
  • Loading branch information
billyquith committed Oct 28, 2016
1 parent a4b628b commit 1648fa3
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 19 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ Ponder Changelog

- [Notes with examples on blog](http://billyquith.github.io/ponder/blog/).

### 2.1.1

- Identifiers/names now return IdReturn (`const std::string&`) to improve usability.

### 2.1

- Bind Lua argument convertion directly to function. Saves Value conversion.
- Lua custom type conversion with LuaValueRead and LuaValueWrite.
- Lua supports enums.
- Lua can return multiple values via `std::tuple<...>`.
- Lua functions can parse table arguments.
- Declaration report generator.

## 2.0

Expand Down
2 changes: 1 addition & 1 deletion cmake/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# setup version numbers
set(VERSION_MAJOR 2)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_STR "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("Project version: ${VERSION_STR}")

Expand Down
2 changes: 1 addition & 1 deletion include/ponder/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class PONDER_API Class : public TagHolder, detail::noncopyable
*
* \return String containing the name of the metaclass
*/
IdRef name() const;
IdReturn name() const;

/**
* \brief Return the total number of base metaclasses of this metaclass
Expand Down
2 changes: 1 addition & 1 deletion include/ponder/classbuilder.inl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ClassBuilder<T>& ClassBuilder<T>::base()
{
// Retrieve the base metaclass and its name
const Class& baseClass = classByType<U>();
Id baseName = baseClass.name();
IdReturn baseName = baseClass.name();

// First make sure that the base class is not already a base of the current class
for (Class::BaseInfo& bi : m_target->m_bases)
Expand Down
11 changes: 8 additions & 3 deletions include/ponder/detail/idtraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct IdTraits
typedef std::string string_t;
typedef string_t id_value_t;
typedef const id_value_t& id_ref_t;
typedef const id_value_t& id_return_t;

static inline const char* cstr(id_ref_t r) {return r.c_str();}
};
Expand All @@ -60,9 +61,10 @@ namespace detail {

struct IdTraits
{
typedef std::string string_t;
typedef string_t id_value_t;
typedef string_view id_ref_t;
typedef std::string string_t;
typedef string_t id_value_t;
typedef string_view id_ref_t;
typedef const id_value_t& id_return_t;

static inline const char* cstr(id_ref_t r) {return r.data();}
};
Expand All @@ -83,6 +85,9 @@ typedef detail::IdTraits::id_value_t Id;
/// Type used to pass around references to the an identifier type.
typedef detail::IdTraits::id_ref_t IdRef;

/// Type used to return a identifier value.
typedef detail::IdTraits::id_return_t IdReturn;

namespace id {

static inline const char* c_str(IdRef r) {return ponder::detail::IdTraits::cstr(r);}
Expand Down
6 changes: 3 additions & 3 deletions include/ponder/enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PONDER_API Enum : detail::noncopyable
*
* \return String containing the name of the metaenum
*/
IdRef name() const;
IdReturn name() const;

/**
* \brief Return the size of the metaenum
Expand Down Expand Up @@ -207,7 +207,7 @@ class PONDER_API Enum : detail::noncopyable
*
* \throw InvalidEnumValue value doesn't exist in the metaenum
*/
IdRef name(EnumValue value) const;
IdReturn name(EnumValue value) const;

/**
* \brief Return the name corresponding to given a value for enum class
Expand All @@ -219,7 +219,7 @@ class PONDER_API Enum : detail::noncopyable
* \throw InvalidEnumValue value doesn't exist in the metaenum
*/
template <typename E>
IdRef name(E value) const {return name(static_cast<EnumValue>(value));}
IdReturn name(E value) const {return name(static_cast<EnumValue>(value));}

/**
* \brief Return the value corresponding to given a name
Expand Down
2 changes: 1 addition & 1 deletion include/ponder/enumobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PONDER_API EnumObject
*
* \return String containing the name of the enum object
*/
IdRef name() const;
IdReturn name() const;

/**
* \brief Retrieve the metaenum of the stored enum object
Expand Down
2 changes: 1 addition & 1 deletion include/ponder/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PONDER_API Function : public TagHolder
*
* \return Name of the function
*/
IdRef name() const;
IdReturn name() const;

/**
* \brief Get the kind of function represented here
Expand Down
2 changes: 1 addition & 1 deletion include/ponder/property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PONDER_API Property : public TagHolder
*
* \return Name of the property
*/
IdRef name() const;
IdReturn name() const;

/**
* \brief Get the type of the property
Expand Down
2 changes: 1 addition & 1 deletion src/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Class::Class(IdRef name)
{
}

IdRef Class::name() const
IdReturn Class::name() const
{
return m_id;
}
Expand Down
4 changes: 2 additions & 2 deletions src/enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Enum::Enum(IdRef name)
{
}

IdRef Enum::name() const
IdReturn Enum::name() const
{
return m_name;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ bool Enum::hasValue(EnumValue value) const
return m_enums.containsValue(value);
}

IdRef Enum::name(EnumValue value) const
IdReturn Enum::name(EnumValue value) const
{
auto it = m_enums.findValue(value);

Expand Down
2 changes: 1 addition & 1 deletion src/enumobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ long EnumObject::value() const
return m_value;
}

IdRef EnumObject::name() const
IdReturn EnumObject::name() const
{
return m_enum->name(m_value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Function::~Function()
{
}

IdRef Function::name() const
IdReturn Function::name() const
{
return m_name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Property::~Property()
{
}

IdRef Property::name() const
IdReturn Property::name() const
{
return m_name;
}
Expand Down

0 comments on commit 1648fa3

Please sign in to comment.