Replace boost::function by std::function
This commit is contained in:
parent
2ff6a4966a
commit
567293c14d
@ -26,9 +26,9 @@
|
|||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osgText/Font>
|
#include <osgText/Font>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <functional>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
@ -83,10 +83,10 @@ namespace canvas
|
|||||||
typedef osg::ref_ptr<osgText::Font> FontPtr;
|
typedef osg::ref_ptr<osgText::Font> FontPtr;
|
||||||
|
|
||||||
typedef std::vector<PlacementPtr> Placements;
|
typedef std::vector<PlacementPtr> Placements;
|
||||||
typedef boost::function<Placements( SGPropertyNode*,
|
typedef std::function<Placements( SGPropertyNode*,
|
||||||
CanvasPtr )> PlacementFactory;
|
CanvasPtr )> PlacementFactory;
|
||||||
|
|
||||||
typedef boost::function<void(const EventPtr&)> EventListener;
|
typedef std::function<void(const EventPtr&)> EventListener;
|
||||||
|
|
||||||
} // namespace canvas
|
} // namespace canvas
|
||||||
} // namespace simgear
|
} // namespace simgear
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
#include <osg/BoundingBox>
|
#include <osg/BoundingBox>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Drawable;
|
class Drawable;
|
||||||
@ -61,9 +59,9 @@ namespace canvas
|
|||||||
OSGUserData(ElementPtr element);
|
OSGUserData(ElementPtr element);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::function<bool(Element&, const SGPropertyNode*)>
|
typedef std::function<bool(Element&, const SGPropertyNode*)>
|
||||||
StyleSetterFunc;
|
StyleSetterFunc;
|
||||||
typedef boost::function<void(Element&, const SGPropertyNode*)>
|
typedef std::function<void(Element&, const SGPropertyNode*)>
|
||||||
StyleSetterFuncUnchecked;
|
StyleSetterFuncUnchecked;
|
||||||
struct StyleSetter:
|
struct StyleSetter:
|
||||||
public SGReferenced
|
public SGReferenced
|
||||||
@ -318,7 +316,7 @@ namespace canvas
|
|||||||
StyleSetter
|
StyleSetter
|
||||||
addStyle( const std::string& name,
|
addStyle( const std::string& name,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const boost::function<void (Derived&, T2)>& setter,
|
const std::function<void (Derived&, T2)>& setter,
|
||||||
bool inheritable = true )
|
bool inheritable = true )
|
||||||
{
|
{
|
||||||
StyleInfo& style_info = _style_setters[ name ];
|
StyleInfo& style_info = _style_setters[ name ];
|
||||||
@ -359,7 +357,7 @@ namespace canvas
|
|||||||
StyleSetter
|
StyleSetter
|
||||||
addStyle( const std::string& name,
|
addStyle( const std::string& name,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const boost::function<void (Derived&, T)>& setter,
|
const std::function<void (Derived&, T)>& setter,
|
||||||
bool inheritable = true )
|
bool inheritable = true )
|
||||||
{
|
{
|
||||||
return addStyle<T, T>(name, type, setter, inheritable);
|
return addStyle<T, T>(name, type, setter, inheritable);
|
||||||
@ -380,7 +378,7 @@ namespace canvas
|
|||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
boost::function<void (Derived&, T)>(setter),
|
std::function<void (Derived&, T)>(setter),
|
||||||
inheritable
|
inheritable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -401,7 +399,7 @@ namespace canvas
|
|||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
boost::function<void (Derived&, T2)>(setter),
|
std::function<void (Derived&, T2)>(setter),
|
||||||
inheritable
|
inheritable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -420,7 +418,7 @@ namespace canvas
|
|||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
boost::function<void (Derived&, const std::string&)>(setter),
|
std::function<void (Derived&, const std::string&)>(setter),
|
||||||
inheritable
|
inheritable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -483,7 +481,7 @@ namespace canvas
|
|||||||
StyleSetter
|
StyleSetter
|
||||||
addStyle( const std::string& name,
|
addStyle( const std::string& name,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const boost::function<void (Other&, T2)>& setter,
|
const std::function<void (Other&, T2)>& setter,
|
||||||
OtherRef Derived::*instance_ref,
|
OtherRef Derived::*instance_ref,
|
||||||
bool inheritable = true )
|
bool inheritable = true )
|
||||||
{
|
{
|
||||||
@ -513,7 +511,7 @@ namespace canvas
|
|||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
boost::function<void (Other&, const std::string&)>(setter),
|
std::function<void (Other&, const std::string&)>(setter),
|
||||||
instance_ref,
|
instance_ref,
|
||||||
inheritable
|
inheritable
|
||||||
);
|
);
|
||||||
@ -521,7 +519,7 @@ namespace canvas
|
|||||||
|
|
||||||
template<typename T, class Derived, class Other, class OtherRef>
|
template<typename T, class Derived, class Other, class OtherRef>
|
||||||
static
|
static
|
||||||
boost::function<void (Derived&, T)>
|
std::function<void (Derived&, T)>
|
||||||
bindOther( void (Other::*setter)(T), OtherRef Derived::*instance_ref )
|
bindOther( void (Other::*setter)(T), OtherRef Derived::*instance_ref )
|
||||||
{
|
{
|
||||||
return std::bind(setter,
|
return std::bind(setter,
|
||||||
@ -531,8 +529,8 @@ namespace canvas
|
|||||||
|
|
||||||
template<typename T, class Derived, class Other, class OtherRef>
|
template<typename T, class Derived, class Other, class OtherRef>
|
||||||
static
|
static
|
||||||
boost::function<void (Derived&, T)>
|
std::function<void (Derived&, T)>
|
||||||
bindOther( const boost::function<void (Other&, T)>& setter,
|
bindOther( const std::function<void (Other&, T)>& setter,
|
||||||
OtherRef Derived::*instance_ref )
|
OtherRef Derived::*instance_ref )
|
||||||
{
|
{
|
||||||
return std::bind(setter,
|
return std::bind(setter,
|
||||||
@ -545,7 +543,7 @@ namespace canvas
|
|||||||
static
|
static
|
||||||
StyleSetterFuncUnchecked
|
StyleSetterFuncUnchecked
|
||||||
bindStyleSetter( const std::string& name,
|
bindStyleSetter( const std::string& name,
|
||||||
const boost::function<void (Derived&, T2)>& setter )
|
const std::function<void (Derived&, T2)>& setter )
|
||||||
{
|
{
|
||||||
return std::bind(setter,
|
return std::bind(setter,
|
||||||
// We will only call setters with Derived instances, so we can safely
|
// We will only call setters with Derived instances, so we can safely
|
||||||
|
@ -150,7 +150,7 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool NasalWidget::hasHeightForWidth() const
|
bool NasalWidget::hasHeightForWidth() const
|
||||||
{
|
{
|
||||||
return !_height_for_width.empty() || !_min_height_for_width.empty();
|
return _height_for_width || _min_height_for_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -186,7 +186,7 @@ namespace canvas
|
|||||||
int NasalWidget::callHeightForWidthFunc( const HeightForWidthFunc& hfw,
|
int NasalWidget::callHeightForWidthFunc( const HeightForWidthFunc& hfw,
|
||||||
int w ) const
|
int w ) const
|
||||||
{
|
{
|
||||||
if( hfw.empty() )
|
if( !hfw )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -239,17 +239,17 @@ namespace canvas
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int NasalWidget::heightForWidthImpl(int w) const
|
int NasalWidget::heightForWidthImpl(int w) const
|
||||||
{
|
{
|
||||||
return callHeightForWidthFunc( _height_for_width.empty()
|
return callHeightForWidthFunc( _height_for_width
|
||||||
? _min_height_for_width
|
? _height_for_width
|
||||||
: _height_for_width, w );
|
: _min_height_for_width, w );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int NasalWidget::minimumHeightForWidthImpl(int w) const
|
int NasalWidget::minimumHeightForWidthImpl(int w) const
|
||||||
{
|
{
|
||||||
return callHeightForWidthFunc( _min_height_for_width.empty()
|
return callHeightForWidthFunc( _min_height_for_width
|
||||||
? _height_for_width
|
? _min_height_for_width
|
||||||
: _min_height_for_width, w );
|
: _height_for_width, w );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::function<void (nasal::Me, const SGRecti&)> SetGeometryFunc;
|
typedef std::function<void (nasal::Me, const SGRecti&)> SetGeometryFunc;
|
||||||
typedef boost::function<int (nasal::Me, int)> HeightForWidthFunc;
|
typedef std::function<int (nasal::Me, int)> HeightForWidthFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include <simgear_config.h>
|
#include <simgear_config.h>
|
||||||
#include "HTTPRequest.hxx"
|
#include "HTTPRequest.hxx"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/misc/strutils.hxx>
|
#include <simgear/misc/strutils.hxx>
|
||||||
|
@ -44,7 +44,7 @@ class Request:
|
|||||||
public SGReferenced
|
public SGReferenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::function<void(Request*)> Callback;
|
typedef std::function<void(Request*)> Callback;
|
||||||
|
|
||||||
enum ReadyState
|
enum ReadyState
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#define SG_LISTDIFF_HXX_
|
#define SG_LISTDIFF_HXX_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ namespace simgear
|
|||||||
struct ListDiff
|
struct ListDiff
|
||||||
{
|
{
|
||||||
typedef std::vector<T> List;
|
typedef std::vector<T> List;
|
||||||
typedef boost::function<void (T)> Callback;
|
typedef std::function<void (T)> Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform list diff in-place (modifies both lists) and call cb_add for
|
* Perform list diff in-place (modifies both lists) and call cb_add for
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#ifndef LRU_CACHE_HXX_
|
#ifndef LRU_CACHE_HXX_
|
||||||
#define LRU_CACHE_HXX_
|
#define LRU_CACHE_HXX_
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <simgear/structure/SGWeakPtr.hxx>
|
#include <simgear/structure/SGWeakPtr.hxx>
|
||||||
|
|
||||||
#include <boost/call_traits.hpp>
|
#include <boost/call_traits.hpp>
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -216,7 +215,7 @@ namespace nasal
|
|||||||
* .member("x_writeonly", &MyClass::setX)
|
* .member("x_writeonly", &MyClass::setX)
|
||||||
* // Methods can be nearly anything callable and accepting a reference
|
* // Methods can be nearly anything callable and accepting a reference
|
||||||
* // to an instance of the class type. (member functions, free functions
|
* // to an instance of the class type. (member functions, free functions
|
||||||
* // and anything else bindable using boost::function and std::bind)
|
* // and anything else bindable using std::function and std::bind)
|
||||||
* .method("myMember", &MyClass::myMember)
|
* .method("myMember", &MyClass::myMember)
|
||||||
* .method("doSomething", &MyClass::doSomethingElse)
|
* .method("doSomething", &MyClass::doSomethingElse)
|
||||||
* .method("other", &myOtherFreeMember);
|
* .method("other", &myOtherFreeMember);
|
||||||
@ -233,16 +232,16 @@ namespace nasal
|
|||||||
using weak_ref = typename shared_ptr_traits<T>::weak_ref;
|
using weak_ref = typename shared_ptr_traits<T>::weak_ref;
|
||||||
using member_func_t = naRef (raw_type::*)(const CallContext&);
|
using member_func_t = naRef (raw_type::*)(const CallContext&);
|
||||||
using free_func_t = naRef (*)(raw_type&, const CallContext&);
|
using free_func_t = naRef (*)(raw_type&, const CallContext&);
|
||||||
using getter_t = boost::function<naRef(raw_type&, naContext)>;
|
using getter_t = std::function<naRef(raw_type&, naContext)>;
|
||||||
using setter_t = boost::function<void( raw_type&, naContext, naRef)>;
|
using setter_t = std::function<void( raw_type&, naContext, naRef)>;
|
||||||
using method_t = boost::function<naRef(raw_type&, const CallContext&)>;
|
using method_t = std::function<naRef(raw_type&, const CallContext&)>;
|
||||||
using fallback_getter_t =
|
using fallback_getter_t =
|
||||||
boost::function<bool(raw_type&, naContext, const std::string&, naRef&)>;
|
std::function<bool(raw_type&, naContext, const std::string&, naRef&)>;
|
||||||
using fallback_setter_t =
|
using fallback_setter_t =
|
||||||
boost::function<bool(raw_type&, naContext, const std::string&, naRef)>;
|
std::function<bool(raw_type&, naContext, const std::string&, naRef)>;
|
||||||
|
|
||||||
template<class Ret, class... Args>
|
template<class Ret, class... Args>
|
||||||
using method_variadic_t = boost::function<Ret (raw_type&, Args...)>;
|
using method_variadic_t = std::function<Ret (raw_type&, Args...)>;
|
||||||
|
|
||||||
class MethodHolder:
|
class MethodHolder:
|
||||||
public internal::MethodHolder
|
public internal::MethodHolder
|
||||||
@ -564,7 +563,7 @@ namespace nasal
|
|||||||
const getter_t& getter,
|
const getter_t& getter,
|
||||||
const setter_t& setter = setter_t() )
|
const setter_t& setter = setter_t() )
|
||||||
{
|
{
|
||||||
if( !getter.empty() || !setter.empty() )
|
if( getter || setter )
|
||||||
_members[field] = member_t(getter, setter);
|
_members[field] = member_t(getter, setter);
|
||||||
else
|
else
|
||||||
SG_LOG
|
SG_LOG
|
||||||
@ -591,9 +590,9 @@ namespace nasal
|
|||||||
* of this ghost, and convert it to the given @a Param type.
|
* of this ghost, and convert it to the given @a Param type.
|
||||||
*/
|
*/
|
||||||
template<class Param>
|
template<class Param>
|
||||||
Ghost& _get( const boost::function<bool ( raw_type&,
|
Ghost& _get( const std::function<bool ( raw_type&,
|
||||||
const std::string&,
|
const std::string&,
|
||||||
Param& )>& getter )
|
Param& )>& getter )
|
||||||
{
|
{
|
||||||
return _get(std::bind(convert_param_invoker<Param>,
|
return _get(std::bind(convert_param_invoker<Param>,
|
||||||
getter,
|
getter,
|
||||||
@ -623,7 +622,7 @@ namespace nasal
|
|||||||
Ghost& _get(bool (raw_type::*getter)(const std::string&, Param&) const)
|
Ghost& _get(bool (raw_type::*getter)(const std::string&, Param&) const)
|
||||||
{
|
{
|
||||||
return _get(
|
return _get(
|
||||||
boost::function<bool (raw_type&, const std::string&, Param&)>(getter)
|
std::function<bool (raw_type&, const std::string&, Param&)>(getter)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,9 +665,9 @@ namespace nasal
|
|||||||
* this ghost, and convert it to the given @a Param type.
|
* this ghost, and convert it to the given @a Param type.
|
||||||
*/
|
*/
|
||||||
template<class Param>
|
template<class Param>
|
||||||
Ghost& _set(const boost::function<bool ( raw_type&,
|
Ghost& _set(const std::function<bool ( raw_type&,
|
||||||
const std::string&,
|
const std::string&,
|
||||||
Param )>& setter)
|
Param )>& setter)
|
||||||
{
|
{
|
||||||
// Setter signature: bool( raw_type&,
|
// Setter signature: bool( raw_type&,
|
||||||
// naContext,
|
// naContext,
|
||||||
@ -702,7 +701,7 @@ namespace nasal
|
|||||||
Ghost& _set(bool (raw_type::*setter)(const std::string&, Param))
|
Ghost& _set(bool (raw_type::*setter)(const std::string&, Param))
|
||||||
{
|
{
|
||||||
return _set(
|
return _set(
|
||||||
boost::function<bool (raw_type&, const std::string&, Param)>(setter)
|
std::function<bool (raw_type&, const std::string&, Param)>(setter)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +767,7 @@ namespace nasal
|
|||||||
Ghost& method
|
Ghost& method
|
||||||
(
|
(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const boost::function<Ret (raw_type&, const CallContext&)>& func
|
const std::function<Ret (raw_type&, const CallContext&)>& func
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return method(name, std::bind(method_invoker<Ret>,
|
return method(name, std::bind(method_invoker<Ret>,
|
||||||
@ -789,7 +788,7 @@ namespace nasal
|
|||||||
std::index_sequence<Indices...> )
|
std::index_sequence<Indices...> )
|
||||||
{
|
{
|
||||||
return method<Ret>(name,
|
return method<Ret>(name,
|
||||||
typename boost::function<Ret (raw_type&, const CallContext&)>
|
typename std::function<Ret (raw_type&, const CallContext&)>
|
||||||
(std::bind(func,
|
(std::bind(func,
|
||||||
std::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std::bind(&Ghost::arg_from_nasal<Args>,
|
std::bind(&Ghost::arg_from_nasal<Args>,
|
||||||
@ -1149,9 +1148,9 @@ namespace nasal
|
|||||||
static
|
static
|
||||||
bool convert_param_invoker
|
bool convert_param_invoker
|
||||||
(
|
(
|
||||||
const boost::function<bool ( raw_type&,
|
const std::function<bool ( raw_type&,
|
||||||
const std::string&,
|
const std::string&,
|
||||||
Param& )>& func,
|
Param& )>& func,
|
||||||
raw_type& obj,
|
raw_type& obj,
|
||||||
naContext c,
|
naContext c,
|
||||||
const std::string& key,
|
const std::string& key,
|
||||||
@ -1174,7 +1173,7 @@ namespace nasal
|
|||||||
std::enable_if_t<!std::is_void<Ret>::value, naRef>
|
std::enable_if_t<!std::is_void<Ret>::value, naRef>
|
||||||
method_invoker
|
method_invoker
|
||||||
(
|
(
|
||||||
const boost::function<Ret (raw_type&, const CallContext&)>& func,
|
const std::function<Ret (raw_type&, const CallContext&)>& func,
|
||||||
raw_type& obj,
|
raw_type& obj,
|
||||||
const CallContext& ctx
|
const CallContext& ctx
|
||||||
)
|
)
|
||||||
@ -1190,7 +1189,7 @@ namespace nasal
|
|||||||
std::enable_if_t<std::is_void<Ret>::value, naRef>
|
std::enable_if_t<std::is_void<Ret>::value, naRef>
|
||||||
method_invoker
|
method_invoker
|
||||||
(
|
(
|
||||||
const boost::function<Ret (raw_type&, const CallContext&)>& func,
|
const std::function<Ret (raw_type&, const CallContext&)>& func,
|
||||||
raw_type& obj,
|
raw_type& obj,
|
||||||
const CallContext& ctx
|
const CallContext& ctx
|
||||||
)
|
)
|
||||||
@ -1362,7 +1361,7 @@ namespace nasal
|
|||||||
}
|
}
|
||||||
else if( member->second.func )
|
else if( member->second.func )
|
||||||
*out = member->second.func->get_naRef(c);
|
*out = member->second.func->get_naRef(c);
|
||||||
else if( !member->second.getter.empty() )
|
else if( member->second.getter )
|
||||||
*out = member->second.getter(obj, c);
|
*out = member->second.getter(obj, c);
|
||||||
else
|
else
|
||||||
return "Read-protected member";
|
return "Read-protected member";
|
||||||
@ -1411,7 +1410,7 @@ namespace nasal
|
|||||||
else if( !fallback_set(obj, c, key, val) )
|
else if( !fallback_set(obj, c, key, val) )
|
||||||
naRuntimeError(c, "ghost: Failed to write (_set: %s)", key.c_str());
|
naRuntimeError(c, "ghost: Failed to write (_set: %s)", key.c_str());
|
||||||
}
|
}
|
||||||
else if( member->second.setter.empty() )
|
else if( !member->second.setter )
|
||||||
naRuntimeError(c, "ghost: Write protected member: %s", key.c_str());
|
naRuntimeError(c, "ghost: Write protected member: %s", key.c_str());
|
||||||
else if( member->second.func )
|
else if( member->second.func )
|
||||||
naRuntimeError(c, "ghost: Write to function: %s", key.c_str());
|
naRuntimeError(c, "ghost: Write to function: %s", key.c_str());
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include <simgear/emesary/Emesary.hxx>
|
#include <simgear/emesary/Emesary.hxx>
|
||||||
#include <simgear/emesary/notifications.hxx>
|
#include <simgear/emesary/notifications.hxx>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include <simgear/threads/SGThread.hxx>
|
#include <simgear/threads/SGThread.hxx>
|
||||||
|
@ -52,7 +52,7 @@ namespace nasal
|
|||||||
return Ret();
|
return Ret();
|
||||||
|
|
||||||
Context ctx;
|
Context ctx;
|
||||||
auto func = get_member<boost::function<Ret (Me, Args...)>>(
|
auto func = get_member<std::function<Ret (Me, Args...)>>(
|
||||||
ctx, _nasal_impl.get_naRef(), name
|
ctx, _nasal_impl.get_naRef(), name
|
||||||
);
|
);
|
||||||
if( func )
|
if( func )
|
||||||
|
@ -32,9 +32,8 @@
|
|||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -110,14 +109,14 @@ namespace nasal
|
|||||||
bool from_nasal_helper(naContext c, naRef ref, const bool*);
|
bool from_nasal_helper(naContext c, naRef ref, const bool*);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a Nasal function to a boost::function with the given signature.
|
* Convert a Nasal function to a std::function with the given signature.
|
||||||
*
|
*
|
||||||
* @tparam Sig Signature of returned function (arguments and return value
|
* @tparam Sig Signature of returned function (arguments and return value
|
||||||
* are automatically converted using from_nasal/to_nasal)
|
* are automatically converted using from_nasal/to_nasal)
|
||||||
*/
|
*/
|
||||||
template<class Ret, class... Args>
|
template<class Ret, class... Args>
|
||||||
boost::function<Ret (Args...)>
|
std::function<Ret (Args...)>
|
||||||
from_nasal_helper(naContext c, naRef ref, const boost::function<Ret (Args...)>*)
|
from_nasal_helper(naContext c, naRef ref, const std::function<Ret (Args...)>*)
|
||||||
{
|
{
|
||||||
if( naIsNil(ref) )
|
if( naIsNil(ref) )
|
||||||
return {};
|
return {};
|
||||||
@ -131,11 +130,11 @@ namespace nasal
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Ret, class... Args>
|
template<class Ret, class... Args>
|
||||||
boost::function<Ret (Args...)>
|
std::function<Ret (Args...)>
|
||||||
from_nasal_helper(naContext c, naRef ref, Ret (*const)(Args...))
|
from_nasal_helper(naContext c, naRef ref, Ret (*const)(Args...))
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
from_nasal_helper(c, ref, static_cast<boost::function<Ret (Args...)>*>(0));
|
from_nasal_helper(c, ref, static_cast<std::function<Ret (Args...)>*>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
namespace nasal
|
namespace nasal
|
||||||
{
|
{
|
||||||
// create single instance of the main loop recipient for Nasal - this will self register at the
|
// create single instance of the main loop recipient for Nasal - this will self register at the
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <boost/call_traits.hpp>
|
#include <boost/call_traits.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <functional>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -42,7 +43,7 @@ class SGPath;
|
|||||||
namespace nasal
|
namespace nasal
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef boost::function<naRef (CallContext)> free_function_t;
|
typedef std::function<naRef (CallContext)> free_function_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert std::string to Nasal string
|
* Convert std::string to Nasal string
|
||||||
|
@ -231,25 +231,25 @@ BOOST_AUTO_TEST_CASE( cppbind_misc_testing )
|
|||||||
|
|
||||||
|
|
||||||
// 'func' is a C++ function registered to Nasal and now converted back to C++
|
// 'func' is a C++ function registered to Nasal and now converted back to C++
|
||||||
boost::function<int (int)> f = hash.get<int (int)>("func");
|
std::function<int (int)> f = hash.get<int (int)>("func");
|
||||||
BOOST_REQUIRE( f );
|
BOOST_REQUIRE( f );
|
||||||
BOOST_CHECK_EQUAL(f(3), 3);
|
BOOST_CHECK_EQUAL(f(3), 3);
|
||||||
|
|
||||||
boost::function<std::string (int)> fs = hash.get<std::string (int)>("func");
|
std::function<std::string (int)> fs = hash.get<std::string (int)>("func");
|
||||||
BOOST_REQUIRE( fs );
|
BOOST_REQUIRE( fs );
|
||||||
BOOST_CHECK_EQUAL(fs(14), "14");
|
BOOST_CHECK_EQUAL(fs(14), "14");
|
||||||
|
|
||||||
typedef boost::function<void (int)> FuncVoidInt;
|
typedef std::function<void (int)> FuncVoidInt;
|
||||||
FuncVoidInt fvi = hash.get<FuncVoidInt>("func");
|
FuncVoidInt fvi = hash.get<FuncVoidInt>("func");
|
||||||
BOOST_REQUIRE( fvi );
|
BOOST_REQUIRE( fvi );
|
||||||
fvi(123);
|
fvi(123);
|
||||||
|
|
||||||
typedef boost::function<std::string (const std::string&, int, float)> FuncMultiArg;
|
typedef std::function<std::string (const std::string&, int, float)> FuncMultiArg;
|
||||||
FuncMultiArg fma = hash.get<FuncMultiArg>("func");
|
FuncMultiArg fma = hash.get<FuncMultiArg>("func");
|
||||||
BOOST_REQUIRE( fma );
|
BOOST_REQUIRE( fma );
|
||||||
BOOST_CHECK_EQUAL(fma("test", 3, .5), "test");
|
BOOST_CHECK_EQUAL(fma("test", 3, .5), "test");
|
||||||
|
|
||||||
typedef boost::function<naRef (naRef)> naRefMemFunc;
|
typedef std::function<naRef (naRef)> naRefMemFunc;
|
||||||
naRefMemFunc fmem = hash.get<naRefMemFunc>("func");
|
naRefMemFunc fmem = hash.get<naRefMemFunc>("func");
|
||||||
BOOST_REQUIRE( fmem );
|
BOOST_REQUIRE( fmem );
|
||||||
naRef ret = fmem(hash.get_naRef()),
|
naRef ret = fmem(hash.get_naRef()),
|
||||||
@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE( cppbind_misc_testing )
|
|||||||
|
|
||||||
// Check if nasal::Me gets passed as self/me and remaining arguments are
|
// Check if nasal::Me gets passed as self/me and remaining arguments are
|
||||||
// passed on to function
|
// passed on to function
|
||||||
typedef boost::function<int (Me, int)> MeIntFunc;
|
typedef std::function<int (Me, int)> MeIntFunc;
|
||||||
MeIntFunc fmeint = hash.get<MeIntFunc>("func");
|
MeIntFunc fmeint = hash.get<MeIntFunc>("func");
|
||||||
BOOST_CHECK_EQUAL(fmeint(Me{}, 5), 5);
|
BOOST_CHECK_EQUAL(fmeint(Me{}, 5), 5);
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ BOOST_AUTO_TEST_CASE( cppbind_misc_testing )
|
|||||||
BOOST_CHECK( naIsFunc(thisGetter) );
|
BOOST_CHECK( naIsFunc(thisGetter) );
|
||||||
|
|
||||||
// ...and check if it really gets passed the correct instance
|
// ...and check if it really gets passed the correct instance
|
||||||
typedef boost::function<unsigned long (Me)> MemFunc;
|
typedef std::function<unsigned long (Me)> MemFunc;
|
||||||
MemFunc fGetThis = c.from_nasal<MemFunc>(thisGetter);
|
MemFunc fGetThis = c.from_nasal<MemFunc>(thisGetter);
|
||||||
BOOST_REQUIRE( fGetThis );
|
BOOST_REQUIRE( fGetThis );
|
||||||
BOOST_CHECK_EQUAL( fGetThis(Me{derived}), (unsigned long)d.get() );
|
BOOST_CHECK_EQUAL( fGetThis(Me{derived}), (unsigned long)d.get() );
|
||||||
|
@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE( bind_methods )
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
using TestClassPtr = std::shared_ptr<TestClass>;
|
using TestClassPtr = std::shared_ptr<TestClass>;
|
||||||
auto set_func = boost::function<
|
auto set_func = std::function<
|
||||||
void (TestClass&, int, const std::string&, const std::string&, int)
|
void (TestClass&, int, const std::string&, const std::string&, int)
|
||||||
>(&TestClass::set);
|
>(&TestClass::set);
|
||||||
nasal::Ghost<TestClassPtr>::init("TestClass")
|
nasal::Ghost<TestClassPtr>::init("TestClass")
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
#include <simgear/package/Catalog.hxx>
|
#include <simgear/package/Catalog.hxx>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
|
@ -139,7 +139,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
|
||||||
typedef boost::function<void(Catalog*)> Callback;
|
typedef std::function<void(Catalog*)> Callback;
|
||||||
|
|
||||||
void addStatusCallback(const Callback& cb);
|
void addStatusCallback(const Callback& cb);
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
#include <simgear_config.h>
|
#include <simgear_config.h>
|
||||||
#include <simgear/package/Install.hxx>
|
#include <simgear/package/Install.hxx>
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include <simgear/package/unzip.h>
|
#include <simgear/package/unzip.h>
|
||||||
#include <simgear/package/md5.h>
|
#include <simgear/package/md5.h>
|
||||||
|
@ -52,9 +52,8 @@ class Install : public SGReferenced
|
|||||||
public:
|
public:
|
||||||
virtual ~Install();
|
virtual ~Install();
|
||||||
|
|
||||||
typedef boost::function<void(Install*)> Callback;
|
typedef std::function<void(Install*)> Callback;
|
||||||
typedef boost::function<void(Install*, unsigned int, unsigned int)>
|
typedef std::function<void(Install*, unsigned int, unsigned int)> ProgressCallback;
|
||||||
ProgressCallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create from a directory on disk, or fail.
|
* create from a directory on disk, or fail.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <simgear/package/Package.hxx>
|
#include <simgear/package/Package.hxx>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -51,7 +51,7 @@ typedef std::vector<PackageRef> PackageList;
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::function<void(Package*, Install*)> InstallCallback;
|
typedef std::function<void(Package*, Install*)> InstallCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get or create an install for the package
|
* get or create an install for the package
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
#include <simgear/package/Root.hxx>
|
#include <simgear/package/Root.hxx>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <map>
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "PropertyBasedElement.hxx"
|
#include "PropertyBasedElement.hxx"
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
@ -62,7 +61,7 @@ public:
|
|||||||
virtual const SGPropertyNode* getPropertyRoot() const;
|
virtual const SGPropertyNode* getPropertyRoot() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef boost::function<PropertyBasedElementPtr(SGPropertyNode*)>
|
typedef std::function<PropertyBasedElementPtr(SGPropertyNode*)>
|
||||||
ElementFactory;
|
ElementFactory;
|
||||||
|
|
||||||
/** Branch in the property tree for this property managed subsystem */
|
/** Branch in the property tree for this property managed subsystem */
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef SG_FUNCTION_LIST_HXX_
|
#ifndef SG_FUNCTION_LIST_HXX_
|
||||||
#define SG_FUNCTION_LIST_HXX_
|
#define SG_FUNCTION_LIST_HXX_
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
@ -27,14 +27,14 @@ namespace simgear
|
|||||||
template<typename Sig> class function_list;
|
template<typename Sig> class function_list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a list of callbacks like a single boost::function.
|
* Handle a list of callbacks like a single std::function.
|
||||||
*
|
*
|
||||||
* @tparam Ret Return type of the callbacks
|
* @tparam Ret Return type of the callbacks
|
||||||
* @tparam Args Parameter types of the callbacks
|
* @tparam Args Parameter types of the callbacks
|
||||||
*/
|
*/
|
||||||
template<class Ret, class... Args>
|
template<class Ret, class... Args>
|
||||||
class function_list<Ret(Args...)>:
|
class function_list<Ret(Args...)>:
|
||||||
public std::vector<boost::function<Ret(Args...)>>
|
public std::vector<std::function<Ret(Args...)>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Ret operator()(Args ... args) const
|
Ret operator()(Args ... args) const
|
||||||
@ -53,10 +53,10 @@ namespace simgear
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a list of callbacks with the same signature as the given
|
* Handle a list of callbacks with the same signature as the given
|
||||||
* boost::function type.
|
* std::function type.
|
||||||
*/
|
*/
|
||||||
template<class Ret, class... Args>
|
template<class Ret, class... Args>
|
||||||
class function_list<boost::function<Ret(Args...)>>:
|
class function_list<std::function<Ret(Args...)>>:
|
||||||
public function_list<Ret(Args...)>
|
public function_list<Ret(Args...)>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE( create_and_call )
|
|||||||
BOOST_REQUIRE_EQUAL(func_called, 2);
|
BOOST_REQUIRE_EQUAL(func_called, 2);
|
||||||
BOOST_REQUIRE_EQUAL(func2_called, 1);
|
BOOST_REQUIRE_EQUAL(func2_called, 1);
|
||||||
|
|
||||||
function_list<boost::function<int (int)> > func_list2;
|
function_list<std::function<int (int)> > func_list2;
|
||||||
func_list2.push_back(&func);
|
func_list2.push_back(&func);
|
||||||
func_list2.push_back(&func2);
|
func_list2.push_back(&func2);
|
||||||
func_list2.push_back(&func2);
|
func_list2.push_back(&func2);
|
||||||
@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE( create_and_call )
|
|||||||
BOOST_REQUIRE_EQUAL(func2_called, 3);
|
BOOST_REQUIRE_EQUAL(func2_called, 3);
|
||||||
|
|
||||||
// two parameters
|
// two parameters
|
||||||
function_list<boost::function<int (int, int)> > func_list3;
|
function_list<std::function<int (int, int)> > func_list3;
|
||||||
func_list3.push_back(&func_add);
|
func_list3.push_back(&func_add);
|
||||||
func_list3.push_back(&func2_add);
|
func_list3.push_back(&func2_add);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user