Commit 8accf611 authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@452 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent b6db2707
No preview for this file type
......@@ -103,6 +103,8 @@ Version history:
- full port for Max@OSX
- completely redesigned message and attribute handling: now hashed and much more efficient
- added some prerequisites for usage of flext as a shared library
- completed Max/MSPs inlet/outlet assist description functionality
- Max/MSP signal objects: fixed bug of reporting wrong number of inlets
- put overloaded new/delete into flext support class
- introduced "Finalize" virtual method, called after all "Init" methods
- fixed crash issue in flext_dsp when there are NO signal inlets or outlets defined
......
......@@ -740,6 +740,8 @@ private:
static void cb_loadbang(t_class *c);
#if FLEXT_SYS == FLEXT_SYS_MAX
char **indesc,**outdesc;
static void cb_assist(t_class *c,void *b,long msg,long arg,char *s);
#endif
};
......
......@@ -105,11 +105,21 @@ public:
*/
void AddInSignal(int m = 1) { AddInlet(xlet::tp_sig,m); }
/*! \brief Add signal inlet (with description)
\param desc Description of inlet
*/
void AddInSignal(const char *desc) { AddInlet(xlet::tp_sig,1,desc); }
/*! \brief Add signal outlet(s)
\param m Number of inlets to add
*/
void AddOutSignal(int m = 1) { AddOutlet(xlet::tp_sig,m); }
/*! \brief Add signal outlet (with description)
\param desc Description of outlet
*/
void AddOutSignal(const char *desc) { AddOutlet(xlet::tp_sig,1,desc); }
//! @}
//! @}
......
......@@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include "flinternal.h"
#include <string.h>
// === flext_base ============================================
......@@ -30,6 +30,9 @@ flext_base::flext_base():
methhead(new itemarr),attrhead(new itemarr), //attrcnt(0),
clmethhead(ClMeths(thisClass())),clattrhead(ClAttrs(thisClass())),
inlets(NULL)
#if FLEXT_SYS == FLEXT_SYS_MAX
,indesc(NULL),outdesc(NULL)
#endif
{
LOG1("%s - flext logging is on",thisName());
......@@ -71,6 +74,15 @@ flext_base::~flext_base()
}
#if FLEXT_SYS == FLEXT_SYS_MAX
if(indesc) {
for(int i = 0; i < incnt; ++i) if(indesc[i]) delete[] indesc[i];
delete[] indesc;
}
if(outdesc) {
for(int i = 0; i < outcnt; ++i) if(outdesc[i]) delete[] outdesc[i];
delete[] outdesc;
}
// if(insigs) dsp_free(thisHdr());
if(insigs) dsp_freebox(thisHdr());
#endif
......@@ -81,7 +93,7 @@ flext_base::~flext_base()
It creates the inlets and outlets and the message and attribute lists.
\note You can override it in your own class, but be sure to call it,
\note otherwise no inlets/outlets will be created
\mote All inlet, outlets, method and attribute declarations must be made before a call to Init!
\note All inlet, outlets, method and attribute declarations must be made before a call to Init!
\remark Creation of inlets/outlets can't be done upon declaration, as Max/MSP needs creation
\remark in reverse.
*/
......@@ -147,6 +159,14 @@ void flext_base::m_help()
void flext_base::m_loadbang() {}
void flext_base::m_assist(long /*msg*/,long /*arg*/,char * /*s*/) {}
void flext_base::m_assist(long msg,long arg,char *s)
{
switch(msg) {
case 1: //ASSIST_INLET:
strcpy(s,arg < incnt && indesc[arg]?indesc[arg]:"");
break;
case 2: //ASSIST_OUTLET:
strcpy(s,arg < outcnt && outdesc[arg]?outdesc[arg]:"");
break;
}
}
......@@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include "flinternal.h"
#include <string.h>
#ifndef FLEXT_THREADS
void flext_base::ToOutBang(outlet *o) const { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); }
......@@ -50,6 +50,22 @@ bool flext_base::InitInlets()
xlet::type *list = new xlet::type[incnt];
int i;
for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp;
#if FLEXT_SYS == FLEXT_SYS_MAX
// copy inlet descriptions
indesc = new char *[incnt];
for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) {
int l = xi->desc?strlen(xi->desc):0;
if(l) {
indesc[i] = new char[l+1];
memcpy(indesc[i],xi->desc,l);
indesc[i][l] = 0;
}
else
indesc[i] = NULL;
}
#endif
delete inlist; inlist = NULL;
inlets = new px_object *[incnt];
......@@ -174,7 +190,7 @@ bool flext_base::InitInlets()
}
}
incnt = cnt;
// incnt = cnt;
if(insigs)
// dsp_setup(thisHdr(),insigs); // signal inlets
......@@ -216,6 +232,22 @@ bool flext_base::InitOutlets()
xlet::type *list = new xlet::type[outcnt];
int i;
for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp;
#if FLEXT_SYS == FLEXT_SYS_MAX
// copy outlet descriptions
outdesc = new char *[outcnt];
for(xi = outlist,i = 0; xi; xi = xi->nxt,++i) {
int l = xi->desc?strlen(xi->desc):0;
if(l) {
outdesc[i] = new char[l+1];
memcpy(outdesc[i],xi->desc,l);
outdesc[i][l] = 0;
}
else
outdesc[i] = NULL;
}
#endif
delete outlist; outlist = NULL;
outlets = new outlet *[outcnt];
......@@ -256,7 +288,7 @@ bool flext_base::InitOutlets()
#endif
}
}
delete[] list;
}
......
......@@ -23,8 +23,9 @@ flext_base::xlet::xlet(type t,const char *d):
{
if(d) {
int ln = strlen(d);
desc = new char[ln];
strncpy(desc,d,ln);
desc = new char[ln+1];
memcpy(desc,d,ln);
desc[ln] = 0;
}
else desc = NULL;
}
......@@ -45,9 +46,18 @@ void flext_base::AddXlet(xlet::type tp,int mult,const char *desc,xlet *&root)
}
}
void flext_base::DescXlet(int ix,const char *desc,xlet *&root)
void flext_base::DescXlet(int ix,const char *d,xlet *&root)
{
post("%s - sorry, not implemented",thisName());
xlet *xi = root;
for(int i = 0; xi && i < ix; xi = xi->nxt,++i) {}
if(xi) {
if(xi->desc) delete[] xi->desc;
int ln = strlen(d);
xi->desc = new char[ln+1];
memcpy(xi->desc,d,ln);
xi->desc[ln] = 0;
}
}
unsigned long flext_base::XletCode(xlet::type tp,...)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment