Expose XRecord types and bump ocs_plugin_api to 0.2.1

This commit is contained in:
Sebastian committed 2026-08-30 02:16:49 +02:00
1 parent 8825ce5274
commit c60326ad4a
4 files changed
+201 -23

No files matched your search

+5 -1
View File
@@ -23,8 +23,12 @@ use crate::ribbon::CadModule;
// so out-of-tree plugins can use them without adding their own acadrust
// dependency (which would risk an ABI-mismatching version).
pub use acadrust;
pub use acadrust::{CadDocument, EntityType, Handle};
pub use acadrust::objects::{
DictionaryCloningFlags, KnownXRecordKind, ProxyObjectReference, ProxyReferenceKind, XRecord,
XRecordEntry, XRecordSection, XRecordValue, XRecordValueType,
};
pub use acadrust::xdata::{ExtendedDataRecord, XDataValue};
pub use acadrust::{CadDocument, EntityType, Handle};
use crate::ipc::protocol::{PluginRequest, PluginResponse};
+82 -9
View File
@@ -38,10 +38,25 @@ mod tests {
#[test]
fn embedded_type_registry_contains_expected_acadrust_types() {
let registry: TypeRegistry =
serde_json::from_str(get_embedded_type_registry_json()).expect("valid TypeRegistry JSON");
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
for name in ["Point", "Line", "Circle", "MText", "EntityCommon"] {
for name in [
"Point",
"Line",
"Circle",
"MText",
"EntityCommon",
"XRecord",
"XRecordEntry",
"XRecordValue",
"XRecordValueType",
"XRecordSection",
"DictionaryCloningFlags",
"KnownXRecordKind",
"ProxyObjectReference",
"ProxyReferenceKind",
] {
assert!(
registry.types.contains_key(&TypeId::new(name)),
"registry should contain {}",
@@ -52,8 +67,8 @@ mod tests {
#[test]
fn embedded_type_registry_mtext_is_struct_with_expected_fields() {
let registry: TypeRegistry =
serde_json::from_str(get_embedded_type_registry_json()).expect("valid TypeRegistry JSON");
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
let mtext = registry
.types
@@ -79,8 +94,8 @@ mod tests {
#[test]
fn embedded_type_registry_point_is_struct_with_expected_fields() {
let registry: TypeRegistry =
serde_json::from_str(get_embedded_type_registry_json()).expect("valid TypeRegistry JSON");
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
let point = registry
.types
@@ -107,8 +122,8 @@ mod tests {
#[test]
fn embedded_type_registry_does_not_contain_entity_type() {
let registry: TypeRegistry =
serde_json::from_str(get_embedded_type_registry_json()).expect("valid TypeRegistry JSON");
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
assert!(
!registry.types.contains_key(&TypeId::new("EntityType")),
"EntityType should not be in the allow-list registry"
@@ -120,4 +135,62 @@ mod tests {
let id = TypeId::new("Point");
assert_eq!(id.as_str(), "Point");
}
#[test]
fn embedded_type_registry_xrecord_is_struct_with_expected_fields() {
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
let xrecord = registry
.types
.get(&TypeId::new("XRecord"))
.expect("XRecord in registry");
assert_eq!(xrecord.kind, TypeKind::Struct);
let field_names: Vec<&str> = xrecord.fields.iter().map(|f| f.name.as_str()).collect();
for expected in [
"handle",
"owner",
"reactors",
"xdictionary_handle",
"name",
"cloning_flags",
"entries",
"object_references",
"preserve_object_reference_stream",
"entries_complete",
"raw_data",
"raw_dwg_handle_bits",
] {
assert!(
field_names.contains(&expected),
"XRecord should have field {}",
expected
);
}
}
#[test]
fn embedded_type_registry_xrecord_value_is_enum_with_expected_variants() {
let registry: TypeRegistry = serde_json::from_str(get_embedded_type_registry_json())
.expect("valid TypeRegistry JSON");
let value = registry
.types
.get(&TypeId::new("XRecordValue"))
.expect("XRecordValue in registry");
assert_eq!(value.kind, TypeKind::Enum);
let variant_names: Vec<&str> = value.variants.iter().map(|v| v.name.as_str()).collect();
for expected in [
"String", "Double", "Int16", "Int32", "Int64", "Byte", "Bool", "Handle", "Point3D",
"Chunk",
] {
assert!(
variant_names.contains(&expected),
"XRecordValue should have variant {}",
expected
);
}
}
}