示例#1
0
bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c)
{
#if FLEXT_SYS == FLEXT_SYS_PD && defined(PD_MINOR_VERSION) && PD_MINOR_VERSION >= 37
    if(!c) c = canvas_getcurrent();

    const char *s = GetString(sym);
    if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) {
        const t_symbol *res;
        // patcher parameter detected... get value!
        if(s[0] != '$') {
            char tmp[MAXPDSTRING];
            strcpy(tmp,s);
            tmp[0] = '$';
            res = canvas_realizedollar(c,const_cast<t_symbol *>(MakeSymbol(tmp)));
        }
        else
            res = canvas_realizedollar(c,const_cast<t_symbol *>(sym));

        // check for number
        const char *c = GetString(res);
        while(*c && (isdigit(*c) || *c == '.')) ++c;

        if(!*c) 
            SetFloat(dst,(float)atof(GetString(res)));
        else
            SetSymbol(dst,res);
        return true;
    }
    else
#else
    #pragma message("Not implemented")
#endif
    SetSymbol(dst,sym);
    return true;
}
示例#2
0
void flext_obj::__setup__(t_classid) 
{ 
#if FLEXT_SYS == FLEXT_SYS_MAX
    sym__shP = MakeSymbol("#P");
#endif
    flext::Setup(); 
}	
示例#3
0
bool CGLFTFont::Make(string filename, int height, bool blend)
{
Clear();
m_symbolspacer = height / 20 + 1;
m_height = height;

FT_Library library;
int error = FT_Init_FreeType( &library );
if ( error != 0 )
  return false;

FT_Face face;
error = FT_New_Face( library, filename.c_str(), 0, &face );
if ( error != 0 )
  return false;

int ftheight = height << 6;
FT_Set_Char_Size( face, ftheight, ftheight, 96, 96 );

m_lists = glGenLists( symbolcount );

m_downshift = 0;

for (uchar index = 0; index < symbolcount; ++index)
  {
  bool result = MakeSymbol( face, index, blend );
  if ( result == false )
    return false;
  }

FT_Done_Face(face);
FT_Done_FreeType(library);
}
示例#4
0
文件: clk_client.cpp 项目: jondf/pd
void Client::ms_name(int argc,const t_atom *argv)
{
    const t_symbol *n;
    if(!argc)
        n = NULL;
    else if(CanbeInt(*argv)) {
        // that's mainly for missing $-args which are set as 0
        char tmp[20];
        sprintf(tmp,"%i",GetAInt(*argv));
        n = MakeSymbol(tmp);
    }
    else
        n = GetSymbol(*argv);

    double current;
    if(LIKELY(clock)) {
        if(clock->name == n) return;

        current = clock->Current();

        Clock::Unregister(clock,this);
        clock = NULL;
    }
    else if(!n)
        return;
    else
        current = 0;

    if(LIKELY(n)) {
        clock = Clock::Register(n,this);
        offset += current-clock->Current();
    }
}
示例#5
0
int
main(int argc, char **argv)
{
  int i,j;
  int rc;
  char name[127];

  FILE *fp;

  printf("Making verilog symbols\n");

  for(i=0; i<nGenerate; i++) /* loop over table entries */
    for(j=2; j<10; j++)      /* loop over number of pins */
      {
	/* build file name */
	sprintf(name, "sym/%s%u-%u.sym",
		generate[i].name, j, generate[i].suffix);
	printf("Working on:%s\n",name);
	fp = fopen(name, "wb");
	if(fp == NULL)
	  {
	    fprintf(stderr,"Error: Unable to create file `%s' in %s()\n",
		    name, __func__);
	    return 1;
	  }

	rc = MakeSymbol(fp, j,
			generate[i].inputBubbles, generate[i].outputBubbles,
			generate[i].body);
	if(rc)
	  {
	    fprintf(stderr,"Error: Symbol creation failed in %s()\n",
		    __func__);
	    fclose(fp);
	    return 1;
	  }

	/* and finally add the device attribute */
	fprintf(fp,"T 400 100 5 8 0 0 0 0\ndevice=%s\n",generate[i].name);
	/* and the positional pin directive */
	fprintf(fp,"T 400 200 5 8 0 0 0 0\nVERILOG_PORTS=POSITIONAL");
	fclose(fp);
      }

  return 0;
}
示例#6
0
文件: clk_client.cpp 项目: jondf/pd
void ClientExt::Setup(t_classid c)
{
    sym_message = MakeSymbol("message");

    FLEXT_CADDATTR_VAR(c,"name",mg_name,ms_name);

    FLEXT_CADDMETHOD_(c,0,"reset",m_reset);
    FLEXT_CADDMETHOD_(c,0,sym_message,m_message);

    FLEXT_CADDATTR_VAR(c,"offset",mg_offset,ms_offset);
    FLEXT_CADDATTR_VAR(c,"factor",mg_factor,ms_factor);

    FLEXT_CADDATTR_GET(c,"timebase",mg_timebase);

    FLEXT_CADDATTR_VAR1(c,"dblprec",dblprec);
    FLEXT_CADDATTR_VAR1(c,"t3mode",t3mode);
}
示例#7
0
文件: main.cpp 项目: Angeldude/pd
    static void setup(t_classid c)
    {
        post("audiocube external loaded");
        post("(c)2009 Thomas Grill");

        sym_attach = MakeSymbol("attach");
        sym_detach = MakeSymbol("detach");
        sym_topology = MakeSymbol("topology");
        sym_color = MakeSymbol("color");
        sym_sensor = MakeSymbol("sensor");
        sym_sensors = MakeSymbol("sensors");
        
        FLEXT_CADDMETHOD_4(c,0,sym_color,m_setcolor,int,float,float,float);
        FLEXT_CADDMETHOD_(c,0,"getcolor",m_getcolor);
        FLEXT_CADDMETHOD_II(c,0,"getsensor",m_getsensor);
        FLEXT_CADDMETHOD_I(c,0,"getsensors",m_getsensors);
    }
示例#8
0
manta::manta(int argc,t_atom *argv):
   ConnectedManta(NULL),
   DebugEnabled(false),
   OneIndexed(false)
{ 
	AddInAnything();

	AddOutAnything("Pad Velocity");
	AddOutAnything("Pad and Button Continuous");
	AddOutAnything("Slider");
	AddOutAnything("Processed");

   FLEXT_ADDMETHOD_(0, "pad", SetPadLED);
   FLEXT_ADDMETHOD_3(0, "row", SetPadLEDRow, t_symptr, int, int);
   FLEXT_ADDMETHOD_3(0, "row", SetPadLEDRowNum, int, int, int);
   FLEXT_ADDMETHOD_3(0, "column", SetPadLEDColumn, t_symptr, int, int);
   FLEXT_ADDMETHOD_3(0, "column", SetPadLEDColumnNum, int, int, int);
   FLEXT_ADDMETHOD_2(0, "slider", SetSliderLED, int, t_symptr);
   FLEXT_ADDMETHOD_2(0, "slider", SetSliderLEDNum, int, int);
   FLEXT_ADDMETHOD_3(0, "slidermask", SetSliderLEDMask, t_symptr, int, int);
   FLEXT_ADDMETHOD_3(0, "slidermask", SetSliderLEDMaskNum, int, int, int);
   FLEXT_ADDMETHOD_(0, "button", SetButtonLED);
   FLEXT_ADDMETHOD_(0, "ledsoff", ClearPadAndButtonLEDs);
   FLEXT_ADDMETHOD_2(0, "ledcontrol", SetLEDControl, t_symptr, int);
   FLEXT_ADDMETHOD_(0, "reset", Recalibrate);
   FLEXT_ADDMETHOD_(0, "connect", Connect);
   FLEXT_ADDMETHOD_1(0, "turbo", SetTurboMode, int);
   FLEXT_ADDMETHOD_1(0, "raw", SetRawMode, int);
   FLEXT_ADDMETHOD_1(0, "debug", EnableDebug, int);
   FLEXT_ADDMETHOD_1(0, "oneindex", SetOneIndexed, int);
   
   padSymbol = MakeSymbol("pad");
   sliderSymbol = MakeSymbol("slider");
   sliderMaskSymbol = MakeSymbol("slidermask");
   buttonSymbol = MakeSymbol("button");
   amberSymbol = MakeSymbol("amber");
   offSymbol = MakeSymbol("off");
   redSymbol = MakeSymbol("red");
   rowSymbol = MakeSymbol("row");
   columnSymbol = MakeSymbol("column");
   frameSymbol = MakeSymbol("frame");
   padAndButtonSymbol = MakeSymbol("padandbutton");
   ledsOffSymbol = MakeSymbol("ledsoff");

   MantaFlextList.push_back(this);
   Connect(argc, argv);
} 
示例#9
0
short
CompVar(short t, Type *baseType, long storFlags, long regFlags, Var **pvar)
{
    Var *var = NULL;
    Type *type;
    Symbol *sym = NULL;
    long extraTypeFlags = 0;	/*  propogated through override */
    short protoVoid = 0;

    /*
     *	step 1, parse the name .. get the name symbol and representitive type
     */

    type = baseType;

    t = CompTypeDeclarators(t, &type, &sym, storFlags);

    if (type->Flags & TF_STKCALL) storFlags &= ~TF_REGCALL;

    if (t == TokColon) {
	long bits;
	Exp *exp = NULL;

	if (StructLevel == 0)
	    zerror(EERROR_ILLEGAL_BITFIELD_OP);

	if (type->Id != TID_INT || (type->Size != 4 && type->Size != 2))
	    zerror(EERROR_ILLEGAL_BITFIELD_OP);

	t = GetToken();
	t = CompExp(t, &exp, 0);
	bits = ExpToConstant(exp);

	if (bits > 32 || bits < 0) {
	    zerror(EERROR_ILLEGAL_BITFIELD_OP);
	    bits = 32;
	}
	type = MakeBitfieldType(type->Flags & TF_UNSIGNED, bits);
    }

    /*
     *	Create final type that includes storage qualifiers.
     */

    if ((storFlags & TF_STORNOTLOCAL) == 0 && State != SOUTSIDE)
    {
        /* Check to see that this is a pointer to a function */
        if (type->Id != TID_PTR   ||
            type->SubType == NULL ||
            type->SubType->Id != TID_PROC)
        {
	    if (storFlags & TF_AUTOILLEGAL)
		zerror(EERROR_ILLEGAL_QUALIFIER);
	}
	storFlags |= TF_AUTO;
    }

    {
	long tflags = (type->Flags | storFlags) & ~TF_NOTINTYPE;

	if (type->Flags != tflags)
	    type = TypeToQualdType(type, tflags);
    }

    /*
     *	If typedef we stop here
     */

    if (pvar == NULL) {
	if (type->Flags != (type->Flags | storFlags))
	    type = TypeToQualdType(type, type->Flags | storFlags);

	if (t != TokSemi && t != TokComma)
	    zerror(EERROR_ILLEGAL_TYPEDEF);
	if (sym)
	    SemanticAdd(sym, TokTypeId, type);
	else
	    zerror(EERROR_ILLEGAL_TYPEDEF);
	return(t);
    }

    /*
     *	definitely a variable.	Check for overide of previous def
     *	in this block level, or global block level if not auto.
     *
     *	STATIC VARIABLES inside subroutines are special, they do not bother
     *	global variables outside subroutines of the same name.
     *
     *	check opt '= exp' and optional code if a procedure
     */

    if (sym == NULL)
    {
	/* Well, we have a syntax error */
	zerror(EERROR_SYNTAX_ERROR_DECL);
	sym = MakeSymbol("<PHONEYSYM>", 11, LFBase->lf_Index, NULL);
	storFlags |= VF_DECLD;
    }

    if (StructLevel == 0 && (var = BlockRemoveDuplicateVar(storFlags, sym, type))) {
	extraTypeFlags = (var->Type->Flags | storFlags) & TF_KEEPPROC;
	if (var->Type->Args == 0)   /*	proto was ... foo(void) */
	    protoVoid = 1;

	if ((type->Flags & TF_KEEPPROC) != (extraTypeFlags & TF_KEEPPROC))
	    type = TypeToQualdType(type, type->Flags | extraTypeFlags);
    }

    if (var == NULL) {
	if (StructLevel == 0 && State != SOUTSIDE && (storFlags & TF_STORNOTLOCAL) == 0 && type->Id != TID_PROC) {
	    var = AllocTmpStructure(Var);   /*	does not survive subroutine */
	} else {
	    var = AllocStructure(Var);	    /*	permanent   */
	}
	if (sym && StructLevel == 0) {
	    if (type->Id == TID_PROC || (storFlags & TF_EXTERN))
		SemanticAddTop(sym, TokVarId, var);
	    else
		SemanticAdd(sym, TokVarId, var);
	}
    }

    var->Type = type;
    var->Sym  = sym;
    var->LexIdx = LFBase->lf_Index;

    if (storFlags & TF_REGISTER)
	++var->Refs;

    if ((type->Id == TID_STRUCT || type->Id == TID_UNION) && (type->Size == 0))
    {
	Undefined_Tag(type, sym, LFBase->lf_Index);
    }

    *pvar = var;

    if (State == SOUTSIDE && (storFlags & TF_AUTO))
	zerror(EERROR_ILLEGAL_QUALIFIER);

    var->Flags = type->Flags | storFlags | extraTypeFlags | (var->Flags & VF_DECLD);
    var->RegFlags = regFlags;

#ifdef DYNAMIC
    if ((var->Flags & (TF_EXTERN|TF_DYNAMIC)) == TF_DYNAMIC) {
	var->Type = type = TypeToPtrType(var->Type);
	asm_dynamictag(var);
    }
#endif
    if (type->Id == TID_PROC) {
	if (t != TokSemi && t != TokComma) {	/*  definition	*/
	    var->Flags &= ~(VF_DECLD | TF_EXTERN);

	    /*
	     *	if not a prototyped procedure must munge arguments properly.
	     *	This applies to floats, for example, which are really doubles
	     *	for non-prototyped procedures.
	     */

	    if ((type->Flags & TF_PROTOTYPE) == 0) {
		short i;
		for (i = 0; i < type->Args; ++i) {
		    Type **t2 = &type->Vars[i]->Type;
		    *t2 = ActualArgType(*t2);
		}
	    }

	    /*
	     *	munge routine prototyped as foo(void) but declared foo()
	     */

	    if (protoVoid && type->Args < 0)
		var->Type = type = TypeToProcType(type->SubType, NULL, 0, type->Flags | TF_PROTOTYPE);

	    if (var->u.Block && !(var->Flags & TF_STATIC))
		zerror(EERROR_MULTIPLY_DEFINED_PROC);

	    t = CompProcedure(t, var);

	} else {
	    if (var->u.Block == NULL) {
		if (!(var->Flags & TF_STATIC))
		    var->Flags |= TF_EXTERN;
	    } else {
		zerror(EERROR_MULTIPLY_DEFINED_PROC);
	    }

	    /*
	     *	Generate Register Specification Output Data
	     */

	    if (RegSpecOutputOpt)
		GenerateRegSpecOutput(var);
	}
    } else {
	if (t == TokEq) {	/*  assigned expression */
	    Exp *exp;

            /* Any assignment to a global variable will eliminate the extern */
            /* portion of the symbol.  This is in accordance to ANSI.        */
	    var->Flags &= ~TF_EXTERN;

	    if (StructLevel)
		zerror(EERROR_ILLEGAL_ASSIGNMENT);

	    t = GetToken();
	    if (t == TokLBrace)
	    {
		t = CompBracedAssign(GetToken(), var->Type, &exp, 1, sym);
		if (t != TokRBrace)
		{
		    zerror(EERROR_TOO_MANY_INITIALIZERS);
		    t = match_nesting(t);
		}
		t = GetToken();
	    }
	    else if (t == TokStrConst && var->Type->Id == TID_ARY)
	    {
		t = CompBracedAssign(t, var->Type, &exp, 0, sym);
            }
	    else if ((var->Flags & TF_AUTO) == 0)
	    {
		t = CompBracedAssign(t, var->Type, &exp, 0, sym);
	    } else
	    {
	       /* If we get here, we know that the TF_AUTO bit is on.  If  */
	       /* the TF_STATIC flag is also set, this should be diagnosed */
	       /* This logic used to be in the previous test, but since it */
	       /* really can never occur, we moved it down here and expect */
	       /* to take it out after the beta.                           */
	       /* Note that the assignment code will be pulled out by the  */
	       /* block code in stmt.c (only simple assignments)           */
 	       if (var->Flags & TF_STATIC)
 	       {
 	       	  dbprintf(("Unexpected Type %ld\n", var->Flags));
 	          Assert(0);
 	       }
	       t = CompExp(t, &exp, 0);
            }
	    var->u.AssExp = exp;
	}
    }
    return(t);
}