| @@ -106,24 +106,28 @@ t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ) · 105 unmodified lines |
| 106 | 106 | |
| 107 | 107 | // add good() |
| 108 | 108 | func = make_new_mfun( "int", "good", io_dummy ); |
| 109 | | − func->doc = "_"; |
| 109 | + func->doc = "Returns whether IO is ready for reading."; |
| 110 | 110 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 111 | 111 | |
| 112 | 112 | // add close() |
| 113 | 113 | func = make_new_mfun( "void", "close", io_dummy ); |
| 114 | + func->doc = "Close the currently open IO."; |
| 114 | 115 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 115 | 116 | |
| 116 | 117 | // add flush() |
| 117 | 118 | func = make_new_mfun( "void", "flush", io_dummy ); |
| 119 | + func->doc = "Write any buffered output."; |
| 118 | 120 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 119 | 121 | |
| 120 | 122 | // add mode(int) |
| 121 | 123 | func = make_new_mfun( "int", "mode", io_dummy ); |
| 122 | 124 | func->add_arg( "int", "flag" ); |
| 125 | + func->doc = "Set the current IO mode; either IO.MODE_ASYNC or IO.MODE_SYNC."; |
| 123 | 126 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 124 | 127 | |
| 125 | 128 | // add mode() |
| 126 | 129 | func = make_new_mfun( "int", "mode", io_dummy ); |
| 130 | + func->doc = "Get the current IO mode; either IO.MODE_ASYNC or IO.MODE_SYNC."; |
| 127 | 131 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 128 | 132 | |
| 129 | 133 | // TODO: add this later? |
| @@ -134,11 +138,13 @@ t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ) · 4 unmodified lines |
| 134 | 138 | |
| 135 | 139 | // add readLine() |
| 136 | 140 | func = make_new_mfun( "string", "readLine", io_dummy ); |
| 141 | + func->doc = "Read until an end-of-line character."; |
| 137 | 142 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 138 | 143 | |
| 139 | 144 | // add readInt() |
| 140 | 145 | func = make_new_mfun( "int", "readInt", io_dummy ); |
| 141 | 146 | func->add_arg( "int", "flags" ); |
| 147 | + func->doc = "Read and return the next integer (binary mode); 'flags' denotes the bit-size of int (IO.INT8, IO.INT16, or IO.INT32)."; |
| 142 | 148 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 143 | 149 | |
| 144 | 150 | /* |
| @@ -164,81 +170,92 @@ t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ) · 19 unmodified lines |
| 164 | 170 | |
| 165 | 171 | // add eof() |
| 166 | 172 | func = make_new_mfun( "int", "eof", io_dummy ); |
| 173 | + func->doc = "Return whether end-of-file has been reached; the opposite of .more()."; |
| 167 | 174 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 168 | 175 | |
| 169 | 176 | // add more() |
| 170 | 177 | func = make_new_mfun( "int", "more", io_dummy ); |
| 178 | + func->doc = "Return whether there is more to read; the opposite of .eof()."; |
| 171 | 179 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 172 | 180 | |
| 173 | 181 | // add write(string) |
| 174 | 182 | func = make_new_mfun( "void", "write", io_dummy ); |
| 175 | 183 | func->add_arg( "string", "val" ); |
| 184 | + func->doc = "Write string 'val'."; |
| 176 | 185 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 177 | 186 | |
| 178 | 187 | // add write(int) |
| 179 | 188 | func = make_new_mfun( "void", "write", io_dummy ); |
| 180 | 189 | func->add_arg( "int", "val" ); |
| 190 | + func->doc = "Write integer 'val'."; |
| 181 | 191 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 182 | 192 | |
| 183 | 193 | // add write(float) |
| 184 | 194 | func = make_new_mfun( "void", "write", io_dummy ); |
| 185 | 195 | func->add_arg( "float", "val" ); |
| 196 | + func->doc = "Write floating point number 'val'."; |
| 186 | 197 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 187 | 198 | |
| 188 | 199 | // add newline |
| 189 | 200 | func = make_new_sfun( "string", "newline", io_newline ); |
| 201 | + func->doc = "newline character; same as IO.nl()."; |
| 190 | 202 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 203 | + // add nl |
| 191 | 204 | func = make_new_sfun( "string", "nl", io_newline ); |
| 205 | + func->doc = "newline character; same as IO.newline()."; |
| 192 | 206 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 193 | | − func = make_new_sfun( "string", "newlineEx2VistaHWNDVisualFoxProA", io_newline ); |
| 194 | | − if( !type_engine_import_sfun( env, func ) ) goto error; |
| 207 | + // hmm |
| 208 | + // func = make_new_sfun( "string", "newlineEx2VistaHWNDVisualFoxProA", io_newline ); |
| 209 | + // func->doc = "_"; |
| 210 | + // if( !type_engine_import_sfun( env, func ) ) goto error; |
| 211 | + // new line string |
| 195 | 212 | initialize_object( g_newline, env->t_string ); |
| 196 | 213 | g_newline->set( "\n" ); |
| 197 | 214 | |
| 198 | 215 | // add TYPE_ASCII |
| 199 | 216 | if( !type_engine_import_svar( env, "int", "ASCII", |
| 200 | | − TRUE, (t_CKUINT)&Chuck_IO::TYPE_ASCII ) ) goto error; |
| 217 | + TRUE, (t_CKUINT)&Chuck_IO::TYPE_ASCII, "Flag denoting ASCII IO mode." ) ) goto error; |
| 201 | 218 | // add TYPE_BINARY |
| 202 | 219 | if( !type_engine_import_svar( env, "int", "BINARY", |
| 203 | | − TRUE, (t_CKUINT)&Chuck_IO::TYPE_BINARY ) ) goto error; |
| 220 | + TRUE, (t_CKUINT)&Chuck_IO::TYPE_BINARY, "Flag denoting binary IO mode." ) ) goto error; |
| 204 | 221 | // add INT8 |
| 205 | 222 | if( !type_engine_import_svar( env, "int", "INT8", |
| 206 | | − TRUE, (t_CKUINT)&Chuck_IO::INT8 ) ) goto error; |
| 223 | + TRUE, (t_CKUINT)&Chuck_IO::INT8, "Flag denoting 8-bit integer type." ) ) goto error; |
| 207 | 224 | // add INT16 |
| 208 | 225 | if( !type_engine_import_svar( env, "int", "INT16", |
| 209 | | − TRUE, (t_CKUINT)&Chuck_IO::INT16 ) ) goto error; |
| 226 | + TRUE, (t_CKUINT)&Chuck_IO::INT16, "Flag denoting 16-bit integer type." ) ) goto error; |
| 210 | 227 | // add INT32 |
| 211 | 228 | if( !type_engine_import_svar( env, "int", "INT32", |
| 212 | | − TRUE, (t_CKUINT)&Chuck_IO::INT32 ) ) goto error; |
| 213 | | − // add READ_INT8 |
| 214 | | − if( !type_engine_import_svar( env, "int", "READ_INT8", |
| 215 | | − TRUE, (t_CKUINT)&Chuck_IO::INT8 ) ) goto error; |
| 216 | | − // add READ_INT16 |
| 217 | | − if( !type_engine_import_svar( env, "int", "READ_INT16", |
| 218 | | − TRUE, (t_CKUINT)&Chuck_IO::INT16 ) ) goto error; |
| 219 | | − // add READ_INT32 |
| 220 | | − if( !type_engine_import_svar( env, "int", "READ_INT32", |
| 221 | | − TRUE, (t_CKUINT)&Chuck_IO::INT32 ) ) goto error; |
| 229 | + TRUE, (t_CKUINT)&Chuck_IO::INT32, "Flag denoting 32-bit integer type." ) ) goto error; |
| 230 | +// // add READ_INT8 |
| 231 | +// if( !type_engine_import_svar( env, "int", "READ_INT8", |
| 232 | +// TRUE, (t_CKUINT)&Chuck_IO::INT8, "Flag denoting 8-bit integer type (same as INT8)." ) ) goto error; |
| 233 | +// // add READ_INT16 |
| 234 | +// if( !type_engine_import_svar( env, "int", "READ_INT16", |
| 235 | +// TRUE, (t_CKUINT)&Chuck_IO::INT16, "Flag denoting 16-bit integer type (same as INT16)." ) ) goto error; |
| 236 | +// // add READ_INT32 |
| 237 | +// if( !type_engine_import_svar( env, "int", "READ_INT32", |
| 238 | +// TRUE, (t_CKUINT)&Chuck_IO::INT32, "Flag denoting 32-bit integer type (same as INT32)." ) ) goto error; |
| 222 | 239 | // add MODE_SYNC |
| 223 | 240 | if( !type_engine_import_svar( env, "int", "MODE_SYNC", |
| 224 | | − TRUE, (t_CKUINT)&Chuck_IO::MODE_SYNC ) ) goto error; |
| 241 | + TRUE, (t_CKUINT)&Chuck_IO::MODE_SYNC, "Flag denoting synchronous IO." ) ) goto error; |
| 225 | 242 | #ifndef __DISABLE_FILEIO__ |
| 226 | 243 | // add MODE_ASYNC |
| 227 | 244 | if( !type_engine_import_svar( env, "int", "MODE_ASYNC", |
| 228 | | − TRUE, (t_CKUINT)&Chuck_IO::MODE_ASYNC ) ) goto error; |
| 245 | + TRUE, (t_CKUINT)&Chuck_IO::MODE_ASYNC, "Flag denoting asychronous IO." ) ) goto error; |
| 229 | 246 | #endif |
| 230 | 247 | // add FLAG_READONLY |
| 231 | 248 | if( !type_engine_import_svar( env, "int", "READ", |
| 232 | | − TRUE, (t_CKUINT)&Chuck_IO::FLAG_READONLY ) ) goto error; |
| 249 | + TRUE, (t_CKUINT)&Chuck_IO::FLAG_READONLY, "Flag denoting read mode." ) ) goto error; |
| 233 | 250 | // add FLAG_WRITEONLY |
| 234 | 251 | if( !type_engine_import_svar( env, "int", "WRITE", |
| 235 | | − TRUE, (t_CKUINT)&Chuck_IO::FLAG_WRITEONLY ) ) goto error; |
| 252 | + TRUE, (t_CKUINT)&Chuck_IO::FLAG_WRITEONLY, "Flag denoting write mode." ) ) goto error; |
| 236 | 253 | // add FLAG_APPEND |
| 237 | 254 | if( !type_engine_import_svar( env, "int", "APPEND", |
| 238 | | − TRUE, (t_CKUINT)&Chuck_IO::FLAG_APPEND ) ) goto error; |
| 255 | + TRUE, (t_CKUINT)&Chuck_IO::FLAG_APPEND, "Flag denoting append mode." ) ) goto error; |
| 239 | 256 | // add FLAG_READ_WRITE |
| 240 | 257 | if( !type_engine_import_svar( env, "int", "READ_WRITE", |
| 241 | | − TRUE, (t_CKUINT)&Chuck_IO::FLAG_READ_WRITE ) ) goto error; |
| 258 | + TRUE, (t_CKUINT)&Chuck_IO::FLAG_READ_WRITE, "Flag denoting read/write mode." ) ) goto error; |
| 242 | 259 | |
| 243 | 260 | // end the class import |
| 244 | 261 | type_engine_import_class_end( env ); |
| @@ -273,60 +290,72 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 28 unmodified lines |
| 273 | 290 | // TODO: ctor/dtor? |
| 274 | 291 | // TODO: replace dummy with pure function |
| 275 | 292 | if( !type_engine_import_class_begin( env, type, env->global(), fileio_ctor, fileio_dtor, |
| 276 | | − "Helper class doing file-related operations such as reading, writing, seeking, etc. See examples for usage." ) ) |
| 293 | + "File input and output utilities for reading, writing, seeking, etc. See examples for usage." ) ) |
| 277 | 294 | return FALSE; |
| 278 | 295 | |
| 279 | 296 | // add open(string) |
| 280 | 297 | func = make_new_mfun( "int", "open", fileio_open ); |
| 281 | 298 | func->add_arg( "string", "path" ); |
| 299 | + func->doc = "Open a file by name (and by default in ASCII mode)."; |
| 282 | 300 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 283 | 301 | |
| 284 | 302 | // add open(string, flags) |
| 285 | 303 | func = make_new_mfun( "int", "open", fileio_openflags ); |
| 286 | 304 | func->add_arg( "string", "path" ); |
| 287 | 305 | func->add_arg( "int", "flags" ); |
| 306 | + func->doc = "Open a file by name with flags (bitwise combinations of IO.READ, IO.WRITE, IO.READ_WRITE, IO_APPEND, IO.ASCII, IO.BINARY)."; |
| 288 | 307 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 289 | 308 | |
| 290 | 309 | // add good() |
| 291 | 310 | func = make_new_mfun( "int", "good", fileio_good ); |
| 311 | + func->doc = "Returns whether the file is ready for reading."; |
| 292 | 312 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 293 | 313 | |
| 294 | 314 | // add close() |
| 295 | 315 | func = make_new_mfun( "void", "close", fileio_close ); |
| 316 | + func->doc = "Close (and flush) the currently open file."; |
| 296 | 317 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 297 | 318 | |
| 298 | 319 | // add flush() |
| 299 | 320 | func = make_new_mfun( "void", "flush", fileio_flush ); |
| 321 | + func->doc = "Write any buffered output to file."; |
| 300 | 322 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 301 | 323 | |
| 302 | 324 | // add mode() |
| 303 | 325 | func = make_new_mfun( "int", "mode", fileio_getmode ); |
| 326 | + func->doc = "Get file IO mode (IO.MODE_SYNC or IO.MODE_ASYNC)."; |
| 304 | 327 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 305 | 328 | |
| 306 | 329 | // add mode(int) |
| 307 | 330 | func = make_new_mfun( "int", "mode", fileio_setmode ); |
| 308 | 331 | func->add_arg( "int", "flag" ); |
| 332 | + func->doc = "Set file IO mode (IO.MODE_SYNC or IO.MODE_ASYNC)."; |
| 309 | 333 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 310 | 334 | |
| 311 | 335 | // add size() |
| 312 | 336 | func = make_new_mfun( "int", "size", fileio_size ); |
| 337 | + func->doc = "Return the size of the file in bytes, or -1 if no file is opened or if a directory is opened."; |
| 313 | 338 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 314 | 339 | |
| 315 | 340 | // add seek(int) |
| 316 | 341 | func = make_new_mfun( "void", "seek", fileio_seek ); |
| 317 | 342 | func->add_arg( "int", "pos" ); |
| 343 | + func->doc = "Seek to a specified byte offset in file."; |
| 318 | 344 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 319 | 345 | |
| 320 | 346 | // add tell() |
| 321 | 347 | func = make_new_mfun( "int", "tell", fileio_tell ); |
| 348 | + func->doc = "Return the byte read offset of the file, or -1 if no file is opened."; |
| 322 | 349 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 323 | 350 | |
| 324 | 351 | // add isDir() |
| 325 | 352 | func = make_new_mfun( "int", "isDir", fileio_isdir ); |
| 353 | + func->doc = "Return if the open file is a directory."; |
| 326 | 354 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 327 | 355 | |
| 328 | 356 | // add dirList() |
| 329 | 357 | func = make_new_mfun( "string[]", "dirList", fileio_dirlist ); |
| 358 | + func->doc = "Get an array of file names in an open directory."; |
| 330 | 359 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 331 | 360 | |
| 332 | 361 | // add read() |
| @@ -336,6 +365,7 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 3 unmodified lines |
| 336 | 365 | |
| 337 | 366 | // add readLine() |
| 338 | 367 | func = make_new_mfun( "string", "readLine", fileio_readline ); |
| 368 | + func->doc = "Read and return the next line from file."; |
| 339 | 369 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 340 | 370 | |
| 341 | 371 | // add readInt() |
| @@ -345,6 +375,7 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 3 unmodified lines |
| 345 | 375 | // add readInt(int) |
| 346 | 376 | func = make_new_mfun( "int", "readInt", fileio_readintflags ); |
| 347 | 377 | func->add_arg( "int", "flags" ); |
| 378 | + func->doc = "Read and return an integer by size (binary mode) as specified in 'flags' (IO.INT8, IO.INT16, IO.INT32)."; |
| 348 | 379 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 349 | 380 | |
| 350 | 381 | /* |
| @@ -375,31 +406,37 @@ t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ) · 24 unmodified lines |
| 375 | 406 | |
| 376 | 407 | // add eof() |
| 377 | 408 | func = make_new_mfun( "int", "eof", fileio_eof ); |
| 409 | + func->doc = "Return whether end-of-file has been reached; the opposite of .more()."; |
| 378 | 410 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 379 | 411 | |
| 380 | 412 | // add more() |
| 381 | 413 | func = make_new_mfun( "int", "more", fileio_more ); |
| 414 | + func->doc = "Return whether there is more to read; the opposite of .eof()."; |
| 382 | 415 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 383 | 416 | |
| 384 | 417 | // add write(string) |
| 385 | 418 | func = make_new_mfun( "void", "write", fileio_writestring ); |
| 386 | 419 | func->add_arg( "string", "val" ); |
| 420 | + func->doc = "Write a string to file."; |
| 387 | 421 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 388 | 422 | |
| 389 | 423 | // add write(int) |
| 390 | 424 | func = make_new_mfun( "void", "write", fileio_writeint ); |
| 391 | 425 | func->add_arg( "int", "val" ); |
| 426 | + func->doc = "Write an integer to file."; |
| 392 | 427 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 393 | 428 | |
| 394 | 429 | // add write(int,flags) |
| 395 | 430 | func = make_new_mfun( "void", "write", fileio_writeintflags ); |
| 396 | 431 | func->add_arg( "int", "val" ); |
| 397 | 432 | func->add_arg( "int", "flags" ); |
| 433 | + func->doc = "Write integer to file (binary mode) by size as specified by 'flags' (IO.INT8, IO.INT16, IO.INT32)."; |
| 398 | 434 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 399 | 435 | |
| 400 | 436 | // add write(float) |
| 401 | 437 | func = make_new_mfun( "void", "write", fileio_writefloat ); |
| 402 | 438 | func->add_arg( "float", "val" ); |
| 439 | + func->doc = "Write integer to file."; |
| 403 | 440 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 404 | 441 | |
| 405 | 442 | // add examples |
| @@ -445,7 +482,7 @@ t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type ) · 39 unmodified lines |
| 445 | 482 | EM_log( CK_LOG_SEVERE, "class 'chout'" ); |
| 446 | 483 | |
| 447 | 484 | // TODO: ctor/dtor? |
| 448 | | − if( !type_engine_import_class_begin( env, type, env->global(), NULL, NULL, "Do not instantiate this class directly! Use `chout` instead." ) ) |
| 485 | + if( !type_engine_import_class_begin( env, type, env->global(), NULL, NULL, "Do not instantiate this class directly! Use 'chout' instead." ) ) |
| 449 | 486 | return FALSE; |
| 450 | 487 | |
| 451 | 488 | // add good() |
| @@ -538,7 +575,7 @@ t_CKBOOL init_class_cherr( Chuck_Env * env, Chuck_Type * type ) · 86 unmodified lines |
| 538 | 575 | EM_log( CK_LOG_SEVERE, "class 'cherr'" ); |
| 539 | 576 | |
| 540 | 577 | // TODO: ctor/dtor? |
| 541 | | − if( !type_engine_import_class_begin( env, type, env->global(), NULL, NULL, "Do not instantiate this class directly! Use `cherr` instead." ) ) |
| 578 | + if( !type_engine_import_class_begin( env, type, env->global(), NULL, NULL, "Do not instantiate this class directly! Use 'cherr' instead." ) ) |
| 542 | 579 | return FALSE; |
| 543 | 580 | |
| 544 | 581 | // add good() |
| @@ -698,7 +735,7 @@ t_CKBOOL init_class_Midi( Chuck_Env * env ) · 153 unmodified lines |
| 698 | 735 | |
| 699 | 736 | // add good() |
| 700 | 737 | func = make_new_mfun( "int", "good", MidiIn_good ); |
| 701 | | − func->doc = "Return 1 if a device has been opened for this instance and there was no error connecting to it. Return 0 if a device has not been opened or there was an error opening a device."; |
| 738 | + func->doc = "Return true (1) if a device has been opened for this instance and there was no error connecting to it. Return false (0) if a device has not been opened or there was an error opening a device."; |
| 702 | 739 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 703 | 740 | |
| 704 | 741 | // add num() |
| @@ -725,7 +762,8 @@ t_CKBOOL init_class_Midi( Chuck_Env * env ) · 20 unmodified lines |
| 725 | 762 | |
| 726 | 763 | // add can_wait() |
| 727 | 764 | func = make_new_mfun( "int", "can_wait", MidiIn_can_wait ); |
| 728 | | − func->doc = "Return 1 if the device has no more messages in its queue from the device, 0 if it has more messages."; |
| 765 | + func->doc = "(internal) used by virtual machine for synthronization."; |
| 766 | + // func->doc = "Return 1 if the device has no more messages in its queue from the device, 0 if it has more messages."; |
| 729 | 767 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 730 | 768 | |
| 731 | 769 | // add member variable |
| @@ -762,7 +800,7 @@ t_CKBOOL init_class_Midi( Chuck_Env * env ) · 30 unmodified lines |
| 762 | 800 | |
| 763 | 801 | // add good() |
| 764 | 802 | func = make_new_mfun( "int", "good", MidiOut_good ); |
| 765 | | − func->doc = "Return 1 if a device has been opened for this instance and there was no error connecting to it. Return 0 if a device has not been opened or there was an error opening a device."; |
| 803 | + func->doc = "Return true (1) if a device has been opened for this instance and there was no error connecting to it. Return false (0) if a device has not been opened or there was an error opening a device."; |
| 766 | 804 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 767 | 805 | |
| 768 | 806 | // add num() |
| @@ -854,7 +892,7 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 85 unmodified lines |
| 854 | 892 | std::string doc; |
| 855 | 893 | |
| 856 | 894 | // doc string |
| 857 | | − doc = "Creates a message for receiving HID information."; |
| 895 | + doc = "Helper class for receiving HID information; e.g., which key was pressed, joystick position, etc."; |
| 858 | 896 | |
| 859 | 897 | // init base class |
| 860 | 898 | if( !type_engine_import_class_begin( env, "HidMsg", "Object", |
| @@ -872,11 +910,13 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 11 unmodified lines |
| 872 | 910 | if( HidMsg_offset_device_num == CK_INVALID_OFFSET ) goto error; |
| 873 | 911 | |
| 874 | 912 | // add member variable |
| 875 | | − HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE ); |
| 913 | + doc = "A number representing the message type."; |
| 914 | + HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE, doc.c_str() ); |
| 876 | 915 | if( HidMsg_offset_type == CK_INVALID_OFFSET ) goto error; |
| 877 | 916 | |
| 878 | 917 | // add member variable |
| 879 | | − HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE ); |
| 918 | + doc = "Code (platform dependent) associated with a keyboard key."; |
| 919 | + HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE, doc.c_str() ); |
| 880 | 920 | if( HidMsg_offset_which == CK_INVALID_OFFSET ) goto error; |
| 881 | 921 | |
| 882 | 922 | // add member variable |
| @@ -950,27 +990,33 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 67 unmodified lines |
| 950 | 990 | if( HidMsg_offset_touchy == CK_INVALID_OFFSET ) goto error; |
| 951 | 991 | |
| 952 | 992 | // add member variable (added 1.3.0.0) |
| 953 | | − HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE ); |
| 993 | + doc = "Multi-touch size."; |
| 994 | + HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE, doc.c_str() ); |
| 954 | 995 | if( HidMsg_offset_touchsize == CK_INVALID_OFFSET ) goto error; |
| 955 | 996 | |
| 956 | 997 | // add member variable |
| 957 | | − HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE ); |
| 998 | + doc = "Joystick axis position (int)."; |
| 999 | + HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE, doc.c_str() ); |
| 958 | 1000 | if( HidMsg_offset_axis_position == CK_INVALID_OFFSET ) goto error; |
| 959 | 1001 | |
| 960 | 1002 | // add member variable |
| 961 | | − HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE ); |
| 1003 | + doc = "Joystick axis position (float)."; |
| 1004 | + HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE, doc.c_str() ); |
| 962 | 1005 | if( HidMsg_offset_axis_position2 == CK_INVALID_OFFSET ) goto error; |
| 963 | 1006 | |
| 964 | 1007 | // add member variable |
| 965 | | − HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE ); |
| 1008 | + doc = "Joystick hat position."; |
| 1009 | + HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE, doc.c_str() ); |
| 966 | 1010 | if( HidMsg_offset_hat_position == CK_INVALID_OFFSET ) goto error; |
| 967 | 1011 | |
| 968 | 1012 | // add member variable |
| 969 | | − HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE ); |
| 1013 | + doc = "ASCII value associated with a keyboard key."; |
| 1014 | + HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE, doc.c_str() ); |
| 970 | 1015 | if( HidMsg_offset_ascii == CK_INVALID_OFFSET ) goto error; |
| 971 | 1016 | |
| 972 | 1017 | // add member variable |
| 973 | | − HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE ); |
| 1018 | + doc = "Code (USB) for a keyboard key."; |
| 1019 | + HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE, doc.c_str() ); |
| 974 | 1020 | if( HidMsg_offset_key == CK_INVALID_OFFSET ) goto error; |
| 975 | 1021 | |
| 976 | 1022 | // add member variable |
| @@ -980,48 +1026,70 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 3 unmodified lines |
| 980 | 1026 | |
| 981 | 1027 | // add is_axis_motion() |
| 982 | 1028 | func = make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion ); // deprecated |
| 1029 | + func->doc = "(Deprecated; use .isAxisMotion() instead)."; |
| 983 | 1030 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 984 | 1031 | |
| 985 | 1032 | // add isAxisMotion() |
| 986 | 1033 | func = make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion ); |
| 1034 | + func->doc = "Return whether this message is an axis-motion event."; |
| 987 | 1035 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 988 | 1036 | |
| 989 | 1037 | // add is_button_down() |
| 990 | 1038 | func = make_new_mfun( "int", "is_button_down", HidMsg_is_button_down ); // deprecated |
| 1039 | + func->doc = "(Deprecated; use .isButtonDown() instead)."; |
| 991 | 1040 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 992 | 1041 | |
| 993 | 1042 | // add isButtonDown() |
| 994 | 1043 | func = make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down ); |
| 1044 | + func->doc = "Return whether this message is a button-down event."; |
| 995 | 1045 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 996 | 1046 | |
| 997 | 1047 | // add is_button_up() |
| 998 | 1048 | func = make_new_mfun( "int", "is_button_up", HidMsg_is_button_up ); // deprecated |
| 1049 | + func->doc = "(Deprecated; use .isButtonUp() instead)."; |
| 999 | 1050 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1000 | 1051 | |
| 1001 | 1052 | // add isButtonUp() |
| 1002 | 1053 | func = make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up ); |
| 1054 | + func->doc = "Return whether this message is a button-up event."; |
| 1003 | 1055 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1004 | 1056 | |
| 1005 | 1057 | // add is_mouse_motion() |
| 1006 | 1058 | func = make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion ); // deprecated |
| 1059 | + func->doc = "(Deprecated; use .isMouseMotion() instead)."; |
| 1007 | 1060 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1008 | 1061 | |
| 1009 | 1062 | // add isMouseMotion() |
| 1010 | 1063 | func = make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion ); |
| 1064 | + func->doc = "Return whether this message is a mouse-motion event."; |
| 1011 | 1065 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1012 | 1066 | |
| 1013 | 1067 | // add is_hat_motion() |
| 1014 | 1068 | func = make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion ); // deprecated |
| 1069 | + func->doc = "(Deprecated; use .isHatMotion() instead)."; |
| 1015 | 1070 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1016 | 1071 | |
| 1017 | 1072 | // add isHatMotion() |
| 1018 | 1073 | func = make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion ); |
| 1074 | + func->doc = "Return whether this message is a hat-motion event."; |
| 1019 | 1075 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1020 | 1076 | |
| 1021 | 1077 | // add isWheelMotion() |
| 1022 | 1078 | func = make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion ); |
| 1079 | + func->doc = "Return whether this message is a wheel-motion event."; |
| 1023 | 1080 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1024 | 1081 | |
| 1082 | + // add examples |
| 1083 | + if( !type_engine_import_add_ex( env, "hid/kb.ck" ) ) goto error; |
| 1084 | + if( !type_engine_import_add_ex( env, "hid/keyboard-organ.ck" ) ) goto error; |
| 1085 | + if( !type_engine_import_add_ex( env, "hid/mouse.ck" ) ) goto error; |
| 1086 | + if( !type_engine_import_add_ex( env, "hid/mouse-abs.ck" ) ) goto error; |
| 1087 | + if( !type_engine_import_add_ex( env, "hid/mouse-fm.ck" ) ) goto error; |
| 1088 | + if( !type_engine_import_add_ex( env, "hid/joy.ck" ) ) goto error; |
| 1089 | + if( !type_engine_import_add_ex( env, "hid/joy-fm.ck" ) ) goto error; |
| 1090 | + if( !type_engine_import_add_ex( env, "hid/joy-noise.ck" ) ) goto error; |
| 1091 | + if( !type_engine_import_add_ex( env, "hid/joy-shake.ck" ) ) goto error; |
| 1092 | + |
| 1025 | 1093 | // end the class import |
| 1026 | 1094 | type_engine_import_class_end( env ); |
| 1027 | 1095 | |
| @@ -1031,7 +1099,7 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 3 unmodified lines |
| 1031 | 1099 | |
| 1032 | 1100 | // init base class Hid (copy of HidIn + constants) |
| 1033 | 1101 | if( !type_engine_import_class_begin( env, "Hid", "Event", |
| 1034 | | − env->global(), HidIn_ctor, HidIn_dtor ) ) |
| 1102 | + env->global(), HidIn_ctor, HidIn_dtor, "Class for interacting with human-interface devices (HIDs) such as keyboards, mice, gamepads, joysticks, etc." ) ) |
| 1035 | 1103 | return FALSE; |
| 1036 | 1104 | |
| 1037 | 1105 | // add examples |
| @@ -1049,52 +1117,63 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 11 unmodified lines |
| 1049 | 1117 | func = make_new_mfun( "int", "open", HidIn_open ); |
| 1050 | 1118 | func->add_arg( "int", "type" ); |
| 1051 | 1119 | func->add_arg( "int", "num" ); |
| 1120 | + func->doc = "Open a HID device by device number ('num') and type ('type'). See static member variables for possible types."; |
| 1052 | 1121 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1053 | 1122 | |
| 1054 | 1123 | // add open() |
| 1055 | 1124 | func = make_new_mfun( "int", "open", HidIn_open_named ); |
| 1056 | 1125 | func->add_arg( "string", "name" ); |
| 1126 | + func->doc = "Open a HID device by name."; |
| 1057 | 1127 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1058 | 1128 | |
| 1059 | 1129 | // add openJoystick() |
| 1060 | 1130 | func = make_new_mfun( "int", "openJoystick", HidIn_open_joystick ); |
| 1061 | 1131 | func->add_arg( "int", "num" ); |
| 1132 | + func->doc = "Open a joystick/gamepad by device number."; |
| 1062 | 1133 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1063 | 1134 | |
| 1064 | 1135 | // add openMouse() |
| 1065 | 1136 | func = make_new_mfun( "int", "openMouse", HidIn_open_mouse ); |
| 1066 | 1137 | func->add_arg( "int", "num" ); |
| 1138 | + func->doc = "Open a mouse/trackpad by device number."; |
| 1067 | 1139 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1068 | 1140 | |
| 1069 | 1141 | // add openKeyboard() |
| 1070 | 1142 | func = make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard ); |
| 1071 | 1143 | func->add_arg( "int", "num" ); |
| 1144 | + func->doc = "Open a keyboard by device number."; |
| 1072 | 1145 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1073 | 1146 | |
| 1074 | 1147 | // add openTiltSensor() |
| 1075 | 1148 | func = make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor ); |
| 1149 | + func->doc = "Open a tilt-sensor by device number."; |
| 1076 | 1150 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1077 | 1151 | |
| 1078 | 1152 | // add good() |
| 1079 | 1153 | func = make_new_mfun( "int", "good", HidIn_good ); |
| 1154 | + func->doc = "Get whether a device has been successfully opened on this HID instance."; |
| 1080 | 1155 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1081 | 1156 | |
| 1082 | 1157 | // add num() |
| 1083 | 1158 | func = make_new_mfun( "int", "num", HidIn_num ); |
| 1159 | + func->doc = "Get the number of the currently open device; returns -1 if no device is open on this HID instance."; |
| 1084 | 1160 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1085 | 1161 | |
| 1086 | 1162 | // add name() |
| 1087 | 1163 | func = make_new_mfun( "string", "name", HidIn_name ); |
| 1164 | + func->doc = "Get the name of the currently open device; return empty string (\"\") if no device is open on this HID instance."; |
| 1088 | 1165 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1089 | 1166 | |
| 1090 | 1167 | // add printerr() |
| 1091 | 1168 | func = make_new_mfun( "void", "printerr", HidIn_printerr ); |
| 1092 | | − func->add_arg( "int", "print_or_not" ); |
| 1169 | + func->add_arg( "int", "toPrintOrNot" ); |
| 1170 | + func->doc = "Set whether to print errors (default is YES)."; |
| 1093 | 1171 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1094 | 1172 | |
| 1095 | 1173 | // add recv() |
| 1096 | 1174 | func = make_new_mfun( "int", "recv", HidIn_recv ); |
| 1097 | 1175 | func->add_arg( "HidMsg", "msg" ); |
| 1176 | + func->doc = "Receive the next available HidMsg."; |
| 1098 | 1177 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1099 | 1178 | |
| 1100 | 1179 | // add read() |
| @@ -1102,36 +1181,44 @@ t_CKBOOL init_class_HID( Chuck_Env * env ) · 1 unmodified line |
| 1102 | 1181 | func->add_arg( "int", "type" ); |
| 1103 | 1182 | func->add_arg( "int", "which" ); |
| 1104 | 1183 | func->add_arg( "HidMsg", "msg" ); |
| 1184 | + func->doc = "Read the next HidMsg from device of type 'type' with device id 'which'."; |
| 1105 | 1185 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1106 | 1186 | |
| 1107 | 1187 | // add send() |
| 1108 | 1188 | func = make_new_mfun( "int", "send", HidIn_send ); |
| 1109 | 1189 | func->add_arg( "HidMsg", "msg" ); |
| 1190 | + func->doc = "Send a HidMsg to device; return whether the operation was successful."; |
| 1110 | 1191 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1111 | 1192 | |
| 1112 | 1193 | // add can_wait() |
| 1113 | 1194 | func = make_new_mfun( "int", "can_wait", HidIn_can_wait ); |
| 1195 | + func->doc = "(internal) used by virtual machine for synthronization."; |
| 1114 | 1196 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1115 | 1197 | |
| 1116 | 1198 | // add readTiltSensor() |
| 1117 | 1199 | func = make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor ); |
| 1200 | + func->doc = "Read tilt-sensor and return as an int array."; |
| 1118 | 1201 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 1119 | 1202 | |
| 1120 | 1203 | // add globalTiltPollRate() |
| 1121 | 1204 | func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_ctrl_tiltPollRate ); |
| 1122 | 1205 | func->add_arg( "dur", "d" ); |
| 1206 | + func->doc = "Set tilt-sensor poll rate."; |
| 1123 | 1207 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 1124 | 1208 | |
| 1125 | 1209 | // add globalTiltPollRate() |
| 1126 | 1210 | func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_cget_tiltPollRate ); |
| 1211 | + func->doc = "Get tilt-sensor poll rate."; |
| 1127 | 1212 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 1128 | 1213 | |
| 1129 | 1214 | // add startCursorTrack() |
| 1130 | 1215 | func = make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track ); |
| 1216 | + func->doc = "Start cursor tracking; return whether the request was successful."; |
| 1131 | 1217 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 1132 | 1218 | |
| 1133 | 1219 | // add stopCursorTrack() |
| 1134 | 1220 | func = make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track ); |
| 1221 | + func->doc = "Stop cursor tracking; return whether the request was successful."; |
| 1135 | 1222 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 1136 | 1223 | |
| 1137 | 1224 | // add member variable |
| @@ -4390,7 +4477,7 @@ t_CKBOOL init_class_serialio( Chuck_Env * env ) · 3252 unmodified lines |
| 4390 | 4477 | |
| 4391 | 4478 | // add can_wait |
| 4392 | 4479 | // func = make_new_mfun("int", "can_wait", serialio_canWait); |
| 4393 | | − // func->doc = ""; |
| 4480 | + // func->doc = "(internal) used by virtual machine for synthronization."; |
| 4394 | 4481 | // if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4395 | 4482 | |
| 4396 | 4483 | // add file modes (moved into IO | 1.5.0.0 (ge)) |