Christopher Haster / mbed-hal

Dependencies:   target-freescale

Fork of mbed-hal by Morpheus

Revision:
14:4af7fef9cf08
Parent:
11:f08e03081748
Child:
15:1ce23ed6859a
--- a/api/FunctionPointer.h	Thu Mar 31 20:10:32 2016 -0500
+++ b/api/FunctionPointer.h	Fri Apr 01 01:00:18 2016 -0500
@@ -21,48 +21,48 @@
 
 namespace mbed {
 
-// Reusable FunctionPointerArgs class based on template specialization
+// Reusable FuncPtr class based on template specialization
 template <typename F>
-class FunctionPointerArgs;
+class FuncPtr;
 
 /** A class for storing and calling a pointer to a static or member function
  */
 template <typename R, typename A1, typename A2, typename A3, typename A4>
-class FunctionPointerArgs<R(A1, A2, A3, A4)> {
+class FuncPtr<R(A1, A2, A3, A4)> {
 public:
-    /** Create a FunctionPointerArgs, attaching a static function
+    /** Create a FuncPtr, attaching a static function
      *
      *  @param function The static function to attach (default is none)
      */
-    FunctionPointerArgs(R (*function)(A1, A2, A3, A4) = 0) {
+    FuncPtr(R (*function)(A1, A2, A3, A4) = 0) {
         attach(function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a static function with bound pointer
+    /** Create a FuncPtr, attaching a static function with bound pointer
      *
      *  @param object Pointer to object to bind to function
      *  @param function The static function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (*function)(T*, A1, A2, A3, A4)) {
+    FuncPtr(T *object, R (*function)(T*, A1, A2, A3, A4)) {
         attach(object, function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a member function
+    /** Create a FuncPtr, attaching a member function
      *
      *  @param object The object pointer to invoke the member function on (i.e. the this pointer)
      *  @param function The address of the member function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (T::*member)(A1, A2, A3, A4)) {
+    FuncPtr(T *object, R (T::*member)(A1, A2, A3, A4)) {
         attach(object, member);
     }
 
-    /** Create a FunctionPointerArgs from another FunctionPointerArgs
+    /** Create a FuncPtr from another FuncPtr
      *
      *  @param func The func to attach
      */
-    FunctionPointerArgs(const FunctionPointerArgs<R(A1, A2, A3, A4)> &func) {
+    FuncPtr(const FuncPtr<R(A1, A2, A3, A4)> &func) {
         attach(func);
     }
 
@@ -73,7 +73,7 @@
     void attach(R (*function)(A1, A2, A3, A4)) {
         _object = 0;
         *reinterpret_cast<R (**)(A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::staticthunk;
+        _thunk = &FuncPtr::staticthunk;
     }
 
     /** Attach a static function with bound pointer
@@ -85,7 +85,7 @@
     void attach(T *object, R (*function)(A1, A2, A3, A4)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (**)(T*, A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::boundthunk<T>;
+        _thunk = &FuncPtr::boundthunk<T>;
     }
 
     /** Attach a member function
@@ -97,14 +97,14 @@
     void attach(T *object, R (T::*method)(A1, A2, A3, A4)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (T::**)(A1)>(_function) = method;
-        _thunk = &FunctionPointerArgs::methodthunk<T>;
+        _thunk = &FuncPtr::methodthunk<T>;
     }
 
-    /** Attach a FunctionPointerArgs
+    /** Attach a FuncPtr
      *
      *  @param func The func to attach
      */
-    void attach(const FunctionPointerArgs<R(A1, A2, A3, A4)> &func) {
+    void attach(const FuncPtr<R(A1, A2, A3, A4)> &func) {
         _object = func._object;
         memcpy(_function, func._function, sizeof _function);
         _thunk = func._thunk;
@@ -172,41 +172,41 @@
 /** A class for storing and calling a pointer to a static or member function
  */
 template <typename R, typename A1, typename A2, typename A3>
-class FunctionPointerArgs<R(A1, A2, A3)> {
+class FuncPtr<R(A1, A2, A3)> {
 public:
-    /** Create a FunctionPointerArgs, attaching a static function
+    /** Create a FuncPtr, attaching a static function
      *
      *  @param function The static function to attach (default is none)
      */
-    FunctionPointerArgs(R (*function)(A1, A2, A3) = 0) {
+    FuncPtr(R (*function)(A1, A2, A3) = 0) {
         attach(function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a static function with bound pointer
+    /** Create a FuncPtr, attaching a static function with bound pointer
      *
      *  @param object Pointer to object to bind to function
      *  @param function The static function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (*function)(T*, A1, A2, A3)) {
+    FuncPtr(T *object, R (*function)(T*, A1, A2, A3)) {
         attach(object, function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a member function
+    /** Create a FuncPtr, attaching a member function
      *
      *  @param object The object pointer to invoke the member function on (i.e. the this pointer)
      *  @param function The address of the member function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (T::*member)(A1, A2, A3)) {
+    FuncPtr(T *object, R (T::*member)(A1, A2, A3)) {
         attach(object, member);
     }
 
-    /** Create a FunctionPointerArgs from another FunctionPointerArgs
+    /** Create a FuncPtr from another FuncPtr
      *
      *  @param func The func to attach
      */
-    FunctionPointerArgs(const FunctionPointerArgs<R(A1, A2, A3)> &func) {
+    FuncPtr(const FuncPtr<R(A1, A2, A3)> &func) {
         attach(func);
     }
 
@@ -217,7 +217,7 @@
     void attach(R (*function)(A1, A2, A3)) {
         _object = 0;
         *reinterpret_cast<R (**)(A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::staticthunk;
+        _thunk = &FuncPtr::staticthunk;
     }
 
     /** Attach a static function with bound pointer
@@ -229,7 +229,7 @@
     void attach(T *object, R (*function)(A1, A2, A3)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (**)(T*, A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::boundthunk<T>;
+        _thunk = &FuncPtr::boundthunk<T>;
     }
 
     /** Attach a member function
@@ -241,14 +241,14 @@
     void attach(T *object, R (T::*method)(A1, A2, A3)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (T::**)(A1)>(_function) = method;
-        _thunk = &FunctionPointerArgs::methodthunk<T>;
+        _thunk = &FuncPtr::methodthunk<T>;
     }
 
-    /** Attach a FunctionPointerArgs
+    /** Attach a FuncPtr
      *
      *  @param func The func to attach
      */
-    void attach(const FunctionPointerArgs<R(A1, A2, A3)> &func) {
+    void attach(const FuncPtr<R(A1, A2, A3)> &func) {
         _object = func._object;
         memcpy(_function, func._function, sizeof _function);
         _thunk = func._thunk;
@@ -316,41 +316,41 @@
 /** A class for storing and calling a pointer to a static or member function
  */
 template <typename R, typename A1, typename A2>
-class FunctionPointerArgs<R(A1, A2)> {
+class FuncPtr<R(A1, A2)> {
 public:
-    /** Create a FunctionPointerArgs, attaching a static function
+    /** Create a FuncPtr, attaching a static function
      *
      *  @param function The static function to attach (default is none)
      */
-    FunctionPointerArgs(R (*function)(A1, A2) = 0) {
+    FuncPtr(R (*function)(A1, A2) = 0) {
         attach(function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a static function with bound pointer
+    /** Create a FuncPtr, attaching a static function with bound pointer
      *
      *  @param object Pointer to object to bind to function
      *  @param function The static function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (*function)(T*, A1, A2)) {
+    FuncPtr(T *object, R (*function)(T*, A1, A2)) {
         attach(object, function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a member function
+    /** Create a FuncPtr, attaching a member function
      *
      *  @param object The object pointer to invoke the member function on (i.e. the this pointer)
      *  @param function The address of the member function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (T::*member)(A1, A2)) {
+    FuncPtr(T *object, R (T::*member)(A1, A2)) {
         attach(object, member);
     }
 
-    /** Create a FunctionPointerArgs from another FunctionPointerArgs
+    /** Create a FuncPtr from another FuncPtr
      *
      *  @param func The func to attach
      */
-    FunctionPointerArgs(const FunctionPointerArgs<R(A1, A2)> &func) {
+    FuncPtr(const FuncPtr<R(A1, A2)> &func) {
         attach(func);
     }
 
@@ -361,7 +361,7 @@
     void attach(R (*function)(A1, A2)) {
         _object = 0;
         *reinterpret_cast<R (**)(A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::staticthunk;
+        _thunk = &FuncPtr::staticthunk;
     }
 
     /** Attach a static function with bound pointer
@@ -373,7 +373,7 @@
     void attach(T *object, R (*function)(A1, A2)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (**)(T*, A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::boundthunk<T>;
+        _thunk = &FuncPtr::boundthunk<T>;
     }
 
     /** Attach a member function
@@ -385,14 +385,14 @@
     void attach(T *object, R (T::*method)(A1, A2)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (T::**)(A1)>(_function) = method;
-        _thunk = &FunctionPointerArgs::methodthunk<T>;
+        _thunk = &FuncPtr::methodthunk<T>;
     }
 
-    /** Attach a FunctionPointerArgs
+    /** Attach a FuncPtr
      *
      *  @param func The func to attach
      */
-    void attach(const FunctionPointerArgs<R(A1, A2)> &func) {
+    void attach(const FuncPtr<R(A1, A2)> &func) {
         _object = func._object;
         memcpy(_function, func._function, sizeof _function);
         _thunk = func._thunk;
@@ -460,41 +460,41 @@
 /** A class for storing and calling a pointer to a static or member function
  */
 template <typename R, typename A1>
-class FunctionPointerArgs<R(A1)> {
+class FuncPtr<R(A1)> {
 public:
-    /** Create a FunctionPointerArgs, attaching a static function
+    /** Create a FuncPtr, attaching a static function
      *
      *  @param function The static function to attach (default is none)
      */
-    FunctionPointerArgs(R (*function)(A1) = 0) {
+    FuncPtr(R (*function)(A1) = 0) {
         attach(function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a static function with bound pointer
+    /** Create a FuncPtr, attaching a static function with bound pointer
      *
      *  @param object Pointer to object to bind to function
      *  @param function The static function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (*function)(T*, A1)) {
+    FuncPtr(T *object, R (*function)(T*, A1)) {
         attach(object, function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a member function
+    /** Create a FuncPtr, attaching a member function
      *
      *  @param object The object pointer to invoke the member function on (i.e. the this pointer)
      *  @param function The address of the member function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (T::*member)(A1)) {
+    FuncPtr(T *object, R (T::*member)(A1)) {
         attach(object, member);
     }
 
-    /** Create a FunctionPointerArgs from another FunctionPointerArgs
+    /** Create a FuncPtr from another FuncPtr
      *
      *  @param func The func to attach
      */
-    FunctionPointerArgs(const FunctionPointerArgs<R(A1)> &func) {
+    FuncPtr(const FuncPtr<R(A1)> &func) {
         attach(func);
     }
 
@@ -505,7 +505,7 @@
     void attach(R (*function)(A1)) {
         _object = 0;
         *reinterpret_cast<R (**)(A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::staticthunk;
+        _thunk = &FuncPtr::staticthunk;
     }
 
     /** Attach a static function with bound pointer
@@ -517,7 +517,7 @@
     void attach(T *object, R (*function)(A1)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (**)(T*, A1)>(_function) = function;
-        _thunk = &FunctionPointerArgs::boundthunk<T>;
+        _thunk = &FuncPtr::boundthunk<T>;
     }
 
     /** Attach a member function
@@ -529,14 +529,14 @@
     void attach(T *object, R (T::*method)(A1)) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (T::**)(A1)>(_function) = method;
-        _thunk = &FunctionPointerArgs::methodthunk<T>;
+        _thunk = &FuncPtr::methodthunk<T>;
     }
 
-    /** Attach a FunctionPointerArgs
+    /** Attach a FuncPtr
      *
      *  @param func The func to attach
      */
-    void attach(const FunctionPointerArgs<R(A1)> &func) {
+    void attach(const FuncPtr<R(A1)> &func) {
         _object = func._object;
         memcpy(_function, func._function, sizeof _function);
         _thunk = func._thunk;
@@ -604,41 +604,41 @@
 /** A class for storing and calling a pointer to a static or member function
  */
 template <typename R>
-class FunctionPointerArgs<R()> {
+class FuncPtr<R()> {
 public:
-    /** Create a FunctionPointerArgs, attaching a static function
+    /** Create a FuncPtr, attaching a static function
      *
      *  @param function The static function to attach (default is none)
      */
-    FunctionPointerArgs(R (*function)() = 0) {
+    FuncPtr(R (*function)() = 0) {
         attach(function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a static function with bound pointer
+    /** Create a FuncPtr, attaching a static function with bound pointer
      *
      *  @param object Pointer to object to bind to function
      *  @param function The static function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (*function)(T*)) {
+    FuncPtr(T *object, R (*function)(T*)) {
         attach(object, function);
     }
 
-    /** Create a FunctionPointerArgs, attaching a member function
+    /** Create a FuncPtr, attaching a member function
      *
      *  @param object The object pointer to invoke the member function on (i.e. the this pointer)
      *  @param function The address of the member function to attach
      */
     template<typename T>
-    FunctionPointerArgs(T *object, R (T::*member)()) {
+    FuncPtr(T *object, R (T::*member)()) {
         attach(object, member);
     }
 
-    /** Create a FunctionPointerArgs from another FunctionPointerArgs
+    /** Create a FuncPtr from another FuncPtr
      *
      *  @param func The func to attach
      */
-    FunctionPointerArgs(const FunctionPointerArgs<R()> &func) {
+    FuncPtr(const FuncPtr<R()> &func) {
         attach(func);
     }
 
@@ -649,7 +649,7 @@
     void attach(R (*function)()) {
         _object = 0;
         *reinterpret_cast<R (**)()>(_function) = function;
-        _thunk = &FunctionPointerArgs::staticthunk;
+        _thunk = &FuncPtr::staticthunk;
     }
 
     /** Attach a static function with bound pointer
@@ -661,7 +661,7 @@
     void attach(T *object, R (*function)()) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (**)(T*)>(_function) = function;
-        _thunk = &FunctionPointerArgs::boundthunk<T>;
+        _thunk = &FuncPtr::boundthunk<T>;
     }
 
     /** Attach a member function
@@ -673,14 +673,14 @@
     void attach(T *object, R (T::*method)()) {
         _object = static_cast<void*>(object);
         *reinterpret_cast<R (T::**)()>(_function) = method;
-        _thunk = &FunctionPointerArgs::methodthunk<T>;
+        _thunk = &FuncPtr::methodthunk<T>;
     }
 
-    /** Attach a FunctionPointerArgs
+    /** Attach a FuncPtr
      *
      *  @param func The func to attach
      */
-    void attach(const FunctionPointerArgs<R()> &func) {
+    void attach(const FuncPtr<R()> &func) {
         _object = func._object;
         memcpy(_function, func._function, sizeof _function);
         _thunk = func._thunk;
@@ -750,13 +750,13 @@
 
 // Overloads for backwards compatibility
 template <typename R, typename A1>
-class FunctionPointerArg1 : public FunctionPointerArgs<R(A1)> {};
+class FunctionPointerArg1 : public FuncPtr<R(A1)> {};
 
 template <typename R>
-class FunctionPointerArg1<R, void> : public FunctionPointerArgs<R()> {};
+class FunctionPointerArg1<R, void> : public FuncPtr<R()> {};
 
-typedef FunctionPointerArgs<void()> FunctionPointer;
-typedef FunctionPointerArgs<void(int)> event_callback_t;
+typedef FuncPtr<void()> FunctionPointer;
+typedef FuncPtr<void(int)> event_callback_t;
 
 } // namespace mbed