Move pylash code to lash-bindings project

This commit is contained in:
Nedko Arnaudov 2023-05-04 01:24:40 +03:00
parent 7287ed8733
commit 3da9b8d6e7
8 changed files with 0 additions and 5873 deletions

View File

@ -1,29 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*****************************************************************************
*
* Python bindings for LASH
*
* Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************/
#include "lash/lash.h"
lash_client_t * init(int * argc, char *** argv, const char * client_class, int client_flags)
{
return lash_init(lash_extract_args(argc, argv), client_class, client_flags, LASH_PROTOCOL_VERSION);
}

View File

@ -1,29 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*****************************************************************************
*
* Python bindings for LASH
*
* Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************/
#ifndef LASH_H__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
#define LASH_H__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
lash_client_t * init(int * argc, char *** argv, const char * client_class, int client_flags);
#endif /* #ifndef LASH_H__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED */

View File

@ -1,135 +0,0 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*****************************************************************************
*
* Python bindings for LASH
*
* Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************/
#ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
#define LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
#ifdef SWIG
%module lash
%typemap(in) (int *argc, char ***argv)
{
int i;
if (!PyList_Check($input))
{
PyErr_SetString(PyExc_ValueError, "Expecting a list");
goto fail;
}
$1 = (int *) malloc(sizeof(int));
if ($1 == NULL)
{
PyErr_SetString(PyExc_ValueError, "malloc() failed.");
goto fail;
}
*$1 = PyList_Size($input);
$2 = (char ***) malloc(sizeof(char **));
if ($2 == NULL)
{
PyErr_SetString(PyExc_ValueError, "malloc() failed.");
goto fail;
}
*$2 = (char **) malloc((*$1+1)*sizeof(char *));
if (*$2 == NULL)
{
PyErr_SetString(PyExc_ValueError, "malloc() failed.");
goto fail;
}
for (i = 0; i < *$1; i++)
{
PyObject *s = PyList_GetItem($input,i);
if (!PyString_Check(s))
{
PyErr_SetString(PyExc_ValueError, "List items must be strings");
goto fail;
}
(*$2)[i] = PyString_AsString(s);
}
(*$2)[i] = 0;
}
%typemap(argout) (int *argc, char ***argv)
{
int i;
for (i = 0; i < *$1; i++)
{
PyObject *s = PyString_FromString((*$2)[i]);
PyList_SetItem($input,i,s);
}
while (i < PySequence_Size($input))
{
PySequence_DelItem($input,i);
}
}
%typemap(freearg) (int *argc, char ***argv)
{
if ($1 != NULL)
{
//printf("freeing argc pointer storage\n");
free($1);
$1 = NULL;
}
if ($2 != NULL)
{
if (*$2 != NULL)
{
//printf("freeing array pointed by argv pointer storage\n");
free(*$2);
}
//printf("freeing argv pointer storage\n");
free($2);
$1 = NULL;
}
}
%{
#include <lash/client_interface.h>
#include <lash/types.h>
#include <lash/event.h>
#include <lash/config.h>
#include "lash.h"
typedef unsigned char * uuid_t_compat;
#define uuid_t uuid_t_compat
%}
#endif
%include <lash/client_interface.h>
%include <lash/types.h>
%include <lash/event.h>
%include <lash/config.h>
%include <lash.h>
#endif /* #ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED */

View File

@ -1,285 +0,0 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.40
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
# This file is compatible with both classic and new-style classes.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_lash', [dirname(__file__)])
except ImportError:
import _lash
return _lash
if fp is not None:
try:
_mod = imp.load_module('_lash', fp, pathname, description)
finally:
fp.close()
return _mod
_lash = swig_import_helper()
del swig_import_helper
else:
import _lash
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
LASH_DEFAULT_PORT = _lash.LASH_DEFAULT_PORT
LASH_Config_Data_Set = _lash.LASH_Config_Data_Set
LASH_Config_File = _lash.LASH_Config_File
LASH_Server_Interface = _lash.LASH_Server_Interface
LASH_No_Autoresume = _lash.LASH_No_Autoresume
LASH_Terminal = _lash.LASH_Terminal
LASH_Client_Name = _lash.LASH_Client_Name
LASH_Jack_Client_Name = _lash.LASH_Jack_Client_Name
LASH_Alsa_Client_ID = _lash.LASH_Alsa_Client_ID
LASH_Save_File = _lash.LASH_Save_File
LASH_Restore_File = _lash.LASH_Restore_File
LASH_Save_Data_Set = _lash.LASH_Save_Data_Set
LASH_Restore_Data_Set = _lash.LASH_Restore_Data_Set
LASH_Save = _lash.LASH_Save
LASH_Quit = _lash.LASH_Quit
LASH_Server_Lost = _lash.LASH_Server_Lost
LASH_Project_Add = _lash.LASH_Project_Add
LASH_Project_Remove = _lash.LASH_Project_Remove
LASH_Project_Dir = _lash.LASH_Project_Dir
LASH_Project_Name = _lash.LASH_Project_Name
LASH_Client_Add = _lash.LASH_Client_Add
LASH_Client_Remove = _lash.LASH_Client_Remove
LASH_Percentage = _lash.LASH_Percentage
LASH_PROTOCOL_MAJOR = _lash.LASH_PROTOCOL_MAJOR
LASH_PROTOCOL_MINOR = _lash.LASH_PROTOCOL_MINOR
LASH_PROTOCOL_MAJOR_MASK = _lash.LASH_PROTOCOL_MAJOR_MASK
LASH_PROTOCOL_MINOR_MASK = _lash.LASH_PROTOCOL_MINOR_MASK
def lash_protocol_string(*args):
return _lash.lash_protocol_string(*args)
lash_protocol_string = _lash.lash_protocol_string
def lash_extract_args(*args):
return _lash.lash_extract_args(*args)
lash_extract_args = _lash.lash_extract_args
def lash_init(*args):
return _lash.lash_init(*args)
lash_init = _lash.lash_init
def lash_get_server_name(*args):
return _lash.lash_get_server_name(*args)
lash_get_server_name = _lash.lash_get_server_name
def lash_get_pending_event_count(*args):
return _lash.lash_get_pending_event_count(*args)
lash_get_pending_event_count = _lash.lash_get_pending_event_count
def lash_get_event(*args):
return _lash.lash_get_event(*args)
lash_get_event = _lash.lash_get_event
def lash_get_pending_config_count(*args):
return _lash.lash_get_pending_config_count(*args)
lash_get_pending_config_count = _lash.lash_get_pending_config_count
def lash_get_config(*args):
return _lash.lash_get_config(*args)
lash_get_config = _lash.lash_get_config
def lash_send_event(*args):
return _lash.lash_send_event(*args)
lash_send_event = _lash.lash_send_event
def lash_send_config(*args):
return _lash.lash_send_config(*args)
lash_send_config = _lash.lash_send_config
def lash_server_connected(*args):
return _lash.lash_server_connected(*args)
lash_server_connected = _lash.lash_server_connected
def lash_jack_client_name(*args):
return _lash.lash_jack_client_name(*args)
lash_jack_client_name = _lash.lash_jack_client_name
def lash_alsa_client_id(*args):
return _lash.lash_alsa_client_id(*args)
lash_alsa_client_id = _lash.lash_alsa_client_id
def init(*args):
return _lash.init(*args)
init = _lash.init
def lash_event_new():
return _lash.lash_event_new()
lash_event_new = _lash.lash_event_new
def lash_event_new_with_type(*args):
return _lash.lash_event_new_with_type(*args)
lash_event_new_with_type = _lash.lash_event_new_with_type
def lash_event_new_with_all(*args):
return _lash.lash_event_new_with_all(*args)
lash_event_new_with_all = _lash.lash_event_new_with_all
def lash_event_destroy(*args):
return _lash.lash_event_destroy(*args)
lash_event_destroy = _lash.lash_event_destroy
def lash_event_get_type(*args):
return _lash.lash_event_get_type(*args)
lash_event_get_type = _lash.lash_event_get_type
def lash_event_get_string(*args):
return _lash.lash_event_get_string(*args)
lash_event_get_string = _lash.lash_event_get_string
def lash_event_get_project(*args):
return _lash.lash_event_get_project(*args)
lash_event_get_project = _lash.lash_event_get_project
def lash_event_get_client_id(*args):
return _lash.lash_event_get_client_id(*args)
lash_event_get_client_id = _lash.lash_event_get_client_id
def lash_event_set_type(*args):
return _lash.lash_event_set_type(*args)
lash_event_set_type = _lash.lash_event_set_type
def lash_event_set_string(*args):
return _lash.lash_event_set_string(*args)
lash_event_set_string = _lash.lash_event_set_string
def lash_event_set_project(*args):
return _lash.lash_event_set_project(*args)
lash_event_set_project = _lash.lash_event_set_project
def lash_event_set_client_id(*args):
return _lash.lash_event_set_client_id(*args)
lash_event_set_client_id = _lash.lash_event_set_client_id
def lash_event_set_alsa_client_id(*args):
return _lash.lash_event_set_alsa_client_id(*args)
lash_event_set_alsa_client_id = _lash.lash_event_set_alsa_client_id
def lash_event_get_alsa_client_id(*args):
return _lash.lash_event_get_alsa_client_id(*args)
lash_event_get_alsa_client_id = _lash.lash_event_get_alsa_client_id
def lash_str_set_alsa_client_id(*args):
return _lash.lash_str_set_alsa_client_id(*args)
lash_str_set_alsa_client_id = _lash.lash_str_set_alsa_client_id
def lash_str_get_alsa_client_id(*args):
return _lash.lash_str_get_alsa_client_id(*args)
lash_str_get_alsa_client_id = _lash.lash_str_get_alsa_client_id
def lash_config_new():
return _lash.lash_config_new()
lash_config_new = _lash.lash_config_new
def lash_config_dup(*args):
return _lash.lash_config_dup(*args)
lash_config_dup = _lash.lash_config_dup
def lash_config_new_with_key(*args):
return _lash.lash_config_new_with_key(*args)
lash_config_new_with_key = _lash.lash_config_new_with_key
def lash_config_destroy(*args):
return _lash.lash_config_destroy(*args)
lash_config_destroy = _lash.lash_config_destroy
def lash_config_get_key(*args):
return _lash.lash_config_get_key(*args)
lash_config_get_key = _lash.lash_config_get_key
def lash_config_get_value(*args):
return _lash.lash_config_get_value(*args)
lash_config_get_value = _lash.lash_config_get_value
def lash_config_get_value_size(*args):
return _lash.lash_config_get_value_size(*args)
lash_config_get_value_size = _lash.lash_config_get_value_size
def lash_config_set_key(*args):
return _lash.lash_config_set_key(*args)
lash_config_set_key = _lash.lash_config_set_key
def lash_config_set_value(*args):
return _lash.lash_config_set_value(*args)
lash_config_set_value = _lash.lash_config_set_value
def lash_config_get_value_int(*args):
return _lash.lash_config_get_value_int(*args)
lash_config_get_value_int = _lash.lash_config_get_value_int
def lash_config_get_value_float(*args):
return _lash.lash_config_get_value_float(*args)
lash_config_get_value_float = _lash.lash_config_get_value_float
def lash_config_get_value_double(*args):
return _lash.lash_config_get_value_double(*args)
lash_config_get_value_double = _lash.lash_config_get_value_double
def lash_config_get_value_string(*args):
return _lash.lash_config_get_value_string(*args)
lash_config_get_value_string = _lash.lash_config_get_value_string
def lash_config_set_value_int(*args):
return _lash.lash_config_set_value_int(*args)
lash_config_set_value_int = _lash.lash_config_set_value_int
def lash_config_set_value_float(*args):
return _lash.lash_config_set_value_float(*args)
lash_config_set_value_float = _lash.lash_config_set_value_float
def lash_config_set_value_double(*args):
return _lash.lash_config_set_value_double(*args)
lash_config_set_value_double = _lash.lash_config_set_value_double
def lash_config_set_value_string(*args):
return _lash.lash_config_set_value_string(*args)
lash_config_set_value_string = _lash.lash_config_set_value_string

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
py = import('python')
py = py.find_installation('python2')
libpylash = py.extension_module('pylash', ['lash.c', 'lash_wrap.c'],
include_directories : [lash_inc, inc],
dependencies : [py.dependency()],
install : true)
py.install_sources('lash.py')

View File

@ -1,58 +0,0 @@
#!/usr/bin/python3
#
# This file shows example usage of python bindings for LASH
# As such code here is public domain you can use it as you wish and in
# particular use this code as template for adding LASH support to your program.
#
import sys
import time
import lash
def lash_check_events(lash_client):
event = lash.lash_get_event(lash_client)
while event:
print repr(event)
event_type = lash.lash_event_get_type(event)
if event_type == lash.LASH_Quit:
print ("LASH ordered quit.")
return False
elif event_type == lash.LASH_Save_File:
print ("LASH ordered to save data in directory %s" % lash.lash_event_get_string(event))
lash.lash_send_event(lash_client, event)
elif event_type == lash.LASH_Save_Data_Set:
print ("LASH ordered to save data")
lash.lash_send_event(lash_client, event)
elif event_type == lash.LASH_Restore_Data_Set:
print ("LASH ordered to restore data")
lash.lash_event_destroy(event)
elif event_type == lash.LASH_Restore_File:
print ("LASH ordered to restore data from directory %s" % lash.lash_event_get_string(event))
lash.lash_event_destroy(event)
else:
print ("Got unhandled LASH event, type " + str(event_type))
lash.lash_event_destroy(event)
return True
event = lash.lash_get_event(lash_client)
return True
# sys.argv is modified by this call
lash_client = lash.init(sys.argv, "pylash test", lash.LASH_Config_Data_Set | lash.LASH_Terminal)
if not lash_client:
print ("Cannot connect to LASH server")
sys.exit(1)
print ("Successfully connected to LASH server at " + lash.lash_get_server_name(lash_client))
# Send our client name to server
lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name)
lash.lash_event_set_string(lash_event, "pylash test")
lash.lash_send_event(lash_client, lash_event)
# loop until we receive quit order from LASH server
while lash_check_events(lash_client):
time.sleep(1)

29
wscript
View File

@ -48,7 +48,6 @@ def options(opt):
opt.add_option('--enable-pkg-config-dbus-service-dir', action='store_true', default=False, help='force D-Bus service install dir to be one returned by pkg-config')
opt.add_option('--enable-gladish', action='store_true', default=False, help='Build gladish')
opt.add_option('--enable-liblash', action='store_true', default=False, help='Build LASH compatibility library')
opt.add_option('--enable-pylash', action='store_true', default=False, help='Build python bindings for LASH compatibility library')
opt.add_option('--debug', action='store_true', default=False, dest='debug', help="Build debuggable binaries")
opt.add_option('--siginfo', action='store_true', default=False, dest='siginfo', help="Log backtrace on fatal signal")
opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
@ -225,23 +224,12 @@ def configure(conf):
conf.env['BUILD_GLADISH'] = Options.options.enable_gladish
conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
conf.env['BUILD_PYLASH'] = Options.options.enable_pylash
conf.env['BUILD_SIGINFO'] = Options.options.siginfo
if conf.env['BUILD_PYLASH'] and not conf.env['BUILD_LIBLASH']:
conf.fatal("pylash build was requested but liblash was not")
conf.env['BUILD_PYLASH'] = False
if conf.env['BUILD_PYLASH']:
conf.check_python_version()
conf.check_python_headers()
add_cflag(conf, '-fvisibility=hidden')
conf.env['BUILD_WERROR'] = False #not RELEASE
add_cflag(conf, '-Wall')
# lash_wrap code is generated by swig and causes warnings
if not conf.env['BUILD_PYLASH']:
add_cflag(conf, '-Wextra')
conf.env.append_unique('CXXFLAGS', '-Wno-unused-parameter') # the UNUSED() macro doesnt work for C++
add_cflag(conf, '-Wimplicit-fallthrough=2')
@ -306,7 +294,6 @@ def configure(conf):
display_msg(conf, 'Build gladish', yesno(conf.env['BUILD_GLADISH']))
display_msg(conf, 'Build liblash', yesno(Options.options.enable_liblash))
display_msg(conf, 'Build pylash', yesno(conf.env['BUILD_PYLASH']))
display_msg(conf, 'Build with siginfo', yesno(conf.env['BUILD_SIGINFO']))
display_msg(conf, 'Treat warnings as errors', yesno(conf.env['BUILD_WERROR']))
display_msg(conf, 'Debuggable binaries', yesno(conf.env['BUILD_DEBUG']))
@ -528,22 +515,6 @@ def build(bld):
libdir = bld.env['LIBDIR'],
includedir = os.path.normpath(bld.env['PREFIX'] + '/include'))
#####################################################
# pylash
if bld.env['BUILD_PYLASH']:
pylash = bld.shlib(source = [], features = 'c cshlib pyext', includes = ["lash_compat/liblash"])
pylash.target = '_lash'
pylash.use = 'lash'
pylash.install_path = '${PYTHONDIR}'
for source in [
'lash.c',
'lash_wrap.c',
]:
pylash.source.append(os.path.join("lash_compat", "pylash", source))
bld.install_files('${PYTHONDIR}', os.path.join("lash_compat", "pylash", "lash.py"))
#####################################################
# gladish
if bld.env['BUILD_GLADISH']: