Rval ExpandPrivateRval(EvalContext *ctx, const char *ns, const char *scope, const void *rval_item, RvalType rval_type) { Rval returnval; returnval.item = NULL; returnval.type = RVAL_TYPE_NOPROMISEE; switch (rval_type) { case RVAL_TYPE_SCALAR: returnval.item = ExpandScalar(ctx, ns, scope, rval_item, NULL); returnval.type = RVAL_TYPE_SCALAR; break; case RVAL_TYPE_LIST: returnval.item = ExpandList(ctx, ns, scope, rval_item, true); returnval.type = RVAL_TYPE_LIST; break; case RVAL_TYPE_FNCALL: returnval.item = ExpandFnCall(ctx, ns, scope, rval_item); returnval.type = RVAL_TYPE_FNCALL; break; case RVAL_TYPE_CONTAINER: returnval = RvalNew(rval_item, RVAL_TYPE_CONTAINER); break; case RVAL_TYPE_NOPROMISEE: break; } return returnval; }
Rval ExpandBundleReference(EvalContext *ctx, const char *ns, const char *scope, Rval rval) { // Allocates new memory for the copy switch (rval.type) { case RVAL_TYPE_SCALAR: return (Rval) { ExpandScalar(ctx, ns, scope, RvalScalarValue(rval), NULL), RVAL_TYPE_SCALAR }; case RVAL_TYPE_FNCALL: return (Rval) { ExpandFnCall(ctx, ns, scope, RvalFnCallValue(rval)), RVAL_TYPE_FNCALL }; case RVAL_TYPE_CONTAINER: case RVAL_TYPE_LIST: case RVAL_TYPE_NOPROMISEE: return RvalNew(NULL, RVAL_TYPE_NOPROMISEE); } assert(false); return RvalNew(NULL, RVAL_TYPE_NOPROMISEE); }
Rval ExpandPrivateRval(EvalContext *ctx, const char *ns, const char *scope, const void *rval_item, RvalType rval_type) { Rval returnval; returnval.item = NULL; returnval.type = RVAL_TYPE_NOPROMISEE; switch (rval_type) { case RVAL_TYPE_SCALAR: { Buffer *buffer = BufferNew(); ExpandScalar(ctx, ns, scope, rval_item, buffer); returnval = (Rval) { BufferClose(buffer), RVAL_TYPE_SCALAR }; } break; case RVAL_TYPE_LIST: returnval.item = ExpandList(ctx, ns, scope, rval_item, true); returnval.type = RVAL_TYPE_LIST; break; case RVAL_TYPE_FNCALL: returnval.item = ExpandFnCall(ctx, ns, scope, rval_item); returnval.type = RVAL_TYPE_FNCALL; break; case RVAL_TYPE_CONTAINER: returnval = RvalNew(JsonCopy(rval_item), RVAL_TYPE_CONTAINER); break; case RVAL_TYPE_NOPROMISEE: break; } return returnval; }