Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: third_party/cld/encodings/compact_enc_det/compact_enc_det.swig

Issue 1956183002: CL for perf tryjob on linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/cld/encodings/compact_enc_det/compact_enc_det.swig
diff --git a/third_party/cld/encodings/compact_enc_det/compact_enc_det.swig b/third_party/cld/encodings/compact_enc_det/compact_enc_det.swig
new file mode 100644
index 0000000000000000000000000000000000000000..be75b57260ee3fe931e6930a99741edbfcdf1366
--- /dev/null
+++ b/third_party/cld/encodings/compact_enc_det/compact_enc_det.swig
@@ -0,0 +1,72 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+// Author: roubert@google.com (Fredrik Roubert)
+
+%include base/swig/google.swig
+%include i18n/encodings/public/encodings.swig
+%include i18n/languages/public/languages.swig
+
+%{
+#include "i18n/encodings/compact_enc_det/compact_enc_det.h"
+%}
+
+// Support functions for unit test program.
+%ignore BackmapEncodingToRankedEncoding;
+%ignore TopEncodingOfLangHint;
+%ignore TopEncodingOfTLDHint;
+%ignore TopEncodingOfCharsetHint;
+%ignore Version;
+
+%apply int* OUTPUT { int* bytes_consumed };
+%apply bool* OUTPUT { bool* is_reliable };
+
+#ifdef SWIGJAVA
+
+// The input bytes must not be encoded as a String or the results will be
+// tainted.
+%typemap(in) const char* text {
+ $1 = (char*) JCALL2(GetByteArrayElements, jenv, $input, 0);
+}
+
+%typemap(jni) const char* text "jbyteArray"
+%typemap(jtype) const char* text "byte[]"
+%typemap(jstype) const char* text "byte[]"
+
+%typemap(javain) const char* text "$javainput"
+%typemap(freearg) const char* text {
+ JCALL3(ReleaseByteArrayElements, jenv, $input, (signed char*) $1, 0);
+}
+
+#endif
+
+%include i18n/encodings/compact_enc_det/compact_enc_det.h
+
+#ifdef SWIGGO
+// Wrapper that converts proto Enums to int for simpler Go func.
+%inline %{
+int DetectEncodingWrap(const char* text,
+ int text_length,
+ const char* url_hint,
+ const char* http_charset_hint,
+ const char* meta_charset_hint,
+ const int encoding_hint,
+ int language_hint, // User interface lang
+ const CompactEncDet::TextCorpusType corpus_type,
+ bool ignore_7bit_mail_encodings,
+ int* bytes_consumed,
+ bool* is_reliable) {
+ return (int)CompactEncDet::DetectEncoding(
+ text,
+ text_length,
+ url_hint,
+ http_charset_hint,
+ meta_charset_hint,
+ encoding_hint,
+ (i18n::languages::Language) language_hint,
+ corpus_type,
+ ignore_7bit_mail_encodings,
+ bytes_consumed,
+ is_reliable);
+
+}
+%}
+#endif

Powered by Google App Engine
This is Rietveld 408576698