Ejemplo n.º 1
0
//loads a js file
Handle<Value> load(const Arguments& args) {
  //if less that nbr of formal parameters then do nothing
  int len = args.Length();
  int i;

  if (len < 1) return v8::Undefined();
  //define handle scope
  HandleScope scope;

  // Enter the new context so all the following operations take place
  // within it.
  Context::Scope context_scope(V8GL::context);

  for (i = 0; i < len; ++i) {
	  //get argument
	  String::Utf8Value value0(args[i]);
	  char* arg0 = *value0;
	  char* filepath = V8GLUtils::getRealPath(arg0);

	  char *old_path = V8GLUtils::pushRootPath(filepath);
	  bool success = exec(string(filepath));
	  V8GLUtils::popRootPath(old_path);

	  if(!success) {
		  fprintf(stderr, "Error reading '%s'.\n", arg0);
		  return ThrowException(String::New("Failed to load script"));
	  }
  }

  return v8::Undefined();
}
Ejemplo n.º 2
0
V3MPDRCube* const
V3VrfMPDR::forwardModel(const V3MPDRCube* const curCube) {
   assert (curCube); if (!curCube->getNextCube()) return 0;
   // Set Pattern Values for Simulator
   if (_pdrSize) {
      const V3BitVecX& inputData = curCube->getInputData();
      assert (inputData.size() == _pdrSize); uint32_t j = 0;
      for (uint32_t i = 0; i < _vrfNtk->getInputSize(); ++i, ++j)
         _pdrSim->setSource(_vrfNtk->getInput(i), inputData.bv_slice(j, j));
      for (uint32_t i = 0; i < _vrfNtk->getInoutSize(); ++i, ++j)
         _pdrSim->setSource(_vrfNtk->getInout(i), inputData.bv_slice(j, j));
      assert (j == inputData.size());
   }
   // Set State Variable Values for Simulator
   const V3NetVec& state = curCube->getState(); _pdrSim->setSourceFree(V3_FF, false);
   V3BitVecX value0(1), value1(1); value0.set0(0); value1.set1(0);
   for (uint32_t i = 0; i < state.size(); ++i)
      _pdrSim->setSource(_vrfNtk->getLatch(state[i].id), (state[i].cp ? value0 : value1));
   // Simulate for One Cycle
   _pdrSim->simulate(); _pdrSim->updateNextStateValue();
   // Return the Cube that it Reached
   V3NetVec nextState; nextState.clear(); nextState.reserve(_vrfNtk->getLatchSize());
   for (uint32_t i = 0; i < _vrfNtk->getLatchSize(); ++i) {
      switch (_pdrSim->getSimValue(_vrfNtk->getLatch(i))[0]) {
         case '0' : nextState.push_back(V3NetId::makeNetId(i, 1)); break;
         case '1' : nextState.push_back(V3NetId::makeNetId(i, 0)); break;
      }
   }
   if (existInitial(nextState)) return 0;
   V3MPDRCube* const cube = new V3MPDRCube(0); assert (cube);
   cube->setState(nextState); return cube;
}
Ejemplo n.º 3
0
std::istream& nuc3d::IOController::readIOFile(std::istream& ios, std::map<std::string,int> &Methods, std::map<std::string,double> &Time,std::map<std::string,std::string> &FileType)
{
    std::string word0;
    std::string word1;
    ios>>word0>>word1;
    
    if(Methods.find(word0)!=Methods.end())
    {
        std::istringstream value0(word1);
        int value;
        value0>>value;
        Methods[word0]=value;
    }
Ejemplo n.º 4
0
//prints a string to stdout
Handle<Value> log(const Arguments& args) {
  //if less that nbr of formal parameters then do nothing
  if (args.Length() < 1) return v8::Undefined();
  //define handle scope
  HandleScope scope;
  //get arguments
  String::Utf8Value value0(args[0]);
  char* arg0 = *value0;

  //make call
  fprintf(stdout, "%s", arg0);
  return v8::Undefined();
}
Ejemplo n.º 5
0
Archivo: bind.cpp Proyecto: Qard/jsgame
Handle<Value> ALUTCreateBufferFromFileCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 1)
		return v8::Undefined();
	
	//get arguments
	String::Utf8Value value0(args[0]);
	char* arg0 = *value0;

	//make call
	alutCreateBufferFromFile((const char*)arg0);
	
	return v8::Undefined();
}
Ejemplo n.º 6
0
//loads a text file
Handle<Value> read(const Arguments& args) {
  if (args.Length() < 1) return v8::Undefined();
  //define handle scope
  HandleScope scope;
  //get arguments
  String::Utf8Value value0(args[0]);
  char* arg0 = *value0;
  string str(V8GLUtils::getRealPath(arg0));
  Handle<String> result = ReadFile(str);
  if (result.IsEmpty()) {
      fprintf(stderr, "Error reading '%s'.\n", str.c_str());
      return ThrowException(String::New("Could not open file."));
  }
  return scope.Close(result);
}
Ejemplo n.º 7
0
Archivo: bind.cpp Proyecto: Qard/jsgame
Handle<Value> ALUTCreateBufferFromFileImageCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 2)
		return v8::Undefined();
	
	//get arguments
	String::Utf8Value value0(args[0]);
	char* key0 = *value0;
	void* arg0 = font_[key0];

	//make call
	alutCreateBufferFromFileImage((const ALvoid*)arg0, (ALsizei)arg1);
	
	return v8::Undefined();
}
Ejemplo n.º 8
0
/**************************************************************************************
 I. General IO functions
 **************************************************************************************/
std::istream& nuc3d::fieldOperator3d::readIOFile(
                                                 std::istream& ios,
                                                 std::map<std::string,std::string> &Methods)
{
    std::string word0;
    std::string word1;
    ios>>word0>>word1;
    
    
    if(Methods.find(word0)!=Methods.end())
    {
        std::istringstream value0(word1);
        std::string value;
        value0>>value;
        Methods[word0]=value;
    }
Ejemplo n.º 9
0
Archivo: bind.cpp Proyecto: Qard/jsgame
Handle<Value> ALUTLoadMemoryFromFileCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 4)
		return v8::Undefined();
	
	//get arguments
	String::Utf8Value value0(args[0]);
	char* arg0 = *value0;
	Handle<Array> arg1 = Array::Cast(args[1]);
	Handle<Array> arg2 = Array::Cast(args[2]);
	Handle<Array> arg3 = Array::Cast(args[3]);

	//make call
	alutLoadMemoryFromFile((const char*)arg0, (ALenum*)arg1, (ALsizei*)arg2, (ALfloat*)arg3);
	
	return v8::Undefined();
}
Ejemplo n.º 10
0
Handle<Value> XML::SetAttribute(const Arguments& args) {
	HandleScope scope;
	if (args.Length() != 2) {
		return v8::ThrowException(v8::String::New("Need Parameters"));
	}	
	Handle<Value> arg0 = args[0];
	String::Utf8Value value0(arg0);
	std::string attributeName = *value0;	
	setName(attributeName);
	
	Handle<Value> arg1 = args[1];
	String::Utf8Value value1(arg1);
	std::string attributeValue = *value1;	
	
	setAttribute(attributeName,attributeValue);

	Handle<Boolean> success = Boolean::New(true);
	return(scope.Close(success)); // aqui nao sei como retornar um "nada"
	
}
Ejemplo n.º 11
0
double calin::math::b_spline::
value0(double x, const std::vector<double>& c, double x0, double one_over_dx)
{
  return value0(x, c.data(), c.size(), x0, one_over_dx);
}