Add mostly-correct (albeit leaky) string marshaling

This commit is contained in:
Patrick Walton 2014-11-25 17:45:04 -08:00
parent 14ef53cf57
commit 1ac5bfe830
34 changed files with 175 additions and 147 deletions

View file

@ -81,7 +81,7 @@ cef_static_method_impls! {
-> c_int {
let _window_info: &cef_window_info_t = _window_info;
let client: CefClient = client;
let _url: &str = _url;
let _url: &[u16] = _url;
let _browser_settings: &cef_browser_settings_t = _browser_settings;
let _request_context: CefRequestContext = _request_context;
browser_host_create(client, false);
@ -96,7 +96,7 @@ cef_static_method_impls! {
-> *mut cef_browser_t {
let _window_info: &cef_window_info_t = _window_info;
let client: CefClient = client;
let _url: &str = _url;
let _url: &[u16] = _url;
let _browser_settings: &cef_browser_settings_t = _browser_settings;
let _request_context: CefRequestContext = _request_context;
browser_host_create(client, true)

View file

@ -195,7 +195,7 @@ impl CefApp {
// modify command-line arguments for non-browser processes as this may result
// in undefined behavior including crashes.
//
pub fn on_before_command_line_processing(&self, process_type: &str,
pub fn on_before_command_line_processing(&self, process_type: &[u16],
command_line: interfaces::CefCommandLine) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -152,7 +152,7 @@ impl CefAuthCallback {
//
// Continue the authentication request.
//
pub fn cont(&self, username: &str, password: &str) -> () {
pub fn cont(&self, username: &[u16], password: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -497,7 +497,7 @@ impl CefBrowser {
//
// Returns the frame with the specified name, or NULL if not found.
//
pub fn get_frame(&self, name: &str) -> interfaces::CefFrame {
pub fn get_frame(&self, name: &[u16]) -> interfaces::CefFrame {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1368,7 +1368,7 @@ impl CefBrowserHost {
// the UI thread.
//
pub fn run_file_dialog(&self, mode: types::cef_file_dialog_mode_t,
title: &str, default_file_name: &str, accept_types: Vec<String>,
title: &[u16], default_file_name: &[u16], accept_types: Vec<String>,
callback: interfaces::CefRunFileDialogCallback) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -1388,7 +1388,7 @@ impl CefBrowserHost {
//
// Download the file at |url| using cef_download_handler_t.
//
pub fn start_download(&self, url: &str) -> () {
pub fn start_download(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1421,7 +1421,7 @@ impl CefBrowserHost {
// be case-sensitive. |findNext| indicates whether this is the first request
// or a follow-up.
//
pub fn find(&self, identifier: libc::c_int, searchText: &str,
pub fn find(&self, identifier: libc::c_int, searchText: &[u16],
forward: libc::c_int, matchCase: libc::c_int, findNext: libc::c_int) -> (
) {
if self.c_object.is_null() {
@ -1523,7 +1523,7 @@ impl CefBrowserHost {
// If a misspelled word is currently selected in an editable node calling this
// function will replace it with the specified |word|.
//
pub fn replace_misspelling(&self, word: &str) -> () {
pub fn replace_misspelling(&self, word: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1538,7 +1538,7 @@ impl CefBrowserHost {
//
// Add the specified |word| to the spelling dictionary.
//
pub fn add_word_to_dictionary(&self, word: &str) -> () {
pub fn add_word_to_dictionary(&self, word: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1949,7 +1949,7 @@ impl CefBrowserHost {
// process thread and will not block.
//
pub fn create_browser(windowInfo: &interfaces::CefWindowInfo,
client: interfaces::CefClient, url: &str,
client: interfaces::CefClient, url: &[u16],
settings: &interfaces::CefBrowserSettings,
request_context: interfaces::CefRequestContext) -> libc::c_int {
unsafe {
@ -1969,7 +1969,7 @@ impl CefBrowserHost {
// be used. This function can only be called on the browser process UI thread.
//
pub fn create_browser_sync(windowInfo: &interfaces::CefWindowInfo,
client: interfaces::CefClient, url: &str,
client: interfaces::CefClient, url: &[u16],
settings: &interfaces::CefBrowserSettings,
request_context: interfaces::CefRequestContext) -> interfaces::CefBrowser {
unsafe {

View file

@ -350,7 +350,7 @@ impl CefCommandLine {
// Initialize the command line with the string returned by calling
// GetCommandLineW(). This function is only supported on Windows.
//
pub fn init_from_string(&self, command_line: &str) -> () {
pub fn init_from_string(&self, command_line: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -427,7 +427,7 @@ impl CefCommandLine {
//
// Set the program part of the command line string (the first item).
//
pub fn set_program(&self, program: &str) -> () {
pub fn set_program(&self, program: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -456,7 +456,7 @@ impl CefCommandLine {
//
// Returns true (1) if the command line contains the given switch.
//
pub fn has_switch(&self, name: &str) -> libc::c_int {
pub fn has_switch(&self, name: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -473,7 +473,7 @@ impl CefCommandLine {
// value or isn't present this function returns the NULL string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_switch_value(&self, name: &str) -> String {
pub fn get_switch_value(&self, name: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -505,7 +505,7 @@ impl CefCommandLine {
// Add a switch to the end of the command line. If the switch has no value
// pass an NULL value string.
//
pub fn append_switch(&self, name: &str) -> () {
pub fn append_switch(&self, name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -520,7 +520,7 @@ impl CefCommandLine {
//
// Add a switch with the specified value to the end of the command line.
//
pub fn append_switch_with_value(&self, name: &str, value: &str) -> () {
pub fn append_switch_with_value(&self, name: &[u16], value: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -565,7 +565,7 @@ impl CefCommandLine {
//
// Add an argument to the end of the command line.
//
pub fn append_argument(&self, argument: &str) -> () {
pub fn append_argument(&self, argument: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -581,7 +581,7 @@ impl CefCommandLine {
// Insert a command before the current command. Common for debuggers, like
// "valgrind" or "gdb --args".
//
pub fn prepend_wrapper(&self, wrapper: &str) -> () {
pub fn prepend_wrapper(&self, wrapper: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -251,7 +251,7 @@ impl CefCookieManager {
// ordered by longest path, then by earliest creation date. Returns false (0)
// if cookies cannot be accessed.
//
pub fn visit_url_cookies(&self, url: &str, includeHttpOnly: libc::c_int,
pub fn visit_url_cookies(&self, url: &[u16], includeHttpOnly: libc::c_int,
visitor: interfaces::CefCookieVisitor) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -274,7 +274,7 @@ impl CefCookieManager {
// setting the cookie if such characters are found. This function must be
// called on the IO thread.
//
pub fn set_cookie(&self, url: &str,
pub fn set_cookie(&self, url: &[u16],
cookie: &interfaces::CefCookie) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -297,7 +297,8 @@ impl CefCookieManager {
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
// function must be called on the IO thread.
//
pub fn delete_cookies(&self, url: &str, cookie_name: &str) -> libc::c_int {
pub fn delete_cookies(&self, url: &[u16],
cookie_name: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -319,7 +320,7 @@ impl CefCookieManager {
// browsers do not persist them. Returns false (0) if cookies cannot be
// accessed.
//
pub fn set_storage_path(&self, path: &str,
pub fn set_storage_path(&self, path: &[u16],
persist_session_cookies: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -371,7 +372,7 @@ impl CefCookieManager {
// generally intended to be transient and most Web browsers do not persist
// them. Returns NULL if creation fails.
//
pub fn create_manager(path: &str,
pub fn create_manager(path: &[u16],
persist_session_cookies: libc::c_int) -> interfaces::CefCookieManager {
unsafe {
CefWrap::to_rust(

View file

@ -328,8 +328,8 @@ impl CefDialogHandler {
// return false (0).
//
pub fn on_file_dialog(&self, browser: interfaces::CefBrowser,
mode: types::cef_file_dialog_mode_t, title: &str,
default_file_name: &str, accept_types: Vec<String>,
mode: types::cef_file_dialog_mode_t, title: &[u16],
default_file_name: &[u16], accept_types: Vec<String>,
callback: interfaces::CefFileDialogCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -185,7 +185,7 @@ impl CefDisplayHandler {
// Called when a frame's address has changed.
//
pub fn on_address_change(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, url: &str) -> () {
frame: interfaces::CefFrame, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -203,7 +203,7 @@ impl CefDisplayHandler {
// Called when the page title changes.
//
pub fn on_title_change(&self, browser: interfaces::CefBrowser,
title: &str) -> () {
title: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -243,7 +243,7 @@ impl CefDisplayHandler {
// text that will be displayed in the status message.
//
pub fn on_status_message(&self, browser: interfaces::CefBrowser,
value: &str) -> () {
value: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -261,7 +261,7 @@ impl CefDisplayHandler {
// from being output to the console.
//
pub fn on_console_message(&self, browser: interfaces::CefBrowser,
message: &str, source: &str, line: libc::c_int) -> libc::c_int {
message: &[u16], source: &[u16], line: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -460,7 +460,7 @@ impl CefDOMDocument {
//
// Returns the document element with the specified ID value.
//
pub fn get_element_by_id(&self, id: &str) -> interfaces::CefDOMNode {
pub fn get_element_by_id(&self, id: &[u16]) -> interfaces::CefDOMNode {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -606,7 +606,7 @@ impl CefDOMDocument {
// partial URL.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_complete_url(&self, partialURL: &str) -> String {
pub fn get_complete_url(&self, partialURL: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1032,7 +1032,7 @@ impl CefDOMNode {
//
// Set the value of this node. Returns true (1) on success.
//
pub fn set_value(&self, value: &str) -> libc::c_int {
pub fn set_value(&self, value: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1192,7 +1192,7 @@ impl CefDOMNode {
//
// Returns true (1) if this element has an attribute named |attrName|.
//
pub fn has_element_attribute(&self, attrName: &str) -> libc::c_int {
pub fn has_element_attribute(&self, attrName: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1208,7 +1208,7 @@ impl CefDOMNode {
// Returns the element attribute named |attrName|.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_element_attribute(&self, attrName: &str) -> String {
pub fn get_element_attribute(&self, attrName: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1239,8 +1239,8 @@ impl CefDOMNode {
// Set the value for the element attribute named |attrName|. Returns true (1)
// on success.
//
pub fn set_element_attribute(&self, attrName: &str,
value: &str) -> libc::c_int {
pub fn set_element_attribute(&self, attrName: &[u16],
value: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -151,7 +151,7 @@ impl CefBeforeDownloadCallback {
// suggested name and the default temp directory. Set |show_dialog| to true
// (1) if you do wish to show the default "Save As" dialog.
//
pub fn cont(&self, download_path: &str, show_dialog: libc::c_int) -> () {
pub fn cont(&self, download_path: &[u16], show_dialog: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -453,7 +453,7 @@ impl CefDownloadHandler {
// this function.
//
pub fn on_before_download(&self, browser: interfaces::CefBrowser,
download_item: interfaces::CefDownloadItem, suggested_name: &str,
download_item: interfaces::CefDownloadItem, suggested_name: &[u16],
callback: interfaces::CefBeforeDownloadCallback) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -496,7 +496,7 @@ impl CefDragData {
//
// Set the link URL that is being dragged.
//
pub fn set_link_url(&self, url: &str) -> () {
pub fn set_link_url(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -511,7 +511,7 @@ impl CefDragData {
//
// Set the title associated with the link being dragged.
//
pub fn set_link_title(&self, title: &str) -> () {
pub fn set_link_title(&self, title: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -526,7 +526,7 @@ impl CefDragData {
//
// Set the metadata associated with the link being dragged.
//
pub fn set_link_metadata(&self, data: &str) -> () {
pub fn set_link_metadata(&self, data: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -541,7 +541,7 @@ impl CefDragData {
//
// Set the plain text fragment that is being dragged.
//
pub fn set_fragment_text(&self, text: &str) -> () {
pub fn set_fragment_text(&self, text: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -556,7 +556,7 @@ impl CefDragData {
//
// Set the text/html fragment that is being dragged.
//
pub fn set_fragment_html(&self, html: &str) -> () {
pub fn set_fragment_html(&self, html: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -571,7 +571,7 @@ impl CefDragData {
//
// Set the base URL that the fragment came from.
//
pub fn set_fragment_base_url(&self, base_url: &str) -> () {
pub fn set_fragment_base_url(&self, base_url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -602,7 +602,7 @@ impl CefDragData {
//
// Add a file that is being dragged into the webview.
//
pub fn add_file(&self, path: &str, display_name: &str) -> () {
pub fn add_file(&self, path: &[u16], display_name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -472,7 +472,7 @@ impl CefFrame {
//
// Load the specified |url|.
//
pub fn load_url(&self, url: &str) -> () {
pub fn load_url(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -489,7 +489,7 @@ impl CefFrame {
// should have a standard scheme (for example, http scheme) or behaviors like
// link clicks and web security restrictions may not behave as expected.
//
pub fn load_string(&self, string_val: &str, url: &str) -> () {
pub fn load_string(&self, string_val: &[u16], url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -509,7 +509,7 @@ impl CefFrame {
// error. The |start_line| parameter is the base line number to use for error
// reporting.
//
pub fn execute_java_script(&self, code: &str, script_url: &str,
pub fn execute_java_script(&self, code: &[u16], script_url: &[u16],
start_line: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -312,7 +312,7 @@ impl CefGeolocationHandler {
// request immediately.
//
pub fn on_request_geolocation_permission(&self,
browser: interfaces::CefBrowser, requesting_url: &str,
browser: interfaces::CefBrowser, requesting_url: &[u16],
request_id: libc::c_int,
callback: interfaces::CefGeolocationCallback) -> libc::c_int {
if self.c_object.is_null() {
@ -335,7 +335,7 @@ impl CefGeolocationHandler {
// ID for the permission request.
//
pub fn on_cancel_geolocation_permission(&self,
browser: interfaces::CefBrowser, requesting_url: &str,
browser: interfaces::CefBrowser, requesting_url: &[u16],
request_id: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -148,7 +148,7 @@ impl CefJSDialogCallback {
// Continue the JS dialog request. Set |success| to true (1) if the OK button
// was pressed. The |user_input| value should be specified for prompt dialogs.
//
pub fn cont(&self, success: libc::c_int, user_input: &str) -> () {
pub fn cont(&self, success: libc::c_int, user_input: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -348,9 +348,9 @@ impl CefJSDialogHandler {
// the application must execute |callback| once the custom dialog is
// dismissed.
//
pub fn on_jsdialog(&self, browser: interfaces::CefBrowser, origin_url: &str,
accept_lang: &str, dialog_type: types::cef_jsdialog_type_t,
message_text: &str, default_prompt_text: &str,
pub fn on_jsdialog(&self, browser: interfaces::CefBrowser, origin_url: &[u16],
accept_lang: &[u16], dialog_type: types::cef_jsdialog_type_t,
message_text: &[u16], default_prompt_text: &[u16],
callback: interfaces::CefJSDialogCallback,
suppress_message: &mut libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
@ -380,7 +380,7 @@ impl CefJSDialogHandler {
// dialog is dismissed.
//
pub fn on_before_unload_dialog(&self, browser: interfaces::CefBrowser,
message_text: &str, is_reload: libc::c_int,
message_text: &[u16], is_reload: libc::c_int,
callback: interfaces::CefJSDialogCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -260,8 +260,8 @@ impl CefLifeSpanHandler {
// indicates whether the new browser window should be scriptable and in the
// same process as the source browser.
pub fn on_before_popup(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, target_url: &str, target_frame_name: &str,
popupFeatures: &interfaces::CefPopupFeatures,
frame: interfaces::CefFrame, target_url: &[u16],
target_frame_name: &[u16], popupFeatures: &interfaces::CefPopupFeatures,
windowInfo: &mut interfaces::CefWindowInfo,
client: interfaces::CefClient,
settings: &mut interfaces::CefBrowserSettings,

View file

@ -264,7 +264,7 @@ impl CefLoadHandler {
//
pub fn on_load_error(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, errorCode: types::cef_errorcode_t,
errorText: &str, failedUrl: &str) -> () {
errorText: &[u16], failedUrl: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -526,7 +526,8 @@ impl CefMenuModel {
//
// Add an item to the menu. Returns true (1) on success.
//
pub fn add_item(&self, command_id: libc::c_int, label: &str) -> libc::c_int {
pub fn add_item(&self, command_id: libc::c_int,
label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -543,7 +544,7 @@ impl CefMenuModel {
// Add a check item to the menu. Returns true (1) on success.
//
pub fn add_check_item(&self, command_id: libc::c_int,
label: &str) -> libc::c_int {
label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -560,7 +561,7 @@ impl CefMenuModel {
// Add a radio item to the menu. Only a single item with the specified
// |group_id| can be checked at a time. Returns true (1) on success.
//
pub fn add_radio_item(&self, command_id: libc::c_int, label: &str,
pub fn add_radio_item(&self, command_id: libc::c_int, label: &[u16],
group_id: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -579,7 +580,7 @@ impl CefMenuModel {
// Add a sub-menu to the menu. The new sub-menu is returned.
//
pub fn add_sub_menu(&self, command_id: libc::c_int,
label: &str) -> interfaces::CefMenuModel {
label: &[u16]) -> interfaces::CefMenuModel {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -613,7 +614,7 @@ impl CefMenuModel {
// success.
//
pub fn insert_item_at(&self, index: libc::c_int, command_id: libc::c_int,
label: &str) -> libc::c_int {
label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -632,7 +633,7 @@ impl CefMenuModel {
// on success.
//
pub fn insert_check_item_at(&self, index: libc::c_int,
command_id: libc::c_int, label: &str) -> libc::c_int {
command_id: libc::c_int, label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -652,7 +653,7 @@ impl CefMenuModel {
// (1) on success.
//
pub fn insert_radio_item_at(&self, index: libc::c_int,
command_id: libc::c_int, label: &str,
command_id: libc::c_int, label: &[u16],
group_id: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -673,7 +674,7 @@ impl CefMenuModel {
// returned.
//
pub fn insert_sub_menu_at(&self, index: libc::c_int, command_id: libc::c_int,
label: &str) -> interfaces::CefMenuModel {
label: &[u16]) -> interfaces::CefMenuModel {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -803,7 +804,8 @@ impl CefMenuModel {
//
// Sets the label for the specified |command_id|. Returns true (1) on success.
//
pub fn set_label(&self, command_id: libc::c_int, label: &str) -> libc::c_int {
pub fn set_label(&self, command_id: libc::c_int,
label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -819,7 +821,7 @@ impl CefMenuModel {
//
// Set the label at the specified |index|. Returns true (1) on success.
//
pub fn set_label_at(&self, index: libc::c_int, label: &str) -> libc::c_int {
pub fn set_label_at(&self, index: libc::c_int, label: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -506,7 +506,7 @@ impl CefPrintHandler {
// completed. Return true (1) if the job will proceed or false (0) to cancel
// the job immediately.
//
pub fn on_print_job(&self, document_name: &str, pdf_file_path: &str,
pub fn on_print_job(&self, document_name: &[u16], pdf_file_path: &[u16],
callback: interfaces::CefPrintJobCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -381,7 +381,7 @@ impl CefPrintSettings {
//
// Set the device name.
//
pub fn set_device_name(&self, name: &str) -> () {
pub fn set_device_name(&self, name: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -244,7 +244,7 @@ impl CefProcessMessage {
//
// Create a new cef_process_message_t object with the specified name.
//
pub fn create(name: &str) -> interfaces::CefProcessMessage {
pub fn create(name: &[u16]) -> interfaces::CefProcessMessage {
unsafe {
CefWrap::to_rust(
::process_message::cef_process_message_create(

View file

@ -277,7 +277,7 @@ impl CefRequest {
//
// Set the fully qualified URL.
//
pub fn set_url(&self, url: &str) -> () {
pub fn set_url(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -308,7 +308,7 @@ impl CefRequest {
//
// Set the request function type.
//
pub fn set_method(&self, method: &str) -> () {
pub fn set_method(&self, method: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -382,8 +382,9 @@ impl CefRequest {
//
// Set all values at one time.
//
pub fn set(&self, url: &str, method: &str, postData: interfaces::CefPostData,
headerMap: HashMap<String,Vec<String>>) -> () {
pub fn set(&self, url: &[u16], method: &[u16],
postData: interfaces::CefPostData, headerMap: HashMap<String,
Vec<String>>) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -449,7 +450,7 @@ impl CefRequest {
// Get the URL to the first party for cookies used in combination with
// cef_urlrequest_t.
//
pub fn set_first_party_for_cookies(&self, url: &str) -> () {
pub fn set_first_party_for_cookies(&self, url: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -961,7 +962,7 @@ impl CefPostDataElement {
//
// The post data element will represent a file.
//
pub fn set_to_file(&self, fileName: &str) -> () {
pub fn set_to_file(&self, fileName: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -639,7 +639,7 @@ impl CefRequestHandler {
// the new URL and can be changed if desired.
//
pub fn on_resource_redirect(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, old_url: &str,
frame: interfaces::CefFrame, old_url: &[u16],
new_url: *mut types::cef_string_t) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -663,8 +663,8 @@ impl CefRequestHandler {
// information is available. Return false (0) to cancel the request.
//
pub fn get_auth_credentials(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, isProxy: libc::c_int, host: &str,
port: libc::c_int, realm: &str, scheme: &str,
frame: interfaces::CefFrame, isProxy: libc::c_int, host: &[u16],
port: libc::c_int, realm: &[u16], scheme: &[u16],
callback: interfaces::CefAuthCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -693,7 +693,7 @@ impl CefRequestHandler {
// false (0) to cancel the request.
//
pub fn on_quota_request(&self, browser: interfaces::CefBrowser,
origin_url: &str, new_size: i64,
origin_url: &[u16], new_size: i64,
callback: interfaces::CefQuotaCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -717,7 +717,7 @@ impl CefRequestHandler {
// OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
//
pub fn on_protocol_execution(&self, browser: interfaces::CefBrowser,
url: &str, allow_os_execution: &mut libc::c_int) -> () {
url: &[u16], allow_os_execution: &mut libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -742,7 +742,7 @@ impl CefRequestHandler {
// be accepted without calling this function.
//
pub fn on_certificate_error(&self, cert_error: types::cef_errorcode_t,
request_url: &str,
request_url: &[u16],
callback: interfaces::CefAllowCertificateErrorCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -762,7 +762,7 @@ impl CefRequestHandler {
// true (1) to block loading of the plugin.
//
pub fn on_before_plugin_load(&self, browser: interfaces::CefBrowser,
url: &str, policy_url: &str,
url: &[u16], policy_url: &[u16],
info: interfaces::CefWebPluginInfo) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -783,7 +783,7 @@ impl CefRequestHandler {
// |plugin_path| is the path of the plugin that crashed.
//
pub fn on_plugin_crashed(&self, browser: interfaces::CefBrowser,
plugin_path: &str) -> () {
plugin_path: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -261,7 +261,7 @@ impl CefResponse {
//
// Set the response status text.
//
pub fn set_status_text(&self, statusText: &str) -> () {
pub fn set_status_text(&self, statusText: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -291,7 +291,7 @@ impl CefResponse {
//
// Set the response mime type.
//
pub fn set_mime_type(&self, mimeType: &str) -> () {
pub fn set_mime_type(&self, mimeType: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -307,7 +307,7 @@ impl CefResponse {
// Get the value for the specified response header field.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_header(&self, name: &str) -> String {
pub fn get_header(&self, name: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -231,7 +231,7 @@ impl CefSchemeRegistrar {
// per unique |scheme_name| value. If |scheme_name| is already registered or
// if an error occurs this function will return false (0).
//
pub fn add_custom_scheme(&self, scheme_name: &str, is_standard: libc::c_int,
pub fn add_custom_scheme(&self, scheme_name: &[u16], is_standard: libc::c_int,
is_local: libc::c_int,
is_display_isolated: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
@ -391,7 +391,7 @@ impl CefSchemeHandlerFactory {
// passed to this function will not contain cookie data.
//
pub fn create(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, scheme_name: &str,
frame: interfaces::CefFrame, scheme_name: &[u16],
request: interfaces::CefRequest) -> interfaces::CefResourceHandler {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -478,7 +478,7 @@ impl CefStreamReader {
//
// Create a new cef_stream_reader_t object from a file.
//
pub fn create_for_file(fileName: &str) -> interfaces::CefStreamReader {
pub fn create_for_file(fileName: &[u16]) -> interfaces::CefStreamReader {
unsafe {
CefWrap::to_rust(
::stream::cef_stream_reader_create_for_file(
@ -972,7 +972,7 @@ impl CefStreamWriter {
//
// Create a new cef_stream_writer_t object for a file.
//
pub fn create_for_file(fileName: &str) -> interfaces::CefStreamWriter {
pub fn create_for_file(fileName: &[u16]) -> interfaces::CefStreamWriter {
unsafe {
CefWrap::to_rust(
::stream::cef_stream_writer_create_for_file(

View file

@ -144,7 +144,7 @@ impl CefStringVisitor {
//
// Method that will be executed.
//
pub fn visit(&self, string: &str) -> () {
pub fn visit(&self, string: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -153,7 +153,7 @@ impl CefEndTracingCallback {
// the path at which tracing data was written. The client is responsible for
// deleting |tracing_file|.
//
pub fn on_end_tracing_complete(&self, tracing_file: &str) -> () {
pub fn on_end_tracing_complete(&self, tracing_file: &[u16]) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -553,8 +553,8 @@ impl CefURLRequestClient {
// function will only be called for requests initiated from the browser
// process.
//
pub fn get_auth_credentials(&self, isProxy: libc::c_int, host: &str,
port: libc::c_int, realm: &str, scheme: &str,
pub fn get_auth_credentials(&self, isProxy: libc::c_int, host: &[u16],
port: libc::c_int, realm: &[u16], scheme: &[u16],
callback: interfaces::CefAuthCallback) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")

View file

@ -344,7 +344,7 @@ impl CefV8Context {
// function will return true (1). On failure |exception| will be set to the
// exception, if any, and the function will return false (0).
//
pub fn eval(&self, code: &str, retval: interfaces::CefV8Value,
pub fn eval(&self, code: &[u16], retval: interfaces::CefV8Value,
exception: interfaces::CefV8Exception) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -533,7 +533,7 @@ impl CefV8Handler {
// function return value. If execution fails set |exception| to the exception
// that will be thrown. Return true (1) if execution was handled.
//
pub fn execute(&self, name: &str, object: interfaces::CefV8Value,
pub fn execute(&self, name: &[u16], object: interfaces::CefV8Value,
arguments_count: libc::size_t, arguments: *const interfaces::CefV8Value,
retval: interfaces::CefV8Value,
exception: *mut types::cef_string_t) -> libc::c_int {
@ -706,7 +706,7 @@ impl CefV8Accessor {
// exception that will be thrown. Return true (1) if accessor retrieval was
// handled.
//
pub fn get(&self, name: &str, object: interfaces::CefV8Value,
pub fn get(&self, name: &[u16], object: interfaces::CefV8Value,
retval: interfaces::CefV8Value,
exception: *mut types::cef_string_t) -> libc::c_int {
if self.c_object.is_null() {
@ -730,7 +730,7 @@ impl CefV8Accessor {
// exception that will be thrown. Return true (1) if accessor assignment was
// handled.
//
pub fn set(&self, name: &str, object: interfaces::CefV8Value,
pub fn set(&self, name: &[u16], object: interfaces::CefV8Value,
value: interfaces::CefV8Value,
exception: *mut types::cef_string_t) -> libc::c_int {
if self.c_object.is_null() {
@ -1874,7 +1874,7 @@ impl CefV8Value {
//
// Returns true (1) if the object has a value with the specified identifier.
//
pub fn has_value_bykey(&self, key: &str) -> libc::c_int {
pub fn has_value_bykey(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1907,7 +1907,7 @@ impl CefV8Value {
// exception is thrown. For read-only and don't-delete values this function
// will return true (1) even though deletion failed.
//
pub fn delete_value_bykey(&self, key: &str) -> libc::c_int {
pub fn delete_value_bykey(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1941,7 +1941,7 @@ impl CefV8Value {
// Returns the value with the specified identifier on success. Returns NULL if
// this function is called incorrectly or an exception is thrown.
//
pub fn get_value_bykey(&self, key: &str) -> interfaces::CefV8Value {
pub fn get_value_bykey(&self, key: &[u16]) -> interfaces::CefV8Value {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -1976,7 +1976,7 @@ impl CefV8Value {
// exception is thrown. For read-only values this function will return true
// (1) even though assignment failed.
//
pub fn set_value_bykey(&self, key: &str, value: interfaces::CefV8Value,
pub fn set_value_bykey(&self, key: &[u16], value: interfaces::CefV8Value,
attribute: types::cef_v8_propertyattribute_t) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -2018,7 +2018,7 @@ impl CefV8Value {
// function is called incorrectly or an exception is thrown. For read-only
// values this function will return true (1) even though assignment failed.
//
pub fn set_value_byaccessor(&self, key: &str,
pub fn set_value_byaccessor(&self, key: &[u16],
settings: types::cef_v8_accesscontrol_t,
attribute: types::cef_v8_propertyattribute_t) -> libc::c_int {
if self.c_object.is_null() {
@ -2304,7 +2304,7 @@ impl CefV8Value {
//
// Create a new cef_v8value_t object of type string.
//
pub fn create_string(value: &str) -> interfaces::CefV8Value {
pub fn create_string(value: &[u16]) -> interfaces::CefV8Value {
unsafe {
CefWrap::to_rust(
::v8::cef_v8value_create_string(
@ -2350,7 +2350,7 @@ impl CefV8Value {
// cef_v8handler_t or cef_v8accessor_t callback, or in combination with
// calling enter() and exit() on a stored cef_v8context_t reference.
//
pub fn create_function(name: &str,
pub fn create_function(name: &[u16],
handler: interfaces::CefV8Handler) -> interfaces::CefV8Value {
unsafe {
CefWrap::to_rust(

View file

@ -646,7 +646,7 @@ impl CefDictionaryValue {
//
// Returns true (1) if the current dictionary has a value for the given key.
//
pub fn has_key(&self, key: &str) -> libc::c_int {
pub fn has_key(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -677,7 +677,7 @@ impl CefDictionaryValue {
// Removes the value at the specified key. Returns true (1) is the value was
// removed successfully.
//
pub fn remove(&self, key: &str) -> libc::c_int {
pub fn remove(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -692,7 +692,7 @@ impl CefDictionaryValue {
//
// Returns the value type for the specified key.
//
pub fn get_type(&self, key: &str) -> interfaces::CefValueType {
pub fn get_type(&self, key: &[u16]) -> interfaces::CefValueType {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -707,7 +707,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type bool.
//
pub fn get_bool(&self, key: &str) -> libc::c_int {
pub fn get_bool(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -722,7 +722,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type int.
//
pub fn get_int(&self, key: &str) -> libc::c_int {
pub fn get_int(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -737,7 +737,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type double.
//
pub fn get_double(&self, key: &str) -> libc::c_double {
pub fn get_double(&self, key: &[u16]) -> libc::c_double {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -753,7 +753,7 @@ impl CefDictionaryValue {
// Returns the value at the specified key as type string.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_string(&self, key: &str) -> String {
pub fn get_string(&self, key: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -768,7 +768,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type binary.
//
pub fn get_binary(&self, key: &str) -> interfaces::CefBinaryValue {
pub fn get_binary(&self, key: &[u16]) -> interfaces::CefBinaryValue {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -783,7 +783,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type dictionary.
//
pub fn get_dictionary(&self, key: &str) -> interfaces::CefDictionaryValue {
pub fn get_dictionary(&self, key: &[u16]) -> interfaces::CefDictionaryValue {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -798,7 +798,7 @@ impl CefDictionaryValue {
//
// Returns the value at the specified key as type list.
//
pub fn get_list(&self, key: &str) -> interfaces::CefListValue {
pub fn get_list(&self, key: &[u16]) -> interfaces::CefListValue {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -814,7 +814,7 @@ impl CefDictionaryValue {
// Sets the value at the specified key as type null. Returns true (1) if the
// value was set successfully.
//
pub fn set_null(&self, key: &str) -> libc::c_int {
pub fn set_null(&self, key: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -830,7 +830,7 @@ impl CefDictionaryValue {
// Sets the value at the specified key as type bool. Returns true (1) if the
// value was set successfully.
//
pub fn set_bool(&self, key: &str, value: libc::c_int) -> libc::c_int {
pub fn set_bool(&self, key: &[u16], value: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -847,7 +847,7 @@ impl CefDictionaryValue {
// Sets the value at the specified key as type int. Returns true (1) if the
// value was set successfully.
//
pub fn set_int(&self, key: &str, value: libc::c_int) -> libc::c_int {
pub fn set_int(&self, key: &[u16], value: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -864,7 +864,7 @@ impl CefDictionaryValue {
// Sets the value at the specified key as type double. Returns true (1) if the
// value was set successfully.
//
pub fn set_double(&self, key: &str, value: libc::c_double) -> libc::c_int {
pub fn set_double(&self, key: &[u16], value: libc::c_double) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -881,7 +881,7 @@ impl CefDictionaryValue {
// Sets the value at the specified key as type string. Returns true (1) if the
// value was set successfully.
//
pub fn set_string(&self, key: &str, value: &str) -> libc::c_int {
pub fn set_string(&self, key: &[u16], value: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -901,7 +901,7 @@ impl CefDictionaryValue {
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
//
pub fn set_binary(&self, key: &str,
pub fn set_binary(&self, key: &[u16],
value: interfaces::CefBinaryValue) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -923,7 +923,7 @@ impl CefDictionaryValue {
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
//
pub fn set_dictionary(&self, key: &str,
pub fn set_dictionary(&self, key: &[u16],
value: interfaces::CefDictionaryValue) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -945,7 +945,7 @@ impl CefDictionaryValue {
// Otherwise, ownership will be transferred to this object and the |value|
// reference will be invalidated.
//
pub fn set_list(&self, key: &str,
pub fn set_list(&self, key: &[u16],
value: interfaces::CefListValue) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -1568,7 +1568,7 @@ impl CefListValue {
// Sets the value at the specified index as type string. Returns true (1) if
// the value was set successfully.
//
pub fn set_string(&self, index: libc::c_int, value: &str) -> libc::c_int {
pub fn set_string(&self, index: libc::c_int, value: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -504,7 +504,7 @@ impl CefWebPluginUnstableCallback {
// true (1) if the plugin has reached the crash count threshold of 3 times in
// 120 seconds.
//
pub fn is_unstable(&self, path: &str, unstable: libc::c_int) -> () {
pub fn is_unstable(&self, path: &[u16], unstable: libc::c_int) -> () {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -636,7 +636,7 @@ impl CefXmlReader {
// Returns the value of the attribute with the specified qualified name.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_attribute_byqname(&self, qualifiedName: &str) -> String {
pub fn get_attribute_byqname(&self, qualifiedName: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -653,8 +653,8 @@ impl CefXmlReader {
// namespace URI.
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_attribute_bylname(&self, localName: &str,
namespaceURI: &str) -> String {
pub fn get_attribute_bylname(&self, localName: &[u16],
namespaceURI: &[u16]) -> String {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -737,7 +737,8 @@ impl CefXmlReader {
// Moves the cursor to the attribute with the specified qualified name.
// Returns true (1) if the cursor position was set successfully.
//
pub fn move_to_attribute_byqname(&self, qualifiedName: &str) -> libc::c_int {
pub fn move_to_attribute_byqname(&self,
qualifiedName: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -754,8 +755,8 @@ impl CefXmlReader {
// namespace URI. Returns true (1) if the cursor position was set
// successfully.
//
pub fn move_to_attribute_bylname(&self, localName: &str,
namespaceURI: &str) -> libc::c_int {
pub fn move_to_attribute_bylname(&self, localName: &[u16],
namespaceURI: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}
@ -819,7 +820,7 @@ impl CefXmlReader {
//
pub fn create(stream: interfaces::CefStreamReader,
encodingType: types::cef_xml_encoding_type_t,
URI: &str) -> interfaces::CefXmlReader {
URI: &[u16]) -> interfaces::CefXmlReader {
unsafe {
CefWrap::to_rust(
::xml_reader::cef_xml_reader_create(

View file

@ -254,7 +254,7 @@ impl CefZipReader {
// is true (1) then the search will be case sensitive. Returns true (1) if the
// cursor position was set successfully.
//
pub fn move_to_file(&self, fileName: &str,
pub fn move_to_file(&self, fileName: &[u16],
caseSensitive: libc::c_int) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
@ -333,7 +333,7 @@ impl CefZipReader {
// Opens the file for reading of uncompressed data. A read password may
// optionally be specified.
//
pub fn open_file(&self, password: &str) -> libc::c_int {
pub fn open_file(&self, password: &[u16]) -> libc::c_int {
if self.c_object.is_null() {
panic!("called a CEF method on a null object")
}

View file

@ -30,9 +30,10 @@ use types::{cef_time_t, cef_transition_type_t, cef_urlrequest_status_t};
use types::{cef_v8_accesscontrol_t, cef_v8_propertyattribute_t, cef_value_type_t};
use types::{cef_window_info_t, cef_xml_encoding_type_t, cef_xml_node_type_t};
use libc::{c_char, c_int, c_void};
use libc::{mod, c_char, c_int, c_ushort, c_void};
use std::collections::HashMap;
use std::mem;
use std::ptr;
pub trait CefWrap<CObject> {
fn to_c(rust_object: Self) -> CObject;
@ -177,20 +178,42 @@ cef_unimplemented_wrapper!(cef_string_map_t, HashMap<String,String>)
cef_unimplemented_wrapper!(cef_string_multimap_t, HashMap<String,Vec<String>>)
cef_unimplemented_wrapper!(cef_string_t, String)
impl<'a> CefWrap<*const cef_string_t> for &'a str {
fn to_c(_: &'a str) -> *const cef_string_t {
panic!("unimplemented CEF type conversion: &'a str")
impl<'a> CefWrap<*const cef_string_t> for &'a [u16] {
fn to_c(buffer: &'a [u16]) -> *const cef_string_t {
unsafe {
let ptr: *mut c_ushort = mem::transmute(libc::malloc(((buffer.len() * 2) + 1) as u64));
ptr::copy_memory(ptr, mem::transmute(buffer.as_ptr()), (buffer.len() * 2) as uint);
*ptr.offset(buffer.len() as int) = 0;
// FIXME(pcwalton): This leaks!! We should instead have the caller pass some scratch
// stack space to create the object in. What a botch.
let boxed_string = box cef_string_utf16 {
str: ptr,
length: buffer.len() as u64,
dtor: Some(free_boxed_utf16_string),
};
let result: *const cef_string_utf16 = &*boxed_string;
mem::forget(boxed_string);
result
}
}
unsafe fn to_rust(_: *const cef_string_t) -> &'a str {
panic!("unimplemented CEF type conversion: *const cef_string_t")
unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] {
let (ptr, len): (*mut c_ushort, uint) = ((*cef_string).str, (*cef_string).length as uint);
mem::transmute((ptr, len))
}
}
impl<'a> CefWrap<*mut cef_string_t> for &'a mut str {
fn to_c(_: &'a mut str) -> *mut cef_string_t {
extern "C" fn free_boxed_utf16_string(string: *mut c_ushort) {
unsafe {
libc::free(string as *mut c_void)
}
}
impl<'a> CefWrap<*mut cef_string_t> for &'a mut [u16] {
fn to_c(_: &'a mut [u16]) -> *mut cef_string_t {
panic!("unimplemented CEF type conversion: &'a str")
}
unsafe fn to_rust(_: *mut cef_string_t) -> &'a mut str {
unsafe fn to_rust(_: *mut cef_string_t) -> &'a mut [u16] {
mem::transmute::<(int,int),_>(panic!("unimplemented CEF type conversion: *mut \
cef_string_t"))
}