void dispinit(CSOUND *csound) { OPARMS O; csound->GetOParms(csound, &O); if (O.displays && !(O.graphsoff || O.postscript)) { if (!csound->isGraphable_) find_opcode_new(csound, "FLrun", NULL, NULL); /* load FLTK for displays */ if (csound->isGraphable_) return; /* provided by window driver: is this session able? */ } if (!O.displays) { csound->Message(csound, Str("displays suppressed\n")); csound->csoundMakeGraphCallback_ = DummyFn1; csound->csoundDrawGraphCallback_ = DummyFn2; csound->csoundKillGraphCallback_ = DummyFn2; } else { csound->Message(csound, Str("graphics %s, ascii substituted\n"), ((O.graphsoff || O.postscript) ? Str("suppressed") : Str("not supported on this terminal"))); csound->csoundMakeGraphCallback_ = MakeAscii; csound->csoundDrawGraphCallback_ = DrawAscii; csound->csoundKillGraphCallback_ = KillAscii; } csound->csoundExitGraphCallback_ = DummyFn3; }
void test_find_opcode_new(void) { CSOUND* csound = csoundCreate(NULL); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##error", "i", "i")); CU_ASSERT_PTR_NULL(find_opcode_new(csound, "##error", NULL, "i")); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin64", "i", NULL)); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin256", "i", NULL)); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##userOpcode", NULL, NULL)); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##array_set", NULL, "k[]k")); CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, ">=", "B", "kc")); }
/** Adds a UDO definition as an T_OPCODE or T_OPCODE0 type to the symbol table * used at parse time. An OENTRY is also added at this time so that at * verification time the opcode can be looked up to get its signature. */ int add_udo_definition(CSOUND *csound, char *opname, char *outtypes, char *intypes) { OENTRY tmpEntry, *opc, *newopc; OPCODINFO *inm; if (UNLIKELY(!check_instr_name(opname))) { synterr(csound, Str("invalid name for opcode")); return -1; } /* check if opcode is already defined */ opc = find_opcode_new(csound, opname, outtypes, intypes); if (opc != NULL) { /* IV - Oct 31 2002: redefine old opcode if possible */ if (UNLIKELY( !strcmp(opname, "instr") || !strcmp(opname, "endin") || !strcmp(opname, "opcode") || !strcmp(opname, "endop") || !strcmp(opname, "$label") || !strcmp(opname, "pset") || !strcmp(opname, "xin") || !strcmp(opname, "xout") || !strcmp(opname, "subinstr"))) { synterr(csound, Str("cannot redefine %s"), opname); return -2; } csound->Message(csound, Str("WARNING: redefined opcode: %s\n"), opname); } /* IV - Oct 31 2002 */ /* store the name in a linked list (note: must use csound->Calloc) */ inm = (OPCODINFO *) csound->Calloc(csound, sizeof(OPCODINFO)); inm->name = cs_strdup(csound, opname); inm->intypes = intypes; inm->outtypes = outtypes; inm->in_arg_pool = csoundCreateVarPool(csound); inm->out_arg_pool = csoundCreateVarPool(csound); inm->prv = csound->opcodeInfo; csound->opcodeInfo = inm; /* IV - Oct 31 2002: */ /* create a fake opcode so we can call it as such */ opc = find_opcode(csound, "##userOpcode"); memcpy(&tmpEntry, opc, sizeof(OENTRY)); tmpEntry.opname = cs_strdup(csound, opname); csound->AppendOpcodes(csound, &tmpEntry, 1); newopc = csound_find_internal_oentry(csound, &tmpEntry); newopc->useropinfo = (void*) inm; /* ptr to opcode parameters */ /* check in/out types and copy to the opcode's */ /* IV - Sep 8 2002: opcodes have an optional arg for ksmps */ newopc->outypes = csound->Malloc(csound, strlen(outtypes) + 1 + strlen(intypes) + 2); newopc->intypes = &(newopc->outypes[strlen(outtypes) + 1]); if (UNLIKELY(parse_opcode_args(csound, newopc) != 0)) return -3; if (strcmp(outtypes, "0")==0) { add_token(csound, opname, T_OPCODE0); } else { add_token(csound, opname, T_OPCODE); } return 0; }