1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // name: chuck_lang.cpp
27 // desc: chuck class library base
29 // authors: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
32 //-----------------------------------------------------------------------------
33 #include "chuck_lang.h"
34 #include "chuck_type.h"
35 #include "chuck_instr.h"
37 #include "chuck_errmsg.h"
38 #include "chuck_ugen.h"
39 #include "midiio_rtmidi.h"
40 #include "hidio_sdl.h"
41 #include "util_string.h"
49 CK_DLL_TICK(__ugen_tick
) { *out
= in
; return TRUE
; }
50 // object string offset
51 static t_CKUINT Object_offset_string
= 0;
54 //-----------------------------------------------------------------------------
55 // name: init_class_object()
57 //-----------------------------------------------------------------------------
58 t_CKBOOL
init_class_object( Chuck_Env
* env
, Chuck_Type
* type
)
60 Chuck_DL_Func
* func
= NULL
;
63 EM_log( CK_LOG_SEVERE
, "class 'object'" );
66 if( !type_engine_import_class_begin( env
, type
, env
->global(), object_ctor
, object_dtor
) )
69 // add member to hold string
70 Object_offset_string
= type_engine_import_mvar( env
, "string", "@string", FALSE
);
71 if( Object_offset_string
== CK_INVALID_OFFSET
) goto error
;
74 func
= make_new_mfun( "string", "toString", object_toString
);
75 if( !type_engine_import_mfun( env
, func
) ) goto error
;
77 // end the class import
78 type_engine_import_class_end( env
);
84 // end the class import
85 type_engine_import_class_end( env
);
93 //-----------------------------------------------------------------------------
94 // name: init_class_ugen()
96 //-----------------------------------------------------------------------------
97 t_CKBOOL
init_class_ugen( Chuck_Env
* env
, Chuck_Type
* type
)
99 Chuck_DL_Func
* func
= NULL
;
101 EM_log( CK_LOG_SEVERE
, "class 'ugen'" );
104 type
->ugen_info
= new Chuck_UGen_Info
;
105 type
->ugen_info
->add_ref();
106 type
->ugen_info
->tick
= __ugen_tick
;
107 type
->ugen_info
->num_ins
= 1;
108 type
->ugen_info
->num_outs
= 1;
110 // init as base class
111 // TODO: ctor/dtor, ugen's sometimes created internally?
112 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
116 func
= make_new_mfun( "float", "gain", ugen_gain
);
117 func
->add_arg( "float", "val" );
118 if( !type_engine_import_mfun( env
, func
) ) goto error
;
119 func
= make_new_mfun( "float", "gain", ugen_cget_gain
);
120 if( !type_engine_import_mfun( env
, func
) ) goto error
;
123 func = make_new_mfun( "float", "next", ugen_next );
124 func->add_arg( "float", "val" );
125 if( !type_engine_import_mfun( env, func ) ) goto error;
126 func = make_new_mfun( "float", "next", ugen_cget_next );
127 if( !type_engine_import_mfun( env, func ) ) goto error;
130 func
= make_new_mfun( "float", "last", ugen_last
);
131 if( !type_engine_import_mfun( env
, func
) ) goto error
;
134 func
= make_new_mfun( "int", "op", ugen_op
);
135 func
->add_arg( "int", "val" );
136 if( !type_engine_import_mfun( env
, func
) ) goto error
;
137 func
= make_new_mfun( "int", "op", ugen_cget_op
);
138 if( !type_engine_import_mfun( env
, func
) ) goto error
;
141 func
= make_new_mfun( "int", "channels", ugen_numChannels
);
142 func
->add_arg( "int", "num" );
143 if( !type_engine_import_mfun( env
, func
) ) goto error
;
144 func
= make_new_mfun( "int", "channels", ugen_cget_numChannels
);
145 if( !type_engine_import_mfun( env
, func
) ) goto error
;
148 func
= make_new_mfun( "UGen", "chan", ugen_chan
);
149 func
->add_arg( "int", "num" );
150 if( !type_engine_import_mfun( env
, func
) ) goto error
;
153 func
= make_new_mfun( "int", "isConnectedTo", ugen_connected
);
154 func
->add_arg( "UGen", "right" );
155 if( !type_engine_import_mfun( env
, func
) ) goto error
;
158 type_engine_import_class_end( env
);
164 // end the class import
165 type_engine_import_class_end( env
);
173 // virtual table offset
174 static t_CKINT uana_offset_blob
= 0;
175 //-----------------------------------------------------------------------------
176 // name: init_class_uana()
178 //-----------------------------------------------------------------------------
179 t_CKBOOL
init_class_uana( Chuck_Env
* env
, Chuck_Type
* type
)
181 Chuck_DL_Func
* func
= NULL
;
183 EM_log( CK_LOG_SEVERE
, "class 'uana'" );
186 type
->ugen_info
= new Chuck_UGen_Info
;
187 type
->ugen_info
->add_ref();
188 type
->ugen_info
->tick
= __ugen_tick
;
189 type
->ugen_info
->num_ins
= 1;
190 type
->ugen_info
->num_outs
= 1;
192 // init as base class, type should already know the parent type
193 // TODO: ctor/dtor, ugen's sometimes created internally?
194 if( !type_engine_import_class_begin( env
, type
, env
->global(), uana_ctor
, uana_dtor
) )
198 uana_offset_blob
= type_engine_import_mvar( env
, "UAnaBlob", "m_blob", FALSE
);
199 if( uana_offset_blob
== CK_INVALID_OFFSET
) goto error
;
202 func
= make_new_mfun( "UAnaBlob", "upchuck", uana_upchuck
);
203 if( !type_engine_import_mfun( env
, func
) ) goto error
;
206 func
= make_new_mfun( "float[]", "fvals", uana_fvals
);
207 if( !type_engine_import_mfun( env
, func
) ) goto error
;
210 func
= make_new_mfun( "complex[]", "cvals", uana_cvals
);
211 if( !type_engine_import_mfun( env
, func
) ) goto error
;
214 func
= make_new_mfun( "float", "fval", uana_fval
);
215 func
->add_arg( "int", "index" );
216 if( !type_engine_import_mfun( env
, func
) ) goto error
;
219 func
= make_new_mfun( "complex", "cval", uana_cval
);
220 func
->add_arg( "int", "index" );
221 if( !type_engine_import_mfun( env
, func
) ) goto error
;
223 // TODO: add nonchuck
224 // func = make_new_mfun( "void", "nonchuck", uana_nonchuck );
225 // if( !type_engine_import_mfun( env, func ) ) goto error;
228 // func = make_new_mfun( "Event", "event", uana_event );
229 // if( !type_engine_import_mfun( env, func ) ) goto error;
232 type_engine_import_class_end( env
);
238 // end the class import
239 type_engine_import_class_end( env
);
247 // virtual table offset
248 static t_CKINT uanablob_offset_when
= 0;
249 static t_CKINT uanablob_offset_fvals
= 0;
250 static t_CKINT uanablob_offset_cvals
= 0;
251 //-----------------------------------------------------------------------------
252 // name: init_class_blob()
254 //-----------------------------------------------------------------------------
255 t_CKBOOL
init_class_blob( Chuck_Env
* env
, Chuck_Type
* type
)
257 Chuck_DL_Func
* func
= NULL
;
258 Chuck_Value
* value
= NULL
;
261 EM_log( CK_LOG_SEVERE
, "class 'uanablob'" );
265 if( !type_engine_import_class_begin( env
, type
, env
->global(), uanablob_ctor
, uanablob_dtor
) )
269 uanablob_offset_when
= type_engine_import_mvar( env
, "time", "m_when", FALSE
);
270 if( uanablob_offset_when
== CK_INVALID_OFFSET
) goto error
;
271 uanablob_offset_fvals
= type_engine_import_mvar( env
, "float[]", "m_fvals", FALSE
);
272 if( uanablob_offset_fvals
== CK_INVALID_OFFSET
) goto error
;
273 uanablob_offset_cvals
= type_engine_import_mvar( env
, "complex[]", "m_cvals", FALSE
);
274 if( uanablob_offset_cvals
== CK_INVALID_OFFSET
) goto error
;
277 func
= make_new_mfun( "time", "when", uanablob_when
);
278 if( !type_engine_import_mfun( env
, func
) ) goto error
;
281 func
= make_new_mfun( "float[]", "fvals", uanablob_fvals
);
282 if( !type_engine_import_mfun( env
, func
) ) goto error
;
285 func
= make_new_mfun( "complex[]", "cvals", uanablob_cvals
);
286 if( !type_engine_import_mfun( env
, func
) ) goto error
;
289 func
= make_new_mfun( "float", "fval", uanablob_fval
);
290 func
->add_arg( "int", "index" );
291 if( !type_engine_import_mfun( env
, func
) ) goto error
;
294 func
= make_new_mfun( "complex", "cval", uanablob_cval
);
295 func
->add_arg( "int", "index" );
296 if( !type_engine_import_mfun( env
, func
) ) goto error
;
299 type_engine_import_class_end( env
);
307 type_engine_import_class_end( env
);
316 // static t_CKUINT event_offset_data = 0;
317 //-----------------------------------------------------------------------------
318 // name: init_class_event()
320 //-----------------------------------------------------------------------------
321 t_CKBOOL
init_class_event( Chuck_Env
* env
, Chuck_Type
* type
)
323 Chuck_DL_Func
* func
= NULL
;
324 Chuck_Value
* value
= NULL
;
327 EM_log( CK_LOG_SEVERE
, "class 'event'" );
329 // init as base class
331 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
335 func
= make_new_mfun( "void", "signal", event_signal
);
336 if( !type_engine_import_mfun( env
, func
) ) goto error
;
339 func
= make_new_mfun( "void", "broadcast", event_broadcast
);
340 if( !type_engine_import_mfun( env
, func
) ) goto error
;
343 func
= make_new_mfun( "void", "wait", event_wait
);
344 func
->add_arg( "Shred", "me" );
345 if( !type_engine_import_mfun( env
, func
) ) goto error
;
348 func
= make_new_mfun( "int", "can_wait", event_can_wait
);
349 if( !type_engine_import_mfun( env
, func
) ) goto error
;
351 // end the class import
352 type_engine_import_class_end( env
);
354 // find the offset for can_wait
355 value
= type_engine_find_value( type
, "can_wait" );
356 assert( value
!= NULL
);
357 assert( value
->func_ref
!= NULL
);
359 Chuck_Event::our_can_wait
= value
->func_ref
->vt_index
;
365 // end the class import
366 type_engine_import_class_end( env
);
374 static t_CKUINT shred_offset_args
= 0;
375 //-----------------------------------------------------------------------------
376 // name: init_class_shred()
378 //-----------------------------------------------------------------------------
379 t_CKBOOL
init_class_shred( Chuck_Env
* env
, Chuck_Type
* type
)
381 // init as base class
382 Chuck_DL_Func
* func
= NULL
;
385 EM_log( CK_LOG_SEVERE
, "class 'shred'" );
387 // init as base class
389 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
396 func
= make_new_mfun( "void", "clone", shred_clone
);
397 if( !type_engine_import_mfun( env
, func
) ) goto error
;
400 func
= make_new_mfun( "void", "exit", shred_exit
);
401 if( !type_engine_import_mfun( env
, func
) ) goto error
;
404 func
= make_new_mfun( "int", "id", shred_id
);
405 if( !type_engine_import_mfun( env
, func
) ) goto error
;
408 func
= make_new_mfun( "void", "yield", shred_yield
);
409 if( !type_engine_import_mfun( env
, func
) ) goto error
;
412 // func = make_new_mfun( "int", "numArgs", shred_numArgs );
413 // if( !type_engine_import_mfun( env, func ) ) goto error;
416 func
= make_new_mfun( "int", "args", shred_numArgs
);
417 if( !type_engine_import_mfun( env
, func
) ) goto error
;
420 // func = make_new_mfun( "string", "getArg", shred_getArg );
421 // func->add_arg( "int", "index" );
422 // if( !type_engine_import_mfun( env, func ) ) goto error;
425 func
= make_new_mfun( "string", "arg", shred_getArg
);
426 func
->add_arg( "int", "index" );
427 if( !type_engine_import_mfun( env
, func
) ) goto error
;
429 // end the class import
430 type_engine_import_class_end( env
);
436 // end the class import
437 type_engine_import_class_end( env
);
445 static t_CKUINT io_offset_args
= 0;
446 //-----------------------------------------------------------------------------
447 // name: init_class_io()
449 //-----------------------------------------------------------------------------
450 t_CKBOOL
init_class_io( Chuck_Env
* env
, Chuck_Type
* type
)
452 // init as base class
453 Chuck_DL_Func
* func
= NULL
;
456 EM_log( CK_LOG_SEVERE
, "class 'io'" );
458 // init as base class
460 // TODO: replace dummy with pure function
461 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
465 func
= make_new_mfun( "int", "more", io_dummy
);
466 if( !type_engine_import_mfun( env
, func
) ) goto error
;
469 func
= make_new_mfun( "int", "eof", io_dummy
);
470 if( !type_engine_import_mfun( env
, func
) ) goto error
;
473 func
= make_new_mfun( "int", "good", io_dummy
);
474 if( !type_engine_import_mfun( env
, func
) ) goto error
;
477 func
= make_new_mfun( "int", "good2read", io_dummy
);
478 if( !type_engine_import_mfun( env
, func
) ) goto error
;
481 func
= make_new_mfun( "int", "good2write", io_dummy
);
482 if( !type_engine_import_mfun( env
, func
) ) goto error
;
485 func
= make_new_mfun( "void", "close", io_dummy
);
486 if( !type_engine_import_mfun( env
, func
) ) goto error
;
489 func
= make_new_mfun( "int", "readInt", io_dummy
);
490 if( !type_engine_import_mfun( env
, func
) ) goto error
;
493 func
= make_new_mfun( "float", "readFloat", io_dummy
);
494 if( !type_engine_import_mfun( env
, func
) ) goto error
;
497 func
= make_new_mfun( "string", "readString", io_dummy
);
498 if( !type_engine_import_mfun( env
, func
) ) goto error
;
501 func
= make_new_mfun( "string", "readLine", io_dummy
);
502 if( !type_engine_import_mfun( env
, func
) ) goto error
;
505 func
= make_new_mfun( "void", "writeInt", io_dummy
);
506 func
->add_arg( "int", "val" );
507 if( !type_engine_import_mfun( env
, func
) ) goto error
;
510 func
= make_new_mfun( "void", "writeFloat", io_dummy
);
511 func
->add_arg( "float", "val" );
512 if( !type_engine_import_mfun( env
, func
) ) goto error
;
515 func
= make_new_mfun( "void", "writeString", io_dummy
);
516 func
->add_arg( "string", "val" );
517 if( !type_engine_import_mfun( env
, func
) ) goto error
;
520 func
= make_new_mfun( "string", "writeLine", io_dummy
);
521 func
->add_arg( "string", "line" );
522 if( !type_engine_import_mfun( env
, func
) ) goto error
;
525 if( !type_engine_import_svar( env
, "int", "READ", TRUE
, (t_CKUINT
)&Chuck_IO::READ
) ) goto error
;
528 if( !type_engine_import_svar( env
, "int", "WRITE", TRUE
, (t_CKUINT
)&Chuck_IO::WRITE
) ) goto error
;
531 if( !type_engine_import_svar( env
, "int", "APPEND", TRUE
, (t_CKUINT
)&Chuck_IO::APPEND
) ) goto error
;
534 if( !type_engine_import_svar( env
, "int", "TRUNCATE", TRUE
, (t_CKUINT
)&Chuck_IO::TRUNCATE
) ) goto error
;
537 if( !type_engine_import_svar( env
, "int", "BINARY", TRUE
, (t_CKUINT
)&Chuck_IO::BINARY
) ) goto error
;
539 // end the class import
540 type_engine_import_class_end( env
);
546 // end the class import
547 type_engine_import_class_end( env
);
555 //-----------------------------------------------------------------------------
556 // name: init_class_fileio()
558 //-----------------------------------------------------------------------------
559 t_CKBOOL
init_class_fileio( Chuck_Env
* env
, Chuck_Type
* type
)
561 // init as base class
562 Chuck_DL_Func
* func
= NULL
;
565 EM_log( CK_LOG_SEVERE
, "class 'fileio'" );
567 // init as base class
569 // TODO: replace dummy with pure function
570 if( !type_engine_import_class_begin( env
, type
, env
->global(), fileio_ctor
, fileio_dtor
) )
574 func
= make_new_mfun( "int", "more", fileio_more
);
575 if( !type_engine_import_mfun( env
, func
) ) goto error
;
578 func
= make_new_mfun( "int", "eof", fileio_eof
);
579 if( !type_engine_import_mfun( env
, func
) ) goto error
;
582 func
= make_new_mfun( "int", "good", fileio_good
);
583 if( !type_engine_import_mfun( env
, func
) ) goto error
;
586 func
= make_new_mfun( "int", "good2read", fileio_good2read
);
587 if( !type_engine_import_mfun( env
, func
) ) goto error
;
590 func
= make_new_mfun( "int", "good2write", fileio_good2write
);
591 if( !type_engine_import_mfun( env
, func
) ) goto error
;
594 func
= make_new_mfun( "void", "close", fileio_close
);
595 if( !type_engine_import_mfun( env
, func
) ) goto error
;
598 func
= make_new_mfun( "int", "readInt", fileio_readint
);
599 if( !type_engine_import_mfun( env
, func
) ) goto error
;
602 func
= make_new_mfun( "float", "readFloat", fileio_readfloat
);
603 if( !type_engine_import_mfun( env
, func
) ) goto error
;
606 func
= make_new_mfun( "string", "readString", fileio_readstring
);
607 if( !type_engine_import_mfun( env
, func
) ) goto error
;
610 func
= make_new_mfun( "string", "readLine", fileio_readline
);
611 if( !type_engine_import_mfun( env
, func
) ) goto error
;
614 func
= make_new_mfun( "void", "writeInt", fileio_writeint
);
615 func
->add_arg( "int", "val" );
616 if( !type_engine_import_mfun( env
, func
) ) goto error
;
619 func
= make_new_mfun( "void", "writeFloat", fileio_writefloat
);
620 func
->add_arg( "float", "val" );
621 if( !type_engine_import_mfun( env
, func
) ) goto error
;
624 func
= make_new_mfun( "void", "writeString", fileio_writestring
);
625 func
->add_arg( "string", "val" );
626 if( !type_engine_import_mfun( env
, func
) ) goto error
;
629 func
= make_new_mfun( "string", "writeLine", fileio_writeline
);
630 func
->add_arg( "string", "line" );
631 if( !type_engine_import_mfun( env
, func
) ) goto error
;
633 // end the class import
634 type_engine_import_class_end( env
);
640 // end the class import
641 type_engine_import_class_end( env
);
649 //-----------------------------------------------------------------------------
650 // name: init_class_string()
652 //-----------------------------------------------------------------------------
653 t_CKBOOL
init_class_string( Chuck_Env
* env
, Chuck_Type
* type
)
655 // init as base class
656 Chuck_DL_Func
* func
= NULL
;
659 EM_log( CK_LOG_SEVERE
, "class 'string'" );
661 // init as base class
663 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
667 func
= make_new_mfun( "int", "length", string_length
);
668 if( !type_engine_import_mfun( env
, func
) ) goto error
;
671 func
= make_new_mfun( "string", "upper", string_upper
);
672 if( !type_engine_import_mfun( env
, func
) ) goto error
;
675 func
= make_new_mfun( "string", "lower", string_lower
);
676 if( !type_engine_import_mfun( env
, func
) ) goto error
;
679 func
= make_new_mfun( "string", "ltrim", string_ltrim
);
680 if( !type_engine_import_mfun( env
, func
) ) goto error
;
683 func
= make_new_mfun( "string", "rtrim", string_rtrim
);
684 if( !type_engine_import_mfun( env
, func
) ) goto error
;
687 func
= make_new_mfun( "string", "trim", string_trim
);
688 if( !type_engine_import_mfun( env
, func
) ) goto error
;
691 func
= make_new_mfun( "string", "toString", string_toString
);
692 if( !type_engine_import_mfun( env
, func
) ) goto error
;
695 func = make_new_mfun( "int", "ch", string_set_at );
696 func->add_arg( "int", "index" );
697 func->add_arg( "int", "val" );
698 if( !type_engine_import_mfun( env, func ) ) goto error;
699 func = make_new_mfun( "int", "ch", string_get_at );
700 func->add_arg( "int", "index" );
701 if( !type_engine_import_mfun( env, func ) ) goto error;
703 // end the class import
704 type_engine_import_class_end( env
);
710 // end the class import
711 type_engine_import_class_end( env
);
719 //-----------------------------------------------------------------------------
720 // name: init_class_array()
722 //-----------------------------------------------------------------------------
723 t_CKBOOL
init_class_array( Chuck_Env
* env
, Chuck_Type
* type
)
725 // init as base class
726 Chuck_DL_Func
* func
= NULL
;
729 EM_log( CK_LOG_SEVERE
, "class 'array'" );
731 // init as base class
733 if( !type_engine_import_class_begin( env
, type
, env
->global(), NULL
, NULL
) )
737 func
= make_new_mfun( "void", "clear", array_clear
);
738 if( !type_engine_import_mfun( env
, func
) ) goto error
;
741 func
= make_new_mfun( "void", "popBack", array_pop_back
);
742 if( !type_engine_import_mfun( env
, func
) ) goto error
;
745 func
= make_new_mfun( "int", "size", array_get_size
);
746 if( !type_engine_import_mfun( env
, func
) ) goto error
;
748 func
= make_new_mfun( "int", "size", array_set_size
);
749 func
->add_arg( "int", "newSize" );
750 if( !type_engine_import_mfun( env
, func
) ) goto error
;
753 func
= make_new_mfun( "int", "cap", array_get_capacity_hack
);
754 if( !type_engine_import_mfun( env
, func
) ) goto error
;
755 //func = make_new_mfun( "int", "cap", array_set_capacity );
756 //func->add_arg( "int", "val" );
757 //if( !type_engine_import_mfun( env, func ) ) goto error;
760 func
= make_new_mfun( "int", "capacity", array_get_capacity
);
761 if( !type_engine_import_mfun( env
, func
) ) goto error
;
764 func
= make_new_mfun( "int", "find", array_find
);
765 func
->add_arg( "string", "key" );
766 if( !type_engine_import_mfun( env
, func
) ) goto error
;
769 func
= make_new_mfun( "int", "erase", array_erase
);
770 func
->add_arg( "string", "key" );
771 if( !type_engine_import_mfun( env
, func
) ) goto error
;
773 type_engine_import_class_end( env
);
779 // end the class import
780 type_engine_import_class_end( env
);
789 static t_CKUINT MidiIn_offset_data
= 0;
790 static t_CKUINT MidiMsg_offset_data1
= 0;
791 static t_CKUINT MidiMsg_offset_data2
= 0;
792 static t_CKUINT MidiMsg_offset_data3
= 0;
793 static t_CKUINT MidiMsg_offset_when
= 0;
794 static t_CKUINT MidiOut_offset_data
= 0;
796 //-----------------------------------------------------------------------------
797 // name: init_class_Midi()
799 //-----------------------------------------------------------------------------
800 t_CKBOOL
init_class_Midi( Chuck_Env
* env
)
802 Chuck_DL_Func
* func
= NULL
;
806 if( !type_engine_import_class_begin( env
, "MidiMsg", "Object",
807 env
->global(), NULL
, NULL
) )
810 // add member variable
811 MidiMsg_offset_data1
= type_engine_import_mvar( env
, "int", "data1", FALSE
);
812 if( MidiMsg_offset_data1
== CK_INVALID_OFFSET
) goto error
;
814 // add member variable
815 MidiMsg_offset_data2
= type_engine_import_mvar( env
, "int", "data2", FALSE
);
816 if( MidiMsg_offset_data2
== CK_INVALID_OFFSET
) goto error
;
818 // add member variable
819 MidiMsg_offset_data3
= type_engine_import_mvar( env
, "int", "data3", FALSE
);
820 if( MidiMsg_offset_data3
== CK_INVALID_OFFSET
) goto error
;
822 // add member variable
823 MidiMsg_offset_when
= type_engine_import_mvar( env
, "time", "when", FALSE
);
824 if( MidiMsg_offset_when
== CK_INVALID_OFFSET
) goto error
;
826 // end the class import
827 type_engine_import_class_end( env
);
831 if( !type_engine_import_class_begin( env
, "MidiIn", "Event",
832 env
->global(), MidiIn_ctor
, MidiIn_dtor
) )
836 func
= make_new_mfun( "int", "open", MidiIn_open
);
837 func
->add_arg( "int", "port" );
838 if( !type_engine_import_mfun( env
, func
) ) goto error
;
841 func
= make_new_mfun( "int", "good", MidiIn_good
);
842 if( !type_engine_import_mfun( env
, func
) ) goto error
;
845 func
= make_new_mfun( "int", "num", MidiIn_num
);
846 if( !type_engine_import_mfun( env
, func
) ) goto error
;
849 func
= make_new_mfun( "string", "name", MidiIn_name
);
850 if( !type_engine_import_mfun( env
, func
) ) goto error
;
853 func
= make_new_mfun( "void", "printerr", MidiIn_printerr
);
854 func
->add_arg( "int", "print_or_not" );
855 if( !type_engine_import_mfun( env
, func
) ) goto error
;
858 func
= make_new_mfun( "int", "recv", MidiIn_recv
);
859 func
->add_arg( "MidiMsg", "msg" );
860 if( !type_engine_import_mfun( env
, func
) ) goto error
;
863 func
= make_new_mfun( "int", "can_wait", MidiIn_can_wait
);
864 if( !type_engine_import_mfun( env
, func
) ) goto error
;
866 // add member variable
867 MidiIn_offset_data
= type_engine_import_mvar( env
, "int", "@MidiIn_data", FALSE
);
868 if( MidiIn_offset_data
== CK_INVALID_OFFSET
) goto error
;
870 // end the class import
871 type_engine_import_class_end( env
);
874 if( !type_engine_import_class_begin( env
, "MidiOut", "Object",
875 env
->global(), MidiOut_ctor
, MidiOut_dtor
) )
879 func
= make_new_mfun( "int", "open", MidiOut_open
);
880 func
->add_arg( "int", "port" );
881 if( !type_engine_import_mfun( env
, func
) ) goto error
;
884 func
= make_new_mfun( "int", "good", MidiOut_good
);
885 if( !type_engine_import_mfun( env
, func
) ) goto error
;
888 func
= make_new_mfun( "int", "num", MidiOut_num
);
889 if( !type_engine_import_mfun( env
, func
) ) goto error
;
892 func
= make_new_mfun( "string", "name", MidiOut_name
);
893 if( !type_engine_import_mfun( env
, func
) ) goto error
;
896 func
= make_new_mfun( "void", "printerr", MidiOut_printerr
);
897 func
->add_arg( "int", "print_or_not" );
898 if( !type_engine_import_mfun( env
, func
) ) goto error
;
901 func
= make_new_mfun( "int", "send", MidiOut_send
);
902 func
->add_arg( "MidiMsg", "msg" );
903 if( !type_engine_import_mfun( env
, func
) ) goto error
;
905 // add member variable
906 MidiOut_offset_data
= type_engine_import_mvar( env
, "int", "@MidiOut_data", FALSE
);
907 if( MidiOut_offset_data
== CK_INVALID_OFFSET
) goto error
;
909 // end the class import
910 type_engine_import_class_end( env
);
916 // end the class import
917 type_engine_import_class_end( env
);
926 static t_CKUINT HidIn_offset_data
= 0;
928 static t_CKUINT HidMsg_offset_device_type
= 0;
929 static t_CKUINT HidMsg_offset_device_num
= 0;
930 static t_CKUINT HidMsg_offset_type
= 0;
931 static t_CKUINT HidMsg_offset_which
= 0;
932 static t_CKUINT HidMsg_offset_idata
= 0;
933 static t_CKUINT HidMsg_offset_fdata
= 0;
934 static t_CKUINT HidMsg_offset_when
= 0;
935 static t_CKUINT HidMsg_offset_deltax
= 0;
936 static t_CKUINT HidMsg_offset_deltay
= 0;
937 static t_CKUINT HidMsg_offset_axis_position
= 0; // deprecated
938 static t_CKUINT HidMsg_offset_axis_position2
= 0;
939 static t_CKUINT HidMsg_offset_scaled_axis_position
= 0; // deprecated
940 static t_CKUINT HidMsg_offset_hat_position
= 0;
941 static t_CKUINT HidMsg_offset_cursorx
= 0;
942 static t_CKUINT HidMsg_offset_cursory
= 0;
943 static t_CKUINT HidMsg_offset_scaledcursorx
= 0;
944 static t_CKUINT HidMsg_offset_scaledcursory
= 0;
945 static t_CKUINT HidMsg_offset_x
= 0;
946 static t_CKUINT HidMsg_offset_y
= 0;
947 static t_CKUINT HidMsg_offset_z
= 0;
948 static t_CKUINT HidMsg_offset_ascii
= 0;
949 static t_CKUINT HidMsg_offset_key
= 0;
951 static t_CKUINT HidOut_offset_data
= 0;
953 //-----------------------------------------------------------------------------
954 // name: init_class_HID()
956 //-----------------------------------------------------------------------------
957 t_CKBOOL
init_class_HID( Chuck_Env
* env
)
959 Chuck_DL_Func
* func
= NULL
;
962 if( !type_engine_import_class_begin( env
, "HidMsg", "Object",
963 env
->global(), NULL
, NULL
) )
966 // add member variable
967 HidMsg_offset_device_type
= type_engine_import_mvar( env
, "int", "deviceType", FALSE
);
968 if( HidMsg_offset_device_type
== CK_INVALID_OFFSET
) goto error
;
970 // add member variable
971 HidMsg_offset_device_num
= type_engine_import_mvar( env
, "int", "deviceNum", FALSE
);
972 if( HidMsg_offset_device_num
== CK_INVALID_OFFSET
) goto error
;
974 // add member variable
975 HidMsg_offset_type
= type_engine_import_mvar( env
, "int", "type", FALSE
);
976 if( HidMsg_offset_type
== CK_INVALID_OFFSET
) goto error
;
978 // add member variable
979 HidMsg_offset_which
= type_engine_import_mvar( env
, "int", "which", FALSE
);
980 if( HidMsg_offset_which
== CK_INVALID_OFFSET
) goto error
;
982 // add member variable
983 HidMsg_offset_idata
= type_engine_import_mvar( env
, "int", "idata", FALSE
);
984 if( HidMsg_offset_idata
== CK_INVALID_OFFSET
) goto error
;
986 // add member variable
987 HidMsg_offset_fdata
= type_engine_import_mvar( env
, "float", "fdata", FALSE
);
988 if( HidMsg_offset_fdata
== CK_INVALID_OFFSET
) goto error
;
990 // add member variable
991 HidMsg_offset_when
= type_engine_import_mvar( env
, "time", "when", FALSE
);
992 if( HidMsg_offset_when
== CK_INVALID_OFFSET
) goto error
;
994 // add member variable
995 HidMsg_offset_deltax
= type_engine_import_mvar( env
, "int", "deltaX", FALSE
);
996 if( HidMsg_offset_deltax
== CK_INVALID_OFFSET
) goto error
;
998 // add member variable
999 HidMsg_offset_deltay
= type_engine_import_mvar( env
, "int", "deltaY", FALSE
);
1000 if( HidMsg_offset_deltay
== CK_INVALID_OFFSET
) goto error
;
1002 // add member variable
1003 HidMsg_offset_cursorx
= type_engine_import_mvar( env
, "int", "cursorX", FALSE
);
1004 if( HidMsg_offset_cursorx
== CK_INVALID_OFFSET
) goto error
;
1006 // add member variable
1007 HidMsg_offset_cursory
= type_engine_import_mvar( env
, "int", "cursorY", FALSE
);
1008 if( HidMsg_offset_cursory
== CK_INVALID_OFFSET
) goto error
;
1010 // add member variable
1011 HidMsg_offset_scaledcursorx
= type_engine_import_mvar( env
, "float", "scaledCursorX", FALSE
);
1012 if( HidMsg_offset_scaledcursorx
== CK_INVALID_OFFSET
) goto error
;
1014 // add member variable
1015 HidMsg_offset_scaledcursory
= type_engine_import_mvar( env
, "float", "scaledCursorY", FALSE
);
1016 if( HidMsg_offset_scaledcursory
== CK_INVALID_OFFSET
) goto error
;
1018 // add member variable
1019 HidMsg_offset_x
= type_engine_import_mvar( env
, "int", "x", FALSE
);
1020 if( HidMsg_offset_x
== CK_INVALID_OFFSET
) goto error
;
1022 // add member variable
1023 HidMsg_offset_y
= type_engine_import_mvar( env
, "int", "y", FALSE
);
1024 if( HidMsg_offset_y
== CK_INVALID_OFFSET
) goto error
;
1026 // add member variable
1027 HidMsg_offset_z
= type_engine_import_mvar( env
, "int", "z", FALSE
);
1028 if( HidMsg_offset_z
== CK_INVALID_OFFSET
) goto error
;
1030 // add member variable
1031 HidMsg_offset_axis_position
= type_engine_import_mvar( env
, "int", "axis_position", FALSE
);
1032 if( HidMsg_offset_axis_position
== CK_INVALID_OFFSET
) goto error
;
1034 // add member variable
1035 HidMsg_offset_axis_position2
= type_engine_import_mvar( env
, "float", "axisPosition", FALSE
);
1036 if( HidMsg_offset_axis_position2
== CK_INVALID_OFFSET
) goto error
;
1038 // add member variable
1039 HidMsg_offset_hat_position
= type_engine_import_mvar( env
, "int", "hatPosition", FALSE
);
1040 if( HidMsg_offset_hat_position
== CK_INVALID_OFFSET
) goto error
;
1042 // add member variable
1043 HidMsg_offset_ascii
= type_engine_import_mvar( env
, "int", "ascii", FALSE
);
1044 if( HidMsg_offset_ascii
== CK_INVALID_OFFSET
) goto error
;
1046 // add member variable
1047 HidMsg_offset_key
= type_engine_import_mvar( env
, "int", "key", FALSE
);
1048 if( HidMsg_offset_key
== CK_INVALID_OFFSET
) goto error
;
1050 // add member variable
1051 HidMsg_offset_scaled_axis_position
= type_engine_import_mvar( env
, "float", "scaled_axis_position", FALSE
);
1052 if( HidMsg_offset_scaled_axis_position
== CK_INVALID_OFFSET
) goto error
;
1054 // add is_axis_motion()
1055 func
= make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion
); // deprecated
1056 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1058 // add isAxisMotion()
1059 func
= make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion
);
1060 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1062 // add is_button_down()
1063 func
= make_new_mfun( "int", "is_button_down", HidMsg_is_button_down
); // deprecated
1064 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1066 // add isButtonDown()
1067 func
= make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down
);
1068 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1070 // add is_button_up()
1071 func
= make_new_mfun( "int", "is_button_up", HidMsg_is_button_up
); // deprecated
1072 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1075 func
= make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up
);
1076 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1078 // add is_mouse_motion()
1079 func
= make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion
); // deprecated
1080 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1082 // add isMouseMotion()
1083 func
= make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion
);
1084 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1086 // add is_hat_motion()
1087 func
= make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion
); // deprecated
1088 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1090 // add isHatMotion()
1091 func
= make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion
);
1092 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1094 // add isWheelMotion()
1095 func
= make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion
);
1096 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1098 // end the class import
1099 type_engine_import_class_end( env
);
1102 // register deprecate
1103 type_engine_register_deprecate( env
, "HidIn", "Hid" );
1105 // init base class Hid (copy of HidIn + constants)
1106 if( !type_engine_import_class_begin( env
, "Hid", "Event",
1107 env
->global(), HidIn_ctor
, HidIn_dtor
) )
1111 func
= make_new_mfun( "int", "open", HidIn_open
);
1112 func
->add_arg( "int", "type" );
1113 func
->add_arg( "int", "num" );
1114 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1116 // add openJoystick()
1117 func
= make_new_mfun( "int", "openJoystick", HidIn_open_joystick
);
1118 func
->add_arg( "int", "num" );
1119 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1122 func
= make_new_mfun( "int", "openMouse", HidIn_open_mouse
);
1123 func
->add_arg( "int", "num" );
1124 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1126 // add openKeyboard()
1127 func
= make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard
);
1128 func
->add_arg( "int", "num" );
1129 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1131 // add openTiltSensor()
1132 func
= make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor
);
1133 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1136 func
= make_new_mfun( "int", "good", HidIn_good
);
1137 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1140 func
= make_new_mfun( "int", "num", HidIn_num
);
1141 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1144 func
= make_new_mfun( "string", "name", HidIn_name
);
1145 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1148 func
= make_new_mfun( "void", "printerr", HidIn_printerr
);
1149 func
->add_arg( "int", "print_or_not" );
1150 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1153 func
= make_new_mfun( "int", "recv", HidIn_recv
);
1154 func
->add_arg( "HidMsg", "msg" );
1155 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1158 func
= make_new_mfun( "int", "read", HidIn_read
);
1159 func
->add_arg( "int", "type" );
1160 func
->add_arg( "int", "which" );
1161 func
->add_arg( "HidMsg", "msg" );
1162 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1165 func
= make_new_mfun( "int", "send", HidIn_send
);
1166 func
->add_arg( "HidMsg", "msg" );
1167 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1170 func
= make_new_mfun( "int", "can_wait", HidIn_can_wait
);
1171 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1173 // add readTiltSensor()
1174 func
= make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor
);
1175 if( !type_engine_import_sfun( env
, func
) ) goto error
;
1177 // add startCursorTrack()
1178 func
= make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track
);
1179 if( !type_engine_import_sfun( env
, func
) ) goto error
;
1181 // add stopCursorTrack()
1182 func
= make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track
);
1183 if( !type_engine_import_sfun( env
, func
) ) goto error
;
1185 // add member variable
1186 HidIn_offset_data
= type_engine_import_mvar( env
, "int", "@Hid_data", FALSE
);
1187 if( HidIn_offset_data
== CK_INVALID_OFFSET
) goto error
;
1189 // add static member variable joystick
1190 if( type_engine_import_svar( env
, "int", "JOYSTICK", TRUE
,
1191 ( t_CKUINT
) &CK_HID_DEV_JOYSTICK
) == FALSE
)
1194 // add static member variable keyboard
1195 if( type_engine_import_svar( env
, "int", "KEYBOARD", TRUE
,
1196 ( t_CKUINT
) &CK_HID_DEV_KEYBOARD
) == FALSE
)
1199 // add static member variable mouse
1200 if( type_engine_import_svar( env
, "int", "MOUSE", TRUE
,
1201 ( t_CKUINT
) &CK_HID_DEV_MOUSE
) == FALSE
)
1204 // add static member variable wii_remote
1205 if( type_engine_import_svar( env
, "int", "WII_REMOTE", TRUE
,
1206 ( t_CKUINT
) &CK_HID_DEV_WIIREMOTE
) == FALSE
)
1209 // add static member variable wii_remote
1210 if( type_engine_import_svar( env
, "int", "TILT_SENSOR", TRUE
,
1211 ( t_CKUINT
) &CK_HID_DEV_TILTSENSOR
) == FALSE
)
1214 // add static member variable tablet
1215 if( type_engine_import_svar( env
, "int", "TABLET", TRUE
,
1216 ( t_CKUINT
) &CK_HID_DEV_TABLET
) == FALSE
)
1219 // add static member variable axisMotion
1220 if( type_engine_import_svar( env
, "int", "AXIS_MOTION", TRUE
,
1221 ( t_CKUINT
) &CK_HID_JOYSTICK_AXIS
) == FALSE
)
1224 // add static member variable buttonDown
1225 if( type_engine_import_svar( env
, "int", "BUTTON_DOWN", TRUE
,
1226 ( t_CKUINT
) &CK_HID_BUTTON_DOWN
) == FALSE
)
1229 // add static member variable buttonUp
1230 if( type_engine_import_svar( env
, "int", "BUTTON_UP", TRUE
,
1231 ( t_CKUINT
) &CK_HID_BUTTON_UP
) == FALSE
)
1234 // add static member variable joystickHat
1235 if( type_engine_import_svar( env
, "int", "JOYSTICK_HAT", TRUE
,
1236 ( t_CKUINT
) &CK_HID_JOYSTICK_HAT
) == FALSE
)
1239 // add static member variable JOYSTICK_BALL
1240 if( type_engine_import_svar( env
, "int", "JOYSTICK_BALL", TRUE
,
1241 ( t_CKUINT
) &CK_HID_JOYSTICK_BALL
) == FALSE
)
1244 // add static member variable mouseMotion
1245 if( type_engine_import_svar( env
, "int", "MOUSE_MOTION", TRUE
,
1246 ( t_CKUINT
) &CK_HID_MOUSE_MOTION
) == FALSE
)
1249 // add static member variable mouseWheel
1250 if( type_engine_import_svar( env
, "int", "MOUSE_WHEEL", TRUE
,
1251 ( t_CKUINT
) &CK_HID_MOUSE_WHEEL
) == FALSE
)
1254 // add static member variable DEVICE_CONNECTED
1255 if( type_engine_import_svar( env
, "int", "DEVICE_CONNECTED", TRUE
,
1256 ( t_CKUINT
) &CK_HID_DEVICE_CONNECTED
) == FALSE
)
1259 // add static member variable DEVICE_DISCONNECTED
1260 if( type_engine_import_svar( env
, "int", "DEVICE_DISCONNECTED", TRUE
,
1261 ( t_CKUINT
) &CK_HID_DEVICE_DISCONNECTED
) == FALSE
)
1264 // add static member variable ACCELEROMETER
1265 if( type_engine_import_svar( env
, "int", "ACCELEROMETER", TRUE
,
1266 ( t_CKUINT
) &CK_HID_ACCELEROMETER
) == FALSE
)
1269 // add static member variable LED
1270 if( type_engine_import_svar( env
, "int", "LED", TRUE
,
1271 ( t_CKUINT
) &CK_HID_LED
) == FALSE
)
1274 // add static member variable LED
1275 if( type_engine_import_svar( env
, "int", "FORCE_FEEDBACK", TRUE
,
1276 ( t_CKUINT
) &CK_HID_FORCE_FEEDBACK
) == FALSE
)
1279 // end the class import
1280 type_engine_import_class_end( env
);
1284 if( !type_engine_import_class_begin( env, "HidOut", "Object",
1285 env->global(), HidOut_ctor ) )
1289 func = make_new_mfun( "int", "open", HidOut_open );
1290 func->add_arg( "int", "port" );
1291 if( !type_engine_import_mfun( env, func ) ) goto error;
1294 func = make_new_mfun( "int", "good", HidOut_good );
1295 if( !type_engine_import_mfun( env, func ) ) goto error;
1298 func = make_new_mfun( "int", "num", HidOut_num );
1299 if( !type_engine_import_mfun( env, func ) ) goto error;
1302 func = make_new_mfun( "string", "name", HidOut_name );
1303 if( !type_engine_import_mfun( env, func ) ) goto error;
1306 func = make_new_mfun( "void", "printerr", HidOut_printerr );
1307 func->add_arg( "int", "print_or_not" );
1308 if( !type_engine_import_mfun( env, func ) ) goto error;
1311 func = make_new_mfun( "int", "send", HidOut_send );
1312 func->add_arg( "HidMsg", "msg" );
1313 if( !type_engine_import_mfun( env, func ) ) goto error;
1315 // add member variable
1316 HidOut_offset_data = type_engine_import_mvar( env, "int", "@HidOut_data", FALSE );
1317 if( HidOut_offset_data == CK_INVALID_OFFSET ) goto error;
1319 // end the class import
1320 type_engine_import_class_end( env );
1326 // end the class import
1327 type_engine_import_class_end( env
);
1336 static t_CKUINT MidiRW_offset_data
= 0;
1337 static t_CKUINT MidiMsgOut_offset_data
= 0;
1338 static t_CKUINT MidiMsgIn_offset_data
= 0;
1339 //-----------------------------------------------------------------------------
1340 // name: init_class_MidiRW()
1342 //-----------------------------------------------------------------------------
1343 t_CKBOOL
init_class_MidiRW( Chuck_Env
* env
)
1345 Chuck_DL_Func
* func
= NULL
;
1348 if( !type_engine_import_class_begin( env
, "MidiRW", "Object",
1349 env
->global(), MidiRW_ctor
, MidiRW_dtor
) )
1353 func
= make_new_mfun( "int", "open", MidiRW_open
);
1354 func
->add_arg( "string", "filename" );
1355 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1358 func
= make_new_mfun( "int", "close", MidiRW_close
);
1359 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1362 func
= make_new_mfun( "int", "write", MidiRW_write
);
1363 func
->add_arg( "MidiMsg", "msg" );
1364 func
->add_arg( "time", "t" );
1365 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1368 func
= make_new_mfun( "int", "read", MidiRW_read
);
1369 func
->add_arg( "MidiMsg", "msg" );
1370 //func->add_arg( "time", "t" );
1371 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1373 // add member variable
1374 MidiRW_offset_data
= type_engine_import_mvar( env
, "int", "@MidiRW_data", FALSE
);
1375 if( MidiRW_offset_data
== CK_INVALID_OFFSET
) goto error
;
1377 // end the class import
1378 type_engine_import_class_end( env
);
1381 if( !type_engine_import_class_begin( env
, "MidiMsgOut", "Object",
1382 env
->global(), MidiMsgOut_ctor
, MidiMsgOut_dtor
) )
1386 func
= make_new_mfun( "int", "open", MidiMsgOut_open
);
1387 func
->add_arg( "string", "filename" );
1388 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1391 func
= make_new_mfun( "int", "close", MidiMsgOut_close
);
1392 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1395 func
= make_new_mfun( "int", "write", MidiMsgOut_write
);
1396 func
->add_arg( "MidiMsg", "msg" );
1397 func
->add_arg( "time", "t" );
1398 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1400 // add member variable
1401 MidiMsgOut_offset_data
= type_engine_import_mvar( env
, "int", "@MidiMsgOut_data", FALSE
);
1402 if( MidiMsgOut_offset_data
== CK_INVALID_OFFSET
) goto error
;
1404 // end the class import
1405 type_engine_import_class_end( env
);
1408 if( !type_engine_import_class_begin( env
, "MidiMsgIn", "Object",
1409 env
->global(), MidiMsgIn_ctor
, MidiMsgIn_dtor
) )
1413 func
= make_new_mfun( "int", "open", MidiMsgIn_open
);
1414 func
->add_arg( "string", "filename" );
1415 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1418 func
= make_new_mfun( "int", "close", MidiMsgIn_close
);
1419 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1422 func
= make_new_mfun( "int", "read", MidiMsgIn_read
);
1423 func
->add_arg( "MidiMsg", "msg" );
1424 //func->add_arg( "time", "t" );
1425 if( !type_engine_import_mfun( env
, func
) ) goto error
;
1427 // add member variable
1428 MidiMsgIn_offset_data
= type_engine_import_mvar( env
, "int", "@MidiMsgIn_data", FALSE
);
1429 if( MidiMsgIn_offset_data
== CK_INVALID_OFFSET
) goto error
;
1431 // end the class import
1432 type_engine_import_class_end( env
);
1435 // HidInManager::init();
1441 // end the class import
1442 type_engine_import_class_end( env
);
1449 CK_DLL_CTOR( object_ctor
)
1452 // EM_log( CK_LOG_FINEST, "Object constructor..." );
1455 OBJ_MEMBER_UINT(SELF
, Object_offset_string
) = 0;
1460 CK_DLL_DTOR( object_dtor
)
1463 // EM_log( CK_LOG_FINEST, "Object destructor..." );
1466 Chuck_String
* str
= (Chuck_String
*)OBJ_MEMBER_UINT(SELF
, Object_offset_string
);
1468 SAFE_RELEASE( str
);
1473 CK_DLL_MFUN( object_toString
)
1476 Chuck_String
* str
= (Chuck_String
*)OBJ_MEMBER_UINT(SELF
, Object_offset_string
);
1481 str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, SHRED
);
1485 // TODO: make this exception
1486 fprintf( stderr
, "[chuck]: Object.toString() out of memory!\n" );
1487 RETURN
->v_object
= NULL
;
1491 ostringstream
strout( ostringstream::out
);
1493 Chuck_Type
* type
= SELF
->type_ref
;
1495 strout
.setf( ios::hex
, ios::basefield
);
1496 strout
<< ((type
!= NULL
) ? type
->c_name() : "[VOID]") << ":" << (t_CKUINT
)SELF
;
1500 str
->str
= strout
.str();
1504 RETURN
->v_object
= str
;
1509 CK_DLL_CTOR( ugen_ctor
)
1513 CK_DLL_DTOR( ugen_dtor
)
1516 // Chuck_UGen * ugen = (Chuck_UGen *)SELF;
1519 CK_DLL_MFUN( ugen_op
)
1522 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1524 t_CKINT op
= GET_CK_INT( ARGS
);
1528 RETURN
->v_int
= ugen
->m_op
;
1530 // for multiple channels
1531 Chuck_DL_Return ret
;
1532 for( t_CKUINT i
= 0; i
< ugen
->m_multi_chan_size
; i
++ )
1533 ugen_op( ugen
->m_multi_chan
[i
], ARGS
, &ret
, SHRED
);
1536 CK_DLL_MFUN( ugen_cget_op
)
1539 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1541 RETURN
->v_int
= ugen
->m_op
;
1544 CK_DLL_MFUN( ugen_last
)
1547 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1549 RETURN
->v_float
= (t_CKFLOAT
)ugen
->m_last
;
1552 CK_DLL_MFUN( ugen_next
)
1555 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1557 t_CKFLOAT next
= GET_CK_FLOAT( ARGS
);
1559 ugen
->m_next
= (SAMPLE
)next
;
1560 ugen
->m_use_next
= TRUE
;
1562 RETURN
->v_float
= (t_CKFLOAT
)ugen
->m_next
;
1564 // for multiple channels
1565 Chuck_DL_Return ret
;
1566 for( t_CKUINT i
= 0; i
< ugen
->m_multi_chan_size
; i
++ )
1567 ugen_next( ugen
->m_multi_chan
[i
], ARGS
, &ret
, SHRED
);
1570 CK_DLL_MFUN( ugen_cget_next
)
1573 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1575 RETURN
->v_float
= ugen
->m_use_next
? (t_CKFLOAT
)ugen
->m_next
: 0.0f
;
1578 CK_DLL_MFUN( ugen_gain
)
1581 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1583 t_CKFLOAT gain
= GET_CK_FLOAT( ARGS
);
1585 ugen
->m_gain
= (SAMPLE
)gain
;
1587 RETURN
->v_float
= (t_CKFLOAT
)ugen
->m_gain
;
1589 // for multiple channels
1590 Chuck_DL_Return ret
;
1591 for( t_CKUINT i
= 0; i
< ugen
->m_multi_chan_size
; i
++ )
1592 ugen_gain( ugen
->m_multi_chan
[i
], ARGS
, &ret
, SHRED
);
1595 CK_DLL_MFUN( ugen_cget_gain
)
1598 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1600 RETURN
->v_float
= (t_CKFLOAT
)ugen
->m_gain
;
1603 CK_DLL_CTRL( ugen_numChannels
)
1606 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1608 EM_error3( "setting .numChannels is not yet supported (use the command line)..." );
1611 CK_DLL_CGET( ugen_cget_numChannels
)
1614 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1616 RETURN
->v_int
= ugen
->m_multi_chan_size
== 0 ? 1 : ugen
->m_multi_chan_size
;
1619 CK_DLL_CTRL( ugen_chan
)
1622 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1623 t_CKINT num
= GET_NEXT_INT(ARGS
);
1625 if( !ugen
->m_multi_chan_size
&& num
== 0 )
1626 RETURN
->v_object
= ugen
;
1627 else if( num
>= 0 && num
< ugen
->m_multi_chan_size
)
1628 RETURN
->v_object
= ugen
->m_multi_chan
[num
];
1630 RETURN
->v_object
= NULL
;
1633 CK_DLL_CTRL( ugen_connected
)
1636 Chuck_UGen
* ugen
= (Chuck_UGen
*)SELF
;
1637 Chuck_UGen
* right
= (Chuck_UGen
*)GET_NEXT_OBJECT(ARGS
);
1640 t_CKINT ret
= FALSE
;
1647 ret
= right
->is_connected_from( ugen
);
1650 RETURN
->v_int
= ret
;
1655 CK_DLL_CTOR( uana_ctor
)
1657 // make an actual blob
1658 Chuck_Object
* blob
= instantiate_and_initialize_object( &t_uanablob
, SHRED
);
1659 // TODO: check out of memory
1660 assert( blob
!= NULL
);
1661 // make a blob proxy
1662 Chuck_UAnaBlobProxy
* proxy
= new Chuck_UAnaBlobProxy( blob
);
1664 OBJ_MEMBER_INT(SELF
, uana_offset_blob
) = (t_CKINT
)proxy
;
1665 // HACK: DANGER: manually call blob's ctor
1666 uanablob_ctor( blob
, NULL
, NULL
);
1669 CK_DLL_DTOR( uana_dtor
)
1671 // TODO: GC should release the blob!
1674 CK_DLL_MFUN( uana_upchuck
)
1677 Chuck_UAna
* uana
= (Chuck_UAna
*)SELF
;
1679 Chuck_VM_Shred
* derhs
= SHRED
;
1680 // make sure it's not NULL
1683 EM_error3( "UAna.upchuck() encountered NULL shred; operation aborting!" );
1688 Chuck_VM
* vm
= derhs
->vm_ref
;
1692 EM_error3( "UAna.upchuck() encountered NULL VM ref; operation aborting!" );
1697 if( uana
->m_uana_time
< vm
->shreduler()->now_system
)
1699 // for multiple channels
1700 Chuck_DL_Return ret
;
1701 for( t_CKUINT i
= 0; i
< uana
->m_multi_chan_size
; i
++ )
1702 uana_upchuck( uana
->m_multi_chan
[i
], ARGS
, &ret
, SHRED
);
1704 // tock it (TODO: order relative to multiple channels?)
1705 uana
->system_tock( vm
->shreduler()->now_system
);
1709 RETURN
->v_object
= uana
->blobProxy()->realblob();
1712 /* CK_DLL_MFUN( uana_blob )
1715 Chuck_UAna * uana = (Chuck_UAna *)SELF;
1718 RETURN->v_object = NULL;
1721 CK_DLL_MFUN( uana_fvals
)
1723 // get the fvals array
1724 Chuck_UAnaBlobProxy
* blob
= (Chuck_UAnaBlobProxy
*)OBJ_MEMBER_INT(SELF
, uana_offset_blob
);
1725 RETURN
->v_object
= &blob
->fvals();
1728 CK_DLL_MFUN( uana_cvals
)
1730 // get the fvals array
1731 Chuck_UAnaBlobProxy
* blob
= (Chuck_UAnaBlobProxy
*)OBJ_MEMBER_INT(SELF
, uana_offset_blob
);
1732 RETURN
->v_object
= &blob
->cvals();
1735 CK_DLL_MFUN( uana_fval
)
1738 t_CKINT i
= GET_NEXT_INT(ARGS
);
1739 // get the fvals array
1740 Chuck_UAnaBlobProxy
* blob
= (Chuck_UAnaBlobProxy
*)OBJ_MEMBER_INT(SELF
, uana_offset_blob
);
1741 Chuck_Array8
& fvals
= blob
->fvals();
1743 if( i
< 0 || fvals
.size() <= i
) RETURN
->v_float
= 0;
1748 fvals
.get( i
, &val
);
1749 RETURN
->v_float
= val
;
1753 CK_DLL_MFUN( uana_cval
)
1756 t_CKINT i
= GET_NEXT_INT(ARGS
);
1757 // get the fvals array
1758 Chuck_UAnaBlobProxy
* blob
= (Chuck_UAnaBlobProxy
*)OBJ_MEMBER_INT(SELF
, uana_offset_blob
);
1759 Chuck_Array16
& cvals
= blob
->cvals();
1761 if( i
< 0 || cvals
.size() <= i
) RETURN
->v_complex
.re
= RETURN
->v_complex
.im
= 0;
1766 cvals
.get( i
, &val
);
1767 RETURN
->v_complex
= val
;
1771 // blob proxy implementation
1772 Chuck_UAnaBlobProxy::Chuck_UAnaBlobProxy( Chuck_Object
* blob
)
1775 assert( m_blob
!= NULL
);
1780 Chuck_UAnaBlobProxy::~Chuck_UAnaBlobProxy()
1783 SAFE_RELEASE( m_blob
);
1786 t_CKTIME
& Chuck_UAnaBlobProxy::when()
1788 // TODO: DANGER: is this actually returning correct reference?!
1789 return OBJ_MEMBER_TIME(m_blob
, uanablob_offset_when
);
1792 Chuck_Array8
& Chuck_UAnaBlobProxy::fvals()
1794 // TODO: DANGER: is this actually returning correct reference?!
1795 Chuck_Array8
* arr8
= (Chuck_Array8
*)OBJ_MEMBER_INT(m_blob
, uanablob_offset_fvals
);
1796 assert( arr8
!= NULL
);
1800 Chuck_Array16
& Chuck_UAnaBlobProxy::cvals()
1802 // TODO: DANGER: is this actually returning correct reference?!
1803 Chuck_Array16
* arr16
= (Chuck_Array16
*)OBJ_MEMBER_INT(m_blob
, uanablob_offset_cvals
);
1804 assert( arr16
!= NULL
);
1809 Chuck_UAnaBlobProxy
* getBlobProxy( const Chuck_UAna
* uana
)
1811 return (Chuck_UAnaBlobProxy
*)OBJ_MEMBER_INT(uana
, uana_offset_blob
);
1815 CK_DLL_CTOR( uanablob_ctor
)
1818 OBJ_MEMBER_TIME(SELF
, uanablob_offset_when
) = 0;
1820 Chuck_Array8
* arr8
= new Chuck_Array8( 8 );
1821 initialize_object( arr8
, &t_array
);
1822 // TODO: check out of memory
1824 OBJ_MEMBER_INT(SELF
, uanablob_offset_fvals
) = (t_CKINT
)arr8
;
1826 Chuck_Array16
* arr16
= new Chuck_Array16( 8 );
1827 initialize_object( arr16
, &t_array
);
1828 // TODO: check out of memory
1830 OBJ_MEMBER_INT(SELF
, uanablob_offset_cvals
) = (t_CKINT
)arr16
;
1834 CK_DLL_DTOR( uanablob_dtor
)
1837 Chuck_Array8
* arr8
= (Chuck_Array8
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_fvals
);
1840 OBJ_MEMBER_INT(SELF
, uanablob_offset_fvals
) = 0;
1843 Chuck_Array16
* arr16
= (Chuck_Array16
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_cvals
);
1846 OBJ_MEMBER_INT(SELF
, uanablob_offset_cvals
) = 0;
1848 OBJ_MEMBER_TIME(SELF
, uanablob_offset_when
) = 0;
1851 CK_DLL_MFUN( uanablob_when
)
1854 RETURN
->v_time
= OBJ_MEMBER_TIME(SELF
, uanablob_offset_when
);
1857 CK_DLL_MFUN( uanablob_fvals
)
1860 RETURN
->v_object
= (Chuck_Array8
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_fvals
);
1863 CK_DLL_MFUN( uanablob_fval
)
1866 t_CKINT i
= GET_NEXT_INT(ARGS
);
1867 // get the fvals array
1868 Chuck_Array8
* fvals
= (Chuck_Array8
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_fvals
);
1870 if( i
< 0 || fvals
->size() <= i
) RETURN
->v_float
= 0;
1875 fvals
->get( i
, &val
);
1876 RETURN
->v_float
= val
;
1880 CK_DLL_MFUN( uanablob_cval
)
1883 t_CKINT i
= GET_NEXT_INT(ARGS
);
1884 // get the fvals array
1885 Chuck_Array16
* cvals
= (Chuck_Array16
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_cvals
);
1887 if( i
< 0 || cvals
->size() <= i
) RETURN
->v_complex
.re
= RETURN
->v_complex
.im
= 0;
1892 cvals
->get( i
, &val
);
1893 RETURN
->v_complex
= val
;
1897 CK_DLL_MFUN( uanablob_cvals
)
1900 RETURN
->v_object
= (Chuck_Array16
*)OBJ_MEMBER_INT(SELF
, uanablob_offset_cvals
);
1904 CK_DLL_CTOR( event_ctor
)
1906 // OBJ_MEMBER_INT(SELF, event_offset_data) = (t_CKUINT)new Data_Event;
1907 // Chuck_Event * event = (Chuck_Event *)SELF;
1911 CK_DLL_DTOR( event_dtor
)
1913 // delete (Data_Event *)OBJ_MEMBER_INT(SELF, event_offset_data);
1916 CK_DLL_MFUN( event_signal
)
1918 Chuck_Event
* d
= (Chuck_Event
*)SELF
;
1922 CK_DLL_MFUN( event_broadcast
)
1924 Chuck_Event
* d
= (Chuck_Event
*)SELF
;
1928 CK_DLL_MFUN( event_wait
)
1930 // Chuck_Event * d = (Chuck_Event *)SELF;
1934 CK_DLL_MFUN( event_can_wait
)
1936 RETURN
->v_int
= TRUE
;
1940 //-----------------------------------------------------------------------------
1942 //-----------------------------------------------------------------------------
1943 CK_DLL_MFUN( io_dummy
)
1945 EM_error3( "(IO): internal error! inside an abstract function! help!" );
1946 EM_error3( " note: please hunt down someone (e.g., Ge) to fix this..." );
1952 //-----------------------------------------------------------------------------
1954 //-----------------------------------------------------------------------------
1955 CK_DLL_CTOR( fileio_ctor
)
1958 CK_DLL_DTOR( fileio_dtor
)
1961 CK_DLL_MFUN( fileio_open
)
1964 CK_DLL_MFUN( fileio_more
)
1967 CK_DLL_MFUN( fileio_eof
)
1970 CK_DLL_MFUN( fileio_good2read
)
1973 CK_DLL_MFUN( fileio_good2write
)
1976 CK_DLL_MFUN( fileio_good
)
1979 CK_DLL_MFUN( fileio_close
)
1982 CK_DLL_MFUN( fileio_readint
)
1985 CK_DLL_MFUN( fileio_readfloat
)
1988 CK_DLL_MFUN( fileio_readstring
)
1991 CK_DLL_MFUN( fileio_readline
)
1994 CK_DLL_MFUN( fileio_writeint
)
1997 CK_DLL_MFUN( fileio_writefloat
)
2000 CK_DLL_MFUN( fileio_writestring
)
2003 CK_DLL_MFUN( fileio_writeline
)
2007 //-----------------------------------------------------------------------------
2009 //-----------------------------------------------------------------------------
2011 //CK_DLL_CTOR( shred_ctor );
2012 //CK_DLL_DTOR( shred_dtor ); //
2014 CK_DLL_MFUN( shred_exit
)
2016 Chuck_VM_Shred
* derhs
= (Chuck_VM_Shred
*)SELF
;
2018 derhs
->is_done
= TRUE
;
2019 derhs
->is_running
= FALSE
;
2020 // return; // thanks
2023 CK_DLL_MFUN( shred_clone
)
2027 CK_DLL_MFUN( shred_id
)
2029 Chuck_VM_Shred
* derhs
= (Chuck_VM_Shred
*)SELF
;
2031 RETURN
->v_int
= derhs
->xid
;
2034 CK_DLL_MFUN( shred_yield
)
2036 Chuck_VM_Shred
* derhs
= (Chuck_VM_Shred
*)SELF
;
2037 Chuck_VM
* vm
= derhs
->vm_ref
;
2040 derhs
->is_running
= FALSE
;
2042 vm
->shreduler()->shredule( derhs
, derhs
->now
);
2045 CK_DLL_MFUN( shred_numArgs
)
2047 Chuck_VM_Shred
* derhs
= (Chuck_VM_Shred
*)SELF
;
2049 // get the number of arguments
2050 RETURN
->v_int
= derhs
->args
.size();
2053 CK_DLL_MFUN( shred_getArg
)
2055 Chuck_VM_Shred
* derhs
= (Chuck_VM_Shred
*)SELF
;
2058 t_CKINT i
= GET_NEXT_INT(ARGS
);
2060 t_CKINT num
= derhs
->args
.size();
2062 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2063 str
->str
= ( i
< num
? derhs
->args
[i
] : "" );
2064 RETURN
->v_string
= str
;
2067 CK_DLL_MFUN( string_length
)
2069 Chuck_String
* s
= (Chuck_String
*)SELF
;
2070 RETURN
->v_int
= s
->str
.length();
2073 CK_DLL_MFUN( string_upper
)
2075 Chuck_String
* s
= (Chuck_String
*)SELF
;
2076 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2077 str
->str
= toupper( s
->str
);
2078 RETURN
->v_string
= str
;
2081 CK_DLL_MFUN( string_lower
)
2083 Chuck_String
* s
= (Chuck_String
*)SELF
;
2084 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2085 str
->str
= tolower( s
->str
);
2086 RETURN
->v_string
= str
;
2089 CK_DLL_MFUN( string_ltrim
)
2091 Chuck_String
* s
= (Chuck_String
*)SELF
;
2092 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2093 str
->str
= ltrim( s
->str
);
2094 RETURN
->v_string
= str
;
2097 CK_DLL_MFUN( string_rtrim
)
2099 Chuck_String
* s
= (Chuck_String
*)SELF
;
2100 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2101 str
->str
= rtrim( s
->str
);
2102 RETURN
->v_string
= str
;
2105 CK_DLL_MFUN( string_trim
)
2107 Chuck_String
* s
= (Chuck_String
*)SELF
;
2108 Chuck_String
* str
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2109 str
->str
= trim( s
->str
);
2110 RETURN
->v_string
= str
;
2113 CK_DLL_MFUN( string_toString
)
2115 Chuck_String
* s
= (Chuck_String
*)SELF
;
2116 RETURN
->v_string
= s
;
2120 CK_DLL_MFUN( string_set_at )
2122 Chuck_String * s = (Chuck_String *)SELF;
2123 t_CKINT c = GET_CK_INT(
2124 RETURN->v_int = s->str.length();
2127 CK_DLL_MFUN( string_get_at )
2129 Chuck_String * s = (Chuck_String *)SELF;
2130 RETURN->v_int = s->str.length();
2136 CK_DLL_MFUN( array_get_size
)
2138 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2139 RETURN
->v_int
= array
->size();
2143 CK_DLL_MFUN( array_set_size
)
2145 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2146 t_CKINT size
= GET_NEXT_INT(ARGS
);
2149 // TODO: make this exception
2150 fprintf( stderr
, "[chuck](via array): attempt to set negative array size!\n" );
2155 array
->set_size( size
);
2156 RETURN
->v_int
= array
->size();
2158 RETURN
->v_int
= array
->size();
2162 CK_DLL_MFUN( array_clear
)
2164 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2169 CK_DLL_MFUN( array_set_capacity
)
2171 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2172 t_CKINT capacity
= GET_NEXT_INT(ARGS
);
2175 // TODO: make this exception
2176 fprintf( stderr
, "[chuck](via array): attempt to set negative array capacity!\n" );
2181 array
->set_capacity( capacity
);
2182 RETURN
->v_int
= array
->capacity();
2187 CK_DLL_MFUN( array_get_capacity_hack
)
2189 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2190 RETURN
->v_int
= array
->size();
2194 CK_DLL_MFUN( array_get_capacity
)
2196 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2197 RETURN
->v_int
= array
->capacity();
2201 CK_DLL_MFUN( array_find
)
2203 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2204 Chuck_String
* name
= GET_NEXT_STRING( ARGS
);
2205 RETURN
->v_int
= array
->find( name
->str
);
2209 CK_DLL_MFUN( array_erase
)
2211 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2212 Chuck_String
* name
= GET_NEXT_STRING( ARGS
);
2213 RETURN
->v_int
= array
->erase( name
->str
);
2216 // array.push_back()
2217 CK_DLL_MFUN( array_push_back
)
2219 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2220 // TODO: make this safe!
2221 if( array
->data_type_size() == CHUCK_ARRAY4_DATASIZE
)
2222 RETURN
->v_int
= ((Chuck_Array4
*)array
)->push_back( GET_NEXT_UINT( ARGS
) );
2223 else if( array
->data_type_size() == CHUCK_ARRAY8_DATASIZE
)
2224 RETURN
->v_int
= ((Chuck_Array8
*)array
)->push_back( GET_NEXT_FLOAT( ARGS
) );
2225 else if( array
->data_type_size() == CHUCK_ARRAY16_DATASIZE
)
2226 RETURN
->v_int
= ((Chuck_Array16
*)array
)->push_back( GET_NEXT_COMPLEX( ARGS
) );
2232 CK_DLL_MFUN( array_pop_back
)
2234 Chuck_Array
* array
= (Chuck_Array
*)SELF
;
2235 // TODO: make this safe!
2236 if( array
->data_type_size() == CHUCK_ARRAY4_DATASIZE
)
2237 RETURN
->v_int
= ((Chuck_Array4
*)array
)->pop_back( );
2238 else if( array
->data_type_size() == CHUCK_ARRAY8_DATASIZE
)
2239 RETURN
->v_int
= ((Chuck_Array8
*)array
)->pop_back( );
2240 else if( array
->data_type_size() == CHUCK_ARRAY16_DATASIZE
)
2241 RETURN
->v_int
= ((Chuck_Array16
*)array
)->push_back( GET_NEXT_COMPLEX( ARGS
) );
2247 //-----------------------------------------------------------------------------
2249 //-----------------------------------------------------------------------------
2250 CK_DLL_CTOR( MidiIn_ctor
)
2252 MidiIn
* min
= new MidiIn
;
2254 OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
) = (t_CKINT
)min
;
2257 CK_DLL_DTOR( MidiIn_dtor
)
2259 delete (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2260 OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
) = 0;
2263 CK_DLL_MFUN( MidiIn_open
)
2265 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2266 t_CKINT port
= GET_CK_INT(ARGS
);
2267 RETURN
->v_int
= min
->open( port
);
2270 CK_DLL_MFUN( MidiIn_good
)
2272 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2273 RETURN
->v_int
= (t_CKINT
)min
->good();
2276 CK_DLL_MFUN( MidiIn_num
)
2278 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2279 RETURN
->v_int
= min
->num();
2282 CK_DLL_MFUN( MidiIn_printerr
)
2284 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2285 t_CKINT print_or_not
= GET_CK_INT(ARGS
);
2286 min
->set_suppress( !print_or_not
);
2289 CK_DLL_MFUN( MidiIn_name
)
2291 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2292 // TODO: memory leak, please fix, Thanks.
2293 Chuck_String
* a
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2296 a
->str
= min
->min
->getPortName( min
->num() );
2297 RETURN
->v_string
= a
;
2300 CK_DLL_MFUN( MidiIn_recv
)
2302 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2303 Chuck_Object
* fake_msg
= GET_CK_OBJECT(ARGS
);
2305 RETURN
->v_int
= min
->recv( &the_msg
);
2308 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
) = the_msg
.data
[0];
2309 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
) = the_msg
.data
[1];
2310 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
) = the_msg
.data
[2];
2315 CK_DLL_MFUN( MidiIn_can_wait
)
2317 MidiIn
* min
= (MidiIn
*)OBJ_MEMBER_INT(SELF
, MidiIn_offset_data
);
2318 RETURN
->v_int
= min
->empty();
2322 //-----------------------------------------------------------------------------
2324 //-----------------------------------------------------------------------------
2325 CK_DLL_CTOR( MidiOut_ctor
)
2327 OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
) = (t_CKUINT
)new MidiOut
;
2330 CK_DLL_DTOR( MidiOut_dtor
)
2332 delete (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2333 OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
) = 0;
2336 CK_DLL_MFUN( MidiOut_open
)
2338 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2339 t_CKINT port
= GET_CK_INT(ARGS
);
2340 RETURN
->v_int
= mout
->open( port
);
2343 CK_DLL_MFUN( MidiOut_good
)
2345 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2346 RETURN
->v_int
= (t_CKINT
)mout
->good();
2349 CK_DLL_MFUN( MidiOut_num
)
2351 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2352 RETURN
->v_int
= mout
->num();
2355 CK_DLL_MFUN( MidiOut_name
)
2357 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2358 // TODO: memory leak, please fix, Thanks.
2359 Chuck_String
* a
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2362 a
->str
= mout
->mout
->getPortName( mout
->num() );
2363 RETURN
->v_string
= a
;
2366 CK_DLL_MFUN( MidiOut_printerr
)
2368 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2369 t_CKINT print_or_not
= GET_CK_INT(ARGS
);
2370 mout
->set_suppress( !print_or_not
);
2373 CK_DLL_MFUN( MidiOut_send
)
2375 MidiOut
* mout
= (MidiOut
*)OBJ_MEMBER_INT(SELF
, MidiOut_offset_data
);
2376 Chuck_Object
* fake_msg
= GET_CK_OBJECT(ARGS
);
2378 the_msg
.data
[0] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
);
2379 the_msg
.data
[1] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
);
2380 the_msg
.data
[2] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
);
2381 RETURN
->v_int
= mout
->send( &the_msg
);
2386 //-----------------------------------------------------------------------------
2388 //-----------------------------------------------------------------------------
2389 CK_DLL_MFUN( HidMsg_is_axis_motion
)
2391 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2392 CK_HID_JOYSTICK_AXIS
? 1 : 0 );
2395 CK_DLL_MFUN( HidMsg_is_button_down
)
2397 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2398 CK_HID_BUTTON_DOWN
? 1 : 0 );
2401 CK_DLL_MFUN( HidMsg_is_button_up
)
2403 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2404 CK_HID_BUTTON_UP
? 1 : 0 );
2407 CK_DLL_MFUN( HidMsg_is_mouse_motion
)
2409 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2410 CK_HID_MOUSE_MOTION
? 1 : 0 );
2413 CK_DLL_MFUN( HidMsg_is_hat_motion
)
2415 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2416 CK_HID_JOYSTICK_HAT
? 1 : 0 );
2419 CK_DLL_MFUN( HidMsg_is_wheel_motion
)
2421 RETURN
->v_int
= ( ( t_CKINT
) OBJ_MEMBER_INT( SELF
, HidMsg_offset_type
) ==
2422 CK_HID_MOUSE_WHEEL
? 1 : 0 );
2425 //-----------------------------------------------------------------------------
2427 //-----------------------------------------------------------------------------
2428 CK_DLL_CTOR( HidIn_ctor
)
2430 HidIn
* min
= new HidIn
;
2432 OBJ_MEMBER_INT(SELF
, HidIn_offset_data
) = (t_CKINT
)min
;
2435 CK_DLL_DTOR( HidIn_dtor
)
2437 delete (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2438 OBJ_MEMBER_INT(SELF
, HidIn_offset_data
) = 0;
2441 CK_DLL_MFUN( HidIn_open
)
2443 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2444 t_CKINT type
= GET_NEXT_INT(ARGS
);
2445 t_CKINT num
= GET_NEXT_INT(ARGS
);
2446 RETURN
->v_int
= min
->open( type
, num
);
2449 CK_DLL_MFUN( HidIn_open_joystick
)
2451 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2452 t_CKINT num
= GET_NEXT_INT(ARGS
);
2453 RETURN
->v_int
= min
->open( CK_HID_DEV_JOYSTICK
, num
);
2456 CK_DLL_MFUN( HidIn_open_mouse
)
2458 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2459 t_CKINT num
= GET_NEXT_INT(ARGS
);
2460 RETURN
->v_int
= min
->open( CK_HID_DEV_MOUSE
, num
);
2463 CK_DLL_MFUN( HidIn_open_keyboard
)
2465 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2466 t_CKINT num
= GET_NEXT_INT(ARGS
);
2467 RETURN
->v_int
= min
->open( CK_HID_DEV_KEYBOARD
, num
);
2470 CK_DLL_MFUN( HidIn_open_tiltsensor
)
2472 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2473 RETURN
->v_int
= min
->open( CK_HID_DEV_TILTSENSOR
, 0 );
2476 CK_DLL_MFUN( HidIn_good
)
2478 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2479 RETURN
->v_int
= (t_CKINT
)min
->good();
2482 CK_DLL_MFUN( HidIn_num
)
2484 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2485 RETURN
->v_int
= min
->num();
2488 CK_DLL_MFUN( HidIn_printerr
)
2490 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2491 t_CKINT print_or_not
= GET_CK_INT(ARGS
);
2492 min
->set_suppress( !print_or_not
);
2495 CK_DLL_MFUN( HidIn_name
)
2497 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2498 // TODO: memory leak, please fix, Thanks.
2499 // Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( &t_string, NULL );
2501 // if( min->good() )
2502 // a->str = min->phin->getPortName( min->num() );
2503 // TODO: is null problem?
2504 RETURN
->v_string
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2505 RETURN
->v_string
->str
= min
->name();
2508 CK_DLL_MFUN( HidIn_recv
)
2510 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2511 Chuck_Object
* fake_msg
= GET_CK_OBJECT(ARGS
);
2513 RETURN
->v_int
= min
->recv( &the_msg
);
2516 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_device_type
) = the_msg
.device_type
;
2517 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_device_num
) = the_msg
.device_num
;
2518 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_type
) = the_msg
.type
;
2519 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_which
) = the_msg
.eid
;
2520 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_idata
) = the_msg
.idata
[0];
2521 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_fdata
) = the_msg
.fdata
[0];
2523 // mouse motion specific member variables
2524 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_deltax
) = the_msg
.idata
[0];
2525 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_deltay
) = the_msg
.idata
[1];
2526 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_cursorx
) = the_msg
.idata
[2];
2527 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_cursory
) = the_msg
.idata
[3];
2528 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaledcursorx
) = the_msg
.fdata
[0];
2529 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaledcursory
) = the_msg
.fdata
[1];
2531 // axis motion specific member variables
2532 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_axis_position
) = the_msg
.idata
[0];
2533 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaled_axis_position
) = the_msg
.fdata
[0];
2534 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_axis_position2
) = the_msg
.fdata
[0];
2536 // hat motion specific variables
2537 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_hat_position
) = the_msg
.idata
[0];
2539 // keyboard specific variables
2540 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_key
) = the_msg
.idata
[1];
2541 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_ascii
) = the_msg
.idata
[2];
2543 // accelerometer (tilt sensor, wii remote) specific members
2544 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_x
) = the_msg
.idata
[0];
2545 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_y
) = the_msg
.idata
[1];
2546 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_z
) = the_msg
.idata
[2];
2550 CK_DLL_MFUN( HidIn_read
)
2552 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2553 t_CKINT type
= GET_NEXT_INT(ARGS
);
2554 t_CKINT num
= GET_NEXT_INT(ARGS
);
2555 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2559 RETURN
->v_int
= min
->read( type
, num
, &the_msg
);
2563 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_device_type
) = the_msg
.device_type
;
2564 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_device_num
) = the_msg
.device_num
;
2565 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_type
) = the_msg
.type
;
2566 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_which
) = the_msg
.eid
;
2568 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_idata
) = the_msg
.idata
[0];
2569 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_fdata
) = the_msg
.fdata
[0];
2571 // mouse motion specific member members
2572 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_deltax
) = the_msg
.idata
[0];
2573 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_deltay
) = the_msg
.idata
[1];
2574 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_cursorx
) = the_msg
.idata
[2];
2575 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_cursory
) = the_msg
.idata
[3];
2576 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaledcursorx
) = the_msg
.fdata
[0];
2577 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaledcursory
) = the_msg
.fdata
[1];
2579 // joystick axis specific member members
2580 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_axis_position
) = the_msg
.idata
[0];
2581 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_scaled_axis_position
) = the_msg
.fdata
[0];
2582 OBJ_MEMBER_FLOAT(fake_msg
, HidMsg_offset_axis_position2
) = the_msg
.fdata
[0];
2584 // joystick hat specific member members
2585 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_hat_position
) = the_msg
.idata
[0];
2587 // keyboard specific members
2588 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_key
) = the_msg
.idata
[1];
2589 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_ascii
) = the_msg
.idata
[2];
2591 // accelerometer (tilt sensor, wii remote) specific members
2592 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_x
) = the_msg
.idata
[0];
2593 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_y
) = the_msg
.idata
[1];
2594 OBJ_MEMBER_INT(fake_msg
, HidMsg_offset_z
) = the_msg
.idata
[2];
2598 CK_DLL_MFUN( HidIn_send
)
2600 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2601 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2604 the_msg
.device_type
= OBJ_MEMBER_INT( fake_msg
, HidMsg_offset_device_type
);
2605 the_msg
.device_num
= OBJ_MEMBER_INT( fake_msg
, HidMsg_offset_device_num
);
2606 the_msg
.type
= OBJ_MEMBER_INT( fake_msg
, HidMsg_offset_type
);
2607 the_msg
.eid
= OBJ_MEMBER_INT( fake_msg
, HidMsg_offset_which
);
2608 the_msg
.idata
[0] = OBJ_MEMBER_INT( fake_msg
, HidMsg_offset_idata
);
2610 RETURN
->v_int
= min
->send( &the_msg
);
2613 CK_DLL_MFUN( HidIn_can_wait
)
2615 HidIn
* min
= (HidIn
*)OBJ_MEMBER_INT(SELF
, HidIn_offset_data
);
2616 RETURN
->v_int
= min
->empty();
2619 CK_DLL_SFUN( HidIn_read_tilt_sensor
)
2622 static t_CKBOOL hi_good
= TRUE
;
2624 Chuck_Array4
* array
= new Chuck_Array4( FALSE
, 3 );
2629 // TODO: reference count?
2631 RETURN
->v_object
= array
;
2633 if( hi_good
== FALSE
)
2639 if( !hi
->open( CK_HID_DEV_TILTSENSOR
, 0 ) )
2648 if( !hi
->read( CK_HID_ACCELEROMETER
, 0, &msg
) )
2653 array
->set( 0, msg
.idata
[0] );
2654 array
->set( 1, msg
.idata
[1] );
2655 array
->set( 2, msg
.idata
[2] );
2658 CK_DLL_SFUN( HidIn_start_cursor_track
)
2660 RETURN
->v_int
= !Mouse_start_cursor_track();
2663 CK_DLL_SFUN( HidIn_stop_cursor_track
)
2665 RETURN
->v_int
= !Mouse_stop_cursor_track();
2668 //-----------------------------------------------------------------------------
2670 //-----------------------------------------------------------------------------
2671 CK_DLL_CTOR( HidOut_ctor
)
2673 OBJ_MEMBER_INT(SELF
, HidOut_offset_data
) = (t_CKUINT
)new HidOut
;
2676 CK_DLL_DTOR( HidOut_dtor
)
2678 delete (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2679 OBJ_MEMBER_INT(SELF
, HidOut_offset_data
) = 0;
2682 CK_DLL_MFUN( HidOut_open
)
2684 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2685 t_CKINT num
= GET_CK_INT(ARGS
);
2686 RETURN
->v_int
= mout
->open( num
);
2689 CK_DLL_MFUN( HidOut_good
)
2691 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2692 RETURN
->v_int
= (t_CKINT
)mout
->good();
2695 CK_DLL_MFUN( HidOut_num
)
2697 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2698 RETURN
->v_int
= mout
->num();
2701 CK_DLL_MFUN( HidOut_name
)
2703 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2704 // TODO: memory leak, please fix, Thanks.
2705 Chuck_String
* a
= (Chuck_String
*)instantiate_and_initialize_object( &t_string
, NULL
);
2707 // if( mout->good() )
2708 // a->str = mout->mout->getPortName( mout->num() );
2709 RETURN
->v_string
= a
;
2712 CK_DLL_MFUN( HidOut_printerr
)
2714 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2715 t_CKINT print_or_not
= GET_CK_INT(ARGS
);
2716 mout
->set_suppress( !print_or_not
);
2719 CK_DLL_MFUN( HidOut_send
)
2721 HidOut
* mout
= (HidOut
*)OBJ_MEMBER_INT(SELF
, HidOut_offset_data
);
2722 Chuck_Object
* fake_msg
= GET_CK_OBJECT(ARGS
);
2724 /* the_msg.data[0] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data1);
2725 the_msg.data[1] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data2);
2726 the_msg.data[2] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data3);
2727 */ RETURN
->v_int
= mout
->send( &the_msg
);
2732 //-----------------------------------------------------------------------------
2734 //-----------------------------------------------------------------------------
2735 CK_DLL_CTOR( MidiRW_ctor
)
2737 OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
) = (t_CKUINT
)new MidiRW
;
2740 CK_DLL_DTOR( MidiRW_dtor
)
2742 delete (MidiRW
*)OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
);
2743 OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
) = 0;
2746 CK_DLL_MFUN( MidiRW_open
)
2748 MidiRW
* mrw
= (MidiRW
*)OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
);
2749 const char * filename
= GET_CK_STRING(ARGS
)->str
.c_str();
2750 RETURN
->v_int
= mrw
->open( filename
);
2753 CK_DLL_MFUN( MidiRW_close
)
2755 MidiRW
* mrw
= (MidiRW
*)OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
);
2756 RETURN
->v_int
= mrw
->close();
2759 CK_DLL_MFUN( MidiRW_read
)
2761 MidiRW
* mrw
= (MidiRW
*)OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
);
2762 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2764 t_CKTIME time
= 0.0;
2765 RETURN
->v_int
= mrw
->read( &the_msg
, &time
);
2766 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
) = the_msg
.data
[0];
2767 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
) = the_msg
.data
[1];
2768 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
) = the_msg
.data
[2];
2769 OBJ_MEMBER_TIME(fake_msg
, MidiMsg_offset_when
) = time
;
2772 CK_DLL_MFUN( MidiRW_write
)
2774 MidiRW
* mrw
= (MidiRW
*)OBJ_MEMBER_INT(SELF
, MidiRW_offset_data
);
2775 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2776 t_CKTIME time
= GET_NEXT_TIME(ARGS
);
2778 the_msg
.data
[0] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
);
2779 the_msg
.data
[1] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
);
2780 the_msg
.data
[2] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
);
2781 RETURN
->v_int
= mrw
->write( &the_msg
, &time
);
2785 //-----------------------------------------------------------------------------
2787 //-----------------------------------------------------------------------------
2788 CK_DLL_CTOR( MidiMsgOut_ctor
)
2790 OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
) = (t_CKUINT
)new MidiMsgOut
;
2793 CK_DLL_DTOR( MidiMsgOut_dtor
)
2795 delete (MidiMsgOut
*)OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
);
2796 OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
) = 0;
2799 CK_DLL_MFUN( MidiMsgOut_open
)
2801 MidiMsgOut
* mrw
= (MidiMsgOut
*)OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
);
2802 const char * filename
= GET_CK_STRING(ARGS
)->str
.c_str();
2803 RETURN
->v_int
= mrw
->open( filename
);
2806 CK_DLL_MFUN( MidiMsgOut_close
)
2808 MidiMsgOut
* mrw
= (MidiMsgOut
*)OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
);
2809 RETURN
->v_int
= mrw
->close();
2812 CK_DLL_MFUN( MidiMsgOut_write
)
2814 MidiMsgOut
* mrw
= (MidiMsgOut
*)OBJ_MEMBER_INT(SELF
, MidiMsgOut_offset_data
);
2815 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2816 t_CKTIME time
= GET_NEXT_TIME(ARGS
);
2818 the_msg
.data
[0] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
);
2819 the_msg
.data
[1] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
);
2820 the_msg
.data
[2] = (t_CKBYTE
)OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
);
2821 RETURN
->v_int
= mrw
->write( &the_msg
, &time
);
2825 //-----------------------------------------------------------------------------
2827 //-----------------------------------------------------------------------------
2828 CK_DLL_CTOR( MidiMsgIn_ctor
)
2830 OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
) = (t_CKUINT
)new MidiMsgIn
;
2833 CK_DLL_DTOR( MidiMsgIn_dtor
)
2835 delete (MidiMsgIn
*)OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
);
2836 OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
) = 0;
2839 CK_DLL_MFUN( MidiMsgIn_open
)
2841 MidiMsgIn
* mrw
= (MidiMsgIn
*)OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
);
2842 const char * filename
= GET_CK_STRING(ARGS
)->str
.c_str();
2843 RETURN
->v_int
= mrw
->open( filename
);
2846 CK_DLL_MFUN( MidiMsgIn_close
)
2848 MidiMsgIn
* mrw
= (MidiMsgIn
*)OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
);
2849 RETURN
->v_int
= mrw
->close();
2852 CK_DLL_MFUN( MidiMsgIn_read
)
2854 MidiMsgIn
* mrw
= (MidiMsgIn
*)OBJ_MEMBER_INT(SELF
, MidiMsgIn_offset_data
);
2855 Chuck_Object
* fake_msg
= GET_NEXT_OBJECT(ARGS
);
2857 t_CKTIME time
= 0.0;
2858 RETURN
->v_int
= mrw
->read( &the_msg
, &time
);
2859 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data1
) = the_msg
.data
[0];
2860 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data2
) = the_msg
.data
[1];
2861 OBJ_MEMBER_INT(fake_msg
, MidiMsg_offset_data3
) = the_msg
.data
[2];
2862 OBJ_MEMBER_TIME(fake_msg
, MidiMsg_offset_when
) = time
;