atom_t* lambda_atom_alloc(atom_t *args, atom_t *body, env_t *env){ atom_t *atom = atom_alloc(T_LAMBDA); atom->body = body; atom->args = args; atom->env = env; return atom; }
atom_t* custom_atom_alloc(uint64_t type, void *data, buildin_func_t func){ atom_t *atom = atom_alloc(T_CUSTOM); atom->custom.type = type; atom->custom.data = data; atom->custom.func = func; return atom; }
t_max_err cc_cfile_get(t_cc *x, t_object *attr, long *argc, t_atom **argv){ char alloc; atom_alloc(argc, argv, &alloc); // allocate return atom atom_setsym(*argv, gensym(x->cfile_fullpath)); return 0; }
atom_t* interpreter_state_atom_alloc(size_t fp_index, size_t ip_index, size_t arg_count, uint8_t scope_escaped, scope_p frame_scope){ atom_t *atom = atom_alloc(T_INTERPRETER_STATE); atom->interpreter_state.fp_index = fp_index; atom->interpreter_state.ip_index = ip_index; atom->interpreter_state.arg_count = arg_count; atom->interpreter_state.padding = 0; atom->interpreter_state.scope_escaped = scope_escaped; atom->interpreter_state.frame_scope = frame_scope; return atom; }
t_max_err polywave_interp_get(t_polywave *x, t_object *attr, long *argc, t_atom **argv) { char alloc; atom_alloc(argc, argv, &alloc); atom_setlong(*argv, x->interp_type); return 0; }
atom_t* pair_atom_alloc(atom_t *first, atom_t *rest){ if (first == NULL || rest == NULL){ warn("Tried to allocate a pair with a NULL pointer in it!"); return nil_atom(); } atom_t *atom = atom_alloc(T_PAIR); atom->first = first; atom->rest = rest; return atom; }
t_max_err adsr_r_get(t_adsr *x, void *attr, long *ac, t_atom **av) { if (ac && av) { char alloc; if (atom_alloc(ac, av, &alloc)) { return MAX_ERR_GENERIC; } atom_setfloat(*av, x->r * 1000.0); } return MAX_ERR_NONE; }
t_max_err poki_interpThresholdSamps_get(t_poki *x, void *attr, long *ac, t_atom **av) { if (ac && av) { char alloc; if (atom_alloc(ac, av, &alloc)) { return MAX_ERR_GENERIC; } atom_setlong(*av, x->p_interpThresholdSamps); } return MAX_ERR_NONE; }
t_max_err poki_recLevel_get(t_poki *x, void *attr, long *ac, t_atom **av) { if (ac && av) { char alloc; if (atom_alloc(ac, av, &alloc)) { return MAX_ERR_GENERIC; } atom_setfloat(*av, x->p_recLevel); } return MAX_ERR_NONE; }
t_max_err ocontext_attr_prefix_get(t_ocontext *x, t_object *attr, long *argc, t_atom **argv) { char alloc; atom_alloc(argc, argv, &alloc); if(x->prefix){ atom_setsym(*argv, x->prefix); }else{ atom_setsym(*argv, gensym("")); } return 0; }
atom_t* compiled_lambda_atom_alloc(bytecode_t bytecode, atom_list_t literal_table, uint16_t arg_count, uint16_t var_count){ atom_t *atom = atom_alloc(T_COMPILED_LAMBDA); atom->bytecode = bytecode; atom->literal_table = literal_table; atom->comp_data = gc_alloc(sizeof(struct compiler_data)); atom->comp_data->arg_count = arg_count; atom->comp_data->var_count = var_count; atom->comp_data->names = NULL; atom->comp_data->max_frame_offset = 0; return atom; }
atom_t* str_atom_alloc(char *str){ atom_t *atom = atom_alloc(T_STR); atom->str = str; return atom; }
t_max_err cc_maxsdk_get(t_cc *x, t_object *attr, long *argc, t_atom **argv){ char alloc; atom_alloc(argc, argv, &alloc); atom_setsym(*argv, x->path_to_maxsdk); return 0; }
t_max_err cc_build_path_get(t_cc *x, t_object *attr, long *argc, t_atom **argv){ char alloc; atom_alloc(argc, argv, &alloc); atom_setsym(*argv, gensym(x->build_path)); return 0; }
atom_t* env_atom_alloc(env_t *env){ atom_t *atom = atom_alloc(T_ENV); atom->env = env; return atom; }
atom_t* runtime_lambda_atom_alloc(atom_t *compiled_lambda, scope_p scopes){ atom_t *atom = atom_alloc(T_RUNTIME_LAMBDA); atom->cl = compiled_lambda; atom->scopes = scopes; return atom; }
void memory_init(){ gc_init(); allocator_nil_atom = atom_alloc(T_NIL); allocator_true_atom = atom_alloc(T_TRUE); allocator_false_atom = atom_alloc(T_FALSE); }
atom_t* buildin_atom_alloc(buildin_func_t func, compile_func_t compile_func){ atom_t *atom = atom_alloc(T_BUILDIN); atom->func = func; atom->compile_func = compile_func; return atom; }
atom_t* num_atom_alloc(int64_t value){ atom_t *atom = atom_alloc(T_NUM); atom->num = value; return atom; }
atom_t* sym_atom_alloc(char *sym){ atom_t *atom = atom_alloc(T_SYM); atom->sym = sym; return atom; }