3353 lines · 118.4 KB · C++
RawDownload
/*----------------------------------------------------------------------------  ChucK Concurrent, On-the-fly Audio Programming Language    Compiler and Virtual Machine   Copyright (c) 2004 Ge Wang and Perry R. Cook.  All rights reserved.    http://chuck.stanford.edu/    http://chuck.cs.princeton.edu/   This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.   This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.   You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  U.S.A.-----------------------------------------------------------------------------*/ //-----------------------------------------------------------------------------// file: chuck_globals.cpp// desc: system to support in-language globals; added 1.4.1.0//// author: Jack Atherton (lja@ccrma.stanford.edu)//         Ge Wang (ge@ccrma.stanford.edu)// date: Spring 2021//-----------------------------------------------------------------------------#include "chuck_globals.h"#include "chuck_vm.h"#include "chuck_instr.h"      //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Int_Request// desc: container for messages to set global ints (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Int_Request{    std::string name;    t_CKINT val;    // constructor    Chuck_Set_Global_Int_Request() : val(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Int_Request// desc: container for messages to get global ints (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Int_Request{    std::string name;    union {        void (* cb_with_name)(const char *, t_CKINT);        void (* cb_with_id)(t_CKINT, t_CKINT);        void (* cb)(t_CKINT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Int_Request() : cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Float_Request// desc: container for messages to set global floats (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Float_Request{    std::string name;    t_CKFLOAT val;    // constructor    Chuck_Set_Global_Float_Request() : val(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Float_Request// desc: container for messages to get global floats (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Float_Request{    std::string name;    union {        void (* cb_with_name)(const char *, t_CKFLOAT);        void (* cb_with_id)(t_CKINT, t_CKFLOAT);        void (* cb)(t_CKFLOAT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Float_Request() : cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Signal_Global_Event_Request// desc: container for messages to signal global events (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Signal_Global_Event_Request{    std::string name;    t_CKBOOL is_broadcast;    // constructor    Chuck_Signal_Global_Event_Request() : is_broadcast(TRUE) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Listen_For_Global_Event_Request// desc: container for messages to wait on global events (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Listen_For_Global_Event_Request{    std::string name;    t_CKBOOL listen_forever;    t_CKBOOL deregister;    union {        void (* cb_with_name)(const char *);        void (* cb_with_id)(t_CKINT);        void (* cb)(void);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Listen_For_Global_Event_Request() : listen_forever(FALSE),    deregister(FALSE), cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_String_Request// desc: container for messages to set global strings (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_String_Request{    std::string name;    std::string val;    // constructor    Chuck_Set_Global_String_Request() { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_String_Request// desc: container for messages to get global strings (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_String_Request{    std::string name;    union {        void (* cb_with_name)(const char *, const char *);        void (* cb_with_id)(t_CKINT, const char *);        void (* cb)(const char *);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_String_Request() : cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Int_Array_Request// desc: container for messages to set global int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Int_Array_Request{    std::string name;    std::vector< t_CKINT > arrayValues;    // constructor    Chuck_Set_Global_Int_Array_Request() { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Int_Array_Request// desc: container for messages to get global int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Int_Array_Request{    std::string name;    union {        void (* cb_with_name)(const char *, t_CKINT[], t_CKUINT);        void (* cb_with_id)(t_CKINT, t_CKINT[], t_CKUINT);        void (* cb)(t_CKINT[], t_CKUINT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Int_Array_Request() : cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Int_Array_Value_Request// desc: container for messages to set individual elements of int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Int_Array_Value_Request{    std::string name;    t_CKUINT index;    t_CKINT value;    // constructor    Chuck_Set_Global_Int_Array_Value_Request() : index(-1), value(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Int_Array_Value_Request// desc: container for messages to get individual elements of int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Int_Array_Value_Request{    std::string name;    t_CKUINT index;    union {        void (* cb_with_name)(const char *, t_CKINT);        void (* cb_with_id)(t_CKINT, t_CKINT);        void (* cb)(t_CKINT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Int_Array_Value_Request() : index(-1), cb(NULL),    cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Associative_Int_Array_Value_Request// desc: container for messages to set elements of associative int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Associative_Int_Array_Value_Request{    std::string name;    std::string key;    t_CKINT value;    // constructor    Chuck_Set_Global_Associative_Int_Array_Value_Request() : value(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Associative_Int_Array_Value_Request// desc: container for messages to get elements of associative int arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Associative_Int_Array_Value_Request{    std::string name;    std::string key;    union {        void (* cb_with_name)(const char *, t_CKINT);        void (* cb_with_id)(t_CKINT, t_CKINT);        void (* cb)(t_CKINT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Associative_Int_Array_Value_Request() : cb(NULL),    cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Float_Array_Request// desc: container for messages to set global float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Float_Array_Request{    std::string name;    std::vector< t_CKFLOAT > arrayValues;    // constructor    Chuck_Set_Global_Float_Array_Request() { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Float_Array_Request// desc: container for messages to get global float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Float_Array_Request{    std::string name;    union {        void (* cb_with_name)(const char *, t_CKFLOAT[], t_CKUINT);        void (* cb_with_id)(t_CKINT, t_CKFLOAT[], t_CKUINT);        void (* cb)(t_CKFLOAT[], t_CKUINT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Float_Array_Request() : cb(NULL), cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Float_Array_Value_Request// desc: container for messages to set individual elements of float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Float_Array_Value_Request{    std::string name;    t_CKUINT index;    t_CKFLOAT value;    // constructor    Chuck_Set_Global_Float_Array_Value_Request() : index(-1), value(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Float_Array_Value_Request// desc: container for messages to get individual elements of float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Float_Array_Value_Request{    std::string name;    t_CKUINT index;    union {        void (* cb_with_name)(const char *, t_CKFLOAT);        void (* cb_with_id)(t_CKINT, t_CKFLOAT);        void (* cb)(t_CKFLOAT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Float_Array_Value_Request() : index(-1), cb(NULL),    cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Set_Global_Associative_Float_Array_Value_Request// desc: container for messages to set elements of associative float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Set_Global_Associative_Float_Array_Value_Request{    std::string name;    std::string key;    t_CKFLOAT value;    // constructor    Chuck_Set_Global_Associative_Float_Array_Value_Request() : value(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Get_Global_Associative_Float_Array_Value_Request// desc: container for messages to get elements of associative float arrays (REFACTOR-2017)//-----------------------------------------------------------------------------struct Chuck_Get_Global_Associative_Float_Array_Value_Request{    std::string name;    std::string key;    union {        void (* cb_with_name)(const char *, t_CKFLOAT);        void (* cb_with_id)(t_CKINT, t_CKFLOAT);        void (* cb)(t_CKFLOAT);    };    Chuck_Global_Get_Callback_Type cb_type;    t_CKINT id;    // constructor    Chuck_Get_Global_Associative_Float_Array_Value_Request() : cb(NULL),    cb_type(ck_get_plain), id(0) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Execute_Chuck_Msg_Request// desc: container for Chuck_Msg (but to be called from the globals callback//       rather than the Chuck_Msg callback)//-----------------------------------------------------------------------------struct Chuck_Execute_Chuck_Msg_Request{    Chuck_Msg * msg;    // constructor    Chuck_Execute_Chuck_Msg_Request() : msg(NULL) { }};    //-----------------------------------------------------------------------------// name: struct Chuck_Global_Int_Container// desc: container for global ints//-----------------------------------------------------------------------------struct Chuck_Global_Int_Container{    t_CKINT val;     Chuck_Global_Int_Container() { val = 0; }};    //-----------------------------------------------------------------------------// name: struct Chuck_Global_Float_Container// desc: container for global floats//-----------------------------------------------------------------------------struct Chuck_Global_Float_Container{    t_CKFLOAT val;     Chuck_Global_Float_Container() { val = 0; }};    //-----------------------------------------------------------------------------// name: struct Chuck_Global_String_Container// desc: container for global ints//-----------------------------------------------------------------------------struct Chuck_Global_String_Container{    Chuck_String * val;     Chuck_Global_String_Container() { val = NULL; }};    //-----------------------------------------------------------------------------// name: struct Chuck_Global_Event_Container// desc: container for global events//-----------------------------------------------------------------------------struct Chuck_Global_Event_Container{    Chuck_Event * val;    Chuck_Type * type;    t_CKBOOL ctor_needs_to_be_called;     Chuck_Global_Event_Container() { val = NULL; type = NULL;        ctor_needs_to_be_called = TRUE; }};    //-----------------------------------------------------------------------------// name: struct Chuck_Global_UGen_Container// desc: container for global ugens//-----------------------------------------------------------------------------struct Chuck_Global_UGen_Container{    Chuck_UGen * val;    Chuck_Type * type;    t_CKBOOL ctor_needs_to_be_called; 

Lines 1–500 of 3353.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t