Skip to content

Commit

Permalink
Merge pull request #14 from geky/funcptr-undo
Browse files Browse the repository at this point in the history
Reverted merge of FuncPtr (#10)
  • Loading branch information
bogdanm committed Apr 7, 2016
2 parents 174d5c7 + 8a5121a commit 6093cb0
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 741 deletions.
787 changes: 71 additions & 716 deletions hal/api/FunctionPointer.h

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions net/NetworkSocketAPI/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
#ifndef NETWORK_INTERFACE_H
#define NETWORK_INTERFACE_H

#ifndef MBED_OPERATORS
#define MBED_OPERATORS
#endif
#include "FunctionPointer.h"
#include "mbed.h"
#include "SocketAddress.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion net/NetworkSocketAPI/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ int Socket::close(bool shutdown)

void Socket::thunk(void *p)
{
mbed::FuncPtr<void()> *fptr = (mbed::FuncPtr<void()> *)p;
FunctionPointer *fptr = (FunctionPointer *)p;
(*fptr)();
}
2 changes: 1 addition & 1 deletion net/NetworkSocketAPI/TCPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int TCPServer::accept(TCPSocket *connection)
}


void TCPServer::attach_accept(mbed::FuncPtr<void()> callback)
void TCPServer::attach_accept(FunctionPointer callback)
{
_accept_cb = callback;

Expand Down
6 changes: 3 additions & 3 deletions net/NetworkSocketAPI/TCPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class TCPServer : public Socket {
\param callback Function to call when accept will succeed, may be called in
interrupt context.
*/
void attach_accept(mbed::FuncPtr<void()> callback);
void attach_accept(FunctionPointer callback);

template <typename T, typename M>
void attach_accept(T *tptr, M mptr) {
attach_accept(mbed::FuncPtr<void()>(tptr, mptr));
attach_accept(FunctionPointer(tptr, mptr));
}

private:
mbed::FuncPtr<void()> _accept_cb;
FunctionPointer _accept_cb;
};

#endif
4 changes: 2 additions & 2 deletions net/NetworkSocketAPI/TCPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int TCPSocket::recv(void *data, unsigned size)
}


void TCPSocket::attach_send(mbed::FuncPtr<void()> callback)
void TCPSocket::attach_send(FunctionPointer callback)
{
_send_cb = callback;

Expand All @@ -94,7 +94,7 @@ void TCPSocket::attach_send(mbed::FuncPtr<void()> callback)
}
}

void TCPSocket::attach_recv(mbed::FuncPtr<void()> callback)
void TCPSocket::attach_recv(FunctionPointer callback)
{
_recv_cb = callback;

Expand Down
12 changes: 6 additions & 6 deletions net/NetworkSocketAPI/TCPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,29 @@ class TCPSocket : public Socket {
\param callback Function to call when send will succeed, may be called in
interrupt context.
*/
void attach_send(mbed::FuncPtr<void()> callback);
void attach_send(FunctionPointer callback);

template <typename T, typename M>
void attach_send(T *tptr, M mptr) {
attach_send(mbed::FuncPtr<void()>(tptr, mptr));
attach_send(FunctionPointer(tptr, mptr));
}

/** Register a callback on when recv is ready
\param callback Function to call when recv will succeed, may be called in
interrupt context.
*/
void attach_recv(mbed::FuncPtr<void()> callback);
void attach_recv(FunctionPointer callback);

template <typename T, typename M>
void attach_recv(T *tptr, M mptr) {
attach_recv(mbed::FuncPtr<void()>(tptr, mptr));
attach_recv(FunctionPointer(tptr, mptr));
}

private:
friend class TCPServer;

mbed::FuncPtr<void()> _send_cb;
mbed::FuncPtr<void()> _recv_cb;
FunctionPointer _send_cb;
FunctionPointer _recv_cb;
};

#endif
4 changes: 2 additions & 2 deletions net/NetworkSocketAPI/UDPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int UDPSocket::recvfrom(SocketAddress *address, void *buffer, unsigned size)
}


void UDPSocket::attach_send(mbed::FuncPtr<void()> callback)
void UDPSocket::attach_send(FunctionPointer callback)
{
_send_cb = callback;
if (_socket && _send_cb) {
Expand All @@ -78,7 +78,7 @@ void UDPSocket::attach_send(mbed::FuncPtr<void()> callback)
}
}

void UDPSocket::attach_recv(mbed::FuncPtr<void()> callback)
void UDPSocket::attach_recv(FunctionPointer callback)
{
_recv_cb = callback;
if (_socket && _recv_cb) {
Expand Down
12 changes: 6 additions & 6 deletions net/NetworkSocketAPI/UDPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ class UDPSocket : public Socket {
\param callback Function to call when send will succeed, may be called in
interrupt context.
*/
void attach_send(mbed::FuncPtr<void()> callback);
void attach_send(FunctionPointer callback);

template <typename T, typename M>
void attach_send(T *tptr, M mptr) {
attach_send(mbed::FuncPtr<void()>(tptr, mptr));
attach_send(FunctionPointer(tptr, mptr));
}

/** Register a callback on when recv is ready
\param callback Function to call when recv will succeed, may be called in
interrupt context.
*/
void attach_recv(mbed::FuncPtr<void()> callback);
void attach_recv(FunctionPointer callback);

template <typename T, typename M>
void attach_recv(T *tptr, M mptr) {
attach_recv(mbed::FuncPtr<void()>(tptr, mptr));
attach_recv(FunctionPointer(tptr, mptr));
}

private:
mbed::FuncPtr<void()> _send_cb;
mbed::FuncPtr<void()> _recv_cb;
FunctionPointer _send_cb;
FunctionPointer _recv_cb;
};

#endif

0 comments on commit 6093cb0

Please sign in to comment.