diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2016-05-20 00:03:30 +0300 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2016-05-20 00:03:30 +0300 |
commit | 445cd962932c1957495a35add8cf5ca4618e035b (patch) | |
tree | d0303f3704acb804cb8281f3b7c38010afa423e6 /indra/lscript/lscript_library | |
parent | 6f5f307e0a751a78fbdfb4c6a1f8757ea55bf1dd (diff) | |
parent | c2ef3b4c7186dbbd95b16520f281b7d58364fb52 (diff) |
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/lscript/lscript_library')
-rwxr-xr-x | indra/lscript/lscript_library/CMakeLists.txt | 35 | ||||
-rwxr-xr-x | indra/lscript/lscript_library/lscript_alloc.cpp | 1136 | ||||
-rwxr-xr-x | indra/lscript/lscript_library/lscript_export.cpp | 26 | ||||
-rwxr-xr-x | indra/lscript/lscript_library/lscript_library.cpp | 582 |
4 files changed, 0 insertions, 1779 deletions
diff --git a/indra/lscript/lscript_library/CMakeLists.txt b/indra/lscript/lscript_library/CMakeLists.txt deleted file mode 100755 index 5af850c41b..0000000000 --- a/indra/lscript/lscript_library/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# -*- cmake -*- - -include(00-Common) -include(LLCommon) -include(LLMath) -include(LScript) - -set(lscript_library_SOURCE_FILES - lscript_alloc.cpp - lscript_export.cpp - lscript_library.cpp - ) - -set(lscript_library_HEADER_FILES - CMakeLists.txt - - ../lscript_library.h - ../lscript_export.h - ) - -set_source_files_properties(${lscript_library_HEADER_FILES} - PROPERTIES HEADER_FILE_ONLY TRUE) - -list(APPEND lscript_library_SOURCE_FILES ${lscript_library_HEADER_FILES}) - -include_directories( - ${LLCOMMON_INCLUDE_DIRS} - ${LLMATH_INCLUDE_DIRS} - ${LSCRIPT_INCLUDE_DIRS} - ) -include_directories(SYSTEM - ${LLCOMMON_SYSTEM_INCLUDE_DIRS} - ) - -add_library (lscript_library ${lscript_library_SOURCE_FILES}) diff --git a/indra/lscript/lscript_library/lscript_alloc.cpp b/indra/lscript/lscript_library/lscript_alloc.cpp deleted file mode 100755 index 62ba029e8a..0000000000 --- a/indra/lscript/lscript_library/lscript_alloc.cpp +++ /dev/null @@ -1,1136 +0,0 @@ -/** - * @file lscript_alloc.cpp - * @brief general heap management for scripting system - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// #define at top of file accelerates gcc compiles -// Under gcc 2.9, the manual is unclear if comments can appear above #ifndef -// Under gcc 3, the manual explicitly states comments can appear above the #ifndef - -#include "linden_common.h" -#include "lscript_alloc.h" -#include "llrand.h" - -// supported data types - -// basic types -// integer 4 bytes of integer data -// float 4 bytes of float data -// string data null terminated 1 byte string -// key data null terminated 1 byte string -// vector data 12 bytes of 3 floats -// quaternion data 16 bytes of 4 floats - -// list type -// list data 4 bytes of number of entries followed by pointer - -// string pointer 4 bytes of address of string data on the heap (only used in list data) -// key pointer 4 bytes of address of key data on the heap (only used in list data) - -// heap format -// -// 4 byte offset to next block (in bytes) -// 1 byte of type of variable or empty -// 2 bytes of reference count -// nn bytes of data - -void reset_hp_to_safe_spot(const U8 *buffer) -{ - set_register((U8 *)buffer, LREG_HP, TOP_OF_MEMORY); -} - -// create a heap from the HR to TM -BOOL lsa_create_heap(U8 *heap_start, S32 size) -{ - LLScriptAllocEntry entry(size, LST_NULL); - - S32 position = 0; - - alloc_entry2bytestream(heap_start, position, entry); - - return TRUE; -} - -S32 lsa_heap_top(U8 *heap_start, S32 maxtop) -{ - S32 offset = 0; - LLScriptAllocEntry entry; - bytestream2alloc_entry(entry, heap_start, offset); - - while (offset + entry.mSize < maxtop) - { - offset += entry.mSize; - bytestream2alloc_entry(entry, heap_start, offset); - } - return offset + entry.mSize; -} - - -// adding to heap -// if block is empty -// if block is at least block size + 4 larger than data -// split block -// insert data into first part -// return address -// else -// insert data into block -// return address -// else -// if next block is >= SP -// set Stack-Heap collision -// return NULL -// if next block is empty -// merge next block with current block -// go to start of algorithm -// else -// move to next block -// go to start of algorithm - -S32 lsa_heap_add_data(U8 *buffer, LLScriptLibData *data, S32 heapsize, BOOL b_delete) -{ - if (get_register(buffer, LREG_FR)) - return 1; - LLScriptAllocEntry entry, nextentry; - S32 hr = get_register(buffer, LREG_HR); - S32 hp = get_register(buffer, LREG_HP); - S32 current_offset, next_offset, offset = hr; - S32 size = 0; - - switch(data->mType) - { - case LST_INTEGER: - size = 4; - break; - case LST_FLOATINGPOINT: - size = 4; - break; - case LST_KEY: - // NOTE: babbage: defensive as some library calls set data to NULL - size = data->mKey ? (S32)strlen(data->mKey) + 1 : 1; /*Flawfinder: ignore*/ - break; - case LST_STRING: - // NOTE: babbage: defensive as some library calls set data to NULL - size = data->mString ? (S32)strlen(data->mString) + 1 : 1; /*Flawfinder: ignore*/ - break; - case LST_LIST: - // list data 4 bytes of number of entries followed by number of pointer - size = 4 + 4*data->getListLength(); - if (data->checkForMultipleLists()) - { - set_fault(buffer, LSRF_NESTING_LISTS); - } - break; - case LST_VECTOR: - size = 12; - break; - case LST_QUATERNION: - size = 16; - break; - default: - break; - } - - current_offset = offset; - bytestream2alloc_entry(entry, buffer, offset); - - do - { - hp = get_register(buffer, LREG_HP); - if (!entry.mType) - { - if (entry.mSize >= size + SIZEOF_SCRIPT_ALLOC_ENTRY + 4) - { - offset = current_offset; - lsa_split_block(buffer, offset, size, entry); - entry.mType = data->mType; - entry.mSize = size; - entry.mReferenceCount = 1; - offset = current_offset; - alloc_entry2bytestream(buffer, offset, entry); - lsa_insert_data(buffer, offset, data, entry, heapsize); - hp = get_register(buffer, LREG_HP); - S32 new_hp = current_offset + size + 2*SIZEOF_SCRIPT_ALLOC_ENTRY; - if (new_hp >= hr + heapsize) - { - break; - } - if (new_hp > hp) - { - set_register(buffer, LREG_HP, new_hp); - hp = get_register(buffer, LREG_HP); - } - if (b_delete) - delete data; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - if (current_offset <= hp) - return current_offset - hr + 1; - else - return hp - hr + 1; - } - else if (entry.mSize >= size) - { - entry.mType = data->mType; - entry.mReferenceCount = 1; - offset = current_offset; - alloc_entry2bytestream(buffer, offset, entry); - lsa_insert_data(buffer, offset, data, entry, heapsize); - hp = get_register(buffer, LREG_HP); - if (b_delete) - delete data; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - return current_offset - hr + 1; - } - } - offset += entry.mSize; - if (offset < hr + heapsize) - { - next_offset = offset; - bytestream2alloc_entry(nextentry, buffer, offset); - if (!nextentry.mType && !entry.mType) - { - entry.mSize += nextentry.mSize + SIZEOF_SCRIPT_ALLOC_ENTRY; - offset = current_offset; - alloc_entry2bytestream(buffer, offset, entry); - } - else - { - current_offset = next_offset; - entry = nextentry; - } - - // this works whether we are bumping out or coming in - S32 new_hp = current_offset + size + 2*SIZEOF_SCRIPT_ALLOC_ENTRY; - - // make sure we aren't about to be stupid - if (new_hp >= hr + heapsize) - { - break; - } - if (new_hp > hp) - { - set_register(buffer, LREG_HP, new_hp); - hp = get_register(buffer, LREG_HP); - } - } - else - { - break; - } - } while (1); - set_fault(buffer, LSRF_STACK_HEAP_COLLISION); - reset_hp_to_safe_spot(buffer); - if (b_delete) - delete data; - return 0; -} - -// split block -// set offset to point to new block -// set offset of new block to point to original offset - block size - data size -// set new block to empty -// set new block reference count to 0 -void lsa_split_block(U8 *buffer, S32 &offset, S32 size, LLScriptAllocEntry &entry) -{ - if (get_register(buffer, LREG_FR)) - return; - LLScriptAllocEntry newentry; - - newentry.mSize = entry.mSize - SIZEOF_SCRIPT_ALLOC_ENTRY - size; - entry.mSize -= newentry.mSize + SIZEOF_SCRIPT_ALLOC_ENTRY; - - alloc_entry2bytestream(buffer, offset, entry); - S32 orig_offset = offset + size; - alloc_entry2bytestream(buffer, orig_offset, newentry); -} - -// insert data -// if data is non-list type -// set type to basic type, set reference count to 1, copy data, return address -// else -// set type to list data type, set reference count to 1 -// save length of list -// for each list entry -// insert data -// return address - -void lsa_insert_data(U8 *buffer, S32 &offset, LLScriptLibData *data, LLScriptAllocEntry &entry, S32 heapsize) -{ - if (get_register(buffer, LREG_FR)) - return; - if (data->mType != LST_LIST) - { - switch(data->mType) - { - case LST_INTEGER: - integer2bytestream(buffer, offset, data->mInteger); - break; - case LST_FLOATINGPOINT: - float2bytestream(buffer, offset, data->mFP); - break; - case LST_KEY: - char2bytestream(buffer, offset, data->mKey ? data->mKey : ""); - break; - case LST_STRING: - char2bytestream(buffer, offset, data->mString ? data->mString : ""); - break; - case LST_VECTOR: - vector2bytestream(buffer, offset, data->mVec); - break; - case LST_QUATERNION: - quaternion2bytestream(buffer, offset, data->mQuat); - break; - default: - break; - } - } - else - { - // store length of list - integer2bytestream(buffer, offset, data->getListLength()); - data = data->mListp; - while(data) - { - // store entry and then store address if valid - S32 address = lsa_heap_add_data(buffer, data, heapsize, FALSE); - integer2bytestream(buffer, offset, address); - data = data->mListp; - } - } -} - -S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset) -{ - S32 offset = 0; - S32 size = 0; - - LLScriptAllocEntry entry; - - if (!data) - { - entry.mType = LST_NULL; - entry.mReferenceCount = 0; - entry.mSize = MAX_HEAP_SIZE; - size = SIZEOF_SCRIPT_ALLOC_ENTRY; - *buffer = new U8[size]; - alloc_entry2bytestream(*buffer, offset, entry); - return size; - } - - entry.mType = data->mType; - entry.mReferenceCount = 1; - - if (data->mType != LST_LIST) - { - if ( (data->mType != LST_STRING) - &&(data->mType != LST_KEY)) - { - size = LSCRIPTDataSize[data->mType]; - } - else - { - if (data->mType == LST_STRING) - { - if (data->mString) - { - size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/ - } - else - { - size = 1; - } - } - if (data->mType == LST_KEY) - { - if (data->mKey) - { - size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/ - } - else - { - size = 1; - } - } - } - entry.mSize = size; - size += SIZEOF_SCRIPT_ALLOC_ENTRY; - *buffer = new U8[size]; - alloc_entry2bytestream(*buffer, offset, entry); - - switch(data->mType) - { - case LST_INTEGER: - integer2bytestream(*buffer, offset, data->mInteger); - break; - case LST_FLOATINGPOINT: - float2bytestream(*buffer, offset, data->mFP); - break; - case LST_KEY: - if (data->mKey) - char2bytestream(*buffer, offset, data->mKey); - else - byte2bytestream(*buffer, offset, 0); - break; - case LST_STRING: - if (data->mString) - char2bytestream(*buffer, offset, data->mString); - else - byte2bytestream(*buffer, offset, 0); - break; - case LST_VECTOR: - vector2bytestream(*buffer, offset, data->mVec); - break; - case LST_QUATERNION: - quaternion2bytestream(*buffer, offset, data->mQuat); - break; - default: - break; - } - } - else - { - U8 *listbuf; - S32 length = data->getListLength(); - size = 4 * length + 4; - entry.mSize = size; - - size += SIZEOF_SCRIPT_ALLOC_ENTRY; - *buffer = new U8[size]; - - alloc_entry2bytestream(*buffer, offset, entry); - // store length of list - integer2bytestream(*buffer, offset, length); - data = data->mListp; - while(data) - { - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - integer2bytestream(*buffer, offset, size + base_offset + 1); - - S32 listsize = lsa_create_data_block(&listbuf, data, base_offset + size); - if (listsize) - { - U8 *tbuff = new U8[size + listsize]; - if (tbuff == NULL) - { - LL_ERRS() << "Memory Allocation Failed" << LL_ENDL; - } - memcpy(tbuff, *buffer, size); /*Flawfinder: ignore*/ - memcpy(tbuff + size, listbuf, listsize); /*Flawfinder: ignore*/ - size += listsize; - delete [] *buffer; - delete [] listbuf; - *buffer = tbuff; - } - data = data->mListp; - } - } - return size; -} - -// increase reference count -// increase reference count by 1 - -void lsa_increase_ref_count(U8 *buffer, S32 offset) -{ - if (get_register(buffer, LREG_FR)) - return; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - offset += get_register(buffer, LREG_HR) - 1; - if ( (offset < get_register(buffer, LREG_HR)) - ||(offset >= get_register(buffer, LREG_HP))) - { - set_fault(buffer, LSRF_BOUND_CHECK_ERROR); - return; - } - S32 orig_offset = offset; - LLScriptAllocEntry entry; - bytestream2alloc_entry(entry, buffer, offset); - - entry.mReferenceCount++; - - alloc_entry2bytestream(buffer, orig_offset, entry); -} - -// decrease reference count -// decrease reference count by 1 -// if reference count == 0 -// set type to empty - -void lsa_decrease_ref_count(U8 *buffer, S32 offset) -{ - if (get_register(buffer, LREG_FR)) - return; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - offset += get_register(buffer, LREG_HR) - 1; - if ( (offset < get_register(buffer, LREG_HR)) - ||(offset >= get_register(buffer, LREG_HP))) - { - set_fault(buffer, LSRF_BOUND_CHECK_ERROR); - return; - } - S32 orig_offset = offset; - LLScriptAllocEntry entry; - bytestream2alloc_entry(entry, buffer, offset); - - entry.mReferenceCount--; - - if (entry.mReferenceCount < 0) - { - entry.mReferenceCount = 0; - set_fault(buffer, LSRF_HEAP_ERROR); - } - else if (!entry.mReferenceCount) - { - if (entry.mType == LST_LIST) - { - S32 i, num = bytestream2integer(buffer, offset); - for (i = 0; i < num; i++) - { - S32 list_offset = bytestream2integer(buffer, offset); - lsa_decrease_ref_count(buffer, list_offset); - } - } - entry.mType = LST_NULL; - } - - alloc_entry2bytestream(buffer, orig_offset, entry); -} - -char gLSAStringRead[TOP_OF_MEMORY]; /*Flawfinder: ignore*/ - - -LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) -{ - if (get_register(buffer, LREG_FR)) - return (new LLScriptLibData); - S32 orig_offset = offset; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - offset += get_register(buffer, LREG_HR) - 1; - if ( (offset < get_register(buffer, LREG_HR)) - ||(offset >= get_register(buffer, LREG_HP))) - { - set_fault(buffer, LSRF_BOUND_CHECK_ERROR); - return (new LLScriptLibData); - } - LLScriptAllocEntry entry; - bytestream2alloc_entry(entry, buffer, offset); - - LLScriptLibData *retval = new LLScriptLibData; - - if (!entry.mType) - { - set_fault(buffer, LSRF_HEAP_ERROR); - return retval; - } - - retval->mType = (LSCRIPTType)entry.mType; - if (entry.mType != LST_LIST) - { - switch(entry.mType) - { - case LST_INTEGER: - retval->mInteger = bytestream2integer(buffer, offset); - break; - case LST_FLOATINGPOINT: - retval->mFP = bytestream2float(buffer, offset); - break; - case LST_KEY: - bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); // global sring buffer? for real? :( - retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ - strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/ - break; - case LST_STRING: - bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); - retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ - strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/ - break; - case LST_VECTOR: - bytestream2vector(retval->mVec, buffer, offset); - break; - case LST_QUATERNION: - bytestream2quaternion(retval->mQuat, buffer, offset); - break; - default: - break; - } - } - else - { - // get length of list - S32 i, length = bytestream2integer(buffer, offset); - LLScriptLibData *tip = retval; - - for (i = 0; i < length; i++) - { - S32 address = bytestream2integer(buffer, offset); - tip->mListp = lsa_get_data(buffer, address, FALSE); - tip = tip->mListp; - } - } - if (retval->checkForMultipleLists()) - { - set_fault(buffer, LSRF_NESTING_LISTS); - } - if (b_dec_ref) - { - lsa_decrease_ref_count(buffer, orig_offset); - } - return retval; -} - -LLScriptLibData *lsa_get_list_ptr(U8 *buffer, S32 &offset, BOOL b_dec_ref) -{ - if (get_register(buffer, LREG_FR)) - return (new LLScriptLibData); - S32 orig_offset = offset; - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) - offset += get_register(buffer, LREG_HR) - 1; - if ( (offset < get_register(buffer, LREG_HR)) - ||(offset >= get_register(buffer, LREG_HP))) - { - set_fault(buffer, LSRF_BOUND_CHECK_ERROR); - return (new LLScriptLibData); - } - LLScriptAllocEntry entry; - bytestream2alloc_entry(entry, buffer, offset); - - if (!entry.mType) - { - set_fault(buffer, LSRF_HEAP_ERROR); - return NULL; - } - - LLScriptLibData base, *tip = &base; - - if (entry.mType != LST_LIST) - { - return NULL; - } - else - { - // get length of list - S32 i, length = bytestream2integer(buffer, offset); - - for (i = 0; i < length; i++) - { - S32 address = bytestream2integer(buffer, offset); - tip->mListp = lsa_get_data(buffer, address, FALSE); - tip = tip->mListp; - } - } - if (b_dec_ref) - { - lsa_decrease_ref_count(buffer, orig_offset); - } - tip = base.mListp; - base.mListp = NULL; - return tip; -} - -S32 lsa_cat_strings(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *string1; - LLScriptLibData *string2; - if (offset1 != offset2) - { - string1 = lsa_get_data(buffer, offset1, TRUE); - string2 = lsa_get_data(buffer, offset2, TRUE); - } - else - { - string1 = lsa_get_data(buffer, offset1, TRUE); - string2 = lsa_get_data(buffer, offset2, TRUE); - } - - if ( (!string1) - ||(!string2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete string1; - delete string2; - return 0; - } - - char *test1 = NULL, *test2 = NULL; - - if (string1->mType == LST_STRING) - { - test1 = string1->mString; - } - else if (string1->mType == LST_KEY) - { - test1 = string1->mKey; - } - if (string2->mType == LST_STRING) - { - test2 = string2->mString; - } - else if (string2->mType == LST_KEY) - { - test2 = string2->mKey; - } - - if ( (!test1) - ||(!test2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete string1; - delete string2; - return 0; - } - - S32 size = (S32)strlen(test1) + (S32)strlen(test2) + 1; /*Flawfinder: ignore*/ - - LLScriptLibData *string3 = new LLScriptLibData; - string3->mType = LST_STRING; - string3->mString = new char[size]; - strcpy(string3->mString, test1); /*Flawfinder: ignore*/ - strcat(string3->mString, test2); /*Flawfinder: ignore*/ - - delete string1; - delete string2; - - return lsa_heap_add_data(buffer, string3, heapsize, TRUE); -} - -S32 lsa_cmp_strings(U8 *buffer, S32 offset1, S32 offset2) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *string1; - LLScriptLibData *string2; - - string1 = lsa_get_data(buffer, offset1, TRUE); - string2 = lsa_get_data(buffer, offset2, TRUE); - - if ( (!string1) - ||(!string2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete string1; - delete string2; - return 0; - } - - char *test1 = NULL, *test2 = NULL; - - if (string1->mType == LST_STRING) - { - test1 = string1->mString; - } - else if (string1->mType == LST_KEY) - { - test1 = string1->mKey; - } - if (string2->mType == LST_STRING) - { - test2 = string2->mString; - } - else if (string2->mType == LST_KEY) - { - test2 = string2->mKey; - } - - if ( (!test1) - ||(!test2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete string1; - delete string2; - return 0; - } - S32 retval = strcmp(test1, test2); - - delete string1; - delete string2; - - return retval; -} - -void lsa_print_heap(U8 *buffer) -{ - S32 offset = get_register(buffer, LREG_HR); - S32 readoffset; - S32 ivalue; - F32 fpvalue; - LLVector3 vvalue; - LLQuaternion qvalue; - char string[4096]; /*Flawfinder: ignore*/ - - LLScriptAllocEntry entry; - - bytestream2alloc_entry(entry, buffer, offset); - - printf("HP: [0x%X]\n", get_register(buffer, LREG_HP)); - printf("==========\n"); - - while (offset + entry.mSize < MAX_HEAP_SIZE) - { - printf("[0x%X] ", offset); - printf("%s ", LSCRIPTTypeNames[entry.mType]); - printf("Ref Count: %d ", entry.mReferenceCount); - printf("Size: %d = ", entry.mSize); - - readoffset = offset; - - switch(entry.mType) - { - case LST_INTEGER: - ivalue = bytestream2integer(buffer, readoffset); - printf("%d\n", ivalue); - break; - case LST_FLOATINGPOINT: - fpvalue = bytestream2float(buffer, readoffset); - printf("%f\n", fpvalue); - break; - case LST_STRING: - bytestream2char(string, buffer, readoffset, sizeof(string)); - printf("%s\n", string); - break; - case LST_KEY: - bytestream2char(string, buffer, readoffset, sizeof(string)); - printf("%s\n", string); - break; - case LST_VECTOR: - bytestream2vector(vvalue, buffer, readoffset); - printf("< %f, %f, %f >\n", vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]); - break; - case LST_QUATERNION: - bytestream2quaternion(qvalue, buffer, readoffset); - printf("< %f, %f, %f, %f >\n", qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]); - break; - case LST_LIST: - ivalue = bytestream2integer(buffer, readoffset); - printf("%d\n", ivalue); - break; - default: - printf("\n"); - break; - } - offset += entry.mSize; - bytestream2alloc_entry(entry, buffer, offset); - } - printf("[0x%X] ", offset); - printf("%s ", LSCRIPTTypeNames[entry.mType]); - printf("Ref Count: %d ", entry.mReferenceCount); - printf("Size: %d\n", entry.mSize); - printf("==========\n"); -} - -void lsa_fprint_heap(U8 *buffer, LLFILE *fp) -{ - S32 offset = get_register(buffer, LREG_HR); - S32 readoffset; - S32 ivalue; - F32 fpvalue; - LLVector3 vvalue; - LLQuaternion qvalue; - char string[4096]; /*Flawfinder: ignore*/ - - LLScriptAllocEntry entry; - - bytestream2alloc_entry(entry, buffer, offset); - - while (offset + entry.mSize < MAX_HEAP_SIZE) - { - fprintf(fp, "[0x%X] ", offset); - fprintf(fp, "%s ", LSCRIPTTypeNames[entry.mType]); - fprintf(fp, "Ref Count: %d ", entry.mReferenceCount); - fprintf(fp, "Size: %d = ", entry.mSize); - - readoffset = offset; - - switch(entry.mType) - { - case LST_INTEGER: - ivalue = bytestream2integer(buffer, readoffset); - fprintf(fp, "%d\n", ivalue); - break; - case LST_FLOATINGPOINT: - fpvalue = bytestream2float(buffer, readoffset); - fprintf(fp, "%f\n", fpvalue); - break; - case LST_STRING: - bytestream2char(string, buffer, readoffset, sizeof(string)); - fprintf(fp, "%s\n", string); - break; - case LST_KEY: - bytestream2char(string, buffer, readoffset, sizeof(string)); - fprintf(fp, "%s\n", string); - break; - case LST_VECTOR: - bytestream2vector(vvalue, buffer, readoffset); - fprintf(fp, "< %f, %f, %f >\n", vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]); - break; - case LST_QUATERNION: - bytestream2quaternion(qvalue, buffer, readoffset); - fprintf(fp, "< %f, %f, %f, %f >\n", qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]); - break; - case LST_LIST: - ivalue = bytestream2integer(buffer, readoffset); - fprintf(fp, "%d\n", ivalue); - break; - default: - fprintf(fp, "\n"); - break; - } - offset += entry.mSize; - bytestream2alloc_entry(entry, buffer, offset); - } - fprintf(fp, "[0x%X] ", offset); - fprintf(fp, "%s ", LSCRIPTTypeNames[entry.mType]); - fprintf(fp, "Ref Count: %d ", entry.mReferenceCount); - fprintf(fp, "Size: %d", entry.mSize); - fprintf(fp, "\n"); -} - -S32 lsa_cat_lists(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *list1; - LLScriptLibData *list2; - if (offset1 != offset2) - { - list1 = lsa_get_data(buffer, offset1, TRUE); - list2 = lsa_get_data(buffer, offset2, TRUE); - } - else - { - list1 = lsa_get_data(buffer, offset1, TRUE); - list2 = lsa_get_data(buffer, offset2, TRUE); - } - - if ( (!list1) - ||(!list2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - delete list2; - return 0; - } - - if ( (list1->mType != LST_LIST) - ||(list2->mType != LST_LIST)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - delete list2; - return 0; - } - - LLScriptLibData *runner = list1; - - while (runner->mListp) - { - runner = runner->mListp; - } - - runner->mListp = list2->mListp; - - list2->mListp = NULL; - - delete list2; - - return lsa_heap_add_data(buffer, list1, heapsize, TRUE); -} - - -S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *list1; - LLScriptLibData *list2; - if (offset1 != offset2) - { - list1 = lsa_get_data(buffer, offset1, TRUE); - list2 = lsa_get_data(buffer, offset2, TRUE); - } - else - { - list1 = lsa_get_data(buffer, offset1, FALSE); - list2 = lsa_get_data(buffer, offset2, TRUE); - } - - if ( (!list1) - ||(!list2)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - delete list2; - return 0; - } - - if ( (list1->mType != LST_LIST) - ||(list2->mType != LST_LIST)) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - delete list2; - return 0; - } - - S32 length1 = list1->getListLength(); - S32 length2 = list2->getListLength(); - delete list1; - delete list2; - return length1 - length2; -} - - -S32 lsa_preadd_lists(U8 *buffer, LLScriptLibData *data, S32 offset2, S32 heapsize) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *list2 = lsa_get_data(buffer, offset2, TRUE); - - if (!list2) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list2; - return 0; - } - - if (list2->mType != LST_LIST) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list2; - return 0; - } - - LLScriptLibData *runner = data->mListp; - - while (runner->mListp) - { - runner = runner->mListp; - } - - - runner->mListp = list2->mListp; - list2->mListp = data->mListp; - - return lsa_heap_add_data(buffer, list2, heapsize, TRUE); -} - - -S32 lsa_postadd_lists(U8 *buffer, S32 offset1, LLScriptLibData *data, S32 heapsize) -{ - if (get_register(buffer, LREG_FR)) - return 0; - LLScriptLibData *list1 = lsa_get_data(buffer, offset1, TRUE); - - if (!list1) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - return 0; - } - - if (list1->mType != LST_LIST) - { - set_fault(buffer, LSRF_HEAP_ERROR); - delete list1; - return 0; - } - - LLScriptLibData *runner = list1; - - while (runner->mListp) - { - runner = runner->mListp; - } - - runner->mListp = data->mListp; - - return lsa_heap_add_data(buffer, list1, heapsize, TRUE); -} - - -LLScriptLibData* lsa_randomize(LLScriptLibData* src, S32 stride) -{ - S32 number = src->getListLength(); - if (number <= 0) - { - return NULL; - } - if (stride <= 0) - { - stride = 1; - } - if(number % stride) - { - LLScriptLibData* retval = src->mListp; - src->mListp = NULL; - return retval; - } - S32 buckets = number / stride; - - // Copy everything into a special vector for sorting; - std::vector<LLScriptLibData*> sort_array; - sort_array.reserve(number); - LLScriptLibData* temp = src->mListp; - while(temp) - { - sort_array.push_back(temp); - temp = temp->mListp; - } - - // We cannot simply call random_shuffle or similar algorithm since - // we need to obey the stride. So, we iterate over what we have - // and swap each with a random other segment. - S32 index = 0; - S32 ii = 0; - for(; ii < number; ii += stride) - { - index = ll_rand(buckets) * stride; - for(S32 jj = 0; jj < stride; ++jj) - { - std::swap(sort_array[ii + jj], sort_array[index + jj]); - } - } - - // copy the pointers back out - ii = 1; - temp = sort_array[0]; - while (ii < number) - { - temp->mListp = sort_array[ii++]; - temp = temp->mListp; - } - temp->mListp = NULL; - - src->mListp = NULL; - - LLScriptLibData* ret_value = sort_array[0]; - return ret_value; -} diff --git a/indra/lscript/lscript_library/lscript_export.cpp b/indra/lscript/lscript_library/lscript_export.cpp deleted file mode 100755 index 0ed85e3686..0000000000 --- a/indra/lscript/lscript_library/lscript_export.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file lscript_export.cpp - * @brief export interface class - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - diff --git a/indra/lscript/lscript_library/lscript_library.cpp b/indra/lscript/lscript_library/lscript_library.cpp deleted file mode 100755 index 84ce94eead..0000000000 --- a/indra/lscript/lscript_library/lscript_library.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/** - * @file lscript_library.cpp - * @brief external library interface - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -// ## ## ### ######## ## ## #### ## ## ###### #### #### -// ## ## ## ## ## ## ## ### ## ## ### ## ## ## #### #### -// ## ## ## ## ## ## ## #### ## ## #### ## ## #### #### -// ## ## ## ## ## ######## ## ## ## ## ## ## ## ## #### ## ## -// ## ## ## ######### ## ## ## #### ## ## #### ## ## -// ## ## ## ## ## ## ## ## ### ## ## ### ## ## #### #### -// ### ### ## ## ## ## ## ## #### ## ## ###### #### #### -// -// When adding functions, they <b>MUST</b> be appended to the end of -// the init() method. The init() associates the name with a number, -// which is then serialized into the bytecode. Inserting a new -// function in the middle will lead to many sim crashes. Phoenix 2006-04-10. - -#include "linden_common.h" - -#include "lscript_library.h" - -LLScriptLibrary::LLScriptLibrary() -{ - init(); -} - -LLScriptLibrary::~LLScriptLibrary() -{ -} - -void dummy_func(LLScriptLibData *retval, LLScriptLibData *args, const LLUUID &id) -{ -} - -void LLScriptLibrary::init() -{ - // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST. - // Otherwise the bytecode numbers for each call will be wrong, and all - // existing scripts will crash. - - // energy, sleep, dummy_func, name, return type, parameters, gods-only - addFunction(10.f, 0.f, dummy_func, "llSin", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llCos", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llTan", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llAtan2", "f", "ff"); - addFunction(10.f, 0.f, dummy_func, "llSqrt", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llPow", "f", "ff"); - addFunction(10.f, 0.f, dummy_func, "llAbs", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llFabs", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llFrand", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llFloor", "i", "f"); - addFunction(10.f, 0.f, dummy_func, "llCeil", "i", "f"); - addFunction(10.f, 0.f, dummy_func, "llRound", "i", "f"); - addFunction(10.f, 0.f, dummy_func, "llVecMag", "f", "v"); - addFunction(10.f, 0.f, dummy_func, "llVecNorm", "v", "v"); - addFunction(10.f, 0.f, dummy_func, "llVecDist", "f", "vv"); - addFunction(10.f, 0.f, dummy_func, "llRot2Euler", "v", "q"); - addFunction(10.f, 0.f, dummy_func, "llEuler2Rot", "q", "v"); - addFunction(10.f, 0.f, dummy_func, "llAxes2Rot", "q", "vvv"); - addFunction(10.f, 0.f, dummy_func, "llRot2Fwd", "v", "q"); - addFunction(10.f, 0.f, dummy_func, "llRot2Left", "v", "q"); - addFunction(10.f, 0.f, dummy_func, "llRot2Up", "v", "q"); - addFunction(10.f, 0.f, dummy_func, "llRotBetween", "q", "vv"); - addFunction(10.f, 0.f, dummy_func, "llWhisper", NULL, "is"); - addFunction(10.f, 0.f, dummy_func, "llSay", NULL, "is"); - addFunction(10.f, 0.f, dummy_func, "llShout", NULL, "is"); - addFunction(10.f, 0.f, dummy_func, "llListen", "i", "isks"); - addFunction(10.f, 0.f, dummy_func, "llListenControl", NULL, "ii"); - addFunction(10.f, 0.f, dummy_func, "llListenRemove", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llSensor", NULL, "skiff"); - addFunction(10.f, 0.f, dummy_func, "llSensorRepeat", NULL, "skifff"); - addFunction(10.f, 0.f, dummy_func, "llSensorRemove", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llDetectedName", "s", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedKey", "k", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedOwner", "k", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedType", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedPos", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedVel", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedGrab", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedRot", "q", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedGroup", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedLinkNumber", "i", "i"); - addFunction(0.f, 0.f, dummy_func, "llDie", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llGround", "f", "v"); - addFunction(10.f, 0.f, dummy_func, "llCloud", "f", "v"); - addFunction(10.f, 0.f, dummy_func, "llWind", "v", "v"); - addFunction(10.f, 0.f, dummy_func, "llSetStatus", NULL, "ii"); - addFunction(10.f, 0.f, dummy_func, "llGetStatus", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llSetScale", NULL, "v"); - addFunction(10.f, 0.f, dummy_func, "llGetScale", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetColor", NULL, "vi"); - addFunction(10.f, 0.f, dummy_func, "llGetAlpha", "f", "i"); - addFunction(10.f, 0.f, dummy_func, "llSetAlpha", NULL, "fi"); - addFunction(10.f, 0.f, dummy_func, "llGetColor", "v", "i"); - addFunction(10.f, 0.2f, dummy_func, "llSetTexture", NULL, "si"); - addFunction(10.f, 0.2f, dummy_func, "llScaleTexture", NULL, "ffi"); - addFunction(10.f, 0.2f, dummy_func, "llOffsetTexture", NULL, "ffi"); - addFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi"); - addFunction(10.f, 0.f, dummy_func, "llGetTexture", "s", "i"); - addFunction(10.f, 0.2f, dummy_func, "llSetPos", NULL, "v"); - addFunction(10.f, 0.f, dummy_func, "llGetPos", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetLocalPos", "v", NULL); - addFunction(10.f, 0.2f, dummy_func, "llSetRot", NULL, "q"); - addFunction(10.f, 0.f, dummy_func, "llGetRot", "q", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetLocalRot", "q", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetForce", NULL, "vi"); - addFunction(10.f, 0.f, dummy_func, "llGetForce", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llTarget", "i", "vf"); - addFunction(10.f, 0.f, dummy_func, "llTargetRemove", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llRotTarget", "i", "qf"); - addFunction(10.f, 0.f, dummy_func, "llRotTargetRemove", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llMoveToTarget", NULL, "vf"); - addFunction(10.f, 0.f, dummy_func, "llStopMoveToTarget", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llApplyImpulse", NULL, "vi"); - addFunction(10.f, 0.f, dummy_func, "llApplyRotationalImpulse", NULL, "vi"); - addFunction(10.f, 0.f, dummy_func, "llSetTorque", NULL, "vi"); - addFunction(10.f, 0.f, dummy_func, "llGetTorque", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetForceAndTorque", NULL, "vvi"); - addFunction(10.f, 0.f, dummy_func, "llGetVel", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetAccel", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetOmega", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetTimeOfDay", "f", ""); - addFunction(10.f, 0.f, dummy_func, "llGetWallclock", "f", ""); - addFunction(10.f, 0.f, dummy_func, "llGetTime", "f", NULL); - addFunction(10.f, 0.f, dummy_func, "llResetTime", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llGetAndResetTime", "f", NULL); - addFunction(10.f, 0.f, dummy_func, "llSound", NULL, "sfii"); - addFunction(10.f, 0.f, dummy_func, "llPlaySound", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llLoopSound", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llLoopSoundMaster", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llLoopSoundSlave", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llPlaySoundSlave", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llTriggerSound", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llStopSound", NULL, ""); - addFunction(10.f, 1.f, dummy_func, "llPreloadSound", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llGetSubString", "s", "sii"); - addFunction(10.f, 0.f, dummy_func, "llDeleteSubString", "s", "sii"); - addFunction(10.f, 0.f, dummy_func, "llInsertString", "s", "sis"); - addFunction(10.f, 0.f, dummy_func, "llToUpper", "s", "s"); - addFunction(10.f, 0.f, dummy_func, "llToLower", "s", "s"); - addFunction(10.f, 0.f, dummy_func, "llGiveMoney", "i", "ki"); - addFunction(10.f, 0.1f, dummy_func, "llMakeExplosion", NULL, "iffffsv"); - addFunction(10.f, 0.1f, dummy_func, "llMakeFountain", NULL, "iffffisvf"); - addFunction(10.f, 0.1f, dummy_func, "llMakeSmoke", NULL, "iffffsv"); - addFunction(10.f, 0.1f, dummy_func, "llMakeFire", NULL, "iffffsv"); - addFunction(200.f, 0.1f, dummy_func, "llRezObject", NULL, "svvqi"); - addFunction(10.f, 0.f, dummy_func, "llLookAt", NULL, "vff"); - addFunction(10.f, 0.f, dummy_func, "llStopLookAt", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llSetTimerEvent", NULL, "f"); - addFunction(0.f, 0.f, dummy_func, "llSleep", NULL, "f"); - addFunction(10.f, 0.f, dummy_func, "llGetMass", "f", NULL); - addFunction(10.f, 0.f, dummy_func, "llCollisionFilter", NULL, "ski"); - addFunction(10.f, 0.f, dummy_func, "llTakeControls", NULL, "iii"); - addFunction(10.f, 0.f, dummy_func, "llReleaseControls", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llAttachToAvatar", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llDetachFromAvatar", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llTakeCamera", NULL, "k"); - addFunction(10.f, 0.f, dummy_func, "llReleaseCamera", NULL, "k"); - addFunction(10.f, 0.f, dummy_func, "llGetOwner", "k", NULL); - addFunction(10.f, 2.f, dummy_func, "llInstantMessage", NULL, "ks"); - addFunction(10.f, 20.f, dummy_func, "llEmail", NULL, "sss"); - addFunction(10.f, 0.f, dummy_func, "llGetNextEmail", NULL, "ss"); - addFunction(10.f, 0.f, dummy_func, "llGetKey", "k", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetBuoyancy", NULL, "f"); - addFunction(10.f, 0.f, dummy_func, "llSetHoverHeight", NULL, "fif"); - addFunction(10.f, 0.f, dummy_func, "llStopHover", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llMinEventDelay", NULL, "f"); - addFunction(10.f, 0.f, dummy_func, "llSoundPreload", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llRotLookAt", NULL, "qff"); - addFunction(10.f, 0.f, dummy_func, "llStringLength", "i", "s"); - addFunction(10.f, 0.f, dummy_func, "llStartAnimation", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llStopAnimation", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llPointAt", NULL, "v"); - addFunction(10.f, 0.f, dummy_func, "llStopPointAt", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llTargetOmega", NULL, "vff"); - addFunction(10.f, 0.f, dummy_func, "llGetStartParameter", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llGodLikeRezObject", NULL, "kv", TRUE); - addFunction(10.f, 0.f, dummy_func, "llRequestPermissions", NULL, "ki"); - addFunction(10.f, 0.f, dummy_func, "llGetPermissionsKey", "k", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetPermissions", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetLinkNumber", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetLinkColor", NULL, "ivi"); - addFunction(10.f, 1.f, dummy_func, "llCreateLink", NULL, "ki"); - addFunction(10.f, 0.f, dummy_func, "llBreakLink", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llBreakAllLinks", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llGetLinkKey", "k", "i"); - addFunction(10.f, 0.f, dummy_func, "llGetLinkName", "s", "i"); - addFunction(10.f, 0.f, dummy_func, "llGetInventoryNumber", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llGetInventoryName", "s", "ii"); - addFunction(10.f, 0.f, dummy_func, "llSetScriptState", NULL, "si"); - addFunction(10.f, 0.f, dummy_func, "llGetEnergy", "f", NULL); - addFunction(10.f, 0.f, dummy_func, "llGiveInventory", NULL, "ks"); - addFunction(10.f, 0.f, dummy_func, "llRemoveInventory", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llSetText", NULL, "svf"); - addFunction(10.f, 0.f, dummy_func, "llWater", "f", "v"); - addFunction(10.f, 0.f, dummy_func, "llPassTouches", NULL, "i"); - addFunction(10.f, 0.1f, dummy_func, "llRequestAgentData", "k", "ki"); - addFunction(10.f, 1.f, dummy_func, "llRequestInventoryData", "k", "s"); - addFunction(10.f, 0.f, dummy_func, "llSetDamage", NULL, "f"); - addFunction(100.f, 5.f, dummy_func, "llTeleportAgentHome", NULL, "k"); - addFunction(10.f, 0.f, dummy_func, "llModifyLand", NULL, "ii"); - addFunction(10.f, 0.f, dummy_func, "llCollisionSound", NULL, "sf"); - addFunction(10.f, 0.f, dummy_func, "llCollisionSprite", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llGetAnimation", "s", "k"); - addFunction(10.f, 0.f, dummy_func, "llResetScript", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llMessageLinked", NULL, "iisk"); - addFunction(10.f, 0.f, dummy_func, "llPushObject", NULL, "kvvi"); - addFunction(10.f, 0.f, dummy_func, "llPassCollisions", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llGetScriptName", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetNumberOfSides", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llAxisAngle2Rot", "q", "vf"); - addFunction(10.f, 0.f, dummy_func, "llRot2Axis", "v", "q"); - addFunction(10.f, 0.f, dummy_func, "llRot2Angle", "f", "q"); - addFunction(10.f, 0.f, dummy_func, "llAcos", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llAsin", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llAngleBetween", "f", "qq"); - addFunction(10.f, 0.f, dummy_func, "llGetInventoryKey", "k", "s"); - addFunction(10.f, 0.f, dummy_func, "llAllowInventoryDrop", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llGetSunDirection", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetTextureOffset", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llGetTextureScale", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llGetTextureRot", "f", "i"); - addFunction(10.f, 0.f, dummy_func, "llSubStringIndex", "i", "ss"); - addFunction(10.f, 0.f, dummy_func, "llGetOwnerKey", "k", "k"); - addFunction(10.f, 0.f, dummy_func, "llGetCenterOfMass", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llListSort", "l", "lii"); - addFunction(10.f, 0.f, dummy_func, "llGetListLength", "i", "l"); - addFunction(10.f, 0.f, dummy_func, "llList2Integer", "i", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2Float", "f", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2String", "s", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2Key", "k", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2Vector", "v", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2Rot", "q", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2List", "l", "lii"); - addFunction(10.f, 0.f, dummy_func, "llDeleteSubList", "l", "lii"); - addFunction(10.f, 0.f, dummy_func, "llGetListEntryType", "i", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2CSV", "s", "l"); - addFunction(10.f, 0.f, dummy_func, "llCSV2List", "l", "s"); - addFunction(10.f, 0.f, dummy_func, "llListRandomize", "l", "li"); - addFunction(10.f, 0.f, dummy_func, "llList2ListStrided", "l", "liii"); - addFunction(10.f, 0.f, dummy_func, "llGetRegionCorner", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llListInsertList", "l", "lli"); - addFunction(10.f, 0.f, dummy_func, "llListFindList", "i", "ll"); - addFunction(10.f, 0.f, dummy_func, "llGetObjectName", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetObjectName", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llGetDate", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llEdgeOfWorld", "i", "vv"); - addFunction(10.f, 0.f, dummy_func, "llGetAgentInfo", "i", "k"); - addFunction(10.f, 0.1f, dummy_func, "llAdjustSoundVolume", NULL, "f"); - addFunction(10.f, 0.f, dummy_func, "llSetSoundQueueing", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llSetSoundRadius", NULL, "f"); - addFunction(10.f, 0.f, dummy_func, "llKey2Name", "s", "k"); - addFunction(10.f, 0.f, dummy_func, "llSetTextureAnim", NULL, "iiiifff"); - addFunction(10.f, 0.f, dummy_func, "llTriggerSoundLimited", NULL, "sfvv"); - addFunction(10.f, 0.f, dummy_func, "llEjectFromLand", NULL, "k"); - addFunction(10.f, 0.f, dummy_func, "llParseString2List", "l", "sll"); - addFunction(10.f, 0.f, dummy_func, "llOverMyLand", "i", "k"); - addFunction(10.f, 0.f, dummy_func, "llGetLandOwnerAt", "k", "v"); - addFunction(10.f, 0.1f, dummy_func, "llGetNotecardLine", "k", "si"); - addFunction(10.f, 0.f, dummy_func, "llGetAgentSize", "v", "k"); - addFunction(10.f, 0.f, dummy_func, "llSameGroup", "i", "k"); - addFunction(10.f, 0.f, dummy_func, "llUnSit", NULL, "k"); - addFunction(10.f, 0.f, dummy_func, "llGroundSlope", "v", "v"); - addFunction(10.f, 0.f, dummy_func, "llGroundNormal", "v", "v"); - addFunction(10.f, 0.f, dummy_func, "llGroundContour", "v", "v"); - addFunction(10.f, 0.f, dummy_func, "llGetAttached", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetFreeMemory", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetRegionName", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetRegionTimeDilation", "f", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetRegionFPS", "f", NULL); - - addFunction(10.f, 0.f, dummy_func, "llParticleSystem", NULL, "l"); - addFunction(10.f, 0.f, dummy_func, "llGroundRepel", NULL, "fif"); - addFunction(10.f, 3.f, dummy_func, "llGiveInventoryList", NULL, "ksl"); - -// script calls for vehicle action - addFunction(10.f, 0.f, dummy_func, "llSetVehicleType", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llSetVehicleFloatParam", NULL, "if"); - addFunction(10.f, 0.f, dummy_func, "llSetVehicleVectorParam", NULL, "iv"); - addFunction(10.f, 0.f, dummy_func, "llSetVehicleRotationParam", NULL, "iq"); - addFunction(10.f, 0.f, dummy_func, "llSetVehicleFlags", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llRemoveVehicleFlags", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llSitTarget", NULL, "vq"); - addFunction(10.f, 0.f, dummy_func, "llAvatarOnSitTarget", "k", NULL); - addFunction(10.f, 0.1f, dummy_func, "llAddToLandPassList", NULL, "kf"); - addFunction(10.f, 0.f, dummy_func, "llSetTouchText", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llSetSitText", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llSetCameraEyeOffset", NULL, "v"); - addFunction(10.f, 0.f, dummy_func, "llSetCameraAtOffset", NULL, "v"); - - addFunction(10.f, 0.f, dummy_func, "llDumpList2String", "s", "ls"); - addFunction(10.f, 0.f, dummy_func, "llScriptDanger", "i", "v"); - addFunction(10.f, 1.f, dummy_func, "llDialog", NULL, "ksli"); - addFunction(10.f, 0.f, dummy_func, "llVolumeDetect", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llResetOtherScript", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llGetScriptState", "i", "s"); - addFunction(10.f, 3.f, dummy_func, "llRemoteLoadScript", NULL, "ksii"); - - addFunction(10.f, 0.2f, dummy_func, "llSetRemoteScriptAccessPin", NULL, "i"); - addFunction(10.f, 3.f, dummy_func, "llRemoteLoadScriptPin", NULL, "ksiii"); - - addFunction(10.f, 1.f, dummy_func, "llOpenRemoteDataChannel", NULL, NULL); - addFunction(10.f, 3.f, dummy_func, "llSendRemoteData", "k", "ksis"); - addFunction(10.f, 3.f, dummy_func, "llRemoteDataReply", NULL, "kksi"); - addFunction(10.f, 1.f, dummy_func, "llCloseRemoteDataChannel", NULL, "k"); - - addFunction(10.f, 0.f, dummy_func, "llMD5String", "s", "si"); - addFunction(10.f, 0.2f, dummy_func, "llSetPrimitiveParams", NULL, "l"); - addFunction(10.f, 0.f, dummy_func, "llStringToBase64", "s", "s"); - addFunction(10.f, 0.f, dummy_func, "llBase64ToString", "s", "s"); - addFunction(10.f, 0.3f, dummy_func, "llXorBase64Strings", "s", "ss"); - addFunction(10.f, 0.f, dummy_func, "llRemoteDataSetRegion", NULL, NULL); - addFunction(10.f, 0.f, dummy_func, "llLog10", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llLog", "f", "f"); - addFunction(10.f, 0.f, dummy_func, "llGetAnimationList", "l", "k"); - addFunction(10.f, 2.f, dummy_func, "llSetParcelMusicURL", NULL, "s"); - - addFunction(10.f, 0.f, dummy_func, "llGetRootPosition", "v", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetRootRotation", "q", NULL); - - addFunction(10.f, 0.f, dummy_func, "llGetObjectDesc", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetObjectDesc", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llGetCreator", "k", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetTimestamp", "s", NULL); - addFunction(10.f, 0.f, dummy_func, "llSetLinkAlpha", NULL, "ifi"); - addFunction(10.f, 0.f, dummy_func, "llGetNumberOfPrims", "i", NULL); - addFunction(10.f, 0.1f, dummy_func, "llGetNumberOfNotecardLines", "k", "s"); - - addFunction(10.f, 0.f, dummy_func, "llGetBoundingBox", "l", "k"); - addFunction(10.f, 0.f, dummy_func, "llGetGeometricCenter", "v", NULL); - addFunction(10.f, 0.2f, dummy_func, "llGetPrimitiveParams", "l", "l"); - addFunction(10.f, 0.0f, dummy_func, "llIntegerToBase64", "s", "i"); - addFunction(10.f, 0.0f, dummy_func, "llBase64ToInteger", "i", "s"); - addFunction(10.f, 0.f, dummy_func, "llGetGMTclock", "f", ""); - addFunction(10.f, 10.f, dummy_func, "llGetSimulatorHostname", "s", ""); - - addFunction(10.f, 0.2f, dummy_func, "llSetLocalRot", NULL, "q"); - - addFunction(10.f, 0.f, dummy_func, "llParseStringKeepNulls", "l", "sll"); - addFunction(200.f, 0.1f, dummy_func, "llRezAtRoot", NULL, "svvqi"); - - addFunction(10.f, 0.f, dummy_func, "llGetObjectPermMask", "i", "i", FALSE); - addFunction(10.f, 0.f, dummy_func, "llSetObjectPermMask", NULL, "ii", TRUE); - - addFunction(10.f, 0.f, dummy_func, "llGetInventoryPermMask", "i", "si", FALSE); - addFunction(10.f, 0.f, dummy_func, "llSetInventoryPermMask", NULL, "sii", TRUE); - addFunction(10.f, 0.f, dummy_func, "llGetInventoryCreator", "k", "s", FALSE); - addFunction(10.f, 0.f, dummy_func, "llOwnerSay", NULL, "s"); - addFunction(10.f, 1.f, dummy_func, "llRequestSimulatorData", "k", "si"); - addFunction(10.f, 0.f, dummy_func, "llForceMouselook", NULL, "i"); - addFunction(10.f, 0.f, dummy_func, "llGetObjectMass", "f", "k"); - addFunction(10.f, 0.f, dummy_func, "llListReplaceList", "l", "llii"); - addFunction(10.f, 10.f, dummy_func, "llLoadURL", NULL, "kss"); - - addFunction(10.f, 2.f, dummy_func, "llParcelMediaCommandList", NULL, "l"); - addFunction(10.f, 2.f, dummy_func, "llParcelMediaQuery", "l", "l"); - - addFunction(10.f, 1.f, dummy_func, "llModPow", "i", "iii"); - - addFunction(10.f, 0.f, dummy_func, "llGetInventoryType", "i", "s"); - addFunction(10.f, 0.f, dummy_func, "llSetPayPrice", NULL, "il"); - addFunction(10.f, 0.f, dummy_func, "llGetCameraPos", "v", ""); - addFunction(10.f, 0.f, dummy_func, "llGetCameraRot", "q", ""); - - addFunction(10.f, 20.f, dummy_func, "llSetPrimURL", NULL, "s"); - addFunction(10.f, 20.f, dummy_func, "llRefreshPrimURL", NULL, ""); - addFunction(10.f, 0.f, dummy_func, "llEscapeURL", "s", "s"); - addFunction(10.f, 0.f, dummy_func, "llUnescapeURL", "s", "s"); - - addFunction(10.f, 1.f, dummy_func, "llMapDestination", NULL, "svv"); - addFunction(10.f, 0.1f, dummy_func, "llAddToLandBanList", NULL, "kf"); - addFunction(10.f, 0.1f, dummy_func, "llRemoveFromLandPassList", NULL, "k"); - addFunction(10.f, 0.1f, dummy_func, "llRemoveFromLandBanList", NULL, "k"); - - addFunction(10.f, 0.f, dummy_func, "llSetCameraParams", NULL, "l"); - addFunction(10.f, 0.f, dummy_func, "llClearCameraParams", NULL, NULL); - - addFunction(10.f, 0.f, dummy_func, "llListStatistics", "f", "il"); - addFunction(10.f, 0.f, dummy_func, "llGetUnixTime", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llGetParcelFlags", "i", "v"); - addFunction(10.f, 0.f, dummy_func, "llGetRegionFlags", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llXorBase64StringsCorrect", "s", "ss"); - - addFunction(10.f, 0.f, dummy_func, "llHTTPRequest", "k", "sls"); - - addFunction(10.f, 0.1f, dummy_func, "llResetLandBanList", NULL, NULL); - addFunction(10.f, 0.1f, dummy_func, "llResetLandPassList", NULL, NULL); - - addFunction(10.f, 0.f, dummy_func, "llGetObjectPrimCount", "i", "k"); - addFunction(10.f, 2.0f, dummy_func, "llGetParcelPrimOwners", "l", "v"); - addFunction(10.f, 0.f, dummy_func, "llGetParcelPrimCount", "i", "vii"); - addFunction(10.f, 0.f, dummy_func, "llGetParcelMaxPrims", "i", "vi"); - addFunction(10.f, 0.f, dummy_func, "llGetParcelDetails", "l", "vl"); - - - addFunction(10.f, 0.2f, dummy_func, "llSetLinkPrimitiveParams", NULL, "il"); - addFunction(10.f, 0.2f, dummy_func, "llSetLinkTexture", NULL, "isi"); - - - addFunction(10.f, 0.f, dummy_func, "llStringTrim", "s", "si"); - addFunction(10.f, 0.f, dummy_func, "llRegionSay", NULL, "is"); - addFunction(10.f, 0.f, dummy_func, "llGetObjectDetails", "l", "kl"); - addFunction(10.f, 0.f, dummy_func, "llSetClickAction", NULL, "i"); - - addFunction(10.f, 0.f, dummy_func, "llGetRegionAgentCount", "i", NULL); - addFunction(10.f, 1.f, dummy_func, "llTextBox", NULL, "ksi"); - addFunction(10.f, 0.f, dummy_func, "llGetAgentLanguage", "s", "k"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchUV", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchFace", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchPos", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchNormal", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchBinormal", "v", "i"); - addFunction(10.f, 0.f, dummy_func, "llDetectedTouchST", "v", "i"); - - addFunction(10.f, 0.f, dummy_func, "llSHA1String", "s", "s"); - - addFunction(10.f, 0.f, dummy_func, "llGetFreeURLs", "i", NULL); - addFunction(10.f, 0.f, dummy_func, "llRequestURL", "k", NULL); - addFunction(10.f, 0.f, dummy_func, "llRequestSecureURL", "k", NULL); - addFunction(10.f, 0.f, dummy_func, "llReleaseURL", NULL, "s"); - addFunction(10.f, 0.f, dummy_func, "llHTTPResponse", NULL, "kis"); - addFunction(10.f, 0.f, dummy_func, "llGetHTTPHeader", "s", "ks"); - - // Prim media (see lscript_prim_media.h) - addFunction(10.f, 1.0f, dummy_func, "llSetPrimMediaParams", "i", "il"); - addFunction(10.f, 1.0f, dummy_func, "llGetPrimMediaParams", "l", "il"); - addFunction(10.f, 1.0f, dummy_func, "llClearPrimMedia", "i", "i"); - addFunction(10.f, 0.f, dummy_func, "llSetLinkPrimitiveParamsFast", NULL, "il"); - addFunction(10.f, 0.f, dummy_func, "llGetLinkPrimitiveParams", "l", "il"); - addFunction(10.f, 0.f, dummy_func, "llLinkParticleSystem", NULL, "il"); - addFunction(10.f, 0.f, dummy_func, "llSetLinkTextureAnim", NULL, "iiiiifff"); - - addFunction(10.f, 0.f, dummy_func, "llGetLinkNumberOfSides", "i", "i"); - - // IDEVO Name lookup calls, see lscript_avatar_names.h - addFunction(10.f, 0.f, dummy_func, "llGetUsername", "s", "k"); - addFunction(10.f, 0.f, dummy_func, "llRequestUsername", "k", "k"); - addFunction(10.f, 0.f, dummy_func, "llGetDisplayName", "s", "k"); - addFunction(10.f, 0.f, dummy_func, "llRequestDisplayName", "k", "k"); - - addFunction(10.f, 0.f, dummy_func, "llGetEnv", "s", "s"); - addFunction(10.f, 0.f, dummy_func, "llRegionSayTo", NULL, "kis"); - - // energy, sleep, dummy_func, name, return type, parameters, help text, gods-only - - // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST. - // Otherwise the bytecode numbers for each call will be wrong, and all - // existing scripts will crash. -} - -LLScriptLibraryFunction::LLScriptLibraryFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only) - : mEnergyUse(eu), mSleepTime(st), mExecFunc(exec_func), mName(name), mReturnType(ret_type), mArgs(args), mGodOnly(god_only) -{ -} - -LLScriptLibraryFunction::~LLScriptLibraryFunction() -{ -} - -void LLScriptLibrary::addFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only) -{ - LLScriptLibraryFunction func(eu, st, exec_func, name, ret_type, args, god_only); - mFunctions.push_back(func); -} - -void LLScriptLibrary::assignExec(const char *name, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &)) -{ - for (std::vector<LLScriptLibraryFunction>::iterator i = mFunctions.begin(); - i != mFunctions.end(); ++i) - { - if (!strcmp(name, i->mName)) - { - i->mExecFunc = exec_func; - return; - } - } - - LL_ERRS() << "Unknown LSL function in assignExec: " << name << LL_ENDL; -} - -void LLScriptLibData::print(std::ostream &s, BOOL b_prepend_comma) -{ - char tmp[1024]; /*Flawfinder: ignore*/ - if (b_prepend_comma) - { - s << ", "; - } - switch (mType) - { - case LST_INTEGER: - s << mInteger; - break; - case LST_FLOATINGPOINT: - snprintf(tmp, 1024, "%f", mFP); /* Flawfinder: ignore */ - s << tmp; - break; - case LST_KEY: - s << mKey; - break; - case LST_STRING: - s << mString; - break; - case LST_VECTOR: - snprintf(tmp, 1024, "<%f, %f, %f>", mVec.mV[VX], /* Flawfinder: ignore */ - mVec.mV[VY], mVec.mV[VZ]); - s << tmp; - break; - case LST_QUATERNION: - snprintf(tmp, 1024, "<%f, %f, %f, %f>", mQuat.mQ[VX], mQuat.mQ[VY], /* Flawfinder: ignore */ - mQuat.mQ[VZ], mQuat.mQ[VS]); - s << tmp; - break; - default: - break; - } -} - -void LLScriptLibData::print_separator(std::ostream& ostr, BOOL b_prepend_sep, char* sep) -{ - if (b_prepend_sep) - { - ostr << sep; - } - //print(ostr, FALSE); - { - char tmp[1024]; /* Flawfinder: ignore */ - switch (mType) - { - case LST_INTEGER: - ostr << mInteger; - break; - case LST_FLOATINGPOINT: - snprintf(tmp, 1024, "%f", mFP); /* Flawfinder: ignore */ - ostr << tmp; - break; - case LST_KEY: - ostr << mKey; - break; - case LST_STRING: - ostr << mString; - break; - case LST_VECTOR: - snprintf(tmp, 1024, "<%f, %f, %f>", mVec.mV[VX], /* Flawfinder: ignore */ - mVec.mV[VY], mVec.mV[VZ]); - ostr << tmp; - break; - case LST_QUATERNION: - snprintf(tmp, 1024, "<%f, %f, %f, %f>", mQuat.mQ[VX], mQuat.mQ[VY], /* Flawfinder: ignore */ - mQuat.mQ[VZ], mQuat.mQ[VS]); - ostr << tmp; - break; - default: - break; - } - } -} - - -LLScriptLibrary gScriptLibrary; |