aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vasp/source/ops_assign.cpp
blob: 1d08a373cac58c03311e20fe5d18b9e77f72fc6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* 

VASP modular - vector assembling signal processor / objects for Max/MSP and PD

Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.  

*/

#include "main.h"
#include "ops_assign.h"
#include "opdefs.h"


VASP_BINARY("vasp.set vasp.=",set,false,VASP_ARG_R(0),"Assigns a value, envelope or vasp")
VASP_BINARY("vasp.cset vasp.c=",cset,false,VASP_ARG_R(0),"Assigns a complex value, real envelope or vasp")



Vasp *VaspOp::m_copy(OpParam &p,CVasp &src,CVasp &arg) 
{ 
	Vasp *s = NULL,*d = NULL;
	RVecBlock *vecs = GetRVecs(p.opname,src,&arg);
	if(vecs) {
		d = DoOp(vecs,VecOp::d_copy,p);
		s = vecs->SrcVasp();
		if(d) arg = *d; else { arg.Clear(); delete d; }
		delete vecs;
	}
	return s;
}

Vasp *VaspOp::m_ccopy(OpParam &p,CVasp &src,CVasp &arg) 
{ 
	Vasp *s = NULL,*d = NULL;
	CVecBlock *vecs = GetCVecs(p.opname,src,&arg);
	if(vecs) {
		d = DoOp(vecs,VecOp::d_ccopy,p);
		s = vecs->SrcVasp();
		if(d) arg = *d; else { arg.Clear(); delete d; }
		delete vecs;
	}
	return s;
}


class vasp_copy:
	public vasp_anyop
{																				
	FLEXT_HEADER(vasp_copy,vasp_anyop)
public:			
	
	vasp_copy(I argc,const t_atom *argv): vasp_anyop(argc,argv,VASP_ARG(),true,XletCode(xlet::tp_any,0)) {}

	virtual V m_to(I,const t_atom *) { post("s - destination vasp is ignored!",thisName()); }

	virtual Vasp *do_copy(OpParam &p,CVasp &dst) { CVasp cref(ref); return VaspOp::m_copy(p,cref,dst); }
		
	virtual Vasp *tx_work(const Argument &arg) 
	{ 
		OpParam p(thisName(),0);													
		
		if(arg.CanbeVasp()) {
			CVasp dst(arg.GetAVasp());
			Vasp *ret = do_copy(p,dst);
			ToOutVasp(1,dst);
			return ret;
		}
		else {
			post("%s - argument is not a valid vasp!",thisName());  // \todo check earlier!
			return NULL;
		}
	}

	virtual V m_help() { post("%s - Copies the triggering vasp to the argument vasp",thisName()); }
};																				
FLEXT_LIB_V("vasp, vasp.copy vasp.->",vasp_copy)


class vasp_ccopy:
	public vasp_copy
{																				
	FLEXT_HEADER(vasp_ccopy,vasp_copy)
public:			
	
	vasp_ccopy(I argc,const t_atom *argv): vasp_copy(argc,argv) {}

	virtual Vasp *do_copy(OpParam &p,CVasp &dst) { CVasp cref(ref); return VaspOp::m_ccopy(p,cref,dst); }

	virtual V m_help() { post("%s - Copies complex pairs of the triggering vasp to the argument vasp",thisName()); }
};																				
FLEXT_LIB_V("vasp, vasp.ccopy vasp.c->",vasp_ccopy)