Exemplo n.º 1
0
   dataStruct *get_data (const Handle AttrHandle, const attrStruct *AttrPtr = 0) {

      dataStruct *ds (0);

      if (cache && (cache->AttrHandle == AttrHandle)) { ds = cache; }

      if (!ds) {

         ds = dataTable.lookup (AttrHandle);

         if (!ds && AttrPtr && AttrHandle) {

            ds = new dataStruct (AttrHandle, *AttrPtr);

            if (!dataTable.store (AttrHandle, ds)) { delete ds; ds = 0; }
         }

         if (ds) { cache = ds; }
      }

      return ds;
   }
Exemplo n.º 2
0
dmz::Boolean
dmz::JsExtV8Archive::_register_callback (
      const Handle Instance,
      const String &Name,
      const Handle Archive,
      V8Object self,
      V8Function func,
      HashTableHandleTemplate<CallbackTable> &table) {

   Boolean result (False);

   if (Instance && Archive && (func.IsEmpty () == false)) {

      InstanceStruct *is = _instanceTable.lookup (Instance);

      if (!is) {

         is = new InstanceStruct (Instance, Name);

         if (!_instanceTable.store (Instance, is)) { delete is; is = 0; }
      }

      if (is) {

         CallbackTable *ct = table.lookup (Archive);

         if (!ct) {

            ct = new CallbackTable (Archive);

            if (!table.store (Archive, ct)) { delete ct; ct = 0; }
         }

         if (ct) {

            CallbackStruct *cs = ct->table.lookup (Instance);

            if (!cs) {

               cs = new CallbackStruct (*is, *ct);

               if (ct->table.store (Instance, cs)) {

                  cs->next = is->list;
                  is->list = cs;
               }
               else if (cs) { delete cs; cs = 0; }
            }

            if (cs) {

               result = True;

               cs->self.Dispose (); cs->self.Clear ();
               cs->func.Dispose (); cs->func.Clear ();

               cs->self = V8ObjectPersist::New (self);
               cs->func = V8FunctionPersist::New (func);

               if (!is_active_archive_handle (Archive)) {

                  activate_archive (Archive);
               }
            }
         }
      }
   }

   return result;
}