Fix the swig bindings for melted++.
authorDan Dennedy <dan@dennedy.org>
Fri, 15 May 2009 08:50:57 +0000 (01:50 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 15 May 2009 08:50:57 +0000 (01:50 -0700)
Signed-off-by: Dan Dennedy <dan@dennedy.org>

src/swig/java/build
src/swig/melted.i
src/swig/perl/Makefile.PL
src/swig/php/build [changed mode: 0644->0755]
src/swig/python/build
src/swig/ruby/build
src/swig/ruby/melted.rb [deleted file]
src/swig/ruby/server.rb [new file with mode: 0755]
src/swig/tcl/build

index 0f8ba2e..f9045b9 100755 (executable)
@@ -9,25 +9,24 @@ then
        path=`dirname $path`
 
        # Change this as needed
-       export JAVA_INCLUDE="-I$path/include -I$path/include/linux"
+       # export JAVA_INCLUDE="-I$path/include -I$path/include/linux"
 
-       ln -sf ../mltpp.i .
+       ln -sf ../melted.i
 
        # Invoke swig
-       mkdir -p src_swig/net/sourceforge/mltpp
-       swig -c++ -I../../src `pkg-config mlt-framework --cflags` -java -outdir src_swig/net/sourceforge/mltpp -package net.sourceforge.mltpp mltpp.i || exit $?
+       mkdir -p src_swig/org/mltframework
+       swig -c++ -I../../melted++ `pkg-config mlt++ --cflags` -java -outdir src_swig/org/mltframework -package org.mltframework melted.i || exit $?
 
        # Compile the wrapper
-       g++ -D_GNU_SOURCE -c -rdynamic -pthread -I../../src `pkg-config mlt-framework --cflags` mltpp_wrap.cxx $JAVA_INCLUDE || exit $?
+       g++ -D_GNU_SOURCE -c -rdynamic -pthread -I../../melted++ `pkg-config mlt++ --cflags` melted_wrap.cxx $JAVA_INCLUDE || exit $?
        
        # Create the module
-       gcc -shared mltpp_wrap.o -L../../src -lmlt++ -o libmltpp_java.so || exit $?
+       gcc -shared melted_wrap.o -L../../melted++ -lmelted++ -o libmelted_java.so || exit $?
 
        # Compile the test
        javac `find src_swig -name '*.java'` || exit $?
 
        export CLASSPATH=`pwd`/src_swig
-       javac Play.java
 else
        echo "Java command not found"
        exit 1
index e261d1d..9f874c8 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * melted.i - Swig Bindings for melted++
- * Copyright (C) 2004-2005 Charles Yates
+ * Copyright (C) 2004-2009 Charles Yates
  * Author: Charles Yates <charles.yates@pandora.be>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,9 @@
 %array_class(unsigned char, unsignedCharArray);
 
 %{
-#include <melted++/MltMelted.h>
+#include <Mlt.h>
+#include <MltMelted.h>
+#include <MltResponse.h>
 %}
 
 /** These methods return objects which should be gc'd.
@@ -31,6 +33,7 @@
 
 namespace Mlt {
 %newobject Melted::execute( char * );
+%newobject Melted::received( char *, char * );
 %newobject Melted::push( char *, Service & );
 %newobject Melted::unit( int );
 }
@@ -38,5 +41,67 @@ namespace Mlt {
 /** Classes to wrap.
  */
 
-%include <MltMiracle.h>
+%include <MltMelted.h>
 %include <MltResponse.h>
+
+#if defined(SWIGRUBY)
+
+%{
+
+static void ruby_listener( mlt_properties owner, void *object );
+
+class RubyListener
+{
+       private:
+               VALUE callback;
+               Mlt::Event *event;
+
+       public:
+               RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : 
+                       callback( callback ) 
+               {
+                       event = properties.listen( id, this, ( mlt_listener )ruby_listener );
+               }
+
+               ~RubyListener( )
+               {
+                       delete event;
+               }
+
+       void mark( ) 
+               { 
+                       ((void (*)(VALUE))(rb_gc_mark))( callback ); 
+               }
+
+       void doit( ) 
+               {
+               ID method = rb_intern( "call" );
+               rb_funcall( callback, method, 0 );
+       }
+};
+
+static void ruby_listener( mlt_properties owner, void *object )
+{
+       RubyListener *o = static_cast< RubyListener * >( object );
+       o->doit( );
+}
+
+void markRubyListener( void* p ) 
+{
+    RubyListener *o = static_cast<RubyListener*>( p );
+    o->mark( );
+}
+
+%}
+
+// Ruby wrapper
+%rename( Listener )  RubyListener;
+%markfunc RubyListener "markRubyListener";
+
+class RubyListener 
+{
+       public:
+               RubyListener( Mlt::Properties &properties, char *id, VALUE callback );
+};
+
+#endif
index 07e1827..7b3c0ee 100644 (file)
@@ -3,14 +3,14 @@ use ExtUtils::MakeMaker;
 
 my $CXX = $ENV{'CXX'} || 'g++';
 
-system( "ln -sf ../mltpp.i ." );
-system( "swig -c++ -I../../src `pkg-config mlt-framework --cflags` -perl5 mltpp.i" ); 
+system( "ln -sf ../melted.i" );
+system( "swig -c++ -I../../melted++ `pkg-config mlt++ --cflags` -perl5 melted.i" ); 
 WriteMakefile(
-       'NAME'    => 'mltpp',
-       'CC'      => '${CXX} `pkg-config mlt-framework --cflags` -I../../src',
+       'NAME'    => 'melted',
+       'CC'      => '${CXX} `pkg-config mlt++ --cflags` -I../../melted++',
        'OPTIMIZE' => '-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386',
-       'LIBS'    => ['-L../../src -lmlt++'],
-       'OBJECT'  => 'mltpp_wrap.o',
+       'LIBS'    => ['-L../../melted++ -lmelted++'],
+       'OBJECT'  => 'melted_wrap.o',
        'DESTDIR' => $ENV{'DESTDIR'},
 );
 
old mode 100644 (file)
new mode 100755 (executable)
index a06ed48..4c7e494
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-ln -s ../mltpp.i
-swig -c++ -I../../src `pkg-config --cflags mlt-framework` -php5 -noproxy mltpp.i
-g++ -fPIC -DPIC -D_GNU_SOURCE -c -rdynamic -pthread `pkg-config --cflags mlt-framework` `php-config --includes` mltpp_wrap.cpp
-
+ln -s ../melted.i
+swig -c++ -I../../melted++ `pkg-config --cflags mlt++` -php5 -noproxy melted.i
+g++ -fPIC -DPIC -D_GNU_SOURCE -c -rdynamic -pthread -I../../melted++ `pkg-config --cflags mlt++` `php-config --includes` melted_wrap.cpp
+gcc -shared melted_wrap.o -L../../melted++ -lmelted++ -o melted.so || exit $?
index 7c7ff23..63423ad 100755 (executable)
@@ -9,16 +9,16 @@ then
 
        [ ! -d "$PYTHON_INCLUDE" ] && echo python development missing && exit 1
 
-       ln -sf ../mltpp.i .
+       ln -sf ../melted.i
 
        # Invoke swig
-       swig -c++ -I../../src `pkg-config mlt-framework --cflags` -python mltpp.i || exit $?
+       swig -c++ -I../../melted++ `pkg-config mlt++ --cflags` -python melted.i || exit $?
 
        # Compile the wrapper
-       g++ -fPIC -D_GNU_SOURCE -c -rdynamic -pthread `pkg-config mlt-framework --cflags` -I$PYTHON_INCLUDE mltpp_wrap.cxx || exit $?
+       g++ -fPIC -D_GNU_SOURCE -c -rdynamic -pthread -I../../melted++ `pkg-config mlt++ --cflags` -I$PYTHON_INCLUDE melted_wrap.cxx || exit $?
 
        # Create the module
-       gcc -shared mltpp_wrap.o -L../../src -lmlt++ -o _mltpp.so || exit $?
+       gcc -shared melted_wrap.o -L../../melted++ -lmelted++ -o _melted.so || exit $?
 else
        echo Python not installed.
        exit 1
index bc2dda7..33c3b1d 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/env ruby
 require 'mkmf'
-system( "ln -sf ../mltpp.i mltpp.i" )
-system( "swig -c++ -ruby -I../../src `pkg-config mlt-framework --cflags` mltpp.i" )
-$CFLAGS += " -I../../src `pkg-config mlt-framework --cflags`"
-$LDFLAGS += " -L../../src -lmlt++"
-create_makefile('mltpp')
+system( "ln -sf ../melted.i" )
+system( "swig -c++ -ruby -I../../melted++ `pkg-config mlt++ --cflags` melted.i" )
+$CFLAGS += " -I../../melted++ `pkg-config mlt++ --cflags`"
+$LDFLAGS += " -L../../melted++ -lmelted++"
+create_makefile('melted')
 system( 'make' )
diff --git a/src/swig/ruby/melted.rb b/src/swig/ruby/melted.rb
deleted file mode 100755 (executable)
index 1340a6c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'mltpp'
-
-def command 
-       puts "command"
-end
-
-def push 
-       puts "push"
-end
-
-miracle = Mltpp::Miracle.new( "miracle-ruby", 5260 )
-miracle.start
-miracle.execute( "uadd sdl" )
-listener = Mltpp::Listener.new( miracle, "command-received", method( :command ) )
-listener = Mltpp::Listener.new( miracle, "push-received", method( :push ) )
-miracle.wait_for_shutdown
-
diff --git a/src/swig/ruby/server.rb b/src/swig/ruby/server.rb
new file mode 100755 (executable)
index 0000000..f432660
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require 'mlt'
+require 'melted'
+
+def command 
+       puts "command"
+end
+
+def push 
+       puts "push"
+end
+
+melted = Melted::Melted.new( "melted-ruby", 5260 )
+melted.start
+melted.execute( "uadd sdl" )
+listener = Melted::Listener.new( melted, "command-received", method( :command ) )
+listener = Melted::Listener.new( melted, "push-received", method( :push ) )
+melted.wait_for_shutdown
index 4b2b32b..8ab09d6 100755 (executable)
@@ -4,16 +4,16 @@ path=`which tclsh 2>/dev/null`
 
 if [ "$path" != "" ]
 then
-       ln -sf ../mltpp.i .
+       ln -sf ../melted.i
 
        # Invoke swig
-       swig -c++ -I../../src `pkg-config mlt-framework --cflags` -tcl mltpp.i || exit 1
+       swig -c++ -I../../melted++ `pkg-config mlt++ --cflags` -tcl melted.i || exit 1
 
        # Compile the wrapper
-       g++ -D_GNU_SOURCE -c -rdynamic -pthread -I../../src `pkg-config mlt-framework --cflags` mltpp_wrap.cxx || exit 1
+       g++ -D_GNU_SOURCE -c -rdynamic -pthread -I../../melted++ `pkg-config mlt++ --cflags` melted_wrap.cxx || exit 1
 
        # Create the module
-       gcc -shared mltpp_wrap.o -L../../src -lmlt++ -o mltpp.so || exit 1
+       gcc -shared melted_wrap.o -L../../melted++ -lmelted++ -o melted.so || exit 1
 else
        echo "Unable to locate tclsh."
        exit 1