[pytango] 284/483: first experiment with swig

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:50 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 969dc0f649534d6158145fcd95a1d1efc1ce0fd9
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Tue Sep 24 13:20:40 2013 +0000

    first experiment with swig
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@23765 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 src/swig/Makefile      | 106 ++++++++++++++++++++++
 src/swig/deviceproxy.i | 236 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/swig/tango.i       |  33 +++++++
 3 files changed, 375 insertions(+)

diff --git a/src/swig/Makefile b/src/swig/Makefile
new file mode 100644
index 0000000..6555b4a
--- /dev/null
+++ b/src/swig/Makefile
@@ -0,0 +1,106 @@
+
+# -----------------------------------------------------------------------------
+# Common stuff
+# -----------------------------------------------------------------------------
+COMMON_OUT = _common
+
+CSCC = cscc
+CC = c++
+LD = c++
+
+SRC = src
+SWIG = swig -c++
+
+INTERFACE_FILE=tango.i
+
+# -----------------------------------------------------------------------------
+# PERL stuff
+# -----------------------------------------------------------------------------
+PERL_FLAGS =$(shell perl -MConfig -e 'print join(" ", @Config{qw(ccflags optimize cccdlflags)}, "-I$$Config{archlib}/CORE")')
+PERL_LINK_FLAGS = $(shell perl -MConfig -e 'print $$Config{lddlflags}')
+PERL_OUT = _perl
+PERL_SWIG = $(SWIG) -perl5 -outdir $(PERL_OUT)
+PERL_CC = $(CC) $(PERL_FLAGS)
+PERL_LD = $(CC) $(PERL_LINK_FLAGS)
+
+# -----------------------------------------------------------------------------
+# Python stuff
+# -----------------------------------------------------------------------------
+PY_FLAGS = -g -fPIC -Wall $(shell python-config --includes) -std=c++0x
+PY_LINK_FLAGS = -ltango -llog4tango -lpthread -lrt -ldl -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lzmq
+PY_OUT = _python
+PY_SWIG = $(SWIG) -python -outdir $(PY_OUT)
+PY_CC = $(CC) $(PY_FLAGS)
+PY_LD = $(LD) $(PY_LINK_FLAGS) -shared
+
+# -----------------------------------------------------------------------------
+# C# stuff
+# -----------------------------------------------------------------------------
+CSHARP_FLAGS = -fPIC
+CSHARP_OUT = _csharp
+CSHARP_SWIG = $(SWIG) -csharp -outdir $(CSHARP_OUT)
+CSHARP_CC = $(CC) $(CSHARP_FLAGS)
+CSHARP_LD = $(CC) -shared
+
+# -----------------------------------------------------------------------------
+# TCL stuff
+# -----------------------------------------------------------------------------
+TCL_FLAGS = -I/usr/include/tcl -fPIC
+TCL_OUT = _tcl
+TCL_SWIG = $(SWIG) -tcl -outdir $(TCL_OUT)
+TCL_CC = $(CC) $(TCL_FLAGS)
+TCL_LD = $(LD) -shared
+
+# -----------------------------------------------------------------------------
+# GO stuff
+# -----------------------------------------------------------------------------
+GO_FLAGS = -fPIC
+GO_OUT = _go
+GO_SWIG = $(SWIG) -go -intgosize 32 -outdir $(GO_OUT)
+GO_CC = $(CC) $(GO_FLAGS)
+GO_LD = $(CC) -shared
+
+# -----------------------------------------------------------------------------
+# commands
+# -----------------------------------------------------------------------------
+
+all: perl python csharp tcl
+
+common:
+	mkdir -p $(COMMON_OUT)
+
+perl: common
+	mkdir -p $(PERL_OUT)
+	$(PERL_SWIG) -o $(PERL_OUT)/tango_wrap.cpp $(INTERFACE_FILE)
+	$(PERL_CC) -c $(PERL_OUT)/tango_wrap.cpp -o $(PERL_OUT)/tango_wrap.o
+	$(PERL_LD) $(COMMON_OUT)/tango_wrap.o -o $(PERL_OUT)/_Tango.so
+	
+python: common
+	mkdir -p $(PY_OUT)
+	$(PY_SWIG) -o $(PY_OUT)/tango_wrap.cpp $(INTERFACE_FILE)
+	$(PY_CC) -c $(PY_OUT)/tango_wrap.cpp -o $(PY_OUT)/tango_wrap.o
+	$(PY_LD) $(PY_OUT)/tango_wrap.o -o $(PY_OUT)/_Tango.so
+
+csharp: common
+	mkdir -p $(CSHARP_OUT)
+	$(CSHARP_SWIG) -o $(CSHARP_OUT)/example_wrap.c $(INTERFACE_FILE)
+	$(CSHARP_CC) -c $(CSHARP_OUT)/example_wrap.c -o $(CSHARP_OUT)/example_wrap.o
+	$(CSHARP_LD) $(COMMON_OUT)/example.o $(CSHARP_OUT)/example_wrap.o -o $(CSHARP_OUT)/libexample.so
+	
+tcl: common
+	mkdir -p $(TCL_OUT)
+	$(TCL_SWIG) -o $(TCL_OUT)/example_wrap.c $(INTERFACE_FILE)
+	$(TCL_CC) -c $(TCL_OUT)/example_wrap.c -o $(TCL_OUT)/example_wrap.o
+	$(TCL_LD) $(COMMON_OUT)/example.o $(TCL_OUT)/example_wrap.o -o $(TCL_OUT)/example.so
+
+go: common
+	mkdir -p $(GO_OUT)
+	$(GO_SWIG) -o $(GO_OUT)/example_wrap.c $(INTERFACE_FILE)
+	$(GO_CC) -c $(GO_OUT)/example_wrap.c -o $(GO_OUT)/example_wrap.o $(GO_FLAGS)
+	$(GO_LD) $(COMMON_OUT)/example.o $(GO_OUT)/example_wrap.o -o $(GO_OUT)/example.so
+	6g -o $(GO_OUT)/example.6 $(GO_OUT)/example.go
+	6c -I $(GOROOT)/pkg/linux_amd64 -o $(GO_OUT)/example_gc.6 $(GO_OUT)/example_gc.c
+	pack grc $(GO_OUT)/example.a $(GO_OUT)/example.6 $(GO_OUT)/example_gc.6
+
+clean:
+	rm -rf $(COMMON_OUT) $(PERL_OUT) $(PY_OUT) $(CSHARP_OUT) $(TCL_OUT) $(GO_OUT)
diff --git a/src/swig/deviceproxy.i b/src/swig/deviceproxy.i
new file mode 100644
index 0000000..1609e76
--- /dev/null
+++ b/src/swig/deviceproxy.i
@@ -0,0 +1,236 @@
+/*******************************************************************************
+
+   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/>.
+   
+*******************************************************************************/
+
+ %{
+ #include <tango.h>
+ %}
+
+namespace Tango
+{
+
+class DeviceProxy: public Connection
+{
+public:
+	%newobject black_box;
+	%newobject command_list_query;
+	%newobject get_attribute_list;
+	%newobject get_attribute_config;
+	%newobject get_attribute_ex;
+	%newobject attribute_list_query;
+	%newobject attribute_list_query_ex;
+	%newobject polling_status;
+
+	DeviceProxy();
+	DeviceProxy(std::string &name, CORBA::ORB *orb=NULL);
+	DeviceProxy(std::string &name, bool ch_access, CORBA::ORB *orb=NULL);
+	DeviceProxy(const char *, bool ch_access, CORBA::ORB *orb=NULL);
+	DeviceProxy(const char *, CORBA::ORB *orb=NULL);
+
+	DeviceProxy(const DeviceProxy &);
+	DeviceProxy & operator=(const DeviceProxy &);
+	virtual ~DeviceProxy();
+
+//
+// general methods
+//
+
+	virtual Tango::DeviceInfo const &info();
+	virtual inline std::string dev_name() { return device_name; }
+	virtual void parse_name(std::string &);
+	virtual Tango::Database *get_device_db();
+
+	virtual std::string status();
+	virtual Tango::DevState state();
+	virtual std::string adm_name();
+	virtual std::string description();
+	virtual std::string name();
+	virtual std::string alias();
+
+	int get_tango_lib_version();
+
+	virtual int ping();
+	virtual std::vector<std::string> *black_box(int);
+//
+// device methods
+//
+	virtual Tango::CommandInfo command_query(std::string);
+	virtual Tango::CommandInfoList *command_list_query();
+
+	virtual Tango::DbDevImportInfo import_info();
+//
+// property methods
+//
+	virtual void get_property(std::string&, Tango::DbData&);
+	virtual void get_property(std::vector<std::string>&, Tango::DbData&);
+	virtual void get_property(Tango::DbData&);
+	virtual void put_property(Tango::DbData&);
+	virtual void delete_property(std::string&);
+	virtual void delete_property(std::vector<std::string>&);
+	virtual void delete_property(Tango::DbData&);
+	virtual void get_property_list(const std::string &,std::vector<std::string> &);
+//
+// attribute methods
+//
+	virtual std::vector<std::string> *get_attribute_list(); /* MEMORY LEAK */
+
+	virtual Tango::AttributeInfoList *get_attribute_config(std::vector<std::string>&);
+	virtual Tango::AttributeInfoListEx *get_attribute_config_ex(std::vector<std::string>&);
+	virtual Tango::AttributeInfoEx get_attribute_config(const std::string &);
+
+	virtual Tango::AttributeInfoEx attribute_query(std::string name);
+	virtual Tango::AttributeInfoList *attribute_list_query();
+	virtual Tango::AttributeInfoListEx *attribute_list_query_ex();
+
+	virtual void set_attribute_config(Tango::AttributeInfoList &);
+	virtual void set_attribute_config(Tango::AttributeInfoListEx &);
+
+	virtual Tango::DeviceAttribute read_attribute(std::string&);
+	virtual Tango::DeviceAttribute read_attribute(const char *at);
+	void read_attribute(const char *, Tango::DeviceAttribute &);
+	void read_attribute(std::string &at, Tango::DeviceAttribute &da);
+	virtual std::vector<Tango::DeviceAttribute> *read_attributes(std::vector<std::string>&);
+
+	virtual void write_attribute(Tango::DeviceAttribute&);
+	virtual void write_attributes(std::vector<Tango::DeviceAttribute>&);
+
+	virtual Tango::DeviceAttribute write_read_attribute(Tango::DeviceAttribute &);
+
+//
+// history methods
+//
+	virtual std::vector<Tango::DeviceDataHistory> *command_history(std::string &,int);
+	virtual std::vector<Tango::DeviceDataHistory> *command_history(const char *na,int n);
+
+	virtual std::vector<Tango::DeviceAttributeHistory> *attribute_history(std::string &,int);
+	virtual std::vector<Tango::DeviceAttributeHistory> *attribute_history(const char *na,int 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);
+	virtual void poll_attribute(std::string &, int);
+	virtual void poll_attribute(const char *na, int 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);
+	virtual bool is_attribute_polled(std::string &);
+	virtual bool is_attribute_polled(const char *na);
+
+	virtual void stop_poll_command(std::string &);
+	virtual void stop_poll_command(const char *na);
+	virtual void stop_poll_attribute(std::string &);
+	virtual void stop_poll_attribute(const char *na);
+//
+// Asynchronous methods
+//
+	virtual long read_attribute_asynch(const char *na);
+	virtual long read_attribute_asynch(std::string &att_name);
+	virtual long read_attributes_asynch(std::vector <std::string> &);
+
+	virtual std::vector<Tango::DeviceAttribute> *read_attributes_reply(long);
+	virtual std::vector<Tango::DeviceAttribute> *read_attributes_reply(long,long);
+	virtual Tango::DeviceAttribute *read_attribute_reply(long);
+	virtual Tango::DeviceAttribute *read_attribute_reply(long,long);
+
+	virtual long write_attribute_asynch(Tango::DeviceAttribute &);
+	virtual long write_attributes_asynch(std::vector<Tango::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(Tango::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(std::vector<std::string> &, Tango::CallBack &);
+	virtual void read_attribute_asynch(const char *na, Tango::CallBack &cb);
+	virtual void read_attribute_asynch(std::string &, Tango::CallBack &);
+
+	virtual void write_attribute_asynch(Tango::DeviceAttribute &, Tango::CallBack &);
+	virtual void write_attributes_asynch(std::vector<Tango::DeviceAttribute> &, Tango::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, Tango::EventType event, Tango::CallBack *,
+	                   const std::vector<std::string> &filters);  // For compatibility with Tango < 8
+	virtual int subscribe_event(const std::string &attr_name, Tango::EventType event, Tango::CallBack *,
+	                   const std::vector<std::string> &filters, bool stateless); // For compatibility with Tango < 8
+	virtual int subscribe_event(const std::string &attr_name, Tango::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, Tango::EventType event, Tango::CallBack *);
+	virtual int subscribe_event(const std::string &attr_name, Tango::EventType event, Tango::CallBack *,bool stateless);
+	virtual int subscribe_event(const std::string &attr_name, Tango::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, Tango::EventDataList &event_list);
+	virtual void get_events (int event_id, Tango::AttrConfEventDataList &event_list);
+	virtual void get_events (int event_id, Tango::DataReadyEventDataList &event_list);
+	virtual void get_events (int event_id, Tango::CallBack *cb);
+	virtual int  event_queue_size(int event_id);
+	virtual Tango::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(Tango::LockerInfo &);
+};
+
+}
\ No newline at end of file
diff --git a/src/swig/tango.i b/src/swig/tango.i
new file mode 100644
index 0000000..db94833
--- /dev/null
+++ b/src/swig/tango.i
@@ -0,0 +1,33 @@
+/*******************************************************************************
+
+   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/>.
+   
+*******************************************************************************/
+
+%module Tango
+
+%include "std_string.i"
+%include "std_vector.i"
+
+namespace std {
+   %template(vector_string) vector<string>;
+};
+
+%include "deviceproxy.i"
\ No newline at end of file

-- 
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