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