Ejemplo n.º 1
0
bool C_coretestBase::TestPhatObject(int callbackID, const Json::Value& parameters)
{
    Json::Value testObject_JSON;
    FetchObject(parameters, "testObject", testObject_JSON);

    Json::Value array_JSON;
    FetchObject(testObject_JSON, "array", array_JSON);

    std::vector<int32 > array;
    for (int param1_i=0; param1_i<(int)array_JSON.size(); param1_i++)
    {
    Json::Value param1_array;
    FetchArray(array_JSON, param1_i, param1_array);

    int32 param1;
    FetchInt(param1_array, param1);


        array.push_back(param1);
    }


    Json::Value object_JSON;
    FetchObject(testObject_JSON, "object", object_JSON);

    Json::Value param2_JSON;
    FetchObject(object_JSON, "param2", param2_JSON);

    int32 param2;
    FetchInt(param2_JSON, param2);



    Json::Value klass_JSON;
    FetchObject(testObject_JSON, "klass", klass_JSON);

    ClassTest klass=ClassTest::From_JSON(klass_JSON, this);

    Json::Value string_JSON;
    FetchObject(testObject_JSON, "string", string_JSON);

    std::string string;
    FetchString(string_JSON, string);




    TestPhatObject(callbackID, array, param2, klass, string.c_str());
    return true;
}
Ejemplo n.º 2
0
bool C_coretestBase::TestPhatArray(int callbackID, const Json::Value& parameters)
{
    Json::Value testArray_JSON;
    FetchObject(parameters, "testArray", testArray_JSON);

    std::vector<std::vector<int32 > > testArray;
    for (int array_i=0; array_i<(int)testArray_JSON.size(); array_i++)
    {
    Json::Value array_array;
    FetchArray(testArray_JSON, array_i, array_array);

    std::vector<int32 > array;
    for (int param1_i=0; param1_i<(int)array_array.size(); param1_i++)
    {
    Json::Value param1_array;
    FetchArray(array_array, param1_i, param1_array);

    int32 param1;
    FetchInt(param1_array, param1);


        array.push_back(param1);
    }


        testArray.push_back(array);
    }



    TestPhatArray(callbackID, testArray);
    return true;
}
Ejemplo n.º 3
0
//JS->C++ automated converters
bool C_coretestBase::TestInt(int callbackID, const Json::Value& parameters)
{
    Json::Value testInt_JSON;
    FetchObject(parameters, "testInt", testInt_JSON);

    int32 testInt;
    FetchInt(testInt_JSON, testInt);



    TestInt(callbackID, testInt);
    return true;
}
Ejemplo n.º 4
0
bool C_coretestBase::TestObject(int callbackID, const Json::Value& parameters)
{
    Json::Value testObject_JSON;
    FetchObject(parameters, "testObject", testObject_JSON);

    Json::Value param_JSON;
    FetchObject(testObject_JSON, "param", param_JSON);

    int32 param;
    FetchInt(param_JSON, param);




    TestObject(callbackID, param);
    return true;
}
Ejemplo n.º 5
0
void nuiMetaPainter::UpdateIndices() const
{
  if (!mOperationIndices.empty()) // || mLastSize == mOperations.size())
    return;
  
  mOperationIndices.clear();
  mOperationPos = 0;
  uint size = mOperations.size();
  mLastSize = size;
  while (mOperationPos < size)
  {
    mOperationIndices.push_back(mOperationPos);
    OpCode code = FetchOpCode();
    switch (code)
    {
      case eSetSize:
        FetchInt();
        FetchInt();
        break;
      case eStartRendering:
        break;
      case eSetState:
        //FetchPointer();
        FetchInt();
        FetchInt();
        break;
      case eDrawArray:
        //FetchPointer();
        FetchInt();
        break;
      case eClear:
        FetchInt();
        break;
      case eBeginSession:
        break;
      case eEndSession:
        break;
      case eDrawChild:
        FetchPointer();
        break;
      case eLoadMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
      }
        break;
      case eMultMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
      }
        break;
      case ePopMatrix:
        break;
      case ePushMatrix:
        break;
        
        
      case eLoadProjectionMatrix:
      {
        nuiMatrix m;
        nuiSize tmp;
        FetchFloat(tmp);
        FetchFloat(tmp);
        FetchFloat(tmp);
        FetchFloat(tmp);
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
      }
        break;
      case eMultProjectionMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
      }
        break;
      case ePopProjectionMatrix:
        break;
      case ePushProjectionMatrix:
        break;
        
        
        
        
      case ePushClipping:
        break;
      case ePopClipping:
        break;
      case eClip:
      {
        nuiSize tmp;
        FetchFloat(tmp);
        FetchFloat(tmp);
        FetchFloat(tmp);
        FetchFloat(tmp);
      }
        break;
      case eResetClipRect:
        break;
      case eEnableClipping:
        FetchInt();
        break;
      case eBreak:
        break;
      default:
        NGL_ASSERT(false);
        break;
    }
  }
}
Ejemplo n.º 6
0
nglString nuiMetaPainter::GetOperationDescription(int32 OperationIndex) const
{
  nglString str = _T("???");
  mOperationPos = GetOffsetFromOperationIndex(OperationIndex);
  
  OpCode code = FetchOpCode();
  switch (code)
  {
    case eSetSize:
      {
        int32 w = FetchInt();
        int32 h = FetchInt();
        str.CFormat(_T("SetSize(%d, %d)"), w, h);
      }
      break;
    case eStartRendering:
      {
        nuiSize x, y;
        FetchFloat(x);
        FetchFloat(y);
        str.CFormat(_T("StartRendering(%f, %f)"), x, y);
      }
      break;
    case eSetState:
      {
        //FetchPointer();
        FetchInt();
        bool force = FetchInt();
        str.CFormat(_T("SetState(%s)"), TRUEFALSE(force));
      }
      break;
    case eDrawArray:
      {
        //nuiRenderArray* pArray = (nuiRenderArray*)FetchPointer();
        int32 index = FetchInt();
        nuiRenderArray* pArray = mRenderArrays[index];
        const nglChar* pMode = GetGLMode(pArray->GetMode());
        float bounds[6];
        pArray->GetBounds(bounds);
        str.CFormat(_T("DrawArray 0x%x (size %d mode:%s) (%f , %f)->(%f, %f)"), pArray, pArray->GetVertices().size(), pMode, bounds[0], bounds[1], bounds[3], bounds[4]);
      }
      break;
    case eClear:
      {
        int32 v = FetchInt();
        bool color = v & 1;
        bool depth = v & 2;
        bool stencil = v & 4;
        str.CFormat("Clear(color = %s, depth = %s, stencil = %s)", TRUEFALSE(color), TRUEFALSE(depth), TRUEFALSE(stencil));
      }
      break;
    case eBeginSession:
      str = _T("BeginSession");
      break;
    case eEndSession:
      str = _T("EndSession");
      break;
    case eDrawChild:
      {
        nuiWidget* pS = (nuiWidget*)FetchPointer();
        nglString clss(pS->GetObjectClass());
        nglString name(pS->GetObjectName());
        str.CFormat(_T("DrawChild 0x%x / '%s - %s'"), pS, clss.GetChars(), name.GetChars());
      }
      break;
    case eLoadMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
        nglString v;
        m.GetValue(v);
        str = _T("LoadMatrix") + v;
      }
      break;
    case eMultMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
        nglString v;
        m.GetValue(v);
        str = _T("MultMatrix") + v;
      }
      break;
    case ePopMatrix:
      str = _T("PopMatrix");
      break;
    case ePushMatrix:
      str = _T("PushMatrix");
      break;
      
      
    case eLoadProjectionMatrix:
      {
        nuiMatrix m;
        nuiSize a, b, c, d;
        FetchFloat(a);
        FetchFloat(b);
        FetchFloat(c);
        FetchFloat(d);
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
        nglString v;
        m.GetValue(v);
        str.CFormat(_T("LoadProjectionMatrix(%f, %f, %f, %f) / %s"), a, b, c, d, v.GetChars());
      }
      break;
    case eMultProjectionMatrix:
      {
        nuiMatrix m;
        FetchBuffer(m.Array, sizeof(nuiSize), 16);
        nglString v;
        m.GetValue(v);
        str = _T("MultProjectionMatrix") + v;
      }
      break;
    case ePopProjectionMatrix:
      str = _T("PopProjectionMatrix");
      break;
    case ePushProjectionMatrix:
      str = _T("PushProjectionMatrix");
      break;
      
      
      
      
    case ePushClipping:
      str = _T("PushClipping");
      break;
    case ePopClipping:
      str = _T("PopClipping");
      break;
    case eClip:
      {
        nuiSize a, b, c, d;
        FetchFloat(a);
        FetchFloat(b);
        FetchFloat(c);
        FetchFloat(d);
        str.CFormat(_T("Clip(%f, %f, %f, %f)"), a, b, c, d);
      }
      break;
    case eResetClipRect:
      str = _T("ResetClipRect");
      break;
    case eEnableClipping:
      str.CFormat(_T("EnableClipping(%s)"), TRUEFALSE(FetchInt()));
      break;
    case eBreak:
      str = _T("Break");
      break;
    default:
      str.CFormat(_T("Unknown operation %d"), code);
      break;
  }
  
  return nglString().Add(OperationIndex).Add(_T(": ")).Add(str);
}
Ejemplo n.º 7
0
void nuiMetaPainter::PartialReDraw(nuiDrawContext* pContext, int32 first, int32 last) const
{
  nuiPainter* pPainter = pContext->GetPainter();
  mOperationPos = 0;
  uint size = mOperations.size();
  
  const bool DoDrawChild = mNbDrawChild;
  const bool DoDrawArray = mNbDrawArray;
  const bool DoDrawSelf = DoDrawArray || mNbClearColor;
  if (!(DoDrawChild || DoDrawSelf))
    return;
  
  int32 currentop = 0;
  while (mOperationPos < size && currentop < last)
  {
    bool draw = currentop >= first;
    
    OpCode code = FetchOpCode();
    switch (code)
    {
      case eSetSize:
        if (draw)
          pPainter->SetSize(FetchInt(), FetchInt());
        break;
      case eStartRendering:
        if (draw)
        {
          pPainter->StartRendering();
        }
        break;
      case eSetState:
        if (draw)
        {
          int32 index = FetchInt();
          //nuiRenderState* pState = ((nuiRenderState*)FetchPointer());
          const nuiRenderState& rState(mRenderStates[index]);
          bool ForceApply = FetchInt() ? true : false;
          if (DoDrawSelf)
            pPainter->SetState(rState, ForceApply);
        }
        break;
      case eDrawArray:
        if (draw)
        {
          int32 index = FetchInt();
          //nuiRenderState* pState = ((nuiRenderState*)FetchPointer());
          nuiRenderArray* pRenderArray = mRenderArrays[index];
          //nuiRenderArray* pRenderArray = (nuiRenderArray*) FetchPointer();
          pRenderArray->Acquire(); // Pre acquire the render array as the painter will release it
          pPainter->DrawArray(pRenderArray);
        }
        break;
      case eClear:
        {
          int32 v = FetchInt();
          bool color = v & 1;
          bool depth = v & 2;
          bool stencil = v & 4;
          if (draw)
            pPainter->Clear(color, depth, stencil);
        }
        break;
      case eBeginSession:
        if (draw)
          if (DoDrawSelf)
            pPainter->BeginSession();
        break;
      case eEndSession:
        if (draw)
          if (DoDrawSelf)
            pPainter->EndSession();
        break;
      case eDrawChild:
        if (draw)
        {
          nuiWidget* pChild = (nuiWidget*)FetchPointer();
          pChild->DrawWidget(pContext);
        }
        break;
      case eLoadMatrix:
        if (draw)
        {
          nuiMatrix m;
          FetchBuffer(m.Array, sizeof(nuiSize), 16);
          pPainter->LoadMatrix(m);
        }
        break;
      case eMultMatrix:
        if (draw)
        {
          nuiMatrix m;
          FetchBuffer(m.Array, sizeof(nuiSize), 16);
          pPainter->MultMatrix(m);
        }
        break;
      case ePopMatrix:
        if (draw)
          pPainter->PopMatrix();
        break;
      case ePushMatrix:
        if (draw)
          pPainter->PushMatrix();
        break;
        
        
        
        
        
      case eLoadProjectionMatrix:
        if (draw)
        {
          nuiMatrix m;
          float Left, Top, Width, Height;
          FetchFloat(Left);
          FetchFloat(Top);
          FetchFloat(Width);
          FetchFloat(Height);
          FetchBuffer(m.Array, sizeof(nuiSize), 16);
          pPainter->LoadProjectionMatrix(nuiRect(Left, Top, Width, Height), m);
        }
        break;
      case eMultProjectionMatrix:
        if (draw)
        {
          nuiMatrix m;
          FetchBuffer(m.Array, sizeof(nuiSize), 16);
          pPainter->MultProjectionMatrix(m);
        }
        break;
      case ePopProjectionMatrix:
        if (draw)
          pPainter->PopProjectionMatrix();
        break;
      case ePushProjectionMatrix:
        if (draw)
          pPainter->PushProjectionMatrix();
        break;
        
        
        
        
        
        
      case ePushClipping:
        if (draw)
          pPainter->PushClipping();
        break;
      case ePopClipping:
        if (draw)
          pPainter->PopClipping();
        break;
      case eClip:
        if (draw)
        {
          nuiSize x;
          nuiSize y;
          nuiSize xx;
          nuiSize yy;
          FetchFloat(x);
          FetchFloat(y);
          FetchFloat(xx);
          FetchFloat(yy);
          const nuiRect r(x, y, xx, yy, false);
          pPainter->Clip(r);
        }
        break;
      case eEnableClipping:
        if (draw)
          pPainter->EnableClipping(FetchInt()?true:false);
        break;
      case eResetClipRect:
        if (draw)
          pPainter->ResetClipRect();
        break;
      case eBreak:
        if (draw)
          NGL_ASSERT(false);
        break;
      default:
        if (draw)
          NGL_ASSERT(false);
        break;
    }
    
    currentop++;
  }
}
Ejemplo n.º 8
0
nuiMetaPainter::OpCode nuiMetaPainter::FetchOpCode() const
{
  return (OpCode)FetchInt();
}