aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript/lscript_execute_mono/assembly.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/lscript/lscript_execute_mono/assembly.cpp')
-rw-r--r--linden/indra/lscript/lscript_execute_mono/assembly.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/linden/indra/lscript/lscript_execute_mono/assembly.cpp b/linden/indra/lscript/lscript_execute_mono/assembly.cpp
new file mode 100644
index 0000000..dd8b284
--- /dev/null
+++ b/linden/indra/lscript/lscript_execute_mono/assembly.cpp
@@ -0,0 +1,74 @@
1/**
2 * @file llassembly.cpp
3 * @brief keeps track of user scripts, ensures that only one copy exists for each
4 *
5 * $LicenseInfo:firstyear=2007&license=internal$
6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 *
9 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
10 * this source code is governed by the Linden Lab Source Code Disclosure
11 * Agreement ("Agreement") previously entered between you and Linden
12 * Lab. By accessing, using, copying, modifying or distributing this
13 * software, you acknowledge that you have been informed of your
14 * obligations under the Agreement and agree to abide by those obligations.
15 *
16 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
17 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
18 * COMPLETENESS OR PERFORMANCE.
19 * $/LicenseInfo$
20 */
21
22
23#include "llassembly.h"
24#include <map>
25
26
27static std::map<std::string, LLAssembly*> sAssemblyMap;
28
29boost::intrusive_ptr<LLAssembly> LLAssembly::create(const std::string& name,
30 const U8* buffer, U32 size)
31{
32 std::map<std::string, LLAssembly*>::iterator it = sAssemblyMap.find(name);
33 if (it != sAssemblyMap.end())
34 {
35 return it->second;
36 }
37 else
38 {
39 LLAssembly* a = new LLAssembly(name, buffer, size);
40 sAssemblyMap[name] = a;
41 return a;
42 }
43}
44
45
46LLAssembly::LLAssembly(const std::string &name, const U8* buffer, U32 size) :
47 mName(name), mRefCount(0), mBuffer(buffer, buffer+size)
48{
49}
50
51LLAssembly::~LLAssembly()
52{
53 std::map<std::string, LLAssembly*>::iterator it = sAssemblyMap.find(mName);
54 if (it != sAssemblyMap.end())
55 {
56 sAssemblyMap.erase(it);
57 }
58}
59
60
61void intrusive_ptr_add_ref(LLAssembly* p)
62{
63 ++(p->mRefCount);
64}
65
66void intrusive_ptr_release(LLAssembly* p)
67{
68 if (0 == --(p->mRefCount))
69 {
70 delete p;
71 }
72}
73
74