MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / data_decl

Function data_decl

src/py_class/py_class_impl.py:356–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354 write('\n}};\n')
355
356def data_decl():
357 generate_case('data $data_name:ident : $data_type:ty;',
358 new_info = '''
359 /* info: */ {
360 $base_type,
361 /* size: */ $crate::py_class::data_new_size::<$data_type>($size),
362 $class_visibility,
363 $gc,
364 /* data: */ [
365 $($data)*
366 {
367 $crate::py_class::data_offset::<$data_type>($size),
368 $data_name,
369 $data_type,
370 /* init_expr: */ $data_name,
371 /* init_ty: */ $data_type
372 }
373 ]
374 }
375 ''&#x27;,
376 new_impl=''&#x27;
377 impl $class {
378 fn $data_name<'a>(&'a self, py: $crate::Python<'a>) -> &'a $data_type {
379 unsafe {
380 $crate::py_class::data_get::<$data_type>(
381 py,
382 &self._unsafe_inner,
383 $crate::py_class::data_offset::<$data_type>($size)
384 )
385 }
386 }
387 }
388 ''&#x27;)
389
390def shared_data_decl():
391 # the storage type is PySharedRefCell<$data_type>, but unlike plain "data",

Callers 1

mainFunction · 0.85

Calls 1

generate_caseFunction · 0.85

Tested by

no test coverage detected