diff --git a/Makefile b/Makefile index a746331f..c7628414 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CXXFLAGS := $(CXXFLAGS) --std=c++11 -fPIC -DDART_SHARED_LIB=1 -I $(DART_SDK)/include objects := lib/src/angel_wings.o lib/src/wings_socket.o\ -lib/src/bind.o +lib/src/bind.o lib/src/util.o .PHONY: distclean clean @@ -13,10 +13,13 @@ clean: find . -type f -name '*.so' -delete find . -type f -name '*.dylib' -delete -mac: lib/src/libangel_wings.dylib +mac: libangel_wings.dylib linux: lib/src/libangel_wings.so +libangel_wings.dylib: lib/src/libangel_wings.dylib + cp $< $@ + lib/src/libangel_wings.dylib: $(objects) %.dylib: $(objects) diff --git a/lib/src/bind.cc b/lib/src/bind.cc index 9b0351c7..757cdb63 100644 --- a/lib/src/bind.cc +++ b/lib/src/bind.cc @@ -37,7 +37,7 @@ void wingsReturnBound(Dart_NativeArguments arguments, WingsSocket *socket) Dart_Port sendPort; HandleError(Dart_SendPortGetId(socket->getInfo().sendPortHandle, &sendPort)); socket->incrRef(sendPort); - auto ptr = (uint64_t) socket; + auto ptr = (uint64_t)socket; Dart_Handle ptrHandle = Dart_NewIntegerFromUint64(ptr); Dart_SetReturnValue(arguments, ptrHandle); } @@ -138,7 +138,7 @@ WingsSocket *wingsBindNewSocket(Dart_NativeArguments arguments, const WingsSocke return nullptr; } - auto *out = new WingsSocket(info); + auto *out = new WingsSocket(sock, info); globalSocketList.push_back(out); return out; } diff --git a/lib/src/util.cc b/lib/src/util.cc new file mode 100644 index 00000000..51fbd532 --- /dev/null +++ b/lib/src/util.cc @@ -0,0 +1,21 @@ +#include "angel_wings.h" + +void Dart_WingsSocket_getPort(Dart_NativeArguments arguments) +{ + // TODO: Actually do something. +} + +void Dart_WingsSocket_write(Dart_NativeArguments arguments) +{ + // TODO: Actually do something. +} + +void Dart_WingsSocket_closeDescriptor(Dart_NativeArguments arguments) +{ + // TODO: Actually do something. +} + +void Dart_WingsSocket_close(Dart_NativeArguments arguments) +{ + // TODO: Actually do something. +} \ No newline at end of file diff --git a/lib/src/wings_socket.cc b/lib/src/wings_socket.cc index 3c11c6bb..73f04f2a 100644 --- a/lib/src/wings_socket.cc +++ b/lib/src/wings_socket.cc @@ -1 +1,27 @@ -#include "wings_socket.h" \ No newline at end of file +#include +#include "wings_socket.h" +using namespace wings; + +std::vector wings::globalSocketList; + +bool WingsSocketInfo::operator==(const WingsSocketInfo &other) const +{ + return (strcmp(address, other.address) == 0) && + port == other.port; +} + +WingsSocket::WingsSocket(int sockfd, const WingsSocketInfo &info) : sockfd(sockfd), info(info) +{ + refCount = 0; +} + +void WingsSocket::incrRef(Dart_Port port) +{ + refCount++; + sendPorts.push_back(port); +} + +const WingsSocketInfo &WingsSocket::getInfo() const +{ + return info; +} \ No newline at end of file diff --git a/lib/src/wings_socket.h b/lib/src/wings_socket.h index 6c454c66..9a257763 100644 --- a/lib/src/wings_socket.h +++ b/lib/src/wings_socket.h @@ -19,9 +19,9 @@ struct WingsSocketInfo class WingsSocket { public: - explicit WingsSocket(const WingsSocketInfo& info); + explicit WingsSocket(int sockfd, const WingsSocketInfo& info); void incrRef(Dart_Port port); - const WingsSocketInfo getInfo() const; + const WingsSocketInfo& getInfo() const; private: WingsSocketInfo info;