OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // Author: roubert@google.com (Fredrik Roubert) |
| 3 |
| 4 %include base/swig/google.swig |
| 5 %include i18n/encodings/public/encodings.swig |
| 6 %include i18n/languages/public/languages.swig |
| 7 |
| 8 %{ |
| 9 #include "i18n/encodings/compact_enc_det/compact_enc_det.h" |
| 10 %} |
| 11 |
| 12 // Support functions for unit test program. |
| 13 %ignore BackmapEncodingToRankedEncoding; |
| 14 %ignore TopEncodingOfLangHint; |
| 15 %ignore TopEncodingOfTLDHint; |
| 16 %ignore TopEncodingOfCharsetHint; |
| 17 %ignore Version; |
| 18 |
| 19 %apply int* OUTPUT { int* bytes_consumed }; |
| 20 %apply bool* OUTPUT { bool* is_reliable }; |
| 21 |
| 22 #ifdef SWIGJAVA |
| 23 |
| 24 // The input bytes must not be encoded as a String or the results will be |
| 25 // tainted. |
| 26 %typemap(in) const char* text { |
| 27 $1 = (char*) JCALL2(GetByteArrayElements, jenv, $input, 0); |
| 28 } |
| 29 |
| 30 %typemap(jni) const char* text "jbyteArray" |
| 31 %typemap(jtype) const char* text "byte[]" |
| 32 %typemap(jstype) const char* text "byte[]" |
| 33 |
| 34 %typemap(javain) const char* text "$javainput" |
| 35 %typemap(freearg) const char* text { |
| 36 JCALL3(ReleaseByteArrayElements, jenv, $input, (signed char*) $1, 0); |
| 37 } |
| 38 |
| 39 #endif |
| 40 |
| 41 %include i18n/encodings/compact_enc_det/compact_enc_det.h |
| 42 |
| 43 #ifdef SWIGGO |
| 44 // Wrapper that converts proto Enums to int for simpler Go func. |
| 45 %inline %{ |
| 46 int DetectEncodingWrap(const char* text, |
| 47 int text_length, |
| 48 const char* url_hint, |
| 49 const char* http_charset_hint, |
| 50 const char* meta_charset_hint, |
| 51 const int encoding_hint, |
| 52 int language_hint, // User interface lang |
| 53 const CompactEncDet::TextCorpusType corpus_type, |
| 54 bool ignore_7bit_mail_encodings, |
| 55 int* bytes_consumed, |
| 56 bool* is_reliable) { |
| 57 return (int)CompactEncDet::DetectEncoding( |
| 58 text, |
| 59 text_length, |
| 60 url_hint, |
| 61 http_charset_hint, |
| 62 meta_charset_hint, |
| 63 encoding_hint, |
| 64 (i18n::languages::Language) language_hint, |
| 65 corpus_type, |
| 66 ignore_7bit_mail_encodings, |
| 67 bytes_consumed, |
| 68 is_reliable); |
| 69 |
| 70 } |
| 71 %} |
| 72 #endif |
OLD | NEW |