1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/c/pp_var.h"
6 #include "ppapi/shared_impl/private/ppb_char_set_shared.h"
7 #include "ppapi/thunk/thunk.h"
8 #include "ppapi/thunk/enter.h"
15 char* UTF16ToCharSetDeprecated(PP_Instance instance
,
16 const uint16_t* utf16
, uint32_t utf16_len
,
17 const char* output_char_set
,
18 PP_CharSet_ConversionError on_error
,
19 uint32_t* output_length
) {
20 // We validate the instance just to make sure we can make changes in the
21 // future and assume people pass proper instances.
22 EnterInstance
enter(instance
);
26 return PPB_CharSet_Shared::UTF16ToCharSetDeprecated(
27 utf16
, utf16_len
, output_char_set
, on_error
, output_length
);
30 PP_Bool
UTF16ToCharSet(const uint16_t utf16
[],
32 const char* output_char_set
,
33 PP_CharSet_Trusted_ConversionError on_error
,
35 uint32_t* output_length
) {
36 // This interface is a bit odd because it contains a function
37 // (GetDefaultCharSet) that must be called on the instance object and
38 // proxied, but the rest of the functions are implemented in the plugin
39 // process by just calling base functions.
41 // We could have PPB_Instance_API functions for the two charset conversion
42 // functions, and then have the instance impl and proxy call through to the
43 // shared_impl. That would be more consistent, and we may want to do that if
44 // this file is autogenerated in the future. For now, however, it's less code
45 // to just call the shared_impl code directly here.
46 return PPB_CharSet_Shared::UTF16ToCharSet(
47 utf16
, utf16_len
, output_char_set
, on_error
,
48 output_buffer
, output_length
);
51 uint16_t* CharSetToUTF16Deprecated(PP_Instance instance
,
52 const char* input
, uint32_t input_len
,
53 const char* input_char_set
,
54 PP_CharSet_ConversionError on_error
,
55 uint32_t* output_length
) {
56 // We validate the instance just to make sure we can make changes in the
57 // future and assume people pass proper instances.
58 EnterInstance
enter(instance
);
62 return PPB_CharSet_Shared::CharSetToUTF16Deprecated(
63 input
, input_len
, input_char_set
, on_error
, output_length
);
66 PP_Bool
CharSetToUTF16(const char* input
,
68 const char* input_char_set
,
69 PP_CharSet_Trusted_ConversionError on_error
,
70 uint16_t* output_buffer
,
71 uint32_t* output_utf16_length
) {
72 return PPB_CharSet_Shared::CharSetToUTF16(
73 input
, input_len
, input_char_set
, on_error
,
74 output_buffer
, output_utf16_length
);
77 PP_Var
GetDefaultCharSet(PP_Instance instance
) {
78 EnterInstance
enter(instance
);
80 return PP_MakeUndefined();
81 return enter
.functions()->GetDefaultCharSet(instance
);
84 const PPB_CharSet_Dev g_ppb_char_set_thunk
= {
85 &UTF16ToCharSetDeprecated
,
86 &CharSetToUTF16Deprecated
,
90 const PPB_CharSet_Trusted_1_0 g_ppb_char_set_trusted_thunk
= {
98 const PPB_CharSet_Dev_0_4
* GetPPB_CharSet_Dev_0_4_Thunk() {
99 return &g_ppb_char_set_thunk
;
102 const PPB_CharSet_Trusted_1_0
* GetPPB_CharSet_Trusted_1_0_Thunk() {
103 return &g_ppb_char_set_trusted_thunk
;