[pytango] 275/483: some tests with sip
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit 94cd2e02b48a37a7da54f5d407cf7308ac12ad4a
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Aug 30 15:45:39 2013 +0000
some tests with sip
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@23476 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
src/sip/Makefile | 58 +++++++
src/sip/command_info.sip | 131 +++++++++++++++
src/sip/configure.py | 14 +-
src/sip/{dbdatum.sip => db_datum.sip} | 0
src/sip/{tango.sip => db_dev_import_info.sip} | 20 ++-
src/sip/{tango.sip => db_dev_info.sip} | 19 ++-
src/sip/device_proxy.sip | 232 ++++++++++++++++++++++++++
src/sip/deviceproxy.sip | 232 --------------------------
src/sip/{stdutils.sip => std_utils.sip} | 58 +++++++
src/sip/tango.sip | 15 +-
src/sip/test/Makefile | 47 ++++++
src/sip/{ => test}/configure.py | 15 +-
src/sip/test/test.cpp | 25 +++
src/sip/test/test.h | 3 +
src/sip/test/test.sip | 48 ++++++
15 files changed, 658 insertions(+), 259 deletions(-)
diff --git a/src/sip/Makefile b/src/sip/Makefile
new file mode 100644
index 0000000..6820d9c
--- /dev/null
+++ b/src/sip/Makefile
@@ -0,0 +1,58 @@
+TARGET = Tango.so
+OFILES = sipTangocmodule.o sipTangoDatabase.o sipTangoDeviceProxy.o sipTangoConnection.o sipTangoDbDevImportInfo.o sipTangoDbDevInfo.o sipTangoDbDatum.o sipTangoCommandInfoList.o sipTangoCommandInfo.o sipTangoDevCommandInfo.o sipTangostdvector1800.o sipTangostdvector0100stdstring.o sipTangostdstring.o
+HFILES = sipAPITango.h
+
+CC = gcc
+CXX = g++
+LINK = g++
+CPPFLAGS = -DNDEBUG -I. -I/usr/include/python2.6
+CFLAGS = -O2 -g -fPIC -Wall -W
+CXXFLAGS = -std=c++0x -O2 -g -fPIC -Wall -W
+LFLAGS = -z defs -shared -Wl,--version-script=Tango.exp
+LIBS = -ltango -llog4tango -lzmq -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lpython2.6
+.SUFFIXES: .c .o .cpp .cc .cxx .C
+
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
+
+all: $(TARGET)
+
+$(OFILES): $(HFILES)
+
+$(TARGET): $(OFILES)
+ @echo '{ global: initTango; local: *; };' > Tango.exp
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
+
+install: $(TARGET)
+ @test -d $(DESTDIR)/usr/lib/python2.6/dist-packages || mkdir -p $(DESTDIR)/usr/lib/python2.6/dist-packages
+ cp -f $(TARGET) $(DESTDIR)/usr/lib/python2.6/dist-packages/$(TARGET)
+
+clean:
+ -rm -f $(TARGET)
+ -rm -f sipTangocmodule.o
+ -rm -f sipTangoDatabase.o
+ -rm -f sipTangoDeviceProxy.o
+ -rm -f sipTangoConnection.o
+ -rm -f sipTangoDbDevImportInfo.o
+ -rm -f sipTangoDbDevInfo.o
+ -rm -f sipTangoDbDatum.o
+ -rm -f sipTangoCommandInfoList.o
+ -rm -f sipTangoCommandInfo.o
+ -rm -f sipTangoDevCommandInfo.o
+ -rm -f sipTangostdvector1800.o
+ -rm -f sipTangostdvector0100stdstring.o
+ -rm -f sipTangostdstring.o
+ -rm -f Tango.exp
diff --git a/src/sip/command_info.sip b/src/sip/command_info.sip
new file mode 100644
index 0000000..2fc3fca
--- /dev/null
+++ b/src/sip/command_info.sip
@@ -0,0 +1,131 @@
+/*******************************************************************************
+
+ This file is part of PyTango, a python binding for Tango
+
+ http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
+
+ Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+
+ PyTango is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ PyTango 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PyTango. If not, see <http://www.gnu.org/licenses/>.
+
+*******************************************************************************/
+
+struct DevCommandInfo
+{
+%TypeHeaderCode
+#include <tango.h>
+using namespace Tango;
+%End
+
+ std::string cmd_name;
+ long cmd_tag;
+ long in_type;
+ long out_type;
+ std::string in_type_desc;
+ std::string out_type_desc;
+
+ bool operator==(const DevCommandInfo &);
+};
+
+struct CommandInfo : DevCommandInfo
+{
+%TypeHeaderCode
+#include <tango.h>
+using namespace Tango;
+%End
+
+ DispLevel disp_level;
+
+ bool operator==(const CommandInfo &);
+};
+
+/*
+%MappedType CommandInfoList
+{
+%TypeHeaderCode
+#include <vector>
+#include <tango.h>
+using namespace Tango;
+%End
+
+%ConvertToTypeCode
+ // See if we are just being asked to check the type of the Python
+ // object.
+ if(sipIsErr == NULL)
+ {
+ bool aReturnFlag = PyList_Check(sipPy);
+ for(int i = 0; aReturnFlag && i < PySequence_Size(sipPy); ++i)
+ {
+ aReturnFlag = sipCanConvertToType(PySequence_ITEM(sipPy, i),
+ sipType_CommandInfo,
+ SIP_NOT_NONE);
+ }
+ return aReturnFlag;
+ }
+
+ CommandInfoList *cmdInfoList = new CommandInfoList();
+ for(int i = 0; i < PySequence_Size(sipPy); ++i)
+ {
+ int state;
+ CommandInfo *aCommandInfo = reinterpret_cast<CommandInfo*>(
+ sipConvertToType(PySequence_ITEM(sipPy, i),
+ sipType_CommandInfo, Py_None,
+ SIP_NOT_NONE,
+ &state, sipIsErr));
+ // Deal with any errors.
+ if (*sipIsErr)
+ {
+ sipReleaseType(aCommandInfo, sipType_CommandInfo, state);
+
+ // Tidy up.
+ delete cmdInfoList;
+
+ // There is no temporary instance.
+ return 0;
+ }
+ cmdInfoList->push_back(*aCommandInfo);
+ sipReleaseType(aCommandInfo, sipType_CommandInfo, state);
+ }
+ *sipCppPtr = cmdInfoList;
+ return sipGetState(sipTransferObj);
+%End
+
+%ConvertFromTypeCode
+ PyObject *l;
+
+ // Create the Python list of the correct length.
+ if (!(l = PyList_New(sipCpp->size())))
+ return NULL;
+
+ // Go through each element in the C++ instance and convert it to a
+ // wrapped CommandInfo
+ int i = 0;
+ for(std::vector<CommandInfo>::iterator j = sipCpp->begin();
+ j != sipCpp->end(); ++j, ++i)
+ {
+ CommandInfo &aCommandInfo = *j;
+ PyObject *wobj;
+
+ if (!(wobj = sipConvertFromNewType(&aCommandInfo, sipType_CommandInfo, sipTransferObj)))
+ {
+ // There was an error so garbage collect the Python list.
+ Py_DECREF(l);
+ return NULL;
+ }
+ PyList_SET_ITEM(l, i, wobj);
+ }
+ return l;
+%End
+};
+*/
diff --git a/src/sip/configure.py b/src/sip/configure.py
index 81e945e..f73db57 100644
--- a/src/sip/configure.py
+++ b/src/sip/configure.py
@@ -1,4 +1,5 @@
import os
+import sys
import sipconfig
# The name of the SIP build file generated by SIP and used by the build
@@ -14,13 +15,20 @@ os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "tango.sip"]))
# Create the Makefile.
makefile = sipconfig.SIPModuleMakefile(config, build_file)
+python_lib = "python{v[0]}.{v[1]}".format(v=sys.version_info)
+
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
-makefile.extra_libs = ["tango", "zmq"]
-makefile.extra_lib_dirs = ["/home/tcoutinho/.local/lib"]
-makefile.extra_include_dirs = ["/home/tcoutinho/.local/include", "/home/tcoutinho/.local/include/tango"]
+makefile.extra_libs = ["tango", "log4tango", "zmq",
+ "omniORB4", "omniDynamic4", "omnithread", "COS4",
+ python_lib]
+makefile.extra_lib_dirs = [] #["/home/tcoutinho/.local/lib"]
+makefile.extra_include_dirs = [] #["/home/tcoutinho/.local/include", "/home/tcoutinho/.local/include/tango"]
makefile.extra_cxxflags = ["-std=c++0x"]
+# see all undefined references
+makefile.extra_lflags = ['-z defs']
+
# Generate the Makefile itself.
makefile.generate()
diff --git a/src/sip/dbdatum.sip b/src/sip/db_datum.sip
similarity index 100%
rename from src/sip/dbdatum.sip
rename to src/sip/db_datum.sip
diff --git a/src/sip/tango.sip b/src/sip/db_dev_import_info.sip
similarity index 84%
copy from src/sip/tango.sip
copy to src/sip/db_dev_import_info.sip
index 25d4a4b..805b51d 100644
--- a/src/sip/tango.sip
+++ b/src/sip/db_dev_import_info.sip
@@ -21,11 +21,17 @@
*******************************************************************************/
-%Module(name=Tango, version=0801)
+class DbDevImportInfo
+{
-%Include stdutils.sip
-%Include constants.sip
-%Include connection.sip
-%Include dbdatum.sip
-%Include database.sip
-%Include deviceproxy.sip
+%TypeHeaderCode
+#include <tango.h>
+using namespace Tango;
+%End
+
+public :
+ std::string name;
+ long exported;
+ std::string ior;
+ std::string version;
+};
\ No newline at end of file
diff --git a/src/sip/tango.sip b/src/sip/db_dev_info.sip
similarity index 85%
copy from src/sip/tango.sip
copy to src/sip/db_dev_info.sip
index 25d4a4b..ab186ad 100644
--- a/src/sip/tango.sip
+++ b/src/sip/db_dev_info.sip
@@ -21,11 +21,16 @@
*******************************************************************************/
-%Module(name=Tango, version=0801)
+class DbDevInfo
+{
-%Include stdutils.sip
-%Include constants.sip
-%Include connection.sip
-%Include dbdatum.sip
-%Include database.sip
-%Include deviceproxy.sip
+%TypeHeaderCode
+#include <tango.h>
+using namespace Tango;
+%End
+
+public :
+ std::string name;
+ std::string _class;
+ std::string server;
+};
\ No newline at end of file
diff --git a/src/sip/device_proxy.sip b/src/sip/device_proxy.sip
new file mode 100644
index 0000000..f945125
--- /dev/null
+++ b/src/sip/device_proxy.sip
@@ -0,0 +1,232 @@
+/*******************************************************************************
+
+ This file is part of PyTango, a python binding for Tango
+
+ http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
+
+ Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+
+ PyTango is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ PyTango 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PyTango. If not, see <http://www.gnu.org/licenses/>.
+
+*******************************************************************************/
+
+class DeviceProxy : Connection {
+
+%TypeHeaderCode
+#include <tango.h>
+using namespace Tango;
+%End
+
+protected:
+ virtual std::string get_corba_name(bool);
+ virtual std::string build_corba_name();
+ virtual int get_lock_ctr();
+ virtual void set_lock_ctr(int);
+
+public:
+ DeviceProxy();
+ DeviceProxy(const char *, bool ch_access);
+ DeviceProxy(const char *);
+
+ DeviceProxy(const DeviceProxy &);
+// DeviceProxy & operator=(const DeviceProxy &);
+
+//
+// general methods
+//
+
+// virtual DeviceInfo const &info();
+ virtual std::string dev_name();
+ virtual void parse_name(std::string &);
+ virtual Database *get_device_db();
+
+ virtual std::string status();
+ virtual DevState state();
+ virtual std::string adm_name();
+ virtual std::string description();
+ virtual std::string name();
+ virtual std::string alias();
+
+ virtual int ping();
+
+ virtual std::vector<std::string> * black_box(int);
+
+//
+// device methods
+//
+ virtual CommandInfo command_query(std::string);
+ virtual std::vector<CommandInfoList*> *command_list_query();
+
+
+/*
+ virtual DbDevImportInfo import_info();
+//
+// property methods
+//
+ virtual void get_property(std::string&, DbData&);
+ virtual void get_property(vector<std::string>&, DbData&);
+ virtual void get_property(DbData&);
+ virtual void put_property(DbData&);
+ virtual void delete_property(std::string&);
+ virtual void delete_property(vector<std::string>&);
+ virtual void delete_property(DbData&);
+ virtual void get_property_list(const std::string &,vector<std::string> &);
+//
+// attribute methods
+//
+ virtual std::vector<std::string> *get_attribute_list();
+
+ virtual AttributeInfoList *get_attribute_config(vector<std::string>&);
+ virtual AttributeInfoListEx *get_attribute_config_ex(vector<std::string>&);
+ virtual AttributeInfoEx get_attribute_config(const std::string &);
+
+ virtual AttributeInfoEx attribute_query(std::string name) {return get_attribute_config(name);}
+ virtual AttributeInfoList *attribute_list_query();
+ virtual AttributeInfoListEx *attribute_list_query_ex();
+
+ virtual void set_attribute_config(AttributeInfoList &);
+ virtual void set_attribute_config(AttributeInfoListEx &);
+
+ virtual DeviceAttribute read_attribute(std::string&);
+ virtual DeviceAttribute read_attribute(const char *at) {std::string str(at);return read_attribute(str);}
+ void read_attribute(const char *,DeviceAttribute &);
+ void read_attribute(std::string &at,DeviceAttribute &da) {read_attribute(at.c_str(),da);}
+ virtual std::vector<DeviceAttribute> *read_attributes(vector<std::string>&);
+
+ virtual void write_attribute(DeviceAttribute&);
+ virtual void write_attributes(vector<DeviceAttribute>&);
+
+ virtual DeviceAttribute write_read_attribute(DeviceAttribute &);
+
+//
+// history methods
+//
+ virtual std::vector<DeviceDataHistory> *command_history(std::string &,int);
+ virtual std::vector<DeviceDataHistory> *command_history(const char *na,int n)
+ {std::string str(na);return command_history(str,n);}
+
+ virtual std::vector<DeviceAttributeHistory> *attribute_history(std::string &,int);
+ virtual std::vector<DeviceAttributeHistory> *attribute_history(const char *na,int n)
+ {std::string str(na);return attribute_history(str,n);}
+//
+// Polling administration methods
+//
+ virtual std::vector<std::string> *polling_status();
+
+ virtual void poll_command(std::string &, int);
+ virtual void poll_command(const char *na, int per) {std::string tmp(na);poll_command(tmp,per);}
+ virtual void poll_attribute(std::string &, int);
+ virtual void poll_attribute(const char *na, int per) {std::string tmp(na);poll_attribute(tmp,per);}
+
+ virtual int get_command_poll_period(std::string &);
+ virtual int get_command_poll_period(const char *na)
+ {std::string tmp(na);return get_command_poll_period(tmp);}
+ virtual int get_attribute_poll_period(std::string &);
+ virtual int get_attribute_poll_period(const char *na)
+ {std::string tmp(na);return get_attribute_poll_period(tmp);}
+
+ virtual bool is_command_polled(std::string &);
+ virtual bool is_command_polled(const char *na) {std::string tmp(na);return is_command_polled(tmp);}
+ virtual bool is_attribute_polled(std::string &);
+ virtual bool is_attribute_polled(const char *na) {std::string tmp(na);return is_attribute_polled(tmp);}
+
+ virtual void stop_poll_command(std::string &);
+ virtual void stop_poll_command(const char *na) {std::string tmp(na);stop_poll_command(tmp);}
+ virtual void stop_poll_attribute(std::string &);
+ virtual void stop_poll_attribute(const char *na) {std::string tmp(na);stop_poll_attribute(tmp);}
+//
+// Asynchronous methods
+//
+ virtual long read_attribute_asynch(const char *na) {std::string tmp(na);return read_attribute_asynch(tmp);}
+ virtual long read_attribute_asynch(std::string &att_name);
+ virtual long read_attributes_asynch(vector <std::string> &);
+
+ virtual std::vector<DeviceAttribute> *read_attributes_reply(long);
+ virtual std::vector<DeviceAttribute> *read_attributes_reply(long,long);
+ virtual DeviceAttribute *read_attribute_reply(long);
+ virtual DeviceAttribute *read_attribute_reply(long,long);
+
+ virtual long write_attribute_asynch(DeviceAttribute &);
+ virtual long write_attributes_asynch(vector<DeviceAttribute> &);
+
+ virtual void write_attributes_reply(long);
+ virtual void write_attributes_reply(long,long);
+ virtual void write_attribute_reply(long id) {write_attributes_reply(id);}
+ virtual void write_attribute_reply(long to,long id) {write_attributes_reply(to,id);}
+
+ virtual long pending_asynch_call(asyn_req_type req)
+ {if (req == POLLING)return pasyn_ctr;
+ else if (req==CALL_BACK) return pasyn_cb_ctr;
+ else return (pasyn_ctr + pasyn_cb_ctr);}
+
+ virtual void read_attributes_asynch(vector<std::string> &,CallBack &);
+ virtual void read_attribute_asynch(const char *na,CallBack &cb) {std::string tmp(na);read_attribute_asynch(tmp,cb);}
+ virtual void read_attribute_asynch(std::string &,CallBack &);
+
+ virtual void write_attribute_asynch(DeviceAttribute &,CallBack &);
+ virtual void write_attributes_asynch(vector<DeviceAttribute> &,CallBack &);
+//
+// Logging administration methods
+//
+#ifdef TANGO_HAS_LOG4TANGO
+ virtual void add_logging_target(const std::string &target_type_name);
+ virtual void add_logging_target(const char *target_type_name)
+ {add_logging_target(std::string(target_type_name));}
+
+ virtual void remove_logging_target(const std::string &target_type_name);
+ virtual void remove_logging_target(const char *target_type_name)
+ {remove_logging_target(std::string(target_type_name));}
+
+ virtual std::vector<std::string> get_logging_target (void);
+ virtual int get_logging_level (void);
+ virtual void set_logging_level (int level);
+#endif // TANGO_HAS_LOG4TANGO
+//
+// Event methods
+//
+ virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,
+ const std::vector<std::string> &filters); // For compatibility with Tango < 8
+ virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,
+ const std::vector<std::string> &filters, bool stateless); // For compatibility with Tango < 8
+ virtual int subscribe_event(const std::string &attr_name, EventType event, int event_queue_size,
+ const std::vector<std::string> &filters, bool stateless = false); // For compatibility with Tango < 8
+
+ virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *);
+ virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,bool stateless);
+ virtual int subscribe_event(const std::string &attr_name, EventType event, int event_queue_size,bool stateless = false);
+
+ virtual void unsubscribe_event(int event_id);
+//
+// Methods to access data in event queues
+//
+ virtual void get_events (int event_id, EventDataList &event_list);
+ virtual void get_events (int event_id, AttrConfEventDataList &event_list);
+ virtual void get_events (int event_id, DataReadyEventDataList &event_list);
+ virtual void get_events (int event_id, CallBack *cb);
+ virtual int event_queue_size(int event_id);
+ virtual TimeVal get_last_event_date(int event_id);
+ virtual bool is_event_queue_empty(int event_id);
+
+//
+// Locking methods
+//
+ virtual void lock(int lock_validity=DEFAULT_LOCK_VALIDITY);
+ virtual void unlock(bool force=false);
+ virtual std::string locking_status();
+ virtual bool is_locked();
+ virtual bool is_locked_by_me();
+ virtual bool get_locker(LockerInfo &);
+*/
+};
+
diff --git a/src/sip/deviceproxy.sip b/src/sip/deviceproxy.sip
deleted file mode 100644
index e6f7543..0000000
--- a/src/sip/deviceproxy.sip
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
-
- This file is part of PyTango, a python binding for Tango
-
- http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
-
- Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-
- PyTango is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PyTango 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PyTango. If not, see <http://www.gnu.org/licenses/>.
-
-*******************************************************************************/
-
-class DeviceProxy : Connection {
-
-%TypeHeaderCode
-#include <tango.h>
-using namespace Tango;
-%End
-
-protected:
- virtual std::string get_corba_name(bool);
- virtual std::string build_corba_name();
- virtual int get_lock_ctr();
- virtual void set_lock_ctr(int);
-
-public:
- DeviceProxy();
- DeviceProxy(const char *, bool ch_access);
- DeviceProxy(const char *);
-
- DeviceProxy(const DeviceProxy &);
-// DeviceProxy & operator=(const DeviceProxy &);
-
-//
-// general methods
-//
-
-// virtual DeviceInfo const &info();
- virtual std::string dev_name();
- virtual void parse_name(std::string &);
- virtual Database *get_device_db();
-
- virtual std::string status();
- virtual DevState state();
- virtual std::string adm_name();
- virtual std::string description();
- virtual std::string name();
- virtual std::string alias();
-
- virtual int ping();
-
- virtual std::vector<std::string> *black_box(int);
-
-/*
-
-//
-// device methods
-//
- virtual CommandInfo command_query(std::string);
- virtual CommandInfoList *command_list_query();
-
- virtual DbDevImportInfo import_info();
-//
-// property methods
-//
- virtual void get_property(std::string&, DbData&);
- virtual void get_property(vector<std::string>&, DbData&);
- virtual void get_property(DbData&);
- virtual void put_property(DbData&);
- virtual void delete_property(std::string&);
- virtual void delete_property(vector<std::string>&);
- virtual void delete_property(DbData&);
- virtual void get_property_list(const std::string &,vector<std::string> &);
-//
-// attribute methods
-//
- virtual vector<std::string> *get_attribute_list();
-
- virtual AttributeInfoList *get_attribute_config(vector<std::string>&);
- virtual AttributeInfoListEx *get_attribute_config_ex(vector<std::string>&);
- virtual AttributeInfoEx get_attribute_config(const std::string &);
-
- virtual AttributeInfoEx attribute_query(std::string name) {return get_attribute_config(name);}
- virtual AttributeInfoList *attribute_list_query();
- virtual AttributeInfoListEx *attribute_list_query_ex();
-
- virtual void set_attribute_config(AttributeInfoList &);
- virtual void set_attribute_config(AttributeInfoListEx &);
-
- virtual DeviceAttribute read_attribute(std::string&);
- virtual DeviceAttribute read_attribute(const char *at) {std::string str(at);return read_attribute(str);}
- void read_attribute(const char *,DeviceAttribute &);
- void read_attribute(std::string &at,DeviceAttribute &da) {read_attribute(at.c_str(),da);}
- virtual vector<DeviceAttribute> *read_attributes(vector<std::string>&);
-
- virtual void write_attribute(DeviceAttribute&);
- virtual void write_attributes(vector<DeviceAttribute>&);
-
- virtual DeviceAttribute write_read_attribute(DeviceAttribute &);
-
-//
-// history methods
-//
- virtual vector<DeviceDataHistory> *command_history(std::string &,int);
- virtual vector<DeviceDataHistory> *command_history(const char *na,int n)
- {std::string str(na);return command_history(str,n);}
-
- virtual vector<DeviceAttributeHistory> *attribute_history(std::string &,int);
- virtual vector<DeviceAttributeHistory> *attribute_history(const char *na,int n)
- {std::string str(na);return attribute_history(str,n);}
-//
-// Polling administration methods
-//
- virtual vector<std::string> *polling_status();
-
- virtual void poll_command(std::string &, int);
- virtual void poll_command(const char *na, int per) {std::string tmp(na);poll_command(tmp,per);}
- virtual void poll_attribute(std::string &, int);
- virtual void poll_attribute(const char *na, int per) {std::string tmp(na);poll_attribute(tmp,per);}
-
- virtual int get_command_poll_period(std::string &);
- virtual int get_command_poll_period(const char *na)
- {std::string tmp(na);return get_command_poll_period(tmp);}
- virtual int get_attribute_poll_period(std::string &);
- virtual int get_attribute_poll_period(const char *na)
- {std::string tmp(na);return get_attribute_poll_period(tmp);}
-
- virtual bool is_command_polled(std::string &);
- virtual bool is_command_polled(const char *na) {std::string tmp(na);return is_command_polled(tmp);}
- virtual bool is_attribute_polled(std::string &);
- virtual bool is_attribute_polled(const char *na) {std::string tmp(na);return is_attribute_polled(tmp);}
-
- virtual void stop_poll_command(std::string &);
- virtual void stop_poll_command(const char *na) {std::string tmp(na);stop_poll_command(tmp);}
- virtual void stop_poll_attribute(std::string &);
- virtual void stop_poll_attribute(const char *na) {std::string tmp(na);stop_poll_attribute(tmp);}
-//
-// Asynchronous methods
-//
- virtual long read_attribute_asynch(const char *na) {std::string tmp(na);return read_attribute_asynch(tmp);}
- virtual long read_attribute_asynch(std::string &att_name);
- virtual long read_attributes_asynch(vector <std::string> &);
-
- virtual vector<DeviceAttribute> *read_attributes_reply(long);
- virtual vector<DeviceAttribute> *read_attributes_reply(long,long);
- virtual DeviceAttribute *read_attribute_reply(long);
- virtual DeviceAttribute *read_attribute_reply(long,long);
-
- virtual long write_attribute_asynch(DeviceAttribute &);
- virtual long write_attributes_asynch(vector<DeviceAttribute> &);
-
- virtual void write_attributes_reply(long);
- virtual void write_attributes_reply(long,long);
- virtual void write_attribute_reply(long id) {write_attributes_reply(id);}
- virtual void write_attribute_reply(long to,long id) {write_attributes_reply(to,id);}
-
- virtual long pending_asynch_call(asyn_req_type req)
- {if (req == POLLING)return pasyn_ctr;
- else if (req==CALL_BACK) return pasyn_cb_ctr;
- else return (pasyn_ctr + pasyn_cb_ctr);}
-
- virtual void read_attributes_asynch(vector<std::string> &,CallBack &);
- virtual void read_attribute_asynch(const char *na,CallBack &cb) {std::string tmp(na);read_attribute_asynch(tmp,cb);}
- virtual void read_attribute_asynch(std::string &,CallBack &);
-
- virtual void write_attribute_asynch(DeviceAttribute &,CallBack &);
- virtual void write_attributes_asynch(vector<DeviceAttribute> &,CallBack &);
-//
-// Logging administration methods
-//
-#ifdef TANGO_HAS_LOG4TANGO
- virtual void add_logging_target(const std::string &target_type_name);
- virtual void add_logging_target(const char *target_type_name)
- {add_logging_target(std::string(target_type_name));}
-
- virtual void remove_logging_target(const std::string &target_type_name);
- virtual void remove_logging_target(const char *target_type_name)
- {remove_logging_target(std::string(target_type_name));}
-
- virtual vector<std::string> get_logging_target (void);
- virtual int get_logging_level (void);
- virtual void set_logging_level (int level);
-#endif // TANGO_HAS_LOG4TANGO
-//
-// Event methods
-//
- virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,
- const vector<std::string> &filters); // For compatibility with Tango < 8
- virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,
- const vector<std::string> &filters, bool stateless); // For compatibility with Tango < 8
- virtual int subscribe_event(const std::string &attr_name, EventType event, int event_queue_size,
- const vector<std::string> &filters, bool stateless = false); // For compatibility with Tango < 8
-
- virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *);
- virtual int subscribe_event(const std::string &attr_name, EventType event, CallBack *,bool stateless);
- virtual int subscribe_event(const std::string &attr_name, EventType event, int event_queue_size,bool stateless = false);
-
- virtual void unsubscribe_event(int event_id);
-//
-// Methods to access data in event queues
-//
- virtual void get_events (int event_id, EventDataList &event_list);
- virtual void get_events (int event_id, AttrConfEventDataList &event_list);
- virtual void get_events (int event_id, DataReadyEventDataList &event_list);
- virtual void get_events (int event_id, CallBack *cb);
- virtual int event_queue_size(int event_id);
- virtual TimeVal get_last_event_date(int event_id);
- virtual bool is_event_queue_empty(int event_id);
-
-//
-// Locking methods
-//
- virtual void lock(int lock_validity=DEFAULT_LOCK_VALIDITY);
- virtual void unlock(bool force=false);
- virtual std::string locking_status();
- virtual bool is_locked();
- virtual bool is_locked_by_me();
- virtual bool get_locker(LockerInfo &);
-*/
-};
-
diff --git a/src/sip/stdutils.sip b/src/sip/std_utils.sip
similarity index 66%
rename from src/sip/stdutils.sip
rename to src/sip/std_utils.sip
index aec4e07..ba88508 100644
--- a/src/sip/stdutils.sip
+++ b/src/sip/std_utils.sip
@@ -111,3 +111,61 @@ return aReturnListPt;
};
+// vector<TYPE> is implemented as a Python vector.
+template<TYPE>
+%MappedType vector<TYPE>
+{
+%TypeHeaderCode
+#include <vector>
+using namespace std;
+%End
+
+%ConvertFromTypeCode
+ // Create the vector.
+ PyObject *l;
+ if ((l = PyList_New(sipCpp->size())) == NULL)
+ return NULL;
+ // Set the vector elements.
+ vector<TYPE>::iterator iter;
+ int i(0);
+ for (iter = sipCpp->begin(); iter != sipCpp->end(); ++iter) {
+ TYPE *t = new TYPE(*iter);
+ PyObject *tobj;
+ if ((tobj = sipConvertFromNewInstance(t, sipClass_TYPE, sipTransferObj)) == NULL) {
+ Py_DECREF(l);
+ delete t;
+ return NULL;
+ }
+ PyList_SET_ITEM(l, i++, tobj);
+ }
+ return l;
+%End
+
+%ConvertToTypeCode
+ // Check the type if that is all that is required.
+ if (sipIsErr == NULL) {
+ if (!PyList_Check(sipPy))
+ return 0;
+ for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
+ if (!sipCanConvertToInstance(PyList_GET_ITEM(sipPy, i), sipClass_TYPE, SIP_NOT_NONE))
+ return 0;
+ return 1;
+ }
+ vector<TYPE> *qv = new vector<TYPE>;
+ for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) {
+ int state;
+ TYPE *t = reinterpret_cast<TYPE *>(sipConvertToInstance(PyList_GET_ITEM(sipPy, i), sipClass_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
+ if (*sipIsErr) {
+ sipReleaseInstance(t, sipClass_TYPE, state);
+ delete qv;
+ return 0;
+ }
+ qv->push_back(*t);
+ sipReleaseInstance(t, sipClass_TYPE, state);
+ }
+ *sipCppPtr = qv;
+ return sipGetState(sipTransferObj);
+%End
+};
+
+
diff --git a/src/sip/tango.sip b/src/sip/tango.sip
index 25d4a4b..f5ccc55 100644
--- a/src/sip/tango.sip
+++ b/src/sip/tango.sip
@@ -21,11 +21,18 @@
*******************************************************************************/
-%Module(name=Tango, version=0801)
+%Module Tango 008001000
-%Include stdutils.sip
+%Timeline { TANGO_8_0 TANGO_8_1 }
+
+%Platforms {WIN32_PLATFORM POSIX_PLATFORM MACOS_PLATFORM}
+
+%Include std_utils.sip
%Include constants.sip
+%Include command_info.sip
+%Include db_datum.sip
+%Include db_dev_info.sip
+%Include db_dev_import_info.sip
%Include connection.sip
-%Include dbdatum.sip
+%Include device_proxy.sip
%Include database.sip
-%Include deviceproxy.sip
diff --git a/src/sip/test/Makefile b/src/sip/test/Makefile
new file mode 100644
index 0000000..c1a2fdc
--- /dev/null
+++ b/src/sip/test/Makefile
@@ -0,0 +1,47 @@
+TARGET = pytest.so
+OFILES = sippytestcmodule.o sippyteststdvector1801.o
+HFILES = sipAPIpytest.h
+
+CC = gcc
+CXX = g++
+LINK = g++
+CPPFLAGS = -DNDEBUG -I. -I/usr/include/python2.6
+CFLAGS = -O2 -g -fPIC -Wall -W
+CXXFLAGS = -O2 -g -fPIC -Wall -W
+LFLAGS = -z defs -shared -Wl,--version-script=pytest.exp
+LIBS = -lpython2.6 -ltest
+.SUFFIXES: .c .o .cpp .cc .cxx .C
+
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
+
+all: $(TARGET)
+
+$(OFILES): $(HFILES)
+
+$(TARGET): $(OFILES)
+ @echo '{ global: initpytest; local: *; };' > pytest.exp
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
+
+install: $(TARGET)
+ @test -d $(DESTDIR)/usr/lib/python2.6/dist-packages || mkdir -p $(DESTDIR)/usr/lib/python2.6/dist-packages
+ cp -f $(TARGET) $(DESTDIR)/usr/lib/python2.6/dist-packages/$(TARGET)
+
+clean:
+ -rm -f $(TARGET)
+ -rm -f sippytestcmodule.o
+ -rm -f sippyteststdvector1801.o
+ -rm -f pytest.exp
diff --git a/src/sip/configure.py b/src/sip/test/configure.py
similarity index 67%
copy from src/sip/configure.py
copy to src/sip/test/configure.py
index 81e945e..59bea49 100644
--- a/src/sip/configure.py
+++ b/src/sip/test/configure.py
@@ -1,26 +1,29 @@
import os
+import sys
import sipconfig
# The name of the SIP build file generated by SIP and used by the build
# system.
-build_file = "tango.sbf"
+build_file = "test.sbf"
# Get the SIP configuration information.
config = sipconfig.Configuration()
# Run SIP to generate the code.
-os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "tango.sip"]))
+os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "test.sip"]))
# Create the Makefile.
makefile = sipconfig.SIPModuleMakefile(config, build_file)
+python_lib = "python{v[0]}.{v[1]}".format(v=sys.version_info)
+
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
-makefile.extra_libs = ["tango", "zmq"]
-makefile.extra_lib_dirs = ["/home/tcoutinho/.local/lib"]
-makefile.extra_include_dirs = ["/home/tcoutinho/.local/include", "/home/tcoutinho/.local/include/tango"]
-makefile.extra_cxxflags = ["-std=c++0x"]
+makefile.extra_libs = [python_lib, "test"]
+
+# see all undefined references
+makefile.extra_lflags = ['-z defs']
# Generate the Makefile itself.
makefile.generate()
diff --git a/src/sip/test/test.cpp b/src/sip/test/test.cpp
new file mode 100644
index 0000000..718d834
--- /dev/null
+++ b/src/sip/test/test.cpp
@@ -0,0 +1,25 @@
+#include "test.h"
+
+#include <vector>
+
+std::vector<int *> get_numbers(int n)
+{
+ std::vector<int *> v;
+ for(int i = 0; i < n; ++i)
+ {
+ int *val = new int;
+ *val = i;
+ v.push_back(val);
+ }
+ return v;
+}
+
+
+void set_numbers(std::vector<int *> *v)
+{
+ for(int i = 0; i < v->size(); ++i)
+ {
+ delete (*v)[i];
+ }
+ delete v;
+}
diff --git a/src/sip/test/test.h b/src/sip/test/test.h
new file mode 100644
index 0000000..308dc50
--- /dev/null
+++ b/src/sip/test/test.h
@@ -0,0 +1,3 @@
+#include <vector>
+
+std::vector<int *> get_numbers(int n);
diff --git a/src/sip/test/test.sip b/src/sip/test/test.sip
new file mode 100644
index 0000000..c720b94
--- /dev/null
+++ b/src/sip/test/test.sip
@@ -0,0 +1,48 @@
+%Module pytest
+
+%MappedType std::vector<int*>
+{
+%TypeHeaderCode
+#include <vector>
+%End
+
+%ConvertToTypeCode
+if (sipIsErr == NULL)
+{
+bool aReturnFlag = PyList_Check(sipPy);
+for(int i = 0;aReturnFlag && i < PyList_Size(sipPy);++i)
+ aReturnFlag = PyInt_Check(PyList_GET_ITEM(sipPy,i));
+return aReturnFlag;
+}
+
+*sipCppPtr = new std::vector<int*>(PyList_Size(sipPy));
+for(int i = 0;i < PyList_Size(sipPy);++i)
+{
+ int *v = new int;
+ *v = PyInt_AS_LONG(PyList_GET_ITEM(sipPy,i));
+ (*sipCppPtr)->operator[](i) = v;
+}
+ return sipGetState(sipTransferObj);
+%End
+
+%ConvertFromTypeCode
+PyObject* aReturnListPt = PyList_New(sipCpp->size());
+std::vector<int*>::iterator vIter = sipCpp->begin();
+
+for(int i = 0;vIter != sipCpp->end();++vIter,++i)
+{
+ int *v = *vIter;
+ PyList_SET_ITEM(aReturnListPt,i,PyInt_FromLong(*v));
+ delete v;
+}
+//delete sipCpp;
+return aReturnListPt;
+%End
+
+};
+
+%ModuleHeaderCode
+#include "test.h"
+%End
+
+std::vector<int *> get_numbers(int n);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list