You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2026-05-16 09:38:28 +02:00
Обновлен шаблон компоненты
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<bundle xmlns='http://v8.1c.ru/8.2/addin/bundle' name='OPIADDIN'>
|
||||
<component os='Windows' path='AddIn_x86_windows.dll' type='native' arch='i386' />
|
||||
<component os='Windows' path='AddIn_x64_windows.dll' type='native' arch='x86_64' />
|
||||
<component os='Linux' path='AddIn_x86_linux.so' type='native' arch='i386' />
|
||||
<component os='Linux' path='AddIn_x64_linux.so' type='native' arch='x86_64' />
|
||||
</bundle>
|
||||
@@ -1,2 +1,63 @@
|
||||
@echo off
|
||||
|
||||
:: Установить переменную
|
||||
set LIB_NAME=opi_addin
|
||||
set OPENSSL_DIR=C:\msys64\mingw64
|
||||
set OPENSSL_LIB_DIR=%OPENSSL_DIR%\lib
|
||||
set OPENSSL_INCLUDE_DIR=%OPENSSL_DIR%\include
|
||||
|
||||
|
||||
:: Перейти в директорию проекта
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: Создать папку для артефактов
|
||||
set OUTPUT_DIR=artifacts
|
||||
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
|
||||
|
||||
:: Сборка для x86_64-pc-windows-msvc
|
||||
cargo build --release --target x86_64-pc-windows-msvc
|
||||
cargo zigbuild --release --target x86_64-unknown-linux-gnu
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:: Сборка для x86_64-unknown-linux-gnu
|
||||
cargo zigbuild --release --target x86_64-unknown-linux-gnu
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:: Сборка для i686-pc-windows-msvc
|
||||
cargo build --release --target i686-pc-windows-msvc
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:: Сборка для i686-unknown-linux-gnu
|
||||
cargo zigbuild --release --target i686-unknown-linux-gnu
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:: Копирование файлов .dll и .so
|
||||
copy /y target\x86_64-pc-windows-msvc\release\%LIB_NAME%.dll "%OUTPUT_DIR%\AddIn_x64_windows.dll"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
copy /y target\i686-pc-windows-msvc\release\%LIB_NAME%.dll "%OUTPUT_DIR%\AddIn_x86_windows.dll"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
copy /y target\x86_64-unknown-linux-gnu\release\lib%LIB_NAME%.so "%OUTPUT_DIR%\AddIn_x64_linux.so"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
copy /y target\i686-unknown-linux-gnu\release\lib%LIB_NAME%.so "%OUTPUT_DIR%\AddIn_x86_linux.so"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
copy /y MANIFEST.XML "%OUTPUT_DIR%\MANIFEST.XML"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:: Архивация
|
||||
set ZIP_NAME=addin.zip
|
||||
powershell -Command "Compress-Archive -Path '%OUTPUT_DIR%\*' -Force -DestinationPath '%ZIP_NAME%'"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
if exist "%OUTPUT_DIR%" (
|
||||
rmdir /S /Q "%OUTPUT_DIR%"
|
||||
)
|
||||
|
||||
@echo Build and packaging completed successfully.
|
||||
exit /b 0
|
||||
|
||||
:error
|
||||
@echo An error occurred during the build or packaging process.
|
||||
exit /b 1
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
use addin1c::{Variant};
|
||||
use crate::component::AddIn;
|
||||
|
||||
pub fn send_message(obj: &AddIn, params: &[Variant]) -> String {
|
||||
|
||||
let field1 = &obj.field1;
|
||||
params[0].get_string().unwrap_or("".to_string()) + field1
|
||||
|
||||
pub fn method1() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn amount(obj: &AddIn, params: &mut [Variant]) -> i32 {
|
||||
|
||||
let result = params[0].get_i32().unwrap() + params[1].get_i32().unwrap();
|
||||
params[0].set_i32(999);
|
||||
|
||||
result
|
||||
|
||||
}
|
||||
|
||||
@@ -7,27 +7,26 @@ use crate::core::getset;
|
||||
|
||||
// Синонимы
|
||||
pub const METHODS: &[&[u16]] = &[
|
||||
name!("Метод1"), // 0
|
||||
name!("Сложение") // 1
|
||||
name!("Method1"), // 0
|
||||
|
||||
];
|
||||
|
||||
// Число параметров функций компоненты
|
||||
pub fn get_params_amount(num: usize) -> usize {
|
||||
match num {
|
||||
0 => 1,
|
||||
1 => 2,
|
||||
0 => 0,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Соответствие функций Rust функциям компоненты
|
||||
// Вызовы должны быть обернуты в Box::new
|
||||
pub fn cal_func(obj: &AddIn, num: usize, params: &mut [Variant]) -> Box<dyn crate::core::getset::ValueType> {
|
||||
pub fn cal_func(obj: &mut AddIn, num: usize, params: &mut [Variant]) -> Box<dyn getset::ValueType> {
|
||||
|
||||
match num {
|
||||
0 => Box::new(methods::send_message(&obj, ¶ms)),
|
||||
1 => Box::new(methods::amount(&obj, params)),
|
||||
_ => Box::new(false),
|
||||
|
||||
0 => Box::new(methods::method1()),
|
||||
_ => Box::new(false), // Неверный номер команды
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,36 +37,27 @@ pub fn cal_func(obj: &AddIn, num: usize, params: &mut [Variant]) -> Box<dyn crat
|
||||
|
||||
// Синонимы
|
||||
pub const PROPS: &[&[u16]] = &[
|
||||
name!("Свойство1"),
|
||||
name!("Свойство2")
|
||||
name!("Prop1")
|
||||
];
|
||||
|
||||
// Имена и типы
|
||||
|
||||
pub struct AddIn {
|
||||
field1: String,
|
||||
field2: i32
|
||||
pub prop1: String,
|
||||
}
|
||||
|
||||
// Конструктор
|
||||
impl AddIn {
|
||||
|
||||
// Значения по умолчанию
|
||||
pub fn new() -> AddIn {
|
||||
/// Создает новый объект
|
||||
pub fn new() -> Self {
|
||||
AddIn {
|
||||
field1: String::from(""),
|
||||
field2: 0
|
||||
prop1: String::new()
|
||||
}
|
||||
}
|
||||
|
||||
// Сюда просто нужно еще раз добавить имена полей
|
||||
pub fn get_field_ptr(&self, index: usize) -> *const dyn getset::ValueType {
|
||||
match index {
|
||||
0 => &self.field1 as &dyn getset::ValueType as *const _,
|
||||
1 => &self.field2 as &dyn getset::ValueType as *const _,
|
||||
0 => &self.prop1 as &dyn getset::ValueType as *const _,
|
||||
_ => panic!("Index out of bounds"),
|
||||
}
|
||||
}
|
||||
pub fn get_field_ptr_mut(&mut self, index: usize) -> *mut dyn getset::ValueType { self.get_field_ptr(index) as *mut _ }
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
@@ -18,7 +18,7 @@ impl Drop for AddIn {
|
||||
impl RawAddin for AddIn {
|
||||
|
||||
fn register_extension_as(&mut self) -> &'static [u16] {
|
||||
name!("Test")
|
||||
name!("Main")
|
||||
}
|
||||
fn get_n_props(&mut self) -> usize {
|
||||
PROPS.len()
|
||||
|
||||
@@ -31,7 +31,7 @@ pub unsafe extern "C" fn DestroyObject(component: *mut *mut c_void) -> c_long {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn GetClassNames() -> *const u16 {
|
||||
// small strings for performance
|
||||
name!("Main").as_ptr()
|
||||
name!("Client").as_ptr()
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
|
||||
Reference in New Issue
Block a user