Skip to content

Instantly share code, notes, and snippets.

@tumugin
Last active September 23, 2018 01:12
Show Gist options
  • Save tumugin/a86f52b080d5c88e098035461efdbe09 to your computer and use it in GitHub Desktop.
Save tumugin/a86f52b080d5c88e098035461efdbe09 to your computer and use it in GitHub Desktop.
diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt
index 25041d25..3bcdce14 100644
--- a/taglib/CMakeLists.txt
+++ b/taglib/CMakeLists.txt
@@ -331,9 +331,12 @@ set(tag_LIB_SRCS
fileref.cpp
audioproperties.cpp
tagutils.cpp
+ swig/swigout/swig_taglib_wrap.cpp
)
-add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
+add_library(tag SHARED ${tag_LIB_SRCS} ${tag_HDRS})
+find_library(log-lib log)
+target_link_libraries(tag ${log-lib})
if(HAVE_ZLIB AND NOT HAVE_ZLIB_SOURCE)
target_link_libraries(tag ${ZLIB_LIBRARIES})
diff --git a/taglib/swig/taglib.i b/taglib/swig/taglib.i
new file mode 100644
index 00000000..6211afe2
--- /dev/null
+++ b/taglib/swig/taglib.i
@@ -0,0 +1,44 @@
+//MEMO: generate with following command
+//swig -java -c++ -package com.myskng.taglib -outdir /path/to/project/root/app/src/main/java/com/myskng/taglib -o swigout/swig_taglib_wrap.cpp taglib.i
+
+
+%module taglib
+
+%{
+#include "tag.h"
+#include "fileref.h"
+#include "tpropertymap.h"
+using namespace TagLib;
+%}
+
+#define TAGLIB_EXPORT
+#define TAGLIB_IGNORE_MISSING_DESTRUCTOR
+
+typedef const char *FileName;
+
+%typemap(jstype) String "String"
+%typemap(jni) String "jstring"
+%typemap(jtype) String "String"
+%typemap(javaout) String "{ return $jnicall; }"
+%typemap(javain) String "$javainput"
+%typemap(out) String {
+ $result = jenv->NewStringUTF($1.toCString(true));
+}
+%typemap(in) String{
+ $1 = new String(jenv->GetStringUTFChars($input, 0));
+}
+
+%typemap(jstype) String & "String"
+%typemap(jni) String & "jstring"
+%typemap(jtype) String & "String"
+%typemap(javaout) String & "{ return $jnicall; }"
+%typemap(javain) String & "$javainput"
+%typemap(out) String & {
+ $result = jenv->NewStringUTF($1.toCString(true));
+}
+%typemap(in) String& {
+ $1 = new String(jenv->GetStringUTFChars($input, 0));
+}
+
+%include "../tag.h"
+%include "../fileref.h"
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment