Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 6:40e873bbc5f7 1 /* mbed Microcontroller Library
MACRUM 6:40e873bbc5f7 2 * Copyright (c) 2006-2015 ARM Limited
MACRUM 6:40e873bbc5f7 3 *
MACRUM 6:40e873bbc5f7 4 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 6:40e873bbc5f7 5 * you may not use this file except in compliance with the License.
MACRUM 6:40e873bbc5f7 6 * You may obtain a copy of the License at
MACRUM 6:40e873bbc5f7 7 *
MACRUM 6:40e873bbc5f7 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 6:40e873bbc5f7 9 *
MACRUM 6:40e873bbc5f7 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 6:40e873bbc5f7 11 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 6:40e873bbc5f7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 6:40e873bbc5f7 13 * See the License for the specific language governing permissions and
MACRUM 6:40e873bbc5f7 14 * limitations under the License.
MACRUM 6:40e873bbc5f7 15 */
MACRUM 6:40e873bbc5f7 16 #ifndef MBED_FUNCTIONPOINTER_H
MACRUM 6:40e873bbc5f7 17 #define MBED_FUNCTIONPOINTER_H
MACRUM 6:40e873bbc5f7 18
MACRUM 6:40e873bbc5f7 19 #include "platform/Callback.h"
MACRUM 6:40e873bbc5f7 20 #include "platform/mbed_toolchain.h"
MACRUM 6:40e873bbc5f7 21 #include <string.h>
MACRUM 6:40e873bbc5f7 22 #include <stdint.h>
MACRUM 6:40e873bbc5f7 23
MACRUM 6:40e873bbc5f7 24 namespace mbed {
MACRUM 6:40e873bbc5f7 25 /** \addtogroup platform */
MACRUM 6:40e873bbc5f7 26 /** @{*/
MACRUM 6:40e873bbc5f7 27
MACRUM 6:40e873bbc5f7 28
MACRUM 6:40e873bbc5f7 29 // Declarations for backwards compatibility
MACRUM 6:40e873bbc5f7 30 // To be foward compatible, code should adopt the Callback class
MACRUM 6:40e873bbc5f7 31 template <typename R, typename A1>
MACRUM 6:40e873bbc5f7 32 class FunctionPointerArg1 : public Callback<R(A1)> {
MACRUM 6:40e873bbc5f7 33 public:
MACRUM 6:40e873bbc5f7 34 MBED_DEPRECATED_SINCE("mbed-os-5.1",
MACRUM 6:40e873bbc5f7 35 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
MACRUM 6:40e873bbc5f7 36 FunctionPointerArg1(R (*function)(A1) = 0)
MACRUM 6:40e873bbc5f7 37 : Callback<R(A1)>(function) {}
MACRUM 6:40e873bbc5f7 38
MACRUM 6:40e873bbc5f7 39 template<typename T>
MACRUM 6:40e873bbc5f7 40 MBED_DEPRECATED_SINCE("mbed-os-5.1",
MACRUM 6:40e873bbc5f7 41 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
MACRUM 6:40e873bbc5f7 42 FunctionPointerArg1(T *object, R (T::*member)(A1))
MACRUM 6:40e873bbc5f7 43 : Callback<R(A1)>(object, member) {}
MACRUM 6:40e873bbc5f7 44
MACRUM 6:40e873bbc5f7 45 R (*get_function())(A1) {
MACRUM 6:40e873bbc5f7 46 return *reinterpret_cast<R (**)(A1)>(this);
MACRUM 6:40e873bbc5f7 47 }
MACRUM 6:40e873bbc5f7 48
MACRUM 6:40e873bbc5f7 49 R call(A1 a1) const {
MACRUM 6:40e873bbc5f7 50 if (!Callback<R(A1)>::operator bool()) {
MACRUM 6:40e873bbc5f7 51 return (R)0;
MACRUM 6:40e873bbc5f7 52 }
MACRUM 6:40e873bbc5f7 53
MACRUM 6:40e873bbc5f7 54 return Callback<R(A1)>::call(a1);
MACRUM 6:40e873bbc5f7 55 }
MACRUM 6:40e873bbc5f7 56
MACRUM 6:40e873bbc5f7 57 R operator()(A1 a1) const {
MACRUM 6:40e873bbc5f7 58 return Callback<R(A1)>::call(a1);
MACRUM 6:40e873bbc5f7 59 }
MACRUM 6:40e873bbc5f7 60 };
MACRUM 6:40e873bbc5f7 61
MACRUM 6:40e873bbc5f7 62 template <typename R>
MACRUM 6:40e873bbc5f7 63 class FunctionPointerArg1<R, void> : public Callback<R()> {
MACRUM 6:40e873bbc5f7 64 public:
MACRUM 6:40e873bbc5f7 65 MBED_DEPRECATED_SINCE("mbed-os-5.1",
MACRUM 6:40e873bbc5f7 66 "FunctionPointer has been replaced by Callback<void()>")
MACRUM 6:40e873bbc5f7 67 FunctionPointerArg1(R (*function)() = 0)
MACRUM 6:40e873bbc5f7 68 : Callback<R()>(function) {}
MACRUM 6:40e873bbc5f7 69
MACRUM 6:40e873bbc5f7 70 template<typename T>
MACRUM 6:40e873bbc5f7 71 MBED_DEPRECATED_SINCE("mbed-os-5.1",
MACRUM 6:40e873bbc5f7 72 "FunctionPointer has been replaced by Callback<void()>")
MACRUM 6:40e873bbc5f7 73 FunctionPointerArg1(T *object, R (T::*member)())
MACRUM 6:40e873bbc5f7 74 : Callback<R()>(object, member) {}
MACRUM 6:40e873bbc5f7 75
MACRUM 6:40e873bbc5f7 76 R (*get_function())() {
MACRUM 6:40e873bbc5f7 77 return *reinterpret_cast<R (**)()>(this);
MACRUM 6:40e873bbc5f7 78 }
MACRUM 6:40e873bbc5f7 79
MACRUM 6:40e873bbc5f7 80 R call() const {
MACRUM 6:40e873bbc5f7 81 if (!Callback<R()>::operator bool()) {
MACRUM 6:40e873bbc5f7 82 return (R)0;
MACRUM 6:40e873bbc5f7 83 }
MACRUM 6:40e873bbc5f7 84
MACRUM 6:40e873bbc5f7 85 return Callback<R()>::call();
MACRUM 6:40e873bbc5f7 86 }
MACRUM 6:40e873bbc5f7 87
MACRUM 6:40e873bbc5f7 88 R operator()() const {
MACRUM 6:40e873bbc5f7 89 return Callback<R()>::call();
MACRUM 6:40e873bbc5f7 90 }
MACRUM 6:40e873bbc5f7 91 };
MACRUM 6:40e873bbc5f7 92
MACRUM 6:40e873bbc5f7 93 typedef FunctionPointerArg1<void, void> FunctionPointer;
MACRUM 6:40e873bbc5f7 94
MACRUM 6:40e873bbc5f7 95
MACRUM 6:40e873bbc5f7 96 } // namespace mbed
MACRUM 6:40e873bbc5f7 97
MACRUM 6:40e873bbc5f7 98 #endif
MACRUM 6:40e873bbc5f7 99
MACRUM 6:40e873bbc5f7 100 /** @}*/