Exemple #1
0
static xkern_return_t
bidClose(
    XObj	self)
{
    XObj	myProtl = xMyProtl(self);
    PState	*ps = (PState *)myProtl->state;
    SState	*ss = (SState *)self->state;
    XObj	lls;
    Part_s	part;

    xTrace0(bidp, TR_MAJOR_EVENTS, "bid Close");
    lls = xGetDown(self, 0);

    if ( mapRemoveBinding(ps->activeMap, self->binding) == XK_FAILURE ) {
	xAssert(0);
	return XK_FAILURE;
    }
    partInit(&part, 1);
    partPush(part, &ss->peer, sizeof(ss->peer));
    if ( xOpenDisable(myProtl, myProtl, xGetDown(myProtl, BID_CTL_I), &part)
				== XK_FAILURE ) {
	xTrace0(bidp, TR_ERRORS, "bidClose couldn't openDisable cntrl protl");
    }
    xAssert(xIsSession(lls));
    xClose(lls);
    xDestroy(self);
    return XK_SUCCESS;
}
Exemple #2
0
void JSONWriter::end()
  {
  WriteBlock b(this);

  xAssert(_stack.size());
  auto &obj = _stack.back();

  xAssert(!obj.hasOpenElement);
  tabOut();

  if(obj.hasElements)
    {
    beginNewlineImpl();
    }

  if(_stack.back().type == Scope::Object)
    {
    _vector->pushBack('}');
    }
  else
    {
    _vector->pushBack(']');
    }

  _stack.popBack();
  }
Exemple #3
0
void XD3DRenderTargetImpl::clear(
    ID3D11DeviceContext1 *context,
    bool clearColour,
    bool clearDepth,
    const float *col,
    float depthVal,
    xuint8 stencilVal)
  {
  xAssert(renderTargetView);
  xAssert(depthStencilView);

  if(clearColour)
    {
    context->ClearRenderTargetView(
      renderTargetView.Get(),
      col
      );
    }

  if(clearDepth)
    {
    context->ClearDepthStencilView(
      depthStencilView.Get(),
      D3D11_CLEAR_DEPTH,
      depthVal,
      stencilVal
      );
    }
  }
Exemple #4
0
void JSONWriter::endElement()
  {
  xAssert(_stack.size());

  xAssert(_stack.back().hasOpenElement == true);
  _stack.back().hasElements = true;
  _stack.back().hasOpenElement = false;
  }
Exemple #5
0
Map
mapCreate(
    int 	nEntries,
    int 	keySize,
    Path	path)
{
    register Map m;
    register int pow2 = 0;
    int entries = nEntries;
    
    xTrace1(idmap, TR_FULL_TRACE, "mapCreate called, %d entries", nEntries);
    xAssert(nEntries);
    while (nEntries) { nEntries >>= 1; pow2++; }
    xAssert(pow2<8*sizeof(int)-1);
    if (entries == 1<<(pow2-1)) nEntries = entries;
    else nEntries = 1<<pow2;
    xAssert(nEntries<=MAX_MAP_SIZE);

    xTrace1(idmap, TR_EVENTS, "mapCreate: actual map size %d\n", nEntries);
    if (keySize > MAX_MAP_KEY_SIZE) {
	return 0;
    }
    if ( (m = (Map)pathAlloc(path, sizeof(*m))) == 0 ) {
	return 0;
    }
    bzero((char *)m, sizeof(struct map));
    m->tableSize = nEntries;
    m->keySize = keySize;
    m->alloc = pathGetAlloc(path, MD_ALLOC);
    m->table = (MapElement **)allocGet(m->alloc, nEntries * sizeof(MapElement *));
    if ( ! m->table ) {
	allocFree(m);
	return 0;
    }
    bzero((char *)m->table, nEntries * sizeof(MapElement *));
    if (keySize > 0) {
      if (map_functions[keySize].resolve != 0) {
	m->resolve = map_functions[keySize].resolve;
	m->bind    = map_functions[keySize].bind   ;
	m->unbind  = map_functions[keySize].unbind ;
	m->remove  = map_functions[keySize].remove;
      } else {
	m->resolve = mgenericresolve;
	m->bind    = mgenericbind   ;
	m->unbind  = mgenericunbind ;
	m->remove  = mgenericremove;
      }    
    }
    else {  /* this is a map with variable length external id's */
      m->resolve = mgenericerror;
      m->bind =  (XMapBindFunc *)mgenericerror;
      m->unbind = mgenericunbind;
      m->remove = mgenericremove;
    }
    return m;
  }
Exemple #6
0
void JSONWriter::addValueForElement(const char *data)
  {
  xAssert(data);
  WriteBlock b(this);

  appendQuotedEscaped(data);

  xAssert(_stack.size());
  _stack.back().hasElements = true;
  }
Exemple #7
0
void JSONWriter::addKeyValueStandalone(const char *key, const char *value, bool commaFirst)
  {
  xAssert(key);
  xAssert(value);
  WriteBlock b(this);

  if(commaFirst)
    {
    _vector->pushBack(',');
    }

  addKey(key);

  appendQuotedEscaped(value);
  }
Exemple #8
0
bool Attribute::NameChange::inform(bool backwards)
  {
  SProfileFunction
  xAssert(attribute()->entity());
  attribute()->entity()->informTreeObservers(this, backwards);
  return true;
  }
void *GlobalAllocator::alloc(xsize size, xsize alignment)
  {
  void *m = nullptr;

#ifndef X_WIN
  if (alignment != 1)
    {
    posix_memalign(&m, std::max(alignment, sizeof(void*)), size);
    }
  else
    {
    m = malloc(size);
    }

#else
  // msvc malloc should always be 16 byte aligned
  m = _aligned_malloc(size, alignment);

#endif

  xAssert(m);
  xAssertIsSpecificAligned(m, alignment);

  return m;
  }
Exemple #10
0
bool XD3DFrameBufferImpl::create(Renderer *r, ID3D11Device1 *dev, IDXGISwapChain1 *swapChain)
  {
  xAssert(swapChain);

  colour.setRenderer(r);
  depthStencil.setRenderer(r);

  XD3DTexture2DImpl *colImpl = colour.create<XD3DTexture2DImpl>();
  XD3DTexture2DImpl *depthImpl = depthStencil.create<XD3DTexture2DImpl>();

  colImpl->create(dev, swapChain);

  DXGI_SWAP_CHAIN_DESC1 swapDesc;
  swapChain->GetDesc1(&swapDesc);

  depthImpl->create(
        dev,
        swapDesc.Width,
        swapDesc.Height,
        DXGI_FORMAT_D24_UNORM_S8_UINT,
        DXGI_FORMAT_UNKNOWN,
        0,
        32,
        D3D11_BIND_DEPTH_STENCIL,
        D3D11_USAGE_DEFAULT);


  return XD3DRenderTargetImpl::create(dev, &colour, &depthStencil, DXGI_FORMAT_D24_UNORM_S8_UINT);
  }
Exemple #11
0
void JSONWriter::appendQuotedEscaped(const char *data)
  {
  xAssert(_activeBlock);

  _vector->pushBack('"');


  for(const char* p = data; *p; ++p)
    {
    if(*p == '"')
      {
      _vector->pushBack('\\');
      }

    if(*p == '\n')
      {
      _vector->pushBack('\\');
      _vector->pushBack('n');
      }
    else if(*p == '\t')
      {
      _vector->pushBack('\\');
      _vector->pushBack('t');
      }
    else
      {
      _vector->pushBack(*p);
      }
    }

  _vector->pushBack('"');
  }
Exemple #12
0
AssetManager::AssetManager()
    : _assetInterface(nullptr),
      _assets(Shift::TypeRegistry::generalPurposeAllocator())
  {
  xAssert(!_manager);
  _manager = this;
  }
Exemple #13
0
void JSONWriter::beginArrayElement()
  {
  xAssert(_stack.size())
      xAssert(_stack.back().type == Scope::Array);
  xAssert(_stack.back().hasOpenElement == false);

  WriteBlock b(this);

  if(_stack.back().hasElements)
    {
    _vector->pushBack(',');
    }

  beginNewlineImpl();
  _stack.back().hasOpenElement = true;
  }
Exemple #14
0
void JSONWriter::addBlock(const char *data, bool addedElementsToScope)
  {
  xAssert(data);
  WriteBlock b(this);
  beginNewlineImpl();

  _vector->append(data, strlen(data));

  if (addedElementsToScope)
    {
    xAssert(_stack.size());
    auto &obj = _stack.back();

    obj.hasElements = addedElementsToScope;
    }
  }
Exemple #15
0
void Property::setDependantsDirty()
  {
  if(!isDynamic())
    {
    const PropertyInstanceInformation *childBase = baseInstanceInformation();
    const EmbeddedPropertyInstanceInformation *child = childBase->embeddedInfo();
    const xsize *affectsLocations = child->affects();
    if(affectsLocations)
      {
      xuint8* parentLocation = (xuint8*)this;
      parentLocation -= child->location();

      for(;*affectsLocations; ++affectsLocations)
        {
        xuint8* affectedLocation = parentLocation + *affectsLocations;
        Property *affectsProp = (Property *)affectedLocation;

        xAssert(affectsProp);
        affectsProp->setDirty();
        }
      }
    }

  for(Property *o=output(); o; o = o->nextOutput())
    {
    xAssert(o != o->nextOutput());

    o->setDirty();
    }

  // if there is an input, a parent input or this is computed,
  // then when we are dirtied we need to dirty our children
  if(!isUpdating() && (input() || _flags.hasFlag(Property::ParentHasInput) || isComputed()))
    {
    Container *c = castTo<Container>();
    if(c)
      {
      xForeach(auto child, LightWalker(c))
        {
        if(Property *childProp = child->castTo<Property>())
          {
          childProp->setDirty();
          }
        }
      }
    }
Exemple #16
0
void DebugManager::unlockOutputStream()
  {
  xAssert(g_manager->_outputLocked);

  g_manager->flush();

  g_manager->_outputLocked = 0;
  }
Exemple #17
0
void JSONWriter::beginObjectElement(const char *key)
  {
  WriteBlock b(this);

  xAssert(_stack.size());

  auto &back = _stack.back();
  xAssert(back.type == Scope::Object);
  xAssert(back.hasOpenElement == false);

  if(_stack.back().hasElements)
    {
    _vector->pushBack(',');
    }

  addKey(key);
  back.hasOpenElement = true;
  }
Exemple #18
0
void computeView(RCViewableTransform *tr)
  {
  Eks::Transform inv;

  bool invertible = false;
  tr->transform().matrix().computeInverseWithCheck(inv.matrix(),invertible);
  xAssert(invertible);

  tr->viewTransform.computeLock() = inv;
  }
Exemple #19
0
void JSONWriter::beginNewlineImpl()
  {
  xAssert(_activeBlock);

  if (_niceFormatting && _vector->length())
    {
    _vector->pushBack('\n');
    _vector->append(_indentString.data(), _indentString.size());
    }
  }
Exemple #20
0
void computeInverseProjection(RCViewableTransform *tr)
  {
  Eks::ComplexTransform inv;

  bool invertible = false;
  tr->projection().matrix().computeInverseWithCheck(inv.matrix(),invertible);
  xAssert(invertible);

  tr->inverseProjection.computeLock() = inv;
  }
void ScShiftDatabase::computeNode(const SPropertyInstanceInformation *instanceInfo, SPropertyContainer *node)
  {
  ScProfileFunction
  const QVariant &val = instanceInfo->data()[g_computeKey];
  QScriptValue compute = qvariant_cast<QScriptValue>(val);
  xAssert(compute.isFunction());

  // call with this as the node being computed, and no arguments.
  compute.call(ScEmbeddedTypes::packValue(node));
  }
Exemple #22
0
AllocatorBase *Core::globalAllocator()
  {
  xAssert(g_core);

#ifdef X_ENABLE_EVENT_LOGGING
  return &g_core->allocLogger;
#else
  return &g_core->alloc;
#endif
  }
Exemple #23
0
Core::Core()
  {
  xAssert(!g_core);
  _impl = g_core = new Core::Impl;

#ifdef X_ENABLE_EVENT_LOGGING
  g_core->allocLogger.setAllocator(&g_core->alloc);
#endif

  g_core->defaultLogger = globalAllocator();
  }
Exemple #24
0
void Entity::addTreeObserver(TreeObserver *in)
  {
  setupObservers();

  xAssert(in);
  ObserverStruct s;
  s.mode = ObserverStruct::Tree;
  s.observer = in;
  in->_entities << this;
  _observers << s;
  }
Exemple #25
0
void Debugger::connectProperties(const Eks::UnorderedMap<Attribute *, DebugPropertyItem *> &itemsOut)
  {
  Eks::UnorderedMap<Attribute *, DebugPropertyItem *>::const_iterator it = itemsOut.begin();
  Eks::UnorderedMap<Attribute *, DebugPropertyItem *>::const_iterator end = itemsOut.end();
  for(; it != end; ++it)
    {
    Attribute *p = it->first;
    if(Property *prop = p->castTo<Property>())
      {
      if(prop->input())
        {
        const auto &inItem = itemsOut.value(prop->input());
        xAssert(inItem);
        xAssert(it->second);

        connect(it->second, SIGNAL(showConnected()), inItem, SLOT(show()));
        connect(inItem, SIGNAL(showConnected()), it->second, SLOT(show()));

        new ConnectionItem(inItem, it->second, true, Qt::red);
        }
      }

    if(!p->isDynamic())
      {
      const EmbeddedPropertyInstanceInformation *child = p->baseInstanceInformation()->embeddedInfo();
      xAssert(child);


      auto walker = child->affectsWalker(p->parent());
      xForeach(Property *affectsProp, walker)
        {
        const auto &affectItem = itemsOut.value(affectsProp);

        new ConnectionItem(it->second, affectItem, true, Qt::blue);

        connect(it->second, SIGNAL(showConnected()), affectItem, SLOT(show()));
        connect(affectItem, SIGNAL(showConnected()), it->second, SLOT(show()));
        }
      }
    }
  }
Exemple #26
0
static long
bidHdrLoad(
    void	*hdr,
    char 	*src,
    long	len,
    void	*arg)
{
    xAssert( len == sizeof(BidHdr) );
    bcopy(src, hdr, len);
    ((BidHdr *)hdr)->hlpNum = ntohl(((BidHdr *)hdr)->hlpNum);
    return len;
}
Exemple #27
0
DebugManager::DebugManager(bool client, Watcher *w)
  {
  xAssert(!g_manager);
  g_manager = new Impl(this, client);

  g_manager->setupController();

  g_manager->_watcher = w;

  // fake connected straight away, data is buffered locally.
  g_manager->_controller->onDebuggerConnected(client);
  }
Exemple #28
0
bool XD3DRenderTargetImpl::create(
    ID3D11Device1 *dev,
    Texture2D *col,
    Texture2D *depSte,
    DXGI_FORMAT depthRenderFormat)
  {
  XD3DTexture2DImpl *colT = col->data<XD3DTexture2DImpl>();
  XD3DTexture2DImpl *depSteT = depSte->data<XD3DTexture2DImpl>();
  if(failedCheck(dev->CreateRenderTargetView(
          colT->resource.Get(),
          nullptr,
          &renderTargetView
          )))
    {
    return false;
    }
  xAssert(renderTargetView);


  D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc =
  {
    depthRenderFormat,
    D3D11_DSV_DIMENSION_TEXTURE2D,
    0
  };
  depthStencilViewDesc.Texture2D.MipSlice = 0;

  if(failedCheck(dev->CreateDepthStencilView(
          depSteT->resource.Get(),
          &depthStencilViewDesc,
          &depthStencilView
          )))
    {
    return false;
    }
  xAssert(depthStencilView);

  return true;
  }
void APrivateAttributeCommand::inform()
    {
    xAssert( _device );
    // get a property reference
    AProperty &ref = _device->property( _property );
    // check we dont loop round
    if( !ref._informing )
        {
        // inform
        ref._informing = TRUE;
        emit ref.onPropertyChange( &ref );
        }
    // finished informing
    ref._informing = FALSE;
    }
void XAbstractCanvas::update(XAbstractRenderModel::UpdateMode)
  {
  xAssert(!_model || (_model && _iterator));
  if(_model && _iterator)
    {
    _model->resetIterator(_iterator);
    while(_iterator->next())
      {
      const XAbstractDelegate *delegate = _model->delegateFor(_iterator, this);
      if(delegate)
        {
        delegate->update(this, _iterator, _model);
        }
      }
    }
  }