Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The property does not work #4

Closed
Toveal opened this issue Aug 31, 2023 · 5 comments
Closed

The property does not work #4

Toveal opened this issue Aug 31, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@Toveal
Copy link

Toveal commented Aug 31, 2023

Hello. I added a property to the example from the repository. The function works, the property does not

use native_api_1c::{native_api_1c_core::ffi::connection::Connection, native_api_1c_macro::AddIn};
use std::{
    fs::{metadata, File},
    io::Read,
    sync::Arc,
};

#[derive(AddIn)]
pub struct ByteReader {
    #[add_in_con] // соединение с 1С для вызова внешних событий
    connection: Arc<Option<&'static Connection>>, // Arc для возможности многопоточности

    #[add_in_func(name = "ReadBytes", name_ru = "ПрочитатьБайты")]
    #[arg(Str)]
    #[returns(Blob, result)]
    read_bytes: fn(&Self, String) -> Result<Vec<u8>, Box<dyn std::error::Error>>,

    #[add_in_prop(name = "TestProp", name_ru = "ТестПроп", readable, writable)]
    pub my_prop: i32,
}

impl ByteReader {
    pub fn new() -> Self {
        Self {
            connection: Arc::new(None),
            read_bytes: Self::read_bytes,
            my_prop: 230,
        }
    }

    pub fn read_bytes(&self, path: String) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
        let mut f = File::open(&path)?;
        let metadata = metadata(&path)?;
        let mut buffer = vec![0; metadata.len() as usize];
        f.read(&mut buffer)?;
        Ok(buffer)
    }
}

1C does not see the property and does not want to overwrite it
Cleared the cache. Moved the processing to the configuration. Tried different platforms. Tried it on other PCs

@Sebekerga
Copy link
Owner

Sebekerga commented Sep 1, 2023

Hey!

  1. What version of crate do you use?
  2. Can you share part of your 1С code, that works with property?
  3. Can you try both Russian and English names of property?

Sebekerga added a commit that referenced this issue Sep 1, 2023
@Sebekerga
Copy link
Owner

Sebekerga commented Sep 1, 2023

Alright, I checked and there was a bug, where name_ru option get's ignore, fixed it in main branch. You can get this fix if you change your dependency in Cargo.toml to this:

[dependencies]
#...
native_api_1c = { git = "https://github.com/Sebekerga/native_api_1c" }

And then run cargo update.

I'll push it as v0.10.4 to crates.io later too.

@Sebekerga Sebekerga added the bug Something isn't working label Sep 1, 2023
@Toveal
Copy link
Author

Toveal commented Sep 1, 2023

Hey!

  1. What version of crate do you use?
  2. Can you share part of your 1С code, that works with property?
  3. Can you try both Russian and English names of property?
  1. 0.10.3
	InstallAddIn("CommonTemplate.ByteReader");
	
	If Not AttachAddIn("CommonTemplate.ByteReader", "MyAddin", AddInType.Native) Then
		Raise("Error");
		Return;       
	EndIf;
	
 	ObjectAddin = New("Addin.MyAddin.ByteReader"); 
	Bytes = ObjectAddin.ReadBytes("E:\.gitignore");
	
	PropValueRu = ObjectAddin.ТестПроп;
	ObjectAddin.ТестПроп = 304;
	
	PropValueEn = ObjectAddin.TestProp;
	ObjectAddin.TestProp = 505;
  1. Yeah, I've tried both Russian names and English names.

@Toveal Toveal closed this as completed Sep 1, 2023
@Sebekerga
Copy link
Owner

Nice! Thanks for detailed reportings :)

@Sebekerga
Copy link
Owner

@Toveal you can use 0.10.5 now instead of git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants