summaryrefslogtreecommitdiff
path: root/swig
diff options
context:
space:
mode:
authorTobias Grimm <tobias@e-tobi.loc>2009-02-14 23:25:05 +0100
committerTobias Grimm <tobias@e-tobi.loc>2009-02-14 23:25:05 +0100
commit2bae6457006474655f971891a92341b1ae34840e (patch)
tree30a813fdbb1c096a08d7c35dd59fafc3f65154f4 /swig
downloadvdr-plugin-scripting-2bae6457006474655f971891a92341b1ae34840e.tar.gz
vdr-plugin-scripting-2bae6457006474655f971891a92341b1ae34840e.tar.bz2
Initial commitv0.0.1branches/v0.0.1
Diffstat (limited to 'swig')
-rw-r--r--swig/PluginManager.i27
-rw-r--r--swig/cMenuText.i30
-rw-r--r--swig/cOsdItem.i36
-rw-r--r--swig/cOsdMenu.i55
-rw-r--r--swig/cOsdMessage.i25
-rw-r--r--swig/custom/rubytracking.swg69
-rw-r--r--swig/eKeys.i76
-rw-r--r--swig/eOSState.i58
-rw-r--r--swig/typemaps.i30
-rw-r--r--swig/vdr.i39
10 files changed, 445 insertions, 0 deletions
diff --git a/swig/PluginManager.i b/swig/PluginManager.i
new file mode 100644
index 0000000..3afb9b4
--- /dev/null
+++ b/swig/PluginManager.i
@@ -0,0 +1,27 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%{
+#include "src/PluginManager.h"
+%}
+
+%feature("director") PluginManager;
+
+%include "src/PluginManager.h"
diff --git a/swig/cMenuText.i b/swig/cMenuText.i
new file mode 100644
index 0000000..2ce158c
--- /dev/null
+++ b/swig/cMenuText.i
@@ -0,0 +1,30 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%{
+#include <vdr/menu.h>
+%}
+
+class cMenuText : public cOsdMenu
+{
+ public:
+ cMenuText(const char *Title, const char *Text);
+ virtual ~cMenuText();
+};
diff --git a/swig/cOsdItem.i b/swig/cOsdItem.i
new file mode 100644
index 0000000..c50181c
--- /dev/null
+++ b/swig/cOsdItem.i
@@ -0,0 +1,36 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%include "eOSState.i"
+
+%{
+#include <vdr/osdbase.h>
+%}
+
+%feature("director") cOsdItem;
+
+class cOsdItem
+{
+ public:
+ cOsdItem(eOSState State = osUnknown);
+ virtual ~cOsdItem();
+ cOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true);
+ virtual eOSState ProcessKey(eKeys Key);
+};
diff --git a/swig/cOsdMenu.i b/swig/cOsdMenu.i
new file mode 100644
index 0000000..ecc4678
--- /dev/null
+++ b/swig/cOsdMenu.i
@@ -0,0 +1,55 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%include "eKeys.i"
+%include "eOSState.i"
+%include "typemaps.i"
+
+%{
+#include <vdr/osdbase.h>
+%}
+
+%feature("director") cOsdMenu;
+
+//
+// When adding an item to a menu, the menu becomes it's owner and is
+// responsible for deleting it.
+//
+%apply SWIGTYPE* TRANSFER_DELETE_RESPONSIBILITY {cOsdItem* foo};
+
+//
+// When adding an submenu to a menu, the menu becomes it's owner and is
+// responsible for deleting it.
+//
+%apply SWIGTYPE* TRANSFER_DELETE_RESPONSIBILITY {cOsdMenu* foo};
+
+class cOsdMenu
+{
+ protected:
+ eOSState AddSubMenu(cOsdMenu *SubMenu);
+
+ public:
+ cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0);
+ virtual ~cOsdMenu();
+ int Current(void) const;
+ void Add(cOsdItem *Item, bool Current = false, cOsdItem *After = NULL);
+ void Ins(cOsdItem *Item, bool Current = false, cOsdItem *Before = NULL);
+ virtual eOSState ProcessKey(eKeys Key);
+};
diff --git a/swig/cOsdMessage.i b/swig/cOsdMessage.i
new file mode 100644
index 0000000..ca14bd2
--- /dev/null
+++ b/swig/cOsdMessage.i
@@ -0,0 +1,25 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%{
+#include "src/OsdMessage.h"
+%}
+
+%include "src/OsdMessage.h"
diff --git a/swig/custom/rubytracking.swg b/swig/custom/rubytracking.swg
new file mode 100644
index 0000000..1495975
--- /dev/null
+++ b/swig/custom/rubytracking.swg
@@ -0,0 +1,69 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "src/RubyObjectTracker.h"
+
+RubyObjectTracker rubyObjectTracker;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGRUNTIME void SWIG_RubyInitializeTrackings(void)
+{
+ VALUE rubyObjectTrackerClass = rb_define_class_under(_mSWIG, "RubyObjectTrackings", rb_cObject);
+
+ // The object tracker is allocated on the stack, so no free function is needed.
+ // But a mark function is required to keep the tracked ruby objects alive
+ VALUE rbRubyObjectTracker = Data_Wrap_Struct(rubyObjectTrackerClass, RubyObjectTracker::MarkTrackedRubyObjects, 0,
+ &rubyObjectTracker);
+
+ // To keep the RubyObjectTracker alive itself, put it into a variable under the SWIG module:
+ VALUE rubyObjectTrackerSymbol = rb_intern("@ruby_object_tracker");
+ rb_ivar_set(_mSWIG, rubyObjectTrackerSymbol, rbRubyObjectTracker);
+}
+
+SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object)
+{
+ rubyObjectTracker.Track(ptr, object);
+}
+
+SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr)
+{
+ return rubyObjectTracker.GetTrackedRubyObject(ptr);
+}
+
+SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr)
+{
+ rubyObjectTracker.Untrack(ptr);
+}
+
+SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr)
+{
+ VALUE object = SWIG_RubyInstanceFor(ptr);
+
+ if (object != Qnil) {
+ DATA_PTR(object) = 0;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/swig/eKeys.i b/swig/eKeys.i
new file mode 100644
index 0000000..c530fca
--- /dev/null
+++ b/swig/eKeys.i
@@ -0,0 +1,76 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%module vdr
+
+%{
+#include <vdr/keys.h>
+%}
+
+enum eKeys
+{
+ // "Up" and "Down" must be the first two keys!
+ kUp,
+ kDown,
+ kMenu,
+ kOk,
+ kBack,
+ kLeft,
+ kRight,
+ kRed,
+ kGreen,
+ kYellow,
+ kBlue,
+ k0, k1, k2, k3, k4, k5, k6, k7, k8, k9,
+ kInfo,
+ kPlay,
+ kPause,
+ kStop,
+ kRecord,
+ kFastFwd,
+ kFastRew,
+ kNext,
+ kPrev,
+ kPower,
+ kChanUp,
+ kChanDn,
+ kChanPrev,
+ kVolUp,
+ kVolDn,
+ kMute,
+ kAudio,
+ kSubtitles,
+ kSchedule,
+ kChannels,
+ kTimers,
+ kRecordings,
+ kSetup,
+ kCommands,
+ kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9,
+ kNone,
+ kKbd,
+ // The following codes are used internally:
+ k_Plugin,
+ k_Setup,
+ // The following flags are OR'd with the above codes:
+ k_Repeat = 0x8000,
+ k_Release = 0x4000,
+ k_Flags = k_Repeat | k_Release,
+};
diff --git a/swig/eOSState.i b/swig/eOSState.i
new file mode 100644
index 0000000..02cca5b
--- /dev/null
+++ b/swig/eOSState.i
@@ -0,0 +1,58 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%module vdr
+
+%{
+#include <vdr/osdbase.h>
+%}
+
+enum eOSState
+{
+ osUnknown,
+ osContinue,
+ osSchedule,
+ osChannels,
+ osTimers,
+ osRecordings,
+ osPlugin,
+ osSetup,
+ osCommands,
+ osPause,
+ osRecord,
+ osReplay,
+ osStopRecord,
+ osStopReplay,
+ osCancelEdit,
+ osSwitchDvb,
+ osBack,
+ osEnd,
+ os_User, // the following values can be used locally
+ osUser1,
+ osUser2,
+ osUser3,
+ osUser4,
+ osUser5,
+ osUser6,
+ osUser7,
+ osUser8,
+ osUser9,
+ osUser10,
+};
diff --git a/swig/typemaps.i b/swig/typemaps.i
new file mode 100644
index 0000000..919ca0c
--- /dev/null
+++ b/swig/typemaps.i
@@ -0,0 +1,30 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%typemap(in, noblock=1) SWIGTYPE* TRANSFER_DELETE_RESPONSIBILITY(void *argp = 0, int res = 0)
+{
+ res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags);
+ if (!SWIG_IsOK(res))
+ {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ $1 = %reinterpret_cast(argp, $ltype);
+ rubyObjectTracker.KeepRubyObjectAlive($1);
+}
diff --git a/swig/vdr.i b/swig/vdr.i
new file mode 100644
index 0000000..69d5a7a
--- /dev/null
+++ b/swig/vdr.i
@@ -0,0 +1,39 @@
+/*
+ * vdr-scripting - A plugin for the Linux Video Disk Recorder
+ * Copyright (c) 2009 Tobias Grimm <vdr@e-tobi.net>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+%module(directors="1", allprotected="1") "vdr::swig"
+
+%{
+#include <iostream>
+using namespace std;
+%}
+
+%feature("director:except") {
+ VALUE klass = rb_class_path(CLASS_OF($error));
+ VALUE message = rb_obj_as_string($error);
+ cerr << "vdr-scripting Error: " << RSTRING_PTR(klass) << " - " << RSTRING_PTR(message) << endl;
+ throw Swig::DirectorMethodException($error);
+};
+
+%include "PluginManager.i"
+%include "cOsdItem.i"
+%include "cOsdMenu.i"
+%include "cOsdMessage.i"
+%include "cMenuText.i"