xmp_toolkit_ruby 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +4 -0
- data/CHANGELOG.md +37 -2
- data/README.md +131 -0
- data/ext/xmp_toolkit_ruby/xmp_toolkit.cpp +117 -284
- data/ext/xmp_toolkit_ruby/xmp_toolkit.hpp +15 -26
- data/ext/xmp_toolkit_ruby/xmp_toolkit_ruby.cpp +29 -35
- data/ext/xmp_toolkit_ruby/xmp_wrapper.cpp +582 -0
- data/ext/xmp_toolkit_ruby/xmp_wrapper.hpp +35 -0
- data/lib/xmp_toolkit_ruby/namespaces.rb +1 -0
- data/lib/xmp_toolkit_ruby/version.rb +1 -1
- data/lib/xmp_toolkit_ruby/xmp_char_form.rb +45 -0
- data/lib/xmp_toolkit_ruby/xmp_file.rb +308 -0
- data/lib/xmp_toolkit_ruby/xmp_file_open_flags.rb +74 -0
- data/lib/xmp_toolkit_ruby/xmp_value.rb +16 -0
- data/lib/xmp_toolkit_ruby.rb +71 -33
- data/sig/xmp_toolkit_ruby/namespaces.rbs +119 -0
- data/sig/xmp_toolkit_ruby/xmp_char_form.rbs +17 -0
- data/sig/xmp_toolkit_ruby/xmp_file.rbs +45 -0
- data/sig/xmp_toolkit_ruby/xmp_file_format.rbs +11 -0
- data/sig/xmp_toolkit_ruby/xmp_file_handler_flags.rbs +15 -0
- data/sig/xmp_toolkit_ruby/xmp_file_open_flags.rbs +29 -0
- data/sig/xmp_toolkit_ruby/xmp_toolkit.rbs +14 -0
- data/sig/xmp_toolkit_ruby/xmp_value.rbs +19 -0
- data/sig/xmp_toolkit_ruby/xmp_wrapper.rbs +29 -0
- data/sig/xmp_toolkit_ruby.rbs +6 -1
- data/tasks/clang_format.rake +44 -0
- metadata +18 -1
@@ -2,11 +2,11 @@
|
|
2
2
|
#define XMP_TOOLKIT_HPP
|
3
3
|
|
4
4
|
#include <cstdio>
|
5
|
-
#include <vector>
|
6
|
-
#include <string>
|
7
5
|
#include <cstring>
|
6
|
+
#include <string>
|
7
|
+
#include <vector>
|
8
8
|
|
9
|
-
|
9
|
+
// #define ENABLE_XMP_CPP_INTERFACE 1
|
10
10
|
|
11
11
|
// Must be defined to instantiate template classes
|
12
12
|
#define TXMP_STRING_TYPE std::string
|
@@ -20,50 +20,39 @@
|
|
20
20
|
// Provide access to the API
|
21
21
|
#include "XMP.hpp"
|
22
22
|
|
23
|
-
#include <iostream>
|
24
23
|
#include <fstream>
|
24
|
+
#include <iostream>
|
25
25
|
|
26
26
|
#include <ruby.h>
|
27
27
|
|
28
28
|
using namespace std;
|
29
29
|
|
30
|
-
|
30
|
+
// #define ENABLE_XMP_CPP_INTERFACE 1;
|
31
31
|
|
32
32
|
// Must be defined to instantiate template classes
|
33
33
|
#define TXMP_STRING_TYPE std::string
|
34
34
|
// Must be defined to give access to XMPFiles
|
35
35
|
#define XMP_INCLUDE_XMPFILES 1
|
36
36
|
|
37
|
-
#include "XMP.incl_cpp"
|
38
37
|
#include "XMP.hpp"
|
38
|
+
#include "XMP.incl_cpp"
|
39
39
|
|
40
40
|
// TXMPMeta‐style error callback
|
41
|
-
bool xmp_meta_error_callback(
|
42
|
-
void * clientContext,
|
43
|
-
XMP_ErrorSeverity severity,
|
44
|
-
XMP_Int32 cause,
|
45
|
-
XMP_StringPtr message
|
46
|
-
);
|
41
|
+
bool xmp_meta_error_callback(void *clientContext, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message);
|
47
42
|
|
48
43
|
// TXMPFiles‐style error callback
|
49
|
-
bool xmp_file_error_callback(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
);
|
44
|
+
bool xmp_file_error_callback(void *clientContext, XMP_StringPtr filePath, XMP_ErrorSeverity severity, XMP_Int32 cause,
|
45
|
+
XMP_StringPtr message);
|
46
|
+
|
47
|
+
void ensure_sdk_initialized();
|
48
|
+
|
49
|
+
VALUE is_sdk_initialized(VALUE self);
|
56
50
|
|
57
51
|
// Initialize SXMPMeta + SXMPFiles, installing callbacks.
|
58
|
-
//
|
59
|
-
VALUE xmp_initialize(VALUE self);
|
52
|
+
// If PLUGINS_PATH is defined, it will be used to initialize the XMP Toolkit.
|
53
|
+
VALUE xmp_initialize(int argc, VALUE *argv, VALUE self);
|
60
54
|
|
61
55
|
// Terminate SXMPFiles + SXMPMeta.
|
62
56
|
VALUE xmp_terminate(VALUE self);
|
63
57
|
|
64
|
-
// process_file(filename) → Ruby Hash or nil
|
65
|
-
VALUE get_xmp_from_file(VALUE self, VALUE rb_filename);
|
66
|
-
|
67
|
-
VALUE write_xmp_to_file(int argc, VALUE* argv, VALUE self);
|
68
|
-
|
69
58
|
#endif
|
@@ -1,44 +1,38 @@
|
|
1
1
|
// xmp_init.cpp
|
2
2
|
|
3
3
|
#include "xmp_toolkit.hpp"
|
4
|
+
#include "xmp_wrapper.hpp"
|
5
|
+
|
4
6
|
#include <ruby.h>
|
5
7
|
|
6
8
|
// The one and only Init function. Ruby will look for Init_xmp_toolkit_ruby
|
7
9
|
// because we will (in extconf.rb) build this extension as “xmp_toolkit_ruby.so”.
|
8
|
-
extern "C"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
0
|
22
|
-
);
|
23
|
-
|
24
|
-
VALUE mXmpToolkitRuby = rb_define_module("XmpToolkitRuby");
|
25
|
-
VALUE mXMPToolkit = rb_define_module_under(mXmpToolkitRuby, "XmpToolkit");
|
26
|
-
|
27
|
-
rb_define_singleton_method(mXMPToolkit,
|
28
|
-
"initialize_xmp",
|
29
|
-
RUBY_METHOD_FUNC(xmp_initialize),
|
30
|
-
0);
|
31
|
-
rb_define_singleton_method(mXMPToolkit,
|
32
|
-
"terminate",
|
33
|
-
RUBY_METHOD_FUNC(xmp_terminate),
|
34
|
-
0);
|
35
|
-
rb_define_singleton_method(mXMPToolkit,
|
36
|
-
"read_xmp",
|
37
|
-
RUBY_METHOD_FUNC(get_xmp_from_file),
|
38
|
-
1);
|
39
|
-
rb_define_singleton_method(mXMPToolkit,
|
40
|
-
"write_xmp",
|
41
|
-
RUBY_METHOD_FUNC(write_xmp_to_file),
|
42
|
-
-1);
|
10
|
+
extern "C" void Init_xmp_toolkit_ruby() {
|
11
|
+
SXMPMeta::SetDefaultErrorCallback(xmp_meta_error_callback, nullptr, 0);
|
12
|
+
|
13
|
+
SXMPFiles::SetDefaultErrorCallback(xmp_file_error_callback, nullptr, 0);
|
14
|
+
|
15
|
+
VALUE mXmpToolkitRuby = rb_define_module("XmpToolkitRuby");
|
16
|
+
VALUE mXMPToolkit = rb_define_module_under(mXmpToolkitRuby, "XmpToolkit");
|
17
|
+
|
18
|
+
rb_define_singleton_method(mXMPToolkit, "initialize_xmp", RUBY_METHOD_FUNC(xmp_initialize), -1);
|
19
|
+
rb_define_singleton_method(mXMPToolkit, "terminate", RUBY_METHOD_FUNC(xmp_terminate), 0);
|
20
|
+
rb_define_singleton_method(mXMPToolkit, "initialized?", RUBY_METHOD_FUNC(is_sdk_initialized), 0);
|
21
|
+
|
22
|
+
VALUE cXMPWrapper = rb_define_class_under(mXmpToolkitRuby, "XmpWrapper", rb_cObject);
|
43
23
|
|
24
|
+
rb_define_alloc_func(cXMPWrapper, xmpwrapper_allocate);
|
25
|
+
rb_define_method(cXMPWrapper, "open", RUBY_METHOD_FUNC(xmpwrapper_open_file), -1);
|
26
|
+
rb_define_method(cXMPWrapper, "file_info", RUBY_METHOD_FUNC(xmp_file_info), 0);
|
27
|
+
rb_define_method(cXMPWrapper, "packet_info", RUBY_METHOD_FUNC(xmp_packet_info), 0);
|
28
|
+
rb_define_method(cXMPWrapper, "meta", RUBY_METHOD_FUNC(xmp_meta), 0);
|
29
|
+
rb_define_method(cXMPWrapper, "property", RUBY_METHOD_FUNC(xmpwrapper_get_property), 2);
|
30
|
+
rb_define_method(cXMPWrapper, "localized_property", RUBY_METHOD_FUNC(xmpwrapper_get_localized_text), -1);
|
31
|
+
rb_define_method(cXMPWrapper, "update_meta", RUBY_METHOD_FUNC(xmpwrapper_set_meta), -1);
|
32
|
+
rb_define_method(cXMPWrapper, "update_property", RUBY_METHOD_FUNC(xmpwrapper_set_property), 3);
|
33
|
+
rb_define_method(cXMPWrapper, "update_localized_property", RUBY_METHOD_FUNC(xmpwrapper_update_localized_text), -1);
|
34
|
+
rb_define_method(cXMPWrapper, "write", RUBY_METHOD_FUNC(write_xmp),
|
35
|
+
0); // close flushes the file until then the data is not guaranteed to be written
|
36
|
+
rb_define_method(cXMPWrapper, "close", RUBY_METHOD_FUNC(xmpwrapper_close_file), 0);
|
37
|
+
rb_define_singleton_method(cXMPWrapper, "register_namespace", RUBY_METHOD_FUNC(register_namespace), 2);
|
44
38
|
}
|