Unignore index files

This commit is contained in:
Rico Tiongson 2019-03-03 17:40:08 +08:00
parent 2eb66913e5
commit 4117c3a3f1
23 changed files with 312 additions and 10 deletions

1
.gitignore vendored
View File

@ -24,6 +24,7 @@ downloads/
eggs/
.eggs/
lib/
!/lib
lib64/
parts/
sdist/

8
lib/_index.cpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __COMFORTABLE_SWIPE__index_cpp__
#define __COMFORTABLE_SWIPE__index_cpp__
#include "gesture/_index.cpp"
#include "service/_index.cpp"
#include "util/_index.cpp"
#endif /* __COMFORTABLE_SWIPE__index_cpp__ */

8
lib/_index.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __COMFORTABLE_SWIPE__index_hpp__
#define __COMFORTABLE_SWIPE__index_hpp__
#include "gesture/_index.hpp"
#include "service/_index.hpp"
#include "util/_index.hpp"
#endif /* __COMFORTABLE_SWIPE__index_hpp__ */

12
lib/_macro.cpp Normal file
View File

@ -0,0 +1,12 @@
#ifndef __COMFORTABLE_SWIPE__macro_hpp__
#define __COMFORTABLE_SWIPE__macro_hpp__
#ifndef __COMFORTABLE_SWIPE__CONFIG__
#define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
#endif /* __COMFORTABLE_SWIPE__CONFIG__ */
#ifndef __COMFORTABLE_SWIPE__VERSION__
#warning __COMFORTABLE_SWIPE__VERSION__ "must be defined."
#endif /* __COMFORTABLE_SWIPE__VERSION__ */
#endif /* __COMFORTABLE_SWIPE__macro_hpp__ */

8
lib/_python.cpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __COMFORTABLE_SWIPE__python_cpp__
#define __COMFORTABLE_SWIPE__python_cpp__
#include "service/_python.cpp"
#include "util/_python.cpp"
#include "comfortable-swipe.cpp"
#endif /* __COMFORTABLE_SWIPE__python_cpp__ */

1
lib/comfortable-swipe Normal file
View File

@ -0,0 +1 @@
#include "comfortable-swipe.cpp"

26
lib/comfortable-swipe.cpp Normal file
View File

@ -0,0 +1,26 @@
#ifndef __COMFORTABLE_SWIPE__
#define __COMFORTABLE_SWIPE__
/*
Comfortable Swipe
by Rico Tiongson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "_macro.cpp"
#include "_index.hpp"
#include "_index.cpp"
#endif /* __COMFORTABLE_SWIPE__ */

9
lib/gesture/_index.cpp Normal file
View File

@ -0,0 +1,9 @@
#ifndef __COMFORTABLE_SWIPE__gesture_index_cpp__
#define __COMFORTABLE_SWIPE__gesture_index_cpp__
#include "_index.hpp"
#include "xdo_gesture.cpp"
#include "swipe_gesture.cpp"
#include "swipe_gesture.regex.cpp"
#endif /* __COMFORTABLE_SWIPE__gesture_index_cpp__ */

7
lib/gesture/_index.hpp Normal file
View File

@ -0,0 +1,7 @@
#ifndef __COMFORTABLE_SWIPE__gesture_index_hpp__
#define __COMFORTABLE_SWIPE__gesture_index_hpp__
#include "xdo_gesture.h"
#include "swipe_gesture.h"
#endif /* __COMFORTABLE_SWIPE__gesture_index_hpp__ */

15
lib/service/_index.cpp Normal file
View File

@ -0,0 +1,15 @@
#ifndef __COMFORTABLE_SWIPE__service_index_cpp__
#define __COMFORTABLE_SWIPE__service_index_cpp__
#include "_index.hpp"
#include "autostart.cpp"
#include "buffer.cpp"
#include "config.cpp"
#include "debug.cpp"
#include "help.cpp"
#include "restart.cpp"
#include "start.cpp"
#include "status.cpp"
#include "stop.cpp"
#endif /* __COMFORTABLE_SWIPE__service_index_cpp__ */

26
lib/service/_index.hpp Normal file
View File

@ -0,0 +1,26 @@
#ifndef __COMFORTABLE_SWIPE__service_index_hpp__
#define __COMFORTABLE_SWIPE__service_index_hpp__
#include <map> // std::map
#include <string> // std::string
extern "C"
{
namespace comfortable_swipe
{
namespace service
{
void autostart();
void buffer();
void config();
void debug();
void help();
void restart();
void start();
void stop();
void status();
}
}
}
#endif /* __COMFORTABLE_SWIPE__service_index_hpp__ */

82
lib/service/_python.cpp Normal file
View File

@ -0,0 +1,82 @@
#ifndef __COMFORTABLE_SWIPE__service_python__
#define __COMFORTABLE_SWIPE__service_python__
#include "_index.hpp"
#include <Python.h>
// export as python module
namespace comfortable_swipe::service::python
{
#define __comfortable_swipe_void_method(method) \
static PyObject * \
method(PyObject * self, PyObject * args) \
{ \
comfortable_swipe::service::method(); \
Py_RETURN_NONE; \
}
// create the python method signatures
__comfortable_swipe_void_method(status);
__comfortable_swipe_void_method(start);
__comfortable_swipe_void_method(stop);
__comfortable_swipe_void_method(restart);
__comfortable_swipe_void_method(autostart);
__comfortable_swipe_void_method(buffer);
__comfortable_swipe_void_method(help);
__comfortable_swipe_void_method(config);
__comfortable_swipe_void_method(debug);
#undef __comfortable_swipe_void_method
// create the method list for C++
static PyMethodDef methods[] =
{
{ "status", &status, METH_VARARGS , "checks status of program, autostart, and config" },
{ "start", &start, METH_VARARGS , "starts 3/4-finger gesture service" },
{ "stop", &stop, METH_VARARGS , "stops 3/4-finger gesture service" },
{ "restart", &restart, METH_VARARGS , "stops then starts 3/4-finger gesture service" },
{ "autostart", &autostart, METH_VARARGS , "automatically run on startup (toggleable)" },
{ "buffer", &buffer, METH_VARARGS , "parses output of libinput debug-events" },
{ "help", &help, METH_VARARGS , "shows the help dialog" },
{ "config", &config, METH_VARARGS , "locates the config file " },
{ "debug", &debug, METH_VARARGS , "logs raw output from input events taken from libinput" },
{ NULL, NULL, 0, NULL } // sentinel
};
// create the module configuration
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef module_def =
{
PyModuleDef_HEAD_INIT,
"service",
"Comfortable swipe service",
-1,
methods
};
#endif
PyObject * module;
}
// initialize module
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC
PyInit_service(void)
{
using comfortable_swipe::service::python::module_def;
using comfortable_swipe::service::python::module;
if (module != NULL) return module;
return module = PyModule_Create(&module_def);
}
#else /* PY_MAJOR_VERSION < 3 */
PyMODINIT_FUNC
initservice(void)
{
using comfortable_swipe::service::python::methods;
using comfortable_swipe::service::python::module;
if (module != NULL) return;
module = Py_InitModule("service", methods);
}
#endif /* PY_MAJOR_VERSION */
#endif /* __COMFORTABLE_SWIPE__service_python__ */

View File

@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../util/__index__.hpp"
#include "../util/_index.hpp"
#include <iostream> // std::cerr, std::cout, std::endl
#include <fstream> // std::ifstream, std::ofstream
#include <string> // std::string

View File

@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../util/__index__.hpp"
#include "../gesture/__index__.hpp"
#include "../util/_index.hpp"
#include "../gesture/_index.hpp"
#include <cstdio> // fgets_unlocked, stdin
/**

View File

@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../util/__index__.hpp"
#include "../util/_index.hpp"
#include <cstdio> // std::puts
namespace comfortable_swipe::service

View File

@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../util/__index__.hpp"
#include "../util/_index.hpp"
#include <cstdio> // std::puts, std::printf
namespace comfortable_swipe::service

View File

@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../service/__index__.hpp"
#include "../service/_index.hpp"
namespace comfortable_swipe::service
{

View File

@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "__index__.hpp"
#include "_index.hpp"
#include <cstdlib> // std::system
#include <unistd.h> // pipe, fork, perror, exit

View File

@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../util/__index__.hpp"
#include "../gesture/__index__.hpp"
#include "../util/_index.hpp"
#include "../gesture/_index.hpp"
#include <stdexcept> // std::runtime_error
#include <unistd.h> // popen, pclose, getpid, access, F_OK
#include <memory> // std::unique_ptr

9
lib/util/_index.cpp Normal file
View File

@ -0,0 +1,9 @@
#ifndef __COMFORTABLE_SWIPE__util_index_cpp__
#define __COMFORTABLE_SWIPE__util_index_cpp__
#include "_index.hpp"
#include "autostart_filename.cpp"
#include "conf_filename.cpp"
#include "read_config_file.cpp"
#endif /* __COMFORTABLE_SWIPE__util_index_cpp__ */

20
lib/util/_index.hpp Normal file
View File

@ -0,0 +1,20 @@
#ifndef __COMFORTABLE_SWIPE__util_index_hpp__
#define __COMFORTABLE_SWIPE__util_index_hpp__
#include <map> // std::map
#include <string> // std::string
extern "C"
{
namespace comfortable_swipe
{
namespace util
{
const char* autostart_filename();
constexpr const char* conf_filename();
std::map<std::string, std::string> read_config_file(const char*);
}
}
}
#endif /* __COMFORTABLE_SWIPE__util_index_hpp__ */

70
lib/util/_python.cpp Normal file
View File

@ -0,0 +1,70 @@
#ifndef __COMFORTABLE_SWIPE__util_python__
#define __COMFORTABLE_SWIPE__util_python__
#include "_index.hpp"
#include <Python.h>
// export as python module
namespace comfortable_swipe::util::python
{
// create the python method signatures
static PyObject *
autostart_filename(PyObject * self, PyObject * args)
{
return Py_BuildValue("s", comfortable_swipe::util::autostart_filename());
}
static PyObject *
conf_filename(PyObject * self, PyObject * args)
{
return Py_BuildValue("s", comfortable_swipe::util::conf_filename);
}
#undef __comfortable_swipe_void_method
// create the method list for C++
static PyMethodDef methods[] =
{
{ "autostart_filename", &autostart_filename, METH_VARARGS, "the location of the autostart file" },
{ "conf_filename", &conf_filename, METH_VARARGS, "the location of the configuration file" },
{ NULL, NULL, 0, NULL } // sentinel
};
// create the module configuration
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef module_def =
{
PyModuleDef_HEAD_INIT,
"util",
"Comfortable swipe utility",
-1,
methods
};
#endif
PyObject * module;
}
// initialize module
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC
PyInit_util(void)
{
using comfortable_swipe::util::python::module_def;
using comfortable_swipe::util::python::module;
if (module != NULL) return module;
return module = PyModule_Create(&module_def);
}
#else /* PY_MAJOR_VERSION < 3 */
PyMODINIT_FUNC
initutil(void)
{
using comfortable_swipe::util::python::methods;
using comfortable_swipe::util::python::module;
if (module != NULL) return;
module = Py_InitModule("util", methods);
}
#endif /* PY_MAJOR_VERSION */
#endif /* __COMFORTABLE_SWIPE__util_python__ */

View File

@ -51,7 +51,7 @@ try:
extensions = [Extension(
name='{}.{}'.format(PYTHON_NAME, extension_name),
define_macros=list(cpp_macros.items()),
sources=[os.path.join(__DIR__, 'lib', '__python__.cpp')],
sources=[os.path.join(__DIR__, 'lib', '_python.cpp')],
extra_compile_args=['-O2', '-Wno-unused-result'],
libraries=['xdo']
) for extension_name in extension_names]