You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-08-10 22:41:43 +02:00
Поднятие версии addin1c
This commit is contained in:
4
src/addins/tmpl/Cargo.lock
generated
4
src/addins/tmpl/Cargo.lock
generated
@@ -4,9 +4,9 @@ version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addin1c"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ce4a2faf46b8c80fc9f6a9a280bef80b7968d6b5d4324b563e6b8b4717031c3"
|
||||
checksum = "58f985421a06951cfab1529e5bf26203b42fba9d792de9adc99486fbf3214dc3"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"utf16_lit",
|
||||
|
@@ -13,4 +13,4 @@ panic = "abort" # Abort on panic
|
||||
strip = true # Automatically strip symbols from the binary.
|
||||
|
||||
[dependencies]
|
||||
addin1c = "0.1"
|
||||
addin1c = "0.2.0"
|
@@ -13,4 +13,8 @@ pub fn send_message(obj: &AddIn, params: &[Variant]) -> String {
|
||||
"Param error".to_string()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pub fn amount(obj: &AddIn, params: &[Variant]) -> i32 {
|
||||
params[0].get_i32().unwrap() + params[1].get_i32().unwrap()
|
||||
}
|
||||
|
@@ -8,13 +8,15 @@ use crate::core::getset;
|
||||
|
||||
// Синонимы
|
||||
pub const METHODS: &[&[u16]] = &[
|
||||
name!("Метод1") // 0
|
||||
name!("Метод1"), // 0
|
||||
name!("Сложение") // 1
|
||||
];
|
||||
|
||||
// Число параметров функций компоненты
|
||||
pub fn get_params_amount(num: usize) -> usize {
|
||||
match num {
|
||||
0 => 1,
|
||||
1 => 2,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
@@ -25,6 +27,7 @@ pub fn cal_func(obj: &AddIn, num: usize, params: &mut [Variant]) -> Box<dyn crat
|
||||
|
||||
match num {
|
||||
0 => Box::new(methods::send_message(&obj, ¶ms)),
|
||||
1 => Box::new(methods::amount(&obj, ¶ms)),
|
||||
_ => Box::new(false),
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ use addin1c::{Variant, ParamValue, Tm};
|
||||
|
||||
pub trait ValueType {
|
||||
fn get_value(&self, val: &mut Variant) -> bool;
|
||||
fn set_value(&mut self, val: &ParamValue);
|
||||
fn set_value(&mut self, val: &Variant);
|
||||
}
|
||||
|
||||
impl ValueType for i32 {
|
||||
@@ -13,10 +13,8 @@ impl ValueType for i32 {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::I32(x) = val {
|
||||
*self = *x;
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_i32().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +25,8 @@ impl ValueType for f64 {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::F64(x) = val {
|
||||
*self = *x;
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_f64().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +37,8 @@ impl ValueType for bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::Bool(x) = val {
|
||||
*self = *x;
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_bool().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +49,8 @@ impl ValueType for Tm {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::Date(x) = val {
|
||||
*self = *x;
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_date().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,26 +58,21 @@ impl ValueType for Tm {
|
||||
impl ValueType for String {
|
||||
fn get_value(&self, val: &mut Variant) -> bool {
|
||||
let s: Vec<u16> = self.encode_utf16().collect();
|
||||
val.set_str(s.as_slice())
|
||||
val.set_str1c(s.as_slice()).is_ok()
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::Str(x) = val {
|
||||
*self = String::from_utf16(*x).unwrap();
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_string().unwrap_or("".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// Реализация для Vec<u8>
|
||||
impl ValueType for Vec<u8> {
|
||||
fn get_value(&self, val: &mut Variant) -> bool {
|
||||
val.set_blob(self.as_slice())
|
||||
val.set_blob(self.as_slice()).is_ok()
|
||||
}
|
||||
|
||||
fn set_value(&mut self, val: &ParamValue) {
|
||||
if let ParamValue::Blob(x) = val {
|
||||
self.clear();
|
||||
self.extend_from_slice(x);
|
||||
}
|
||||
fn set_value(&mut self, val: &Variant) {
|
||||
*self = val.get_blob().unwrap().to_vec()
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ impl RawAddin for AddIn {
|
||||
}
|
||||
fn get_prop_name(&mut self, num: usize, _alias: usize) -> Option<&'static [u16]> { PROPS.get(num).copied() }
|
||||
fn get_prop_val(&mut self, num: usize, val: &mut Variant) -> bool {let field: &dyn getset::ValueType = &self[num]; field.get_value(val) }
|
||||
fn set_prop_val(&mut self, num: usize, val: &ParamValue) -> bool {let field: &mut dyn getset::ValueType = &mut self[num]; field.set_value(&val); true }
|
||||
fn set_prop_val(&mut self, num: usize, val: &Variant) -> bool {let field: &mut dyn getset::ValueType = &mut self[num]; field.set_value(val); true }
|
||||
fn is_prop_readable(&mut self, _num: usize) -> bool { true }
|
||||
fn is_prop_writable(&mut self, num: usize) -> bool { true }
|
||||
fn get_n_methods(&mut self) -> usize { METHODS.len() }
|
||||
|
Reference in New Issue
Block a user