Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57a106f

Browse files
committed
feat: 修改flatbuffer产物编译
1 parentd602f06 commit57a106f

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

‎flatbuffers/stylesheet.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ table Object {
6666
table DeclarationTuple {
6767
property_id:uint8;
6868
value:Value;
69+
flag:uint8;
6970
}
7071

7172
table Selector {

‎package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"format:rs":"cargo fmt",
5050
"run:rs":"cargo run",
5151
"format:source":"prettier . -w",
52-
"version":"napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
52+
"version":"napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
53+
"flatbuffer":"flatc --rust -o ./src ./flatbuffers/stylesheet.fbs && flatc --cpp -o ./flatbuffers ./flatbuffers/stylesheet.fbs"
5354
},
5455
"packageManager":"pnpm@9.11.0",
5556
"repository":"https://github.com/NervJS/parse-css-to-stylesheet"

‎src/stylesheet_generated.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@ impl<'a> DeclarationTuple<'a> {
17141714
pubconstVT_PROPERTY_ID: flatbuffers::VOffsetT =4;
17151715
pubconstVT_VALUE_TYPE: flatbuffers::VOffsetT =6;
17161716
pubconstVT_VALUE: flatbuffers::VOffsetT =8;
1717+
pubconstVT_FLAG: flatbuffers::VOffsetT =10;
17171718

17181719
#[inline]
17191720
pubunsafefninit_from_table(table: flatbuffers::Table<'a>) ->Self{
@@ -1726,6 +1727,7 @@ impl<'a> DeclarationTuple<'a> {
17261727
) -> flatbuffers::WIPOffset<DeclarationTuple<'bldr>>{
17271728
letmut builder =DeclarationTupleBuilder::new(_fbb);
17281729
ifletSome(x) = args.value{ builder.add_value(x);}
1730+
builder.add_flag(args.flag);
17291731
builder.add_value_type(args.value_type);
17301732
builder.add_property_id(args.property_id);
17311733
builder.finish()
@@ -1754,6 +1756,13 @@ impl<'a> DeclarationTuple<'a> {
17541756
unsafe{self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(DeclarationTuple::VT_VALUE,None)}
17551757
}
17561758
#[inline]
1759+
pubfnflag(&self) ->u8{
1760+
// Safety:
1761+
// Created from valid Table for this object
1762+
// which contains a valid value in this slot
1763+
unsafe{self._tab.get::<u8>(DeclarationTuple::VT_FLAG,Some(0)).unwrap()}
1764+
}
1765+
#[inline]
17571766
#[allow(non_snake_case)]
17581767
pubfnvalue_as_string(&self) ->Option<String<'a>>{
17591768
ifself.value_type() ==Value::String{
@@ -1944,6 +1953,7 @@ impl flatbuffers::Verifiable for DeclarationTuple<'_> {
19441953
_ =>Ok(()),
19451954
}
19461955
})?
1956+
.visit_field::<u8>("flag",Self::VT_FLAG,false)?
19471957
.finish();
19481958
Ok(())
19491959
}
@@ -1952,6 +1962,7 @@ pub struct DeclarationTupleArgs {
19521962
pubproperty_id:u8,
19531963
pubvalue_type:Value,
19541964
pubvalue:Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1965+
pubflag:u8,
19551966
}
19561967
impl<'a>DefaultforDeclarationTupleArgs{
19571968
#[inline]
@@ -1960,6 +1971,7 @@ impl<'a> Default for DeclarationTupleArgs {
19601971
property_id:0,
19611972
value_type:Value::NONE,
19621973
value:None,
1974+
flag:0,
19631975
}
19641976
}
19651977
}
@@ -1982,6 +1994,10 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DeclarationTupleBuilder<'a, 'b,
19821994
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(DeclarationTuple::VT_VALUE, value);
19831995
}
19841996
#[inline]
1997+
pubfnadd_flag(&mutself,flag:u8){
1998+
self.fbb_.push_slot::<u8>(DeclarationTuple::VT_FLAG, flag,0);
1999+
}
2000+
#[inline]
19852001
pubfnnew(_fbb:&'bmut flatbuffers::FlatBufferBuilder<'a,A>) ->DeclarationTupleBuilder<'a,'b,A>{
19862002
let start = _fbb.start_table();
19872003
DeclarationTupleBuilder{
@@ -2084,6 +2100,7 @@ impl core::fmt::Debug for DeclarationTuple<'_> {
20842100
ds.field("value",&x)
20852101
},
20862102
};
2103+
ds.field("flag",&self.flag());
20872104
ds.finish()
20882105
}
20892106
}

‎src/utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,18 @@ pub fn convert_json_to_flatbuffer(json_str: &str) -> Result<Vec<u8>, serde_json:
527527
let property_id = decl_array[0].as_u64().unwrap()asu8;
528528

529529
let(value_type, value) =process_flatbuffer_value(&mut builder,&decl_array[1]);
530+
531+
letmut property_flag =0;
532+
// 判断下标2是否存在
533+
if decl_array.len() ==3{
534+
property_flag = decl_array[2].as_u64().unwrap()asu8;
535+
}
536+
530537
styles::DeclarationTuple::create(&mut builder,&styles::DeclarationTupleArgs{
531538
property_id: property_id,
532539
value_type: value_type,
533540
value:Some(value),
541+
flag: property_flag
534542
})
535543
}).collect();
536544
let declarations = builder.create_vector(&declarations);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp