Exemplo n.º 1
0
//-----------------------------------------------------------------
//!	\brief	Display animation properties (recurse)
//-----------------------------------------------------------------
void NPropertiesCtrl::_DisplayAnimationObjectProperties(NObject* _pobj, udword _dwDepth)
{
	//Get First Object var bloc
	NVarsBloc* pbloc = _pobj->GetFirstVarsBloc();

	while (pbloc)
	{
		//NVarsBlocDesc*	pblocdesc	= pbloc->GetBlocDesc();

		//Parse Vars for this bloc
		for (udword i=0; i<pbloc->Count(); i++)
		{
			//Animation for this variable?
			NObject* pctrlObj = pbloc->GetValueControler(i);
			if (pctrlObj!=null)
			{
				NString str;
				str.Format("Animation %s", pbloc->GetValueDesc(i)->pszName );
				pctrlObj->SetName(str.Buffer());	//##TOFIX### variable bloc name

				//Display properties for this controler
				_DisplayObjectProperties(pctrlObj, _dwDepth);
			}

		}

		//pblocdesc=pblocdesc->	//###TOFIX### Next Bloc
		pbloc=null;	//###TOFIX####
	}


}
Exemplo n.º 2
0
int main(int argc, char *argv[]){
  NAtom *value1 = NAtom::get("value1");
  NAtom *value2 = NAtom::get("value2");
  NList list;
  NObject *ptr = &list;

  assert(ptr->equals(ptr));
  assert(ptr->equals(&list));
  assert(list.equals(&list));
  assert(list.equals(ptr));

  list << value1;
  list << value2;
  assert(list.size() == 2);

  assert(list.popLast() == value2);
  assert(list.popLast() == value1);
  assert(list.size() == 0);

  list.shift(value2);
  list.shift(value1);
  assert(list.size() == 2);

  assert(list.popFirst() == value1);
  assert(list.popFirst() == value2);
  assert(list.size() == 0);

  return 0;
}
Exemplo n.º 3
0
Arquivo: test.cpp Projeto: ilkos/ctree
bool testRecovery()
{
    cout << "Recovery" << endl;
    const std::string malformed = "{{\"data\"}, \"array\":[\"element0\",{\"key\"GARBAGE:\"val\"},\"element1\"],\"escape:\":\"escape\\{\\}\",\"key\":\"value\"}";
    const std::string expected = "{\"array\":[\"element0\",\"element1\"],\"escape\\:\":\"escape\\{\\}\",\"key\":\"value\"}";

    NObject newObject;
    newObject.getFromString(malformed);
    std::string serialized2 = newObject.getAsString();
    cout << "Malformed:" << malformed << endl;
    cout << "Recovered:" << serialized2 << endl;
    cout << "Expected :" << expected << endl;

    return serialized2 == expected;
}
Exemplo n.º 4
0
	static HNThread Create(ParameterizedStartProc pThreadStart, void * pThreadStartParam, const NObject & parameter)
	{
		NCallback threadStart = NTypes::CreateCallback(ParameterizedThreadStartProcImpl, pThreadStart, pThreadStartParam);
		HNThread handle;
		NCheck(NThreadCreateParameterizedN(threadStart.GetHandle(), parameter.GetHandle(), &handle));
		return handle;
	}
 template<typename T> T GetValue(const NObject & object, NAttributes attributes = naNone, bool * pHasValue = NULL) const
 {
     typename NTypeTraits<T>::NativeType value;
     NBool hasValue;
     NCheck(NPropertyInfoGetValue(GetHandle(), object.GetHandle(), NTypeTraits<T>::GetNativeType().GetHandle(), attributes, &value, sizeof(value), 1, pHasValue ? &hasValue : NULL));
     T v = NTypeTraits<T>::FromNative(value);
     if (pHasValue) *pHasValue = hasValue != 0;
     return v;
 }
Exemplo n.º 6
0
void NUseStoredOpsProp::Init()
{
	NObject* pobj;
	m_pvarBloc->GetValue(m_dwvarIdx, 0.0f, pobj);

	char* pszName="";

	//Display referenced object name (from varbloc)
	if (pobj)
	{
		NVarsBloc* pbloc = pobj->GetFirstVarsBloc();
		pbloc->GetValue(0, 0.0f, pszName);
	}

	//Create menu button
	m_button.Create(pszName, NRect(0,0,0,0), m_pParent, 0);
	m_button.OnChanged = FDelegate(this, (TDelegate)&NUseStoredOpsProp::OnValueChanged);

	//Buid menu's items
	NTreeNode* pnode = NEditorGUI::GetInstance()->GetAsset()->GetRootGroup();
	BuildMenu(pnode);
}
Exemplo n.º 7
0
int main(int argc, char** argv){
  NProgram program(argc, argv);

  NMLParser parser;
  // parse the NML code into N code
  nvar code = parser.parseFile("test.nml");

  cout << "code is: " << code << endl;

  // reconstruct the NML code from N code (just for demonstration
  // purposes)
  NMLGenerator generator;
  stringstream sstr;
  generator.generate(sstr, code);
  cout << "------------- reconstructed NML" << endl;
  cout << sstr.str() << endl;

  // execute the code we parsed
  NObject interpreter;
  interpreter.process(code);

  return 0;
}
Exemplo n.º 8
0
Arquivo: test.cpp Projeto: ilkos/ctree
bool testSerialization()
{
    cout << "Serialization" << endl;
    NObject object;
    object.putData("key", "value").putData("escape:", "escape{}");
    object.putData("key", "newvalue");

    NArray& array = object.addElement<NArray>("array");
    array.putData("element0");
    array.putData("element1");
    array.addElement<NObject>(1).putData("key", "val");

    std::string serialized = object.getAsString();
    cout << serialized << endl;

    NObject newObject;
    newObject.getFromString(serialized);
    std::string serialized2 = newObject.getAsString();
    cout << serialized2 << endl;

    return serialized2 == serialized;
}
Exemplo n.º 9
0
int main(int argc, char** argv){
  Program::opt("help", "h", false, "Display usage");

  Program::opt("math", "m", false, "Use Mathematica");  

  Program::opt("show", "s", false, "Show N input/output");  

  Program::opt("history", "", 100, "Number of lines to keep in history"); 

  Program program(argc, argv);

  nvar args = program.args();
    
  if(args["help"]){
    cout << program.usage("neu [OPTION]... [NML FILE]...");
    program.exit(0);
  }

  bool show = args["show"];

  NObject* o = args["math"] ? new NMObject : new NObject;

  Parser parser;
  NMLGenerator generator;

  if(args.empty()){
    stifle_history(args["history"]);

    for(;;){
      parser.reset();
      nvar n = parser.parse();

      if(parser.done()){
        cout << endl;
        NProgram::exit(0);
      }

      if(n == none){
        continue;
      }

      if(show){
        cout << "<< " << n << endl;
      }

      try{
        nvar r = o->process(n);

        if(show){
          cout << ">> " << r << endl;
        }

        if(r != none){
          generator.generate(cout, r);
          cout << endl;
        }
      }
      catch(NError& e){
        cerr << e << endl;
      }
    }    
  }

  for(size_t i = 0; i < args.size(); ++i){
    nvar n = parser.parseFile(args[i]);

    if(n == none){
      NProgram::exit(1);
    }
    
    if(show){
      cout << "<< " << n << endl;
    }
    
    nvar r = o->process(n);

    if(show){
      cout << ">> " << r << endl;
    }
  }   
  
  NProgram::exit(0);
  
  return 0;
}
Exemplo n.º 10
0
	NObjectPart GetObjectPart(const NObject & object) const
	{
		HNObjectPart hObjectPart;
		NCheck(NObjectPartInfoGetObjectPart(GetHandle(), object.GetHandle(), &hObjectPart));
		return FromHandle<NObjectPart>(hObjectPart);
	}
 void SetValue(const NObject & object, const NValue & value) const
 {
     NCheck(NPropertyInfoSetValueN(GetHandle(), object.GetHandle(), value.GetHandle()));
 }
 void ResetValue(const NObject & object) const
 {
     NCheck(NPropertyInfoResetValue(GetHandle(), object.GetHandle()));
 }
 template<typename T> void SetValue(const NObject & object, const T & value, NAttributes attributes = naNone, bool hasValue = true) const
 {
     typename NTypeTraits<T>::NativeType v = NTypeTraits<T>::ToNative(value);
     NCheck(NPropertyInfoSetValue(GetHandle(), object.GetHandle(), NTypeTraits<T>::GetNativeType().GetHandle(), attributes, &value, sizeof(value), 1, hasValue ? NTrue : NFalse));
 }
 void SetValue(const NObject & object, const NType & valueType, NAttributes attributes, const void * arValues, NSizeType valuesSize, NInt valuesLength, bool hasValue = true) const
 {
     NCheck(NPropertyInfoSetValue(GetHandle(), object.GetHandle(), valueType.GetHandle(), attributes, arValues, valuesSize, valuesLength, hasValue ? NTrue : NFalse));
 }