mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2025-09-07 01:12:05 +02:00
dependency system + network library
This commit is contained in:
parent
816305e70d
commit
f1bf8abfb5
12 changed files with 226 additions and 13 deletions
57
src/luaenginenetwork/luaengine/LuaEngineNetwork.cpp
Normal file
57
src/luaenginenetwork/luaengine/LuaEngineNetwork.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*****************************************************************************
|
||||
* luaEngine Lua Engine for Qt
|
||||
* Copyright (C) 2020 Syping
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "LuaEngineNetwork.h"
|
||||
#include <QLocalSocket>
|
||||
|
||||
void LuaEngineNetwork::pushClass(lua_State *L_p)
|
||||
{
|
||||
// Local Socket
|
||||
pushFunction(L_p, "createLocalSocket", createLocalSocket);
|
||||
}
|
||||
|
||||
void LuaEngineNetwork::pushClass(LuaEngine *luaEngine)
|
||||
{
|
||||
pushClass(luaEngine->luaState());
|
||||
}
|
||||
|
||||
int LuaEngineNetwork::createLocalSocket(lua_State *L_p)
|
||||
{
|
||||
QObject *parent = nullptr;
|
||||
QString socketPath = "LuaEngine";
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
socketPath = getVariant(L_p, 1).toString();
|
||||
if (getArgumentCount(L_p) >= 2) {
|
||||
void *pointer = getPointer(L_p, 2);
|
||||
if (pointer != NULL) {
|
||||
parent = (QObject*)pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
QLocalSocket *localSocket = new QLocalSocket(parent);
|
||||
localSocket->setObjectName(nameForPointer(localSocket));
|
||||
localSocket->setServerName(socketPath);
|
||||
pushPointer(L_p, localSocket);
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString LuaEngineNetwork::nameForPointer(void *pointer)
|
||||
{
|
||||
QString nameStorage;
|
||||
QTextStream(&nameStorage) << "LuaEngineNetwork" << pointer;
|
||||
return nameStorage;
|
||||
}
|
38
src/luaenginenetwork/luaengine/LuaEngineNetwork.h
Normal file
38
src/luaenginenetwork/luaengine/LuaEngineNetwork.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*****************************************************************************
|
||||
* luaEngine Lua Engine for Qt
|
||||
* Copyright (C) 2020 Syping
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef LUAENGINENETWORK_H
|
||||
#define LUAENGINENETWORK_H
|
||||
|
||||
#include "LuaEngineNetwork_global.h"
|
||||
#include "LuaEngineAddon.h"
|
||||
#include "LuaEngine.h"
|
||||
|
||||
class LUAENGINENETWORKSHARED_EXPORT LuaEngineNetwork : public LuaEngineAddon
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static void pushClass(lua_State *L_p);
|
||||
static void pushClass(LuaEngine *luaEngine);
|
||||
static int createLocalSocket(lua_State *L_p);
|
||||
|
||||
private:
|
||||
lua_State *L;
|
||||
static QString nameForPointer(void *pointer);
|
||||
};
|
||||
|
||||
#endif // LUAENGINENETWORK_H
|
33
src/luaenginenetwork/luaengine/LuaEngineNetwork_global.h
Normal file
33
src/luaenginenetwork/luaengine/LuaEngineNetwork_global.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*****************************************************************************
|
||||
* luaEngine Lua Engine for Qt
|
||||
* Copyright (C) 2020 Syping
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef LUAENGINENETWORK_GLOBAL_H
|
||||
#define LUAENGINENETWORK_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef LUAENGINE_STATIC
|
||||
#ifdef LUAENGINENETWORK_LIBRARY
|
||||
#define LUAENGINENETWORKSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LUAENGINENETWORKSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define LUAENGINENETWORKSHARED_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // LUAENGINENETWORK_GLOBAL_H
|
Loading…
Add table
Add a link
Reference in a new issue