Codebase list angelscript / a5950d1
Documentation git-svn-id: http://svn.code.sf.net/p/angelscript/code/trunk@2614 404ce1b2-830e-0410-a2e2-b09542c77caf angelcode 4 years ago
3 changed file(s) with 161 addition(s) and 161 deletion(s). Raw diff Collapse all Expand all
394394
395395 \section doc_addon_ctxmgr_2 Public script interface
396396
397 <pre>
398 funcdef void coroutine(dictionary@);
399 void createCoRoutine(coroutine @, dictionary @);
400 void yield();
401 </pre>
402
403 <b>funcdef void coroutine(dictionary@)</b><br>
404 <b>void createCoRoutine(coroutine @, dictionary @)</b>
405
406 This function is used to create a co-routine. The co-routine will initiate in a
407 yielded state, i.e. it will only begin execution once the control is given to it
408 by the current thread.
409
410 Multiple co-routines can be created, and they will each take turn to execute in
411 round-robin fashion.
412
413 <b>void yield()</b>
414
415 Yields control of the execution for the next co-routine in the queue.
416
417 When a co-routine receives control it will resume execution from the last call to
418 yield, or the entry point if this is the first time the co-routine is allowed to execute.
397 \see \ref doc_script_stdlib_coroutine
398
419399
420400
421401
11941174
11951175 \section doc_addon_file_2 Public script interface
11961176
1197 <pre>
1198 class file
1199 {
1200 int open(const string &in filename, const string &in mode);
1201 int close();
1202 int getSize() const;
1203 bool isEndOfFile() const;
1204 string readString(uint length);
1205 string readLine();
1206 int64 readInt(uint bytes);
1207 uint64 readUInt(uint bytes);
1208 float readFloat();
1209 double readDouble();
1210 int writeString(const string &in str);
1211 int writeInt(int64 value, uint bytes);
1212 int writeUInt(uint64 value, uint bytes);
1213 int writeFloat(float value);
1214 int writeDouble(double value);
1215 int getPos() const;
1216 int setPos(int pos);
1217 int movePos(int delta);
1218 bool mostSignificantByteFirst;
1219 }
1220 </pre>
1221
1222 <b>int open(const string &in filename, const string &in mode)</b><br>
1223
1224 Opens a file. The mode can be "r" for reading, "w" for writing, or "a" for appending.
1225
1226 If the file couldn't be opened, a negative value is returned.
1227
1228 <b>int close()</b><br>
1229
1230 Closes the file.
1231
1232 If no file is open, a negative value is returned.
1233
1234 <b>int getSize() const</b><br>
1235
1236 Returns the size of the file, or a negative value if no file is open.
1237
1238 <b>bool isEndOfFile() const</b><br>
1239
1240 Returns true if the current position is at the end of the file.
1241
1242 <b>string readString(uint length)</b><br>
1243
1244 Reads \a length bytes into a string and returns it.
1245
1246 <b>string readLine()</b><br>
1247
1248 Reads until a new line character, e.g. '\\n', or end-of-file and returns the string. The new line character is also returned in the string.
1249
1250 <b>int64 readInt(uint bytes)</b><br>
1251
1252 Reads \a bytes as a signed integer number.
1253
1254 <b>uint64 readUInt(uint bytes)</b><br>
1255
1256 Reads \a bytes as an unsigned integer number.
1257
1258 <b>float readFloat()</b><br>
1259
1260 Reads 4 bytes as a float number.
1261
1262 <b>double readDouble()</b><br>
1263
1264 Reads 8 bytes as a double number.
1265
1266 <b>int writeString(const string &in str)</b><br>
1267
1268 Writes the bytes of the string into the file.
1269
1270 Returns the number of bytes written, or a negative value on error.
1271
1272 <b>int writeInt(int64 value, uint bytes)</b><br>
1273
1274 Writes \a bytes as a signed integer value.
1275
1276 Returns the number of bytes written, or a negative value on error.
1277
1278 <b>int writeUInt(uint64 value, uint bytes)</b><br>
1279
1280 Writes \a bytes as an unsigned integer value.
1281
1282 Returns the number of bytes written, or a negative value on error.
1283
1284 <b>int writeFloat(float value)</b><br>
1285
1286 Writes 4 bytes as a float value.
1287
1288 Returns the number of bytes written, or a negative value on error.
1289
1290 <b>int writeDouble(double value)</b><br>
1291
1292 Writes 8 bytes as a double value.
1293
1294 Returns the number of bytes written, or a negative value on error.
1295
1296 <b>int getPos() const</b><br>
1297
1298 Returns the current position in the file, or a negative value on error.
1299
1300 <b>int setPos(int pos)</b><br>
1301
1302 Sets the current position in the file. Returns the previous position or a negative value on error.
1303
1304 <b>int movePos(int delta)</b><br>
1305
1306 Moves the position \a delta bytes relative to the current position. Returns the previous position or a negative value on error.
1307
1308 <b>bool mostSignificantByteFirst</b><br>
1309
1310 This property should be set to true if the most significant bit should be read or written first in the methods that reads/writes numbers.
1311
1312 It is set to false by default, which is the standard on most platforms.
1313
1314 \section doc_addon_file_3 Script example
1315
1316 <pre>
1317 file f;
1318 // Open the file in 'read' mode
1319 if( f.open("file.txt", "r") >= 0 )
1320 {
1321 // Read the whole file into the string buffer
1322 string str = f.readString(f.getSize());
1323 f.close();
1324 }
1325 </pre>
1177 \see \ref doc_script_stdlib_file
1178
13261179
13271180
13281181
19461799
19471800 <b>Path:</b> /sdk/add_on/scripthelper/
19481801
1949 The \ref try "throw and getExceptionInfo" routines are registered by the application
1802 The exception handling routines are registered by the application
19501803 with a call to RegisterExceptionRoutines.
19511804
19521805 \section doc_addon_helpers_try_1 Public C++ interface
19571810 // 'string getExceptionInfo()'
19581811 void RegisterExceptionRoutines(asIScriptEngine *engine);
19591812 \endcode
1813
1814 \section doc_add_helpers_try_2 Public script interface
1815
1816 \see \ref doc_script_stdlib_exception
19601817
19611818
19621819
218218 - \ref doc_datatypes_strings "string"
219219 - \ref doc_datatypes_arrays "array"
220220 - \ref doc_datatypes_dictionary "dictionary"
221 - \ref doc_addon_file_2 "file"
221 - \ref doc_script_stdlib_file "file"
222222 - \ref doc_addon_filesystem_2 "filesystem"
223223 - \ref doc_script_stdlib_datetime "datetime"
224 - \ref doc_addon_ctxmgr_2 "co-routines"
224 - \ref doc_script_stdlib_coroutine "co-routines"
225225 - \ref doc_script_stdlib_exception "exception routines"
226226
227227
1313 - \subpage doc_datatypes_ref
1414 - \subpage doc_datatypes_weakref
1515 - \subpage doc_script_stdlib_datetime
16
17 \todo Add \ref doc_addon_ctxmgr_2 "co-routines", \ref doc_addon_file_2 "file", \ref doc_addon_filesystem_2 "filesystem",
16 - \subpage doc_script_stdlib_coroutine
17 - \subpage doc_script_stdlib_file
18
19 \todo Add \ref doc_addon_file_2 "file", \ref doc_addon_filesystem_2 "filesystem",
1820
1921
2022 \page doc_script_stdlib_exception Exception handling
101103 foo2(array<int> = {1,2,3,4});
102104 </pre>
103105
104 \section doc_datatypes_arrays_addon Supporting array object and functions
106 \section doc_datatypes_arrays_addon Supporting array object
105107
106108 The array object supports a number of operators and has several class methods to facilitate the manipulation of strings.
107109
305307 </pre>
306308
307309
308 \section doc_datatypes_dictionary_addon Supporting dictionary object and functions
310 \section doc_datatypes_dictionary_addon Supporting dictionary object
309311
310312 The dictionary object is a \ref doc_datatypes_obj "reference type", so it's possible
311313 to use handles to the dictionary object when passing it around to avoid costly copies.
363365
364366
365367
366 \section doc_datatypes_dictionaryValue_addon Supporting dictionaryValue object and functions
368 \section doc_datatypes_dictionaryValue_addon Supporting dictionaryValue object
367369
368370 The dictionaryValue type is how the \ref doc_datatypes_dictionary_addon "dictionary" object stores the
369371 values. When accessing the values through the dictionary index operator a reference to a dictionaryValue is returned.
834836 The datetime object can be compared for equality or relativity.
835837
836838
837
838
839
840 \page doc_script_stdlib_coroutine Co-routines
841
842 \note Support for co-routines is only available in the scripts if the application \ref doc_addon_ctxmgr "registers support for it".
843
844
845 \section doc_script_stdlib_coroutine_1 Functions
846
847 <b>funcdef void coroutine(dictionary@)</b><br>
848 <b>void createCoRoutine(coroutine @, dictionary @)</b>
849
850 This function is used to create a co-routine. The co-routine will initiate in a
851 yielded state, i.e. it will only begin execution once the control is given to it
852 by the current thread.
853
854 Multiple co-routines can be created, and they will each take turn to execute in
855 round-robin fashion.
856
857 <b>void yield()</b>
858
859 Yields control of the execution for the next co-routine in the queue.
860
861 When a co-routine receives control it will resume execution from the last call to
862 yield, or the entry point if this is the first time the co-routine is allowed to execute.
863
864
865
866
867 \page doc_script_stdlib_file file
868
869 \note file is only available in the scripts if the application \ref doc_addon_file "registers support for it".
870
871 Script example:
872
873 <pre>
874 file f;
875 // Open the file in 'read' mode
876 if( f.open("file.txt", "r") >= 0 )
877 {
878 // Read the whole file into the string buffer
879 string str = f.readString(f.getSize());
880 f.close();
881 }
882 </pre>
883
884 \section doc_script_stdlib_file_1 Supporting file object
885
886 \subsection doc_script_stdlib_file_1_1 Methods
887
888 <b>int open(const string &in filename, const string &in mode)</b><br>
889
890 Opens a file. The mode can be "r" for reading, "w" for writing, or "a" for appending.
891
892 If the file couldn't be opened, a negative value is returned.
893
894 <b>int close()</b><br>
895
896 Closes the file.
897
898 If no file is open, a negative value is returned.
899
900 <b>int getSize() const</b><br>
901
902 Returns the size of the file, or a negative value if no file is open.
903
904 <b>bool isEndOfFile() const</b><br>
905
906 Returns true if the current position is at the end of the file.
907
908 <b>string readString(uint length)</b><br>
909
910 Reads \a length bytes into a string and returns it.
911
912 <b>string readLine()</b><br>
913
914 Reads until a new line character, e.g. '\\n', or end-of-file and returns the string. The new line character is also returned in the string.
915
916 <b>int64 readInt(uint bytes)</b><br>
917
918 Reads \a bytes as a signed integer number.
919
920 <b>uint64 readUInt(uint bytes)</b><br>
921
922 Reads \a bytes as an unsigned integer number.
923
924 <b>float readFloat()</b><br>
925
926 Reads 4 bytes as a float number.
927
928 <b>double readDouble()</b><br>
929
930 Reads 8 bytes as a double number.
931
932 <b>int writeString(const string &in str)</b><br>
933
934 Writes the bytes of the string into the file.
935
936 Returns the number of bytes written, or a negative value on error.
937
938 <b>int writeInt(int64 value, uint bytes)</b><br>
939
940 Writes \a bytes as a signed integer value.
941
942 Returns the number of bytes written, or a negative value on error.
943
944 <b>int writeUInt(uint64 value, uint bytes)</b><br>
945
946 Writes \a bytes as an unsigned integer value.
947
948 Returns the number of bytes written, or a negative value on error.
949
950 <b>int writeFloat(float value)</b><br>
951
952 Writes 4 bytes as a float value.
953
954 Returns the number of bytes written, or a negative value on error.
955
956 <b>int writeDouble(double value)</b><br>
957
958 Writes 8 bytes as a double value.
959
960 Returns the number of bytes written, or a negative value on error.
961
962 <b>int getPos() const</b><br>
963
964 Returns the current position in the file, or a negative value on error.
965
966 <b>int setPos(int pos)</b><br>
967
968 Sets the current position in the file. Returns the previous position or a negative value on error.
969
970 <b>int movePos(int delta)</b><br>
971
972 Moves the position \a delta bytes relative to the current position. Returns the previous position or a negative value on error.
973
974 \subsection doc_script_stdlib_file_1_2 Properties
975
976 <b>bool mostSignificantByteFirst</b><br>
977
978 This property should be set to true if the most significant bit should be read or written first in the methods that reads/writes numbers.
979
980 It is set to false by default, which is the standard on most platforms.
981
839982
840983 */