Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jonathan Wilkes
flext
Commits
525afdd2
Commit
525afdd2
authored
Oct 18, 2002
by
thomas
Browse files
no message
git-svn-id:
https://svn.grrrr.org/ext/trunk@320
4d9ac71a-51e6-0310-8455-cad1006bcd31
parent
242ca7b3
Changes
5
Hide whitespace changes
Inline
Side-by-side
source/flbase.cpp
View file @
525afdd2
...
...
@@ -24,8 +24,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
//
/////////////////////////////////////////////////////////
flext_hdr
*
flext_obj
::
m_holder
;
const
char
*
flext_obj
::
m_holdname
;
flext_hdr
*
flext_obj
::
m_holder
=
NULL
;
const
t_symbol
*
flext_obj
::
m_holdname
=
NULL
;
/////////////////////////////////////////////////////////
...
...
@@ -34,7 +34,7 @@ const char *flext_obj::m_holdname;
/////////////////////////////////////////////////////////
flext_obj
::
flext_obj
()
:
x_obj
(
m_holder
)
,
m_name
(
flext_util
::
strdup
(
m_holdname
)
)
,
m_name
(
m_holdname
)
,
init_ok
(
true
)
{
#ifdef PD
...
...
@@ -49,10 +49,7 @@ flext_obj :: flext_obj()
// Destructor
//
/////////////////////////////////////////////////////////
flext_obj
::
~
flext_obj
()
{
if
(
m_name
)
delete
[]
const_cast
<
char
*>
(
m_name
);
}
flext_obj
::
~
flext_obj
()
{}
void
flext_obj
::
DefineHelp
(
t_class
*
c
,
const
char
*
ref
,
const
char
*
dir
,
bool
addtilde
)
...
...
source/flbase.h
View file @
525afdd2
...
...
@@ -118,7 +118,8 @@ class FLEXT_EXT flext_obj:
t_sigobj
*
thisHdr
()
{
return
&
x_obj
->
obj
;
}
const
t_sigobj
*
thisHdr
()
const
{
return
&
x_obj
->
obj
;
}
const
char
*
thisName
()
const
{
return
m_name
;
}
const
char
*
thisName
()
const
{
return
GetString
(
m_name
);
}
const
t_symbol
*
thisNameSym
()
const
{
return
m_name
;
}
#ifdef PD
t_class
*
thisClass
()
{
return
(
t_class
*
)((
t_object
*
)(
x_obj
))
->
te_g
.
g_pd
;
}
...
...
@@ -128,6 +129,9 @@ class FLEXT_EXT flext_obj:
void
InitProblem
()
{
init_ok
=
false
;
}
virtual
bool
Init
()
{
return
true
;
}
virtual
void
Exit
()
{}
// --- help -------------------------------------------------------
/*! \defgroup FLEXT_C_HELP Flext help/assistance functionality
...
...
@@ -164,10 +168,10 @@ class FLEXT_EXT flext_obj:
*/
static
flext_hdr
*
m_holder
;
//! Hold object's name during construction
static
const
char
*
m_holdname
;
static
const
t_symbol
*
m_holdname
;
//! The object's name in the patcher
const
char
*
m_name
;
const
t_symbol
*
m_name
;
//! Check whether construction was successful
bool
InitOk
()
const
{
return
init_ok
;
}
...
...
@@ -193,6 +197,13 @@ namespace flext_util {
}
//@}
// max. 4 creation args (see the following macros)
#define FLEXT_MAXNEWARGS 4
// max. 5 method args (see the following macros)
#define FLEXT_MAXMETHARGS 5
// ----------------------------------------
// These should be used in the header
// ----------------------------------------
...
...
@@ -310,8 +321,6 @@ cl##_tilde_setup()
#define ARGCAST(arg,tp) ARGMEMBER_##tp(arg)
#define FLEXT_MAXNEWARGS 4 // max. 4 creation args (see the following macros)
#define REAL_NEW(NAME,NEW_CLASS,DSP,LIB) \
FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) \
flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \
...
...
source/fldefs.h
View file @
525afdd2
...
...
@@ -76,7 +76,6 @@ FLEXT_REALHDR_S(NEW_CLASS, PARENT_CLASS, SETUPFUN)
which is part of an object library (and not stand-alone).
*/
// NO ARGUMENTS
// ----------------------------------------
...
...
@@ -157,6 +156,45 @@ REAL_NEW_V(NAME,NEW_CLASS, 0,1)
REAL_NEW_V(NAME,NEW_CLASS, 1,1)
// OBJECT NAME + VARIABLE ARGUMENT LIST
// ----------------------------------------
/*! Implementation of a flext class with its name and a variable argument list
\ingroup FLEXT_NEW
*/
#define FLEXT_NEW_NV(NAME,NEW_CLASS) \
\
REAL_NEW_NV(NAME,NEW_CLASS,0,0) \
/*! Implementation of a flext tilde class with its name and a variable argument list
\ingroup FLEXT_NEW_DSP
*/
#define FLEXT_NEW_DSP_NV(NAME,NEW_CLASS) \
\
REAL_NEW_NV(NAME,NEW_CLASS,1,0) \
/*! Implementation of a flext GUI class with its name and a variable argument list
\ingroup FLEXT_NEW_GUI
*/
#define FLEXT_NEW_GUI_NV(NAME,NEW_CLASS) \
\
REAL_NEW_NV(NAME,NEW_CLASS,2,0) \
/*! Implementation of a flext class (part of a library) with its name and a variable argument list
\ingroup FLEXT_LIB
*/
#define FLEXT_LIB_NV(NAME,NEW_CLASS) \
\
REAL_NEW_NV(NAME,NEW_CLASS, 0,1)
/*! Implementation of a flext tilde class (part of a library) with its name and a variable argument list
\ingroup FLEXT_LIB_DSP
*/
#define FLEXT_LIB_DSP_NV(NAME,NEW_CLASS) \
\
REAL_NEW_NV(NAME,NEW_CLASS, 1,1)
// ONE ARGUMENT
// ----------------------------------------
...
...
source/flext.cpp
View file @
525afdd2
...
...
@@ -514,7 +514,6 @@ void flext_base::m_help()
post
(
"%s (using flext "
FLEXT_VERSTR
") - compiled on %s %s"
,
thisName
(),
__DATE__
,
__TIME__
);
}
union
t_any
{
float
ft
;
int
it
;
...
...
@@ -524,12 +523,9 @@ union t_any {
#endif
};
typedef
void
(
*
methfun_
G
)(
flext_base
*
c
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_
XG
)(
flext_base
*
c
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_
V
)(
flext_base
*
c
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_
A
)(
flext_base
*
c
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_0
)(
flext_base
*
c
);
#define MAXARGS 5
typedef
void
(
*
methfun_1
)(
flext_base
*
c
,
t_any
&
);
typedef
void
(
*
methfun_2
)(
flext_base
*
c
,
t_any
&
,
t_any
&
);
typedef
void
(
*
methfun_3
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
);
...
...
@@ -549,16 +545,16 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
LOG4
(
"found method tag %s: inlet=%i, symbol=%s, argc=%i"
,
m
->
tag
->
s_name
,
inlet
,
s
->
s_name
,
argc
);
if
(
m
->
argc
==
1
&&
m
->
args
[
0
]
==
a_gimme
)
{
((
methfun_
G
)
m
->
fun
)(
this
,
argc
,
argv
);
((
methfun_
V
)
m
->
fun
)(
this
,
argc
,
argv
);
ret
=
true
;
}
else
if
(
m
->
argc
==
1
&&
m
->
args
[
0
]
==
a_xgimme
)
{
((
methfun_
XG
)
m
->
fun
)(
this
,
s
,
argc
,
argv
);
((
methfun_
A
)
m
->
fun
)(
this
,
s
,
argc
,
argv
);
ret
=
true
;
}
else
if
(
argc
==
m
->
argc
)
{
int
ix
;
t_any
aargs
[
MAX
ARGS
];
t_any
aargs
[
FLEXT_MAXMETH
ARGS
];
bool
ok
=
true
;
for
(
ix
=
0
;
ix
<
argc
&&
ok
;
++
ix
)
{
switch
(
m
->
args
[
ix
])
{
...
...
@@ -623,7 +619,7 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
// any
LOG4
(
"found any method for %s: inlet=%i, symbol=%s, argc=%i"
,
m
->
tag
->
s_name
,
inlet
,
s
->
s_name
,
argc
);
((
methfun_
XG
)
m
->
fun
)(
this
,
s
,
argc
,
argv
);
((
methfun_
A
)
m
->
fun
)(
this
,
s
,
argc
,
argv
);
ret
=
true
;
}
}
...
...
@@ -767,9 +763,9 @@ void flext_base::AddMethod(int inlet,const char *tag,methfun fun,metharg tp,...)
va_end
(
marker
);
if
(
argc
>
0
)
{
if
(
argc
>
MAX
ARGS
)
{
error
(
"Method %s: only %i arguments are type-checkable: use variable argument list for more"
,
tag
?
tag
:
"?"
,
MAX
ARGS
);
argc
=
MAX
ARGS
;
if
(
argc
>
FLEXT_MAXMETH
ARGS
)
{
error
(
"Method %s: only %i arguments are type-checkable: use variable argument list for more"
,
tag
?
tag
:
"?"
,
FLEXT_MAXMETH
ARGS
);
argc
=
FLEXT_MAXMETH
ARGS
;
}
args
=
new
metharg
[
argc
];
...
...
@@ -777,9 +773,11 @@ void flext_base::AddMethod(int inlet,const char *tag,methfun fun,metharg tp,...)
va_start
(
marker
,
tp
);
metharg
a
=
tp
;
for
(
int
ix
=
0
;
ix
<
argc
;
++
ix
)
{
#ifdef _DEBUG
if
(
a
==
a_gimme
&&
ix
>
0
)
{
ERRINTERNAL
();
}
#endif
#ifdef PD
if
(
a
==
a_pointer
&&
flext_base
::
compatibility
)
{
post
(
"Pointer arguments are not allowed in compatibility mode"
);
...
...
source/fllib.cpp
View file @
525afdd2
...
...
@@ -94,13 +94,17 @@ void flext_obj::obj_add(bool lib,bool dsp,const char *name,void setupfun(t_class
{
if
(
dsp
)
flext_util
::
chktilde
(
name
);
t_class
**
cl
=
lib
?&
lib_class
:
new
t_class
*
;
t_class
**
cl
=
#ifdef MAXMSP
lib
?&
lib_class
:
#endif
new
t_class
*
;
const
t_symbol
*
nsym
=
MakeSymbol
(
flext_util
::
extract
(
name
));
// register object class
#ifdef PD
*
cl
=
::
class_new
(
nsym
,
(
t_symbol
*
)
nsym
,
(
t_newmethod
)
obj_new
,(
t_method
)
obj_free
,
sizeof
(
flext_hdr
),
0
,
A_GIMME
,
A_NULL
);
#elif defined(MAXMSP)
...
...
@@ -156,7 +160,7 @@ void flext_obj::obj_add(bool lib,bool dsp,const char *name,void setupfun(t_class
#ifdef PD
if
(
ix
>
0
)
// in PD the first name is already registered with class creation
::
class_addcreator
((
t_newmethod
)
libfun_new
,
l
->
name
,
A_GIMME
,
A_NULL
);
::
class_addcreator
((
t_newmethod
)
obj_new
,(
t_symbol
*
)
l
->
name
,
A_GIMME
,
A_NULL
);
#elif defined(MAXMSP)
if
(
ix
>
0
||
lib
)
// in MaxMSP the first alias gets its name from the name of the object file,
...
...
@@ -224,13 +228,26 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int argc,t_atom *argv)
obj
=
(
flext_hdr
*
)
::
newobject
(
lo
->
clss
);
#endif
flext_obj
::
m_holder
=
obj
;
flext_obj
::
m_holdname
=
flext
::
GetString
(
l
->
name
)
;
flext_obj
::
m_holdname
=
l
->
name
;
// get actual flext object (newfun calls "new flext_obj()")
obj
->
data
=
lo
->
argc
>=
0
?
lo
->
newfun
(
lo
->
argc
,
args
)
:
lo
->
newfun
(
argc
,
argv
);
if
(
lo
->
argc
>=
0
)
// for interpreted arguments
obj
->
data
=
lo
->
newfun
(
lo
->
argc
,
args
);
else
// for variable argument list
obj
->
data
=
lo
->
newfun
(
argc
,
argv
);
flext_obj
::
m_holder
=
NULL
;
if
(
!
obj
->
data
||
!
obj
->
data
->
InitOk
())
{
flext_obj
::
m_holdname
=
NULL
;
if
(
!
obj
->
data
||
// check constructor exit flag
!
obj
->
data
->
InitOk
()
||
// call virtual init function
!
obj
->
data
->
Init
())
{
// there was some init error, free object
lo
->
freefun
(
obj
);
obj
=
NULL
;
}
...
...
@@ -250,10 +267,14 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int argc,t_atom *argv)
void
flext_obj
::
obj_free
(
flext_hdr
*
hdr
)
{
const
t_symbol
*
name
=
MakeSymbol
(
hdr
->
data
->
m_name
);
const
t_symbol
*
name
=
hdr
->
data
->
thisNameSym
(
);
libname
*
l
=
libname
::
find
(
name
);
if
(
l
)
// call virtual exit function
hdr
->
data
->
Exit
();
// now call object destructor and deallocate
l
->
obj
->
freefun
(
hdr
);
#ifdef _DEBUG
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment