summaryrefslogtreecommitdiff
path: root/indra/lscript/lscript_library.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/lscript/lscript_library.h')
-rw-r--r--indra/lscript/lscript_library.h86
1 files changed, 32 insertions, 54 deletions
diff --git a/indra/lscript/lscript_library.h b/indra/lscript/lscript_library.h
index d9702ced84..89a473a627 100644
--- a/indra/lscript/lscript_library.h
+++ b/indra/lscript/lscript_library.h
@@ -2,30 +2,25 @@
* @file lscript_library.h
* @brief External library interface
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * 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.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * 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.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * 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$
*/
@@ -43,16 +38,15 @@ class LLScriptLibData;
class LLScriptLibraryFunction
{
public:
- LLScriptLibraryFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), char *name, char *ret_type, char *args, char *desc, BOOL god_only = FALSE);
+ 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 = FALSE);
~LLScriptLibraryFunction();
F32 mEnergyUse;
F32 mSleepTime;
void (*mExecFunc)(LLScriptLibData *, LLScriptLibData *, const LLUUID &);
- char *mName;
- char *mReturnType;
- char *mArgs;
- char *mDesc;
+ const char *mName;
+ const char *mReturnType;
+ const char *mArgs;
BOOL mGodOnly;
};
@@ -64,14 +58,13 @@ public:
void init();
- void addFunction(LLScriptLibraryFunction *func);
- void assignExec(char *name, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &));
+ void 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 = FALSE);
+ void assignExec(const char *name, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &));
- S32 mNextNumber;
- LLScriptLibraryFunction **mFunctions;
+ std::vector<LLScriptLibraryFunction> mFunctions;
};
-extern LLScriptLibrary gScriptLibrary;
+
class LLScriptLibData
{
@@ -146,9 +139,9 @@ public:
return FALSE;
}
- S32 getListLength()
+ S32 getListLength() const
{
- LLScriptLibData *data = this;
+ const LLScriptLibData *data = this;
S32 retval = 0;
while (data->mListp)
{
@@ -365,7 +358,7 @@ public:
void print(std::ostream &s, BOOL b_prepend_comma);
void print_separator(std::ostream& ostr, BOOL b_prepend_sep, char* sep);
- void setFromCSV(char *src)
+ void setFromCSV(const char *src)
{
mType = LST_STRING;
mString = new char[strlen(src) + 1]; /* Flawfinder: ignore */
@@ -387,27 +380,10 @@ public:
LLScriptLibData(const LLUUID &id) : mType(LST_KEY), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
{
- mKey = new char[UUID_STR_LENGTH];
- id.toString(mKey);
- }
-
- LLScriptLibData(char *string) : mType(LST_STRING), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- if (!string)
- {
- mString = new char[1];
- mString[0] = 0;
- }
- else
- {
- mString = new char[strlen(string) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- llerrs << "Memory Allocation Failed" << llendl;
- return;
- }
- strcpy(mString, string); /* Flawfinder: ignore */
- }
+ std::string idstr;
+ id.toString(idstr);
+ mKey = new char[idstr.length()+1];
+ LLStringUtil::copy(mKey,idstr.c_str(),idstr.length()+1);
}
LLScriptLibData(const char *string) : mType(LST_STRING), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
@@ -446,4 +422,6 @@ public:
};
+extern LLScriptLibrary gScriptLibrary;
+
#endif