File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,6 +171,15 @@ fn generate(config: &Config) -> Result<(), Box<dyn Error>> {
171171 ) ?;
172172 writeln ! ( file, " }}" ) ?;
173173 }
174+ "rbs_keyword" => {
175+ writeln ! ( file, " pub fn {}(&self) -> RBSKeyword {{" , field. name) ?;
176+ writeln ! (
177+ file,
178+ " RBSKeyword::new(self.parser, unsafe {{ (*self.pointer).{} }})" ,
179+ field. name
180+ ) ?;
181+ writeln ! ( file, " }}" ) ?;
182+ }
174183 _ => eprintln ! ( "Unknown field type: {}" , field. c_type) ,
175184 }
176185 }
Original file line number Diff line number Diff line change @@ -183,6 +183,32 @@ impl RBSSymbol {
183183 }
184184}
185185
186+ pub struct RBSKeyword {
187+ parser : * mut rbs_parser_t ,
188+ pointer : * const rbs_keyword ,
189+ }
190+
191+ impl RBSKeyword {
192+ pub fn new ( parser : * mut rbs_parser_t , pointer : * const rbs_keyword ) -> Self {
193+ Self { parser, pointer }
194+ }
195+
196+ pub fn name ( & self ) -> & [ u8 ] {
197+ unsafe {
198+ let constant_ptr = rbs_constant_pool_id_to_constant (
199+ & ( * self . parser ) . constant_pool ,
200+ ( * self . pointer ) . constant_id ,
201+ ) ;
202+ if constant_ptr. is_null ( ) {
203+ panic ! ( "Constant ID for keyword is not present in the pool" ) ;
204+ }
205+
206+ let constant = & * constant_ptr;
207+ std:: slice:: from_raw_parts ( constant. start , constant. length )
208+ }
209+ }
210+ }
211+
186212#[ cfg( test) ]
187213mod tests {
188214 use super :: * ;
You can’t perform that action at this time.
0 commit comments