cwFlowTypes.h/cpp,cwFlow.cpp,cwFlowNet.cpp : Move global variables from network_t to flow_t.
This commit is contained in:
parent
893fcd02d5
commit
aa12a4b9b3
12
cwFlow.cpp
12
cwFlow.cpp
@ -746,6 +746,18 @@ namespace cw
|
|||||||
|
|
||||||
network_destroy(p->net);
|
network_destroy(p->net);
|
||||||
|
|
||||||
|
global_var_t* gv=p->globalVarL;
|
||||||
|
while( gv != nullptr )
|
||||||
|
{
|
||||||
|
global_var_t* gv0 = gv->link;
|
||||||
|
mem::release(gv->var_label);
|
||||||
|
mem::release(gv->blob);
|
||||||
|
mem::release(gv);
|
||||||
|
gv = gv0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_release_class_desc_array(p->classDescA,p->classDescN);
|
_release_class_desc_array(p->classDescA,p->classDescN);
|
||||||
_release_class_desc_array(p->udpDescA,p->udpDescN);
|
_release_class_desc_array(p->udpDescA,p->udpDescN);
|
||||||
mem::release(p->presetA);
|
mem::release(p->presetA);
|
||||||
|
@ -170,16 +170,6 @@ namespace cw
|
|||||||
mem::release(net->preset_pairA);
|
mem::release(net->preset_pairA);
|
||||||
net->preset_pairN = 0;
|
net->preset_pairN = 0;
|
||||||
|
|
||||||
net_global_var_t* gv=net->globalVarL;
|
|
||||||
while( gv != nullptr )
|
|
||||||
{
|
|
||||||
net_global_var_t* gv0 = gv->link;
|
|
||||||
mem::release(gv->var_label);
|
|
||||||
mem::release(gv->blob);
|
|
||||||
mem::release(gv);
|
|
||||||
gv = gv0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_destroy_ui_net(net->ui_net);
|
_destroy_ui_net(net->ui_net);
|
||||||
|
|
||||||
mem::release(net);
|
mem::release(net);
|
||||||
|
108
cwFlowTypes.cpp
108
cwFlowTypes.cpp
@ -641,6 +641,20 @@ void cw::flow::class_dict_print( flow_t* p )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cw::flow::external_device_t* cw::flow::external_device_find( flow_t* p, const char* device_label, unsigned typeId, unsigned inOrOutFl, const char* midiPortLabel )
|
||||||
|
{
|
||||||
|
for(unsigned i=0; i<p->deviceN; ++i)
|
||||||
|
if( (device_label==nullptr || cw::textIsEqual(p->deviceA[i].devLabel,device_label))
|
||||||
|
&& p->deviceA[i].typeId==typeId
|
||||||
|
&& cwIsFlag(p->deviceA[i].flags,inOrOutFl)
|
||||||
|
&& (midiPortLabel==nullptr || cw::textIsEqual(p->deviceA[i].portLabel,midiPortLabel)) )
|
||||||
|
return p->deviceA + i;
|
||||||
|
|
||||||
|
cwLogError(kInvalidArgRC,"The %s device named '%s' could not be found.", cwIsFlag(inOrOutFl,kInFl) ? "in" : "out", device_label );
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void cw::flow::network_print( const network_t& net )
|
void cw::flow::network_print( const network_t& net )
|
||||||
{
|
{
|
||||||
// for each proc in the network
|
// for each proc in the network
|
||||||
@ -689,51 +703,6 @@ void cw::flow::network_print( const network_t& net )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* cw::flow::network_global_var( proc_t* proc, const char* var_label )
|
|
||||||
{
|
|
||||||
net_global_var_t* gv;
|
|
||||||
|
|
||||||
assert( proc->net != nullptr );
|
|
||||||
|
|
||||||
for(gv=proc->net->globalVarL; gv!=nullptr; gv=gv->link )
|
|
||||||
if( textIsEqual(proc->class_desc->label,gv->class_label) && textIsEqual(gv->var_label,var_label) )
|
|
||||||
return gv->blob;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
cw::rc_t cw::flow::network_global_var_alloc( proc_t* proc, const char* var_label, const void* blob, unsigned blobByteN )
|
|
||||||
{
|
|
||||||
rc_t rc = kOkRC;
|
|
||||||
net_global_var_t* gv;
|
|
||||||
void* v;
|
|
||||||
|
|
||||||
unsigned allocWordN = 0;
|
|
||||||
|
|
||||||
if((v = network_global_var(proc,var_label)) != nullptr )
|
|
||||||
{
|
|
||||||
rc = cwLogError(kInvalidArgRC,"The global variable '%s:%s' already exists.",cwStringNullGuard(proc->class_desc->label),cwStringNullGuard(var_label));
|
|
||||||
goto errLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
gv = mem::allocZ<net_global_var_t>();
|
|
||||||
|
|
||||||
allocWordN = std::max(blobByteN/sizeof(unsigned),1ul);
|
|
||||||
|
|
||||||
gv->class_label = proc->class_desc->label;
|
|
||||||
gv->var_label = mem::duplStr(var_label);
|
|
||||||
gv->blob = mem::allocZ<unsigned>(allocWordN);
|
|
||||||
gv->blobByteN = blobByteN;
|
|
||||||
memcpy(gv->blob,blob,blobByteN);
|
|
||||||
|
|
||||||
gv->link = proc->net->globalVarL;
|
|
||||||
proc->net->globalVarL = gv;
|
|
||||||
|
|
||||||
errLabel:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const cw::flow::network_preset_t* cw::flow::network_preset_from_label( const network_t& net, const char* preset_label )
|
const cw::flow::network_preset_t* cw::flow::network_preset_from_label( const network_t& net, const char* preset_label )
|
||||||
{
|
{
|
||||||
for(unsigned i=0; i<net.presetN; ++i)
|
for(unsigned i=0; i<net.presetN; ++i)
|
||||||
@ -886,20 +855,51 @@ cw::rc_t cw::flow::proc_find( network_t& net, const char* proc_label, unsigned s
|
|||||||
return cwLogError(kInvalidArgRC,"The proc '%s:%i' was not found.", proc_label, sfx_id );
|
return cwLogError(kInvalidArgRC,"The proc '%s:%i' was not found.", proc_label, sfx_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
cw::flow::external_device_t* cw::flow::external_device_find( flow_t* p, const char* device_label, unsigned typeId, unsigned inOrOutFl, const char* midiPortLabel )
|
void* cw::flow::global_var( proc_t* proc, const char* var_label )
|
||||||
{
|
{
|
||||||
for(unsigned i=0; i<p->deviceN; ++i)
|
global_var_t* gv;
|
||||||
if( (device_label==nullptr || cw::textIsEqual(p->deviceA[i].devLabel,device_label))
|
|
||||||
&& p->deviceA[i].typeId==typeId
|
|
||||||
&& cwIsFlag(p->deviceA[i].flags,inOrOutFl)
|
|
||||||
&& (midiPortLabel==nullptr || cw::textIsEqual(p->deviceA[i].portLabel,midiPortLabel)) )
|
|
||||||
return p->deviceA + i;
|
|
||||||
|
|
||||||
cwLogError(kInvalidArgRC,"The %s device named '%s' could not be found.", cwIsFlag(inOrOutFl,kInFl) ? "in" : "out", device_label );
|
assert( proc->net != nullptr );
|
||||||
|
|
||||||
|
for(gv=proc->ctx->globalVarL; gv!=nullptr; gv=gv->link )
|
||||||
|
if( textIsEqual(proc->class_desc->label,gv->class_label) && textIsEqual(gv->var_label,var_label) )
|
||||||
|
return gv->blob;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::global_var_alloc( proc_t* proc, const char* var_label, const void* blob, unsigned blobByteN )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
global_var_t* gv;
|
||||||
|
void* v;
|
||||||
|
|
||||||
|
unsigned allocWordN = 0;
|
||||||
|
|
||||||
|
if((v = global_var(proc,var_label)) != nullptr )
|
||||||
|
{
|
||||||
|
rc = cwLogError(kInvalidArgRC,"The global variable '%s:%s' already exists.",cwStringNullGuard(proc->class_desc->label),cwStringNullGuard(var_label));
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
gv = mem::allocZ<global_var_t>();
|
||||||
|
|
||||||
|
allocWordN = std::max(blobByteN/sizeof(unsigned),1ul);
|
||||||
|
|
||||||
|
gv->class_label = proc->class_desc->label;
|
||||||
|
gv->var_label = mem::duplStr(var_label);
|
||||||
|
gv->blob = mem::allocZ<unsigned>(allocWordN);
|
||||||
|
gv->blobByteN = blobByteN;
|
||||||
|
memcpy(gv->blob,blob,blobByteN);
|
||||||
|
|
||||||
|
gv->link = proc->ctx->globalVarL;
|
||||||
|
proc->ctx->globalVarL = gv;
|
||||||
|
|
||||||
|
errLabel:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cw::flow::proc_print( proc_t* proc )
|
void cw::flow::proc_print( proc_t* proc )
|
||||||
{
|
{
|
||||||
cwLogPrint("%s:%i\n", proc->label,proc->label_sfx_id);
|
cwLogPrint("%s:%i\n", proc->label,proc->label_sfx_id);
|
||||||
@ -936,8 +936,6 @@ char* cw::flow::proc_expand_filename( const proc_t* proc, const char* fname )
|
|||||||
return fn1;
|
return fn1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw::rc_t cw::flow::var_create( proc_t* proc, const char* var_label, unsigned sfx_id, unsigned id, unsigned chIdx, const object_t* value_cfg, unsigned altTypeFl, variable_t*& varRef )
|
cw::rc_t cw::flow::var_create( proc_t* proc, const char* var_label, unsigned sfx_id, unsigned id, unsigned chIdx, const object_t* value_cfg, unsigned altTypeFl, variable_t*& varRef )
|
||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
|
@ -184,16 +184,16 @@ namespace cw
|
|||||||
const value_t* value; //
|
const value_t* value; //
|
||||||
} network_preset_pair_t;
|
} network_preset_pair_t;
|
||||||
|
|
||||||
typedef struct net_global_var_str
|
typedef struct global_var_str
|
||||||
{
|
{
|
||||||
const char* class_label;
|
const char* class_label;
|
||||||
char* var_label;
|
char* var_label;
|
||||||
void* blob;
|
void* blob;
|
||||||
unsigned blobByteN;
|
unsigned blobByteN;
|
||||||
|
|
||||||
struct net_global_var_str* link;
|
struct global_var_str* link;
|
||||||
|
|
||||||
} net_global_var_t;
|
} global_var_t;
|
||||||
|
|
||||||
typedef struct network_str
|
typedef struct network_str
|
||||||
{
|
{
|
||||||
@ -210,8 +210,6 @@ namespace cw
|
|||||||
network_preset_pair_t* preset_pairA;
|
network_preset_pair_t* preset_pairA;
|
||||||
unsigned preset_pairN;
|
unsigned preset_pairN;
|
||||||
|
|
||||||
net_global_var_t* globalVarL;
|
|
||||||
|
|
||||||
struct network_str* poly_link;
|
struct network_str* poly_link;
|
||||||
unsigned poly_idx;
|
unsigned poly_idx;
|
||||||
|
|
||||||
@ -266,6 +264,8 @@ namespace cw
|
|||||||
variable_t ui_var_stub;
|
variable_t ui_var_stub;
|
||||||
variable_t* ui_var_tail;
|
variable_t* ui_var_tail;
|
||||||
|
|
||||||
|
global_var_t* globalVarL;
|
||||||
|
|
||||||
} flow_t;
|
} flow_t;
|
||||||
|
|
||||||
|
|
||||||
@ -293,20 +293,22 @@ namespace cw
|
|||||||
|
|
||||||
const class_preset_t* class_preset_find( const class_desc_t* cd, const char* preset_label );
|
const class_preset_t* class_preset_find( const class_desc_t* cd, const char* preset_label );
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Flow
|
||||||
|
//
|
||||||
|
|
||||||
void class_dict_print( flow_t* p );
|
void class_dict_print( flow_t* p );
|
||||||
|
|
||||||
|
external_device_t* external_device_find( flow_t* p, const char* device_label, unsigned typeId, unsigned inOrOutFl, const char* midiPortLabel=nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Network
|
// Network
|
||||||
//
|
//
|
||||||
|
|
||||||
// Access a blob stored via network_global_var()
|
|
||||||
void* network_global_var( proc_t* proc, const char* var_label );
|
|
||||||
|
|
||||||
// Copy a named blob into the network global variable space.
|
|
||||||
rc_t network_global_var_alloc( proc_t* proc, const char* var_label, const void* blob, unsigned blobByteN );
|
|
||||||
|
|
||||||
|
|
||||||
void network_print(const network_t& net );
|
void network_print(const network_t& net );
|
||||||
|
|
||||||
@ -330,7 +332,12 @@ namespace cw
|
|||||||
proc_t* proc_find( network_t& net, const char* proc_label, unsigned sfx_id );
|
proc_t* proc_find( network_t& net, const char* proc_label, unsigned sfx_id );
|
||||||
rc_t proc_find( network_t& net, const char* proc_label, unsigned sfx_id, proc_t*& procPtrRef );
|
rc_t proc_find( network_t& net, const char* proc_label, unsigned sfx_id, proc_t*& procPtrRef );
|
||||||
|
|
||||||
external_device_t* external_device_find( flow_t* p, const char* device_label, unsigned typeId, unsigned inOrOutFl, const char* midiPortLabel=nullptr );
|
|
||||||
|
// Access a blob stored via global_var()
|
||||||
|
void* global_var( proc_t* proc, const char* var_label );
|
||||||
|
|
||||||
|
// Copy a named blob into the network global variable space.
|
||||||
|
rc_t global_var_alloc( proc_t* proc, const char* var_label, const void* blob, unsigned blobByteN );
|
||||||
|
|
||||||
void proc_print( proc_t* proc );
|
void proc_print( proc_t* proc );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user