Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brittney allen
purr-data
Commits
0c4ff109
Commit
0c4ff109
authored
10 years ago
by
pokergaming
Browse files
Options
Downloads
Patches
Plain Diff
* add "set" method to get, set, getsize, setsize, element, and append
parent
3a02243e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/src/g_traversal.c
+112
-25
112 additions, 25 deletions
pd/src/g_traversal.c
with
112 additions
and
25 deletions
pd/src/g_traversal.c
+
112
−
25
View file @
0c4ff109
...
...
@@ -414,14 +414,19 @@ static void *get_new(t_symbol *why, int argc, t_atom *argv)
t_get
*
x
=
(
t_get
*
)
pd_new
(
get_class
);
int
i
;
t_getvariable
*
sp
;
int
varcount
;
x
->
x_templatesym
=
canvas_makebindsym
(
atom_getsymbolarg
(
0
,
argc
,
argv
));
if
(
argc
)
argc
--
,
argv
++
;
varcount
=
argc
?
argc
:
1
;
/* have at least one outlet */
x
->
x_variables
=
(
t_getvariable
*
)
getbytes
(
ar
g
c
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nout
=
ar
g
c
;
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
ar
g
c
;
i
++
,
sp
++
)
=
(
t_getvariable
*
)
getbytes
(
v
arc
ount
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nout
=
v
arc
ount
;
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
v
arc
ount
;
i
++
,
sp
++
)
{
sp
->
gv_sym
=
atom_getsymbolarg
(
i
,
argc
,
argv
);
if
(
argc
)
sp
->
gv_sym
=
atom_getsymbolarg
(
i
,
argc
,
argv
);
else
sp
->
gv_sym
=
&
s_
;
/* just set field to empty symbol if no args */
sp
->
gv_outlet
=
outlet_new
(
&
x
->
x_obj
,
0
);
/* LATER connect with the template and set the outlet's type
correctly. We can't yet guarantee that the template is there
...
...
@@ -430,6 +435,20 @@ static void *get_new(t_symbol *why, int argc, t_atom *argv)
return
(
x
);
}
static
void
get_set
(
t_get
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
field
)
{
if
(
x
->
x_nout
!=
1
)
{
pd_error
(
x
,
"get: cannot set multiple fields."
);
return
;
}
else
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_variables
->
gv_sym
=
field
;
}
}
static
void
get_pointer
(
t_get
*
x
,
t_gpointer
*
gp
)
{
int
nitems
=
x
->
x_nout
,
i
;
...
...
@@ -480,6 +499,8 @@ static void get_setup(void)
get_class
=
class_new
(
gensym
(
"get"
),
(
t_newmethod
)
get_new
,
(
t_method
)
get_free
,
sizeof
(
t_get
),
0
,
A_GIMME
,
0
);
class_addpointer
(
get_class
,
get_pointer
);
class_addmethod
(
get_class
,
(
t_method
)
get_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- set ----------------------------- */
...
...
@@ -507,6 +528,7 @@ static void *set_new(t_symbol *why, int argc, t_atom *argv)
t_set
*
x
=
(
t_set
*
)
pd_new
(
set_class
);
int
i
;
t_setvariable
*
sp
;
int
varcount
;
if
(
argc
&&
(
argv
[
0
].
a_type
==
A_SYMBOL
)
&&
!
strcmp
(
argv
[
0
].
a_w
.
w_symbol
->
s_name
,
"-symbol"
))
{
...
...
@@ -517,23 +539,24 @@ static void *set_new(t_symbol *why, int argc, t_atom *argv)
else
x
->
x_issymbol
=
0
;
x
->
x_templatesym
=
canvas_makebindsym
(
atom_getsymbolarg
(
0
,
argc
,
argv
));
if
(
argc
)
argc
--
,
argv
++
;
varcount
=
argc
?
argc
:
1
;
/* have at least one variable */
x
->
x_variables
=
(
t_setvariable
*
)
getbytes
(
ar
g
c
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nin
=
ar
g
c
;
if
(
argc
)
=
(
t_setvariable
*
)
getbytes
(
v
arc
ount
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nin
=
v
arc
ount
;
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
varcount
;
i
++
,
sp
++
)
{
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
argc
;
i
++
,
sp
++
)
{
if
(
argc
)
sp
->
gv_sym
=
atom_getsymbolarg
(
i
,
argc
,
argv
);
else
sp
->
gv_sym
=
&
s_
;
if
(
x
->
x_issymbol
)
sp
->
gv_w
.
w_symbol
=
&
s_
;
else
sp
->
gv_w
.
w_float
=
0
;
if
(
i
)
{
if
(
x
->
x_issymbol
)
sp
->
gv_w
.
w_symbol
=
&
s_
;
else
sp
->
gv_w
.
w_float
=
0
;
if
(
i
)
{
if
(
x
->
x_issymbol
)
symbolinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_w
.
w_symbol
);
else
floatinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_w
.
w_float
);
}
symbolinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_w
.
w_symbol
);
else
floatinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_w
.
w_float
);
}
}
pointerinlet_new
(
&
x
->
x_obj
,
&
x
->
x_gp
);
...
...
@@ -541,6 +564,24 @@ static void *set_new(t_symbol *why, int argc, t_atom *argv)
return
(
x
);
}
static
void
set_set
(
t_set
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
field
)
{
if
(
x
->
x_nin
!=
1
)
{
pd_error
(
x
,
"set: cannot set multiple fields."
);
return
;
}
else
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_variables
->
gv_sym
=
field
;
if
(
x
->
x_issymbol
)
x
->
x_variables
->
gv_w
.
w_symbol
=
&
s_
;
else
x
->
x_variables
->
gv_w
.
w_float
=
0
;
}
}
static
void
set_bang
(
t_set
*
x
)
{
int
nitems
=
x
->
x_nin
,
i
;
...
...
@@ -621,6 +662,8 @@ static void set_setup(void)
class_addfloat
(
set_class
,
set_float
);
class_addsymbol
(
set_class
,
set_symbol
);
class_addbang
(
set_class
,
set_bang
);
class_addmethod
(
set_class
,
(
t_method
)
set_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- elem ----------------------------- */
...
...
@@ -648,6 +691,12 @@ static void *elem_new(t_symbol *templatesym, t_symbol *fieldsym)
return
(
x
);
}
static
void
elem_set
(
t_elem
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
fieldsym
)
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_fieldsym
=
fieldsym
;
}
static
void
elem_float
(
t_elem
*
x
,
t_float
f
)
{
int
indx
=
f
,
nitems
,
onset
;
...
...
@@ -720,6 +769,8 @@ static void elem_setup(void)
elem_class
=
class_new
(
gensym
(
"element"
),
(
t_newmethod
)
elem_new
,
(
t_method
)
elem_free
,
sizeof
(
t_elem
),
0
,
A_DEFSYM
,
A_DEFSYM
,
0
);
class_addfloat
(
elem_class
,
elem_float
);
class_addmethod
(
elem_class
,
(
t_method
)
elem_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- getsize ----------------------------- */
...
...
@@ -742,6 +793,12 @@ static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym)
return
(
x
);
}
static
void
getsize_set
(
t_getsize
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
fieldsym
)
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_fieldsym
=
fieldsym
;
}
static
void
getsize_pointer
(
t_getsize
*
x
,
t_gpointer
*
gp
)
{
int
onset
,
type
;
...
...
@@ -790,6 +847,8 @@ static void getsize_setup(void)
getsize_class
=
class_new
(
gensym
(
"getsize"
),
(
t_newmethod
)
getsize_new
,
0
,
sizeof
(
t_getsize
),
0
,
A_DEFSYM
,
A_DEFSYM
,
0
);
class_addpointer
(
getsize_class
,
getsize_pointer
);
class_addmethod
(
getsize_class
,
(
t_method
)
getsize_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- setsize ----------------------------- */
...
...
@@ -816,6 +875,12 @@ static void *setsize_new(t_symbol *templatesym, t_symbol *fieldsym,
return
(
x
);
}
static
void
setsize_set
(
t_setsize
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
fieldsym
)
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_fieldsym
=
fieldsym
;
}
static
void
setsize_float
(
t_setsize
*
x
,
t_float
f
)
{
int
nitems
,
onset
,
type
;
...
...
@@ -944,6 +1009,9 @@ static void setsize_setup(void)
(
t_method
)
setsize_free
,
sizeof
(
t_setsize
),
0
,
A_DEFSYM
,
A_DEFSYM
,
A_DEFFLOAT
,
0
);
class_addfloat
(
setsize_class
,
setsize_float
);
class_addmethod
(
setsize_class
,
(
t_method
)
setsize_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- append ----------------------------- */
...
...
@@ -970,19 +1038,21 @@ static void *append_new(t_symbol *why, int argc, t_atom *argv)
t_append
*
x
=
(
t_append
*
)
pd_new
(
append_class
);
int
i
;
t_appendvariable
*
sp
;
int
varcount
;
x
->
x_templatesym
=
canvas_makebindsym
(
atom_getsymbolarg
(
0
,
argc
,
argv
));
if
(
argc
)
argc
--
,
argv
++
;
varcount
=
argc
?
argc
:
1
;
/* have at least one variable */
x
->
x_variables
=
(
t_appendvariable
*
)
getbytes
(
ar
g
c
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nin
=
ar
g
c
;
if
(
argc
)
=
(
t_appendvariable
*
)
getbytes
(
v
arc
ount
*
sizeof
(
*
x
->
x_variables
));
x
->
x_nin
=
v
arc
ount
;
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
argc
;
i
++
,
sp
++
)
{
for
(
i
=
0
,
sp
=
x
->
x_variables
;
i
<
argc
;
i
++
,
sp
++
)
{
if
(
argc
)
sp
->
gv_sym
=
atom_getsymbolarg
(
i
,
argc
,
argv
);
sp
->
gv_f
=
0
;
if
(
i
)
floatinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_f
);
}
else
sp
->
gv_sym
=
&
s_
;
sp
->
gv_f
=
0
;
if
(
i
)
floatinlet_new
(
&
x
->
x_obj
,
&
sp
->
gv_f
);
}
pointerinlet_new
(
&
x
->
x_obj
,
&
x
->
x_gp
);
outlet_new
(
&
x
->
x_obj
,
&
s_pointer
);
...
...
@@ -990,6 +1060,21 @@ static void *append_new(t_symbol *why, int argc, t_atom *argv)
return
(
x
);
}
static
void
append_set
(
t_append
*
x
,
t_symbol
*
templatesym
,
t_symbol
*
field
)
{
if
(
x
->
x_nin
!=
1
)
{
pd_error
(
x
,
"set: cannot set multiple fields."
);
return
;
}
else
{
x
->
x_templatesym
=
canvas_makebindsym
(
templatesym
);
x
->
x_variables
->
gv_sym
=
field
;
x
->
x_variables
->
gv_f
=
0
;
}
}
static
void
append_float
(
t_append
*
x
,
t_float
f
)
{
int
nitems
=
x
->
x_nin
,
i
;
...
...
@@ -1070,6 +1155,8 @@ static void append_setup(void)
append_class
=
class_new
(
gensym
(
"append"
),
(
t_newmethod
)
append_new
,
(
t_method
)
append_free
,
sizeof
(
t_append
),
0
,
A_GIMME
,
0
);
class_addfloat
(
append_class
,
append_float
);
class_addmethod
(
append_class
,
(
t_method
)
append_set
,
gensym
(
"set"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
}
/* ---------------------- sublist ----------------------------- */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment