Skip to content

Commit

Permalink
not working yet...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed May 13, 2024
1 parent a0318cf commit b0be586
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/utilities/core/CommonImport.i
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
#include <boost/regex.hpp>
#include <boost/variant.hpp>
#include <pugixml.hpp>

#if defined SWIGRUBY
extern "C" {
#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
#endif

rb_encoding *rb_utf8_encoding(void);
ID rb_intern3(const char *name, long len, rb_encoding *enc);
}
#endif
%}

%include <utilities/core/Deprecated.hpp>
Expand Down
7 changes: 6 additions & 1 deletion src/utilities/core/jsoncpp.i
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
#endif

#if defined SWIGRUBY

%fragment("JsonToDict","header", fragment="SWIG_FromCharPtrAndSize") {

SWIGINTERN VALUE SWIG_From_JsonValue(const Json::Value& value) {

if (value.isNull()) {
Expand Down Expand Up @@ -108,7 +110,10 @@
if (value.isObject()) {
VALUE result = rb_hash_new();
for( const auto& id : value.getMemberNames()) {
rb_hash_aset(result, ID2SYM(rb_intern(id.data())), SWIG_From_JsonValue(value[id]));
rb_hash_aset(result,
ID2SYM(rb_intern3(id.data(), id.size(), rb_utf8_encoding())),
SWIG_From_JsonValue(value[id])
);
}
return result;
}
Expand Down

0 comments on commit b0be586

Please sign in to comment.