MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / __init__

Method __init__

bindings/frankenswig/struct.py:107–135  ·  view source on GitHub ↗
(self, program, name, docs='', module=None)

Source from the content-addressed store, hash-verified

105
106class StructWrapper(DeriveMixins):
107 def __init__(self, program, name, docs='', module=None):
108 self.program = program
109 if module is None:
110 self.module = program.module
111 else:
112 self.module = module
113 self.name = name
114 self.c_name = f'{self.program.module}_{sanitize_rust_name(self.name)}'
115 self.members = []
116 self.member_docs = []
117 self.methods = []
118 self.getters = []
119 self.setters = []
120 self.type = StructType(self)
121 self.constructor_ = Function(
122 self.type,
123 f'new_{self.c_name}',
124 [],
125 'set_error(SwigError::Type, "Type cannot be constructed".into());\n0 as *mut _',
126 docs=docs
127 )
128 self.docs = docs
129
130 pre, arg, post = self.type.mut_ref().wrap_c_value('this')
131 self.destructor = Function(void.type, f'delete_{self.c_name}',
132 [Var(self.type, 'this')],
133 pre + f'\nunsafe {{ Box::from_raw({arg}); }}' + post
134 )
135 self.pyextra_ = []
136
137 def constructor(self, rust_method, args, docs='', result=False):
138 method = f'{self.module}::{self.name}::{rust_method}'

Callers

nothing calls this directly

Calls 6

sanitize_rust_nameFunction · 0.85
StructTypeClass · 0.85
FunctionClass · 0.85
VarClass · 0.85
wrap_c_valueMethod · 0.45
mut_refMethod · 0.45

Tested by

no test coverage detected