MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / new_and_init

Function new_and_init

modules/dasUnitTest/test_handles.cpp:193–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193vec4f new_and_init ( Context & context, SimNode_CallBase * call, vec4f * ) {
194 TypeInfo * typeInfo = call->types[0];
195 if ( typeInfo->dim || typeInfo->type!=Type::tStructure ) {
196 context.throw_error_at(call->debugInfo, "invalid type");
197 return v_zero();
198 }
199 auto size = getTypeSize(typeInfo);
200 auto data = context.allocate(size, &call->debugInfo);
201 if ( typeInfo->structType && typeInfo->structType->init_mnh ) {
202 auto fn = context.fnByMangledName(typeInfo->structType->init_mnh);
203 context.callWithCopyOnReturn(fn, nullptr, data, 0);
204 } else {
205 memset(data, 0, size);
206 }
207 return cast<char *>::from(data);
208}
209int g_st = 0;
210int *getPtr() {return &g_st;}
211

Callers

nothing calls this directly

Calls 4

getTypeSizeFunction · 0.85
throw_error_atMethod · 0.80
v_zeroFunction · 0.50
allocateMethod · 0.45

Tested by

no test coverage detected