aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llxml')
-rw-r--r--linden/indra/llxml/llcontrol.cpp6
-rw-r--r--linden/indra/llxml/llcontrol.h80
2 files changed, 86 insertions, 0 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp
index 88eb2c3..1d1f024 100644
--- a/linden/indra/llxml/llcontrol.cpp
+++ b/linden/indra/llxml/llcontrol.cpp
@@ -1217,6 +1217,12 @@ void LLControlGroup::resetWarnings()
1217 } 1217 }
1218} 1218}
1219 1219
1220template <> void jc_rebind::rebind_callback<S32>(const LLSD &data, S32 *reciever){ *reciever = data.asInteger(); }
1221template <> void jc_rebind::rebind_callback<F32>(const LLSD &data, F32 *reciever){ *reciever = data.asReal(); }
1222template <> void jc_rebind::rebind_callback<U32>(const LLSD &data, U32 *reciever){ *reciever = data.asInteger(); }
1223template <> void jc_rebind::rebind_callback<std::string>(const LLSD &data, std::string *reciever){ *reciever = data.asString(); }
1224template <> void jc_rebind::rebind_callback<LLColor4>(const LLSD &data, LLColor4 *reciever){ *reciever = LLColor4(LLColor4U(data)); }
1225
1220//============================================================================ 1226//============================================================================
1221 1227
1222#ifdef TEST_HARNESS 1228#ifdef TEST_HARNESS
diff --git a/linden/indra/llxml/llcontrol.h b/linden/indra/llxml/llcontrol.h
index ba0a1c7..316de5c 100644
--- a/linden/indra/llxml/llcontrol.h
+++ b/linden/indra/llxml/llcontrol.h
@@ -242,4 +242,84 @@ public:
242 void resetWarnings(); 242 void resetWarnings();
243}; 243};
244 244
245///////////////////////
246namespace jc_you_suck
247{
248class jc_rebind
249{
250 template <typename REC> static void rebind_callback(const LLSD &data, REC *reciever){ *reciever = data; }
251
252 typedef boost::signal<void(const LLSD&)> signal_t;
253
254public:
255
256//#define binder_debug
257
258 template <typename RBTYPE> static RBTYPE* rebind_llcontrol(std::string name, LLControlGroup* controlgroup, bool init)
259 {
260 static std::map<LLControlGroup*, std::map<std::string, void*> > references;
261
262#ifdef binder_debug
263 llinfos << "rebind_llcontrol" << llendl;
264#endif
265
266 RBTYPE* type = NULL;
267 if(controlgroup)
268 {
269 if(references.find(controlgroup) == references.end())
270 {
271#ifdef binder_debug
272 llinfos << "was no map for a group, adding" << llendl;
273#endif
274 references[controlgroup] = std::map<std::string, void*>();
275 }
276
277 if(references[controlgroup].find(name) != references[controlgroup].end())
278 {
279#ifdef binder_debug
280 llinfos << "pulling type from map for " << name << llendl;
281#endif
282 type = (RBTYPE*)(references[controlgroup][name]);
283 if(type == NULL)llerrs << "bad type stored" << llendl;
284 }else
285 {
286#ifdef binder_debug
287 llinfos << "creating type in map for " << name << llendl;
288#endif
289 type = new RBTYPE();
290 references[controlgroup][name] = (void*)type;
291 LLControlVariable* control = controlgroup->getControl(name);
292 if(control)
293 {
294#ifdef binder_debug
295 llinfos << "control there " << name << llendl;
296#endif
297 signal_t* signal = control->getSignal();
298 if(signal)
299 {
300#ifdef binder_debug
301 llinfos << "signal there" << name << llendl;
302#endif
303 signal->connect(boost::bind(&jc_rebind::rebind_callback<RBTYPE>, _1, type));
304 if(init)jc_rebind::rebind_callback<RBTYPE>(control->getValue(),type);
305 }else llerrs << "no signal!" << llendl;
306 }else llerrs << "no control for " << name << "!" << llendl;
307 }
308 }
309 return type;
310 }
311};
312
313template <> void jc_rebind::rebind_callback<S32>(const LLSD &data, S32 *reciever);
314template <> void jc_rebind::rebind_callback<F32>(const LLSD &data, F32 *reciever);
315template <> void jc_rebind::rebind_callback<U32>(const LLSD &data, U32 *reciever);
316template <> void jc_rebind::rebind_callback<std::string>(const LLSD &data, std::string *reciever);
317template <> void jc_rebind::rebind_callback<LLColor4>(const LLSD &data, LLColor4 *reciever);
318
319}
320using namespace jc_you_suck;
321#define rebind_llcontrol jc_rebind::rebind_llcontrol
322
323///////////////////////
324
245#endif 325#endif