mediainfo-native 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0f56b4c58101337bd45b648203546d54f092327
4
- data.tar.gz: b81cf0c184cffefc4c1a1d63054a7d153c36f7e3
3
+ metadata.gz: 96cbdd0092637b32864710d15fac06c55bbc6500
4
+ data.tar.gz: fc283a05212d70048b0e69bfa3829d5b86d2f5fa
5
5
  SHA512:
6
- metadata.gz: f8c714cabd82f191654d64a501af61c53b8814a725e35109ea219ca343d3142fb8179715ff689f5ccbcfc01382292a2c2d45291c8f0505ab3128c5944bc3c366
7
- data.tar.gz: 88879bd09a869d7a9c0cbb20dcbdd8386c016d97fbfc7b45f7fd4f34f03625ce0ce62c78dd20d40a71733af3738693f072d76a1bc6677251cff7246d8d6022f7
6
+ metadata.gz: cc8efacc08144c5b3d6ddb97342c83d6ce0e9e9db04620ade5701ffd539abf54baf5c23800c648a1e448e1cee7fa89f3a09672c4fd4325a3c2091c3aa2c45f31
7
+ data.tar.gz: 285c144f1f61558a7ef0a705e89e01b2cfd198515700908f05c385b2aefc66bdea6660d45f3e8a53b448a9a9a8eb15718ef768a0223672ee0b180dcf71ead822
@@ -16,8 +16,8 @@
16
16
  #define MediaInfoDLLH
17
17
 
18
18
 
19
- #undef UNICODE
20
- #undef _UNICODE
19
+ #define UNICODE
20
+ #define _UNICODE
21
21
 
22
22
  //***************************************************************************
23
23
  // Platforms (from libzen)
@@ -68,7 +68,7 @@ extern "C"
68
68
  Check_Type(path, T_STRING);
69
69
  GET_WRAPPER(miw);
70
70
 
71
- OpenParams params = { miw, value_to_ansi_string(path), 0 };
71
+ OpenParams params = { miw, value_to_mediainfo_string(path), 0 };
72
72
  rb_thread_call_without_gvl(miw_open_without_gvl, (void*) &params, NULL, NULL);
73
73
 
74
74
  switch(params.result) {
@@ -103,7 +103,7 @@ extern "C"
103
103
  Check_Type(path, T_STRING);
104
104
  GET_WRAPPER(miw);
105
105
 
106
- miw->open(value_to_ansi_string(path));
106
+ miw->open(value_to_mediainfo_string(path));
107
107
  VALUE inform = miw->inform();
108
108
  miw->close();
109
109
 
@@ -169,9 +169,9 @@ MediaInfoWrapper::MediaInfoWrapper(bool ignore_continuous_file_names)
169
169
  : file_opened(false)
170
170
  {
171
171
  mi = new MediaInfoDLL::MediaInfo();
172
- mi->Option("Inform", "XML");
173
- mi->Option("Complete", "1");
174
- mi->Option("File_TestContinuousFileNames", ignore_continuous_file_names ? "0" : "1");
172
+ mi->Option(L"Inform", L"XML");
173
+ mi->Option(L"Complete", L"1");
174
+ mi->Option(L"File_TestContinuousFileNames", ignore_continuous_file_names ? L"0" : L"1");
175
175
  }
176
176
 
177
177
  MediaInfoWrapper::~MediaInfoWrapper()
@@ -183,7 +183,7 @@ MediaInfoWrapper::~MediaInfoWrapper()
183
183
  delete mi;
184
184
  }
185
185
 
186
- int MediaInfoWrapper::open(std::string path)
186
+ int MediaInfoWrapper::open(MediaInfoDLL::String path)
187
187
  {
188
188
  if(file_opened)
189
189
  return 1;
@@ -225,20 +225,20 @@ VALUE MediaInfoWrapper::wrapStreams()
225
225
 
226
226
  VALUE MediaInfoWrapper::get(StreamType type, unsigned int idx, VALUE key) const
227
227
  {
228
- MediaInfoDLL::String mi_key(value_to_ansi_string(key));
229
- return ansi_string_to_value(mi->Get(convertToMediaInfoStreamType(type), idx, mi_key));
228
+ MediaInfoDLL::String mi_key(value_to_mediainfo_string(key));
229
+ return mediainfo_string_to_value(mi->Get(convertToMediaInfoStreamType(type), idx, mi_key));
230
230
  }
231
231
 
232
232
  VALUE MediaInfoWrapper::inform() const
233
233
  {
234
234
  CHECK_OPEN;
235
235
 
236
- return ansi_string_to_value(mi->Inform());
236
+ return mediainfo_string_to_value(mi->Inform());
237
237
  }
238
238
 
239
239
  VALUE MediaInfoWrapper::option() const
240
240
  {
241
- return ansi_string_to_value(mi->Option("Info_Parameters"));
241
+ return mediainfo_string_to_value(mi->Option(L"Info_Parameters"));
242
242
  }
243
243
 
244
244
  } /* namespace MediaInfoNative */
@@ -1,19 +1,36 @@
1
1
  #include <ruby.h>
2
- #include <ruby/encoding.h>
2
+ #include <cstdlib>
3
3
  #include "unicode.h"
4
4
 
5
- MediaInfoDLL::String value_to_ansi_string(VALUE s)
5
+ MediaInfoDLL::String value_to_mediainfo_string(VALUE s)
6
6
  {
7
- rb_encoding* enc = rb_enc_find("ANSI");
8
- VALUE exported = rb_str_export_to_enc(s, enc);
9
- return MediaInfoDLL::String(StringValueCStr(exported));
7
+ size_t nchars = RSTRING_LEN(s);
8
+ wchar_t buf[nchars + 1];
9
+
10
+ nchars = mbstowcs(buf, StringValueCStr(s), nchars);
11
+
12
+ if((size_t) (-1) == nchars)
13
+ rb_raise(rb_eArgError, "invalid multi-byte sequence in char array");
14
+ else
15
+ // According to mbstowcs(3), this is not nul-terminated when max characters
16
+ // have been written.
17
+ buf[nchars] = L'\0';
18
+
19
+ return MediaInfoDLL::String(buf);
10
20
  }
11
21
 
12
- VALUE ansi_string_to_value(MediaInfoDLL::String s)
22
+ VALUE mediainfo_string_to_value(MediaInfoDLL::String s)
13
23
  {
14
- #ifdef RBX_RUBY_VERSION
15
- return rb_external_str_new_with_enc(s.c_str(), s.length(), rb_enc_find("ANSI"));
16
- #else
17
- return rb_external_str_new_with_enc(s.c_str(), s.length(), rb_ascii8bit_encoding());
18
- #endif
24
+ size_t nbytes = s.length() * 2;
25
+ char buf[nbytes + 1];
26
+
27
+ nbytes = wcstombs(buf, s.data(), nbytes);
28
+
29
+ if((size_t) (-1) == nbytes)
30
+ rb_raise(rb_eArgError, "wide-char sequence not representable in char array");
31
+ else
32
+ // This should actually always be there, just to make sure.
33
+ buf[nbytes] = '\0';
34
+
35
+ return rb_locale_str_new_cstr(buf);
19
36
  }
@@ -4,7 +4,7 @@
4
4
  #include <ruby.h>
5
5
  #include "MediaInfoDLL.h"
6
6
 
7
- MediaInfoDLL::String value_to_ansi_string(VALUE s);
8
- VALUE ansi_string_to_value(MediaInfoDLL::String s);
7
+ MediaInfoDLL::String value_to_mediainfo_string(VALUE s);
8
+ VALUE mediainfo_string_to_value(MediaInfoDLL::String s);
9
9
 
10
10
  #endif /* MEDIAINFO_NATIVE_UNICODE_H */
@@ -1,3 +1,3 @@
1
1
  module MediaInfoNative
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediainfo-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlavourSys Technology GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -91,3 +91,4 @@ signing_key:
91
91
  specification_version: 4
92
92
  summary: Native bindings for mediainfo
93
93
  test_files: []
94
+ has_rdoc: