Made pointers const when possible.
Also fixed some bugs. Some QStringList were being passed as reference even though they should be passed by value.
This commit is contained in:
parent
c831f48002
commit
a63078b951
|
@ -2,7 +2,7 @@
|
|||
name = "ki18n"
|
||||
description = "A crate to use KF5I18n from rust."
|
||||
author = ["Ayush Singh <ayushdevel1325@gmail.com>"]
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
edition = "2021"
|
||||
links = "KF5I18n"
|
||||
license = "MIT"
|
||||
|
|
|
@ -46,7 +46,7 @@ impl KLocalizedContext {
|
|||
|
||||
/// Returns a pointer to the C++ object. The pointer is of the type `KLocalizedContext *` in C++.
|
||||
pub fn cpp_ptr(&self) -> *mut c_void {
|
||||
cpp!(unsafe [self as "KLocalizedContextHolder *"] -> *mut c_void as "KLocalizedContext *" {
|
||||
cpp!(unsafe [self as "const KLocalizedContextHolder *"] -> *mut c_void as "KLocalizedContext *" {
|
||||
return self->klocalized.get();
|
||||
})
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ context.set_translation_domain("Test Domain".into());
|
|||
|
||||
/// Returns the current Translation Domain.
|
||||
pub fn translation_domain(&self) -> QString {
|
||||
cpp!(unsafe [self as "KLocalizedContextHolder *"] -> QString as "QString" {
|
||||
cpp!(unsafe [self as "const KLocalizedContextHolder *"] -> QString as "QString" {
|
||||
return self->klocalized->translationDomain();
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl KLocalizedString {
|
|||
/// Set the languages for which translations will be made.
|
||||
/// This overrides the languages provided by the locale. Languages should be ordered with decreasing priority.
|
||||
/// TODO: Add Test
|
||||
pub fn set_languages(languages: &QStringList) {
|
||||
pub fn set_languages(languages: QStringList) {
|
||||
cpp!(unsafe [languages as "QStringList"] {
|
||||
KLocalizedString::setLanguages(languages);
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ impl KLocalizedString {
|
|||
/// Finalize the translation.
|
||||
/// Creates translated QString, with placeholders substituted by arguments given by KLocalizedString::subs methods.
|
||||
pub fn to_qstring(&self) -> QString {
|
||||
cpp!(unsafe [self as "KLocalizedString *"] -> QString as "QString" {
|
||||
cpp!(unsafe [self as "const KLocalizedString *"] -> QString as "QString" {
|
||||
return self->toString();
|
||||
})
|
||||
}
|
||||
|
@ -107,15 +107,15 @@ impl KLocalizedString {
|
|||
/// TODO: Add Test
|
||||
pub fn with_domain(&self, domain: &CStr) -> KLocalizedString {
|
||||
let domain_ptr = domain.as_ptr();
|
||||
cpp!(unsafe [self as "KLocalizedString *", domain_ptr as "char*"] -> KLocalizedString as "KLocalizedString" {
|
||||
cpp!(unsafe [self as "const KLocalizedString *", domain_ptr as "char*"] -> KLocalizedString as "KLocalizedString" {
|
||||
return self->withDomain(domain_ptr);
|
||||
})
|
||||
}
|
||||
|
||||
/// Indicate to look for translation only in given languages.
|
||||
/// TODO: Add Test
|
||||
pub fn with_languages(&self, languages: &QStringList) -> KLocalizedString {
|
||||
cpp!(unsafe [self as "KLocalizedString *", languages as "QStringList"] -> KLocalizedString as "KLocalizedString" {
|
||||
pub fn with_languages(&self, languages: QStringList) -> KLocalizedString {
|
||||
cpp!(unsafe [self as "const KLocalizedString *", languages as "QStringList"] -> KLocalizedString as "KLocalizedString" {
|
||||
return self->withLanguages(languages);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -74,5 +74,6 @@ pub mod klocalizedtranslator;
|
|||
// pub mod kcountry;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::klocalizedcontext::KLocalizedContext;
|
||||
pub use crate::klocalizedstring::KLocalizedString;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue