示例#1
0
/*! \brief Starts the passed program
 *
 * \param programIndex Index of the program to start.
 */
void start(uint8_t programIndex)
{
	// initialize and start the passed 'program'
	switch (programIndex)
	{
	case 0:
		lcd_clear();
		helloWorld();
		break;
	case 1:
		activateLedMask = 0xFFFF;	// use all LEDs
		initLedBar();
		initClock();
		displayClock();
		break;
	case 2:
		activateLedMask = 0xFFFE;	// don't use led 0
		initLedBar();
		initAdc();
		displayAdc();
		break;
	default:
		break;
	}

	// do not resume to the menu until all buttons are released
	os_waitForNoInput();
}
/* The gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[])
{
    char *name;              /* input scalar */
    double *inMatrix;               /* 1xN input matrix */
    size_t ncols;                   /* size of matrix */
    double *outMatrix;              /* output matrix */

    /* check for proper number of arguments */
    if(nrhs!=1) {
        mexErrMsgIdAndTxt("MyToolbox:arrayProduct:nrhs","One input required.");
    }
    if(nlhs!=0) {
        mexErrMsgIdAndTxt("MyToolbox:arrayProduct:nlhs","No output required.");
    }
    
    /* make sure the first input argument is a string */
    if( !mxIsChar(prhs[0]) ){
        mexErrMsgIdAndTxt("MyToolbox:arrayProduct:notString","Input name must be a string/double.");
    }
    
    /* get the value of the String input  */
    name = (char *) mxCalloc(mxGetN(prhs[0]), sizeof(char));
    mxGetString(prhs[0], name, mxGetN(prhs[0])+1);    
    
    /* call the computational routine */
    helloWorld(name);
}
示例#3
0
int main()
{

   // call a function that is declared in file_with_functions.h and 
   // defined in file_with_functions.c
   helloWorld();

   return 0;
}
示例#4
0
 void Root::Run()
 {
	// Init
	 _context = new Urho3D::Context();
	 _engine = new Urho3D::Engine(_context);

	Urho3D::VariantMap engineParameters;
	engineParameters["WindowTitle"] = "B1UE";
    engineParameters["LogName"]     = "B1UE.log";
    engineParameters["FullScreen"]  = false;
    engineParameters["Headless"]    = false;
	//engineParameters["MultiSample"] = 16;
	//engineParameters["TextureAnisotropy"] = 16;
	//engineParameters["WindowResizable"] = true;
	//_engine->SetPauseMinimized(false);

	if (!_engine->Initialize(engineParameters))
    {
        return;
    }
	_context->GetSubsystem<Urho3D::Input>()->SetMouseVisible(true);
//	_context->GetSubsystem<Urho3D::ResourceCache>()->AddResourceDir("GameData");

	Urho3D::Rocket::Core::RenderInterface::RegisterObject(_context);
	Urho3D::Rocket::Core::SystemInterface::RegisterObject(_context);
	Urho3D::Rocket::Core::RocketDocument::RegisterObject(_context);
	Urho3D::Rocket::RocketDocument2D::RegisterObject(_context);
	Urho3D::Rocket::RocketDocument3D::RegisterObject(_context);

	// Initialize Rocket
	_context->RegisterSubsystem(new Urho3D::Rocket::Core::SystemInterface(_context));
	Rocket::Core::SetSystemInterface(_context->GetSubsystem<Urho3D::Rocket::Core::SystemInterface>());

	Rocket::Core::Initialise();
	Rocket::Controls::Initialise();
	RocketEventListenerInstancer::Register(_context);

	Urho3D::SharedPtr<HelloWorld> helloWorld(new HelloWorld(_context));
	helloWorld->Start();

	// Main thread
	m_bStop = false;
	while (!m_bStop && !_engine->IsExiting())
	{
		_engine->RunFrame();
	}

	helloWorld->Stop();
 }
示例#5
0
/**
 * MAIN function
 */
int main(int argc, const char * argv[])
{
	helloWorld();
	
    // Variables
    int a = 5;
    float b = 6.3;
    char c = 'r';
    printf("- This is an int : %i\n", a);
    printf("- This is a float: %f\n", b);
    printf("- This is a char : %c\n", c);
    
	printf("\n- %i multiplied by 5 is: %i\n", a, multiplyByFive(a));
	
	structureExercise();
	pointerExercise();
	
    return 0;
}
示例#6
0
int main(int argc, char *argv[])
{

  // Disable deprecation warning for getenv call.
#ifdef CHAISCRIPT_MSVC
#pragma warning(push)
#pragma warning(disable : 4996)
#endif

  const char *usepath = getenv("CHAI_USE_PATH");
  const char *modulepath = getenv("CHAI_MODULE_PATH");

#ifdef CHAISCRIPT_MSVC
#pragma warning(pop)
#endif

  std::vector<std::string> usepaths;
  usepaths.push_back("");
  if (usepath)
  {
    usepaths.push_back(usepath);
  }

  std::vector<std::string> modulepaths;
  std::vector<std::string> searchpaths = default_search_paths();
  modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end());
  modulepaths.push_back("");
  if (modulepath)
  {
    modulepaths.push_back(modulepath);
  }

  //chaiscript::ChaiScript chai(modulepaths, usepaths);
  chaiscript::ChaiScript chai(chaiscript::Std_Lib::library(), usepaths);

  chai.add(chaiscript::fun(&myexit), "exit");
  chai.add(chaiscript::fun(&myexit), "quit");
  chai.add(chaiscript::fun(&help), "help");
  chai.add(chaiscript::fun(&throws_exception), "throws_exception");
  chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");

  chai.add(chaiscript::fun(&helloWorld), "helloWorld");

  clock_t begin = clock();

  for (int i = 0; i < 1000; i++)
  {
    std::string str = helloWorld("Bob12345");
    fwrite(str.c_str(), 1, str.size(), stdout);
  }

  clock_t end = clock();
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;

  //begin = clock();

  ////for (int i = 0; i < 1000; i++)
  ////{
  //// chai.eval("puts(helloWorld(\"Bob12345\"));");
  ////}
  //chai.eval_file("E:\\C++\\ChaiScript - 5.4.0\\samples\forx.chai");

  //end = clock();
  //elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
  //printf("**MyProgram::time= %lf\n", elapsed_secs);

  for (int i = 0; i < argc; ++i) {
    if (i == 0 && argc > 1) {
      ++i;
    }

    std::string arg(i ? argv[i] : "--interactive");

    enum {
      eInteractive
        , eCommand
        , eFile
    } mode = eCommand;

    if (arg == "-c" || arg == "--command") {
      if ((i + 1) >= argc) {
        std::cout << "insufficient input following " << arg << std::endl;
        return EXIT_FAILURE;
      }
      else {
        arg = argv[++i];
      }
    }
    else if (arg == "-" || arg == "--stdin") {
      arg = "";
      std::string line;
      while (std::getline(std::cin, line)) {
        arg += line + '\n';
      }
    }
    else if (arg == "-v" || arg == "--version") {
      arg = "version()";
    }
    else if (arg == "-h" || arg == "--help") {
      arg = "help(-1)";
    }
    else if (arg == "-i" || arg == "--interactive") {
      mode = eInteractive;
    }
    else if (arg.find('-') == 0) {
      std::cout << "unrecognised argument " << arg << std::endl;
      return EXIT_FAILURE;
    }
    else {
      mode = eFile;
    }

    chaiscript::Boxed_Value val;
    try {
      switch (mode) {
        case eInteractive: interactive(chai); break;
        case eCommand: val = chai.eval(arg); break;
        case eFile: {
                      begin = clock();

                      val = chai.eval_file(arg);

                      end = clock();
                      double elapsed_secs1 = double(end - begin) / CLOCKS_PER_SEC;
                      printf("**C++::time= %.10f\n", elapsed_secs);
                      printf("**ChaiScript::time= %.10f\n", elapsed_secs1);
                      break;
                    }

      }
    }
    catch (const chaiscript::exception::eval_error &ee) {
      std::cout << ee.pretty_print();
      std::cout << std::endl;
      return EXIT_FAILURE;
    }
    catch (std::exception &e) {
      std::cout << e.what() << std::endl;
      return EXIT_FAILURE;
    }
  }

  return EXIT_SUCCESS;
}
示例#7
0
int main(int argc, char** argv)
{
    // The socket that connects us to the server
    tcp_socket_stream connection;

    std::cout << "Connecting..." << std::flush;
    
    // Connect to the server
    if(argc>1) {
      connection.open(argv[1], 6767);
    } else {
      connection.open("127.0.0.1", 6767);
    }
    
    // The DebugBridge puts all that comes through the codec on cout
    DebugBridge bridge;
    // Do client negotiation with the server
    Atlas::Net::StreamConnect conn("simple_client", connection);

    std::cout << "Negotiating... " << std::flush;
    // conn.poll() does all the negotiation
    while (conn.getState() == Atlas::Net::StreamConnect::IN_PROGRESS) {
        conn.poll();
    }
    std::cout << "done" << std::endl;

    // Check whether negotiation was successful
    if (conn.getState() == Atlas::Net::StreamConnect::FAILED) {
        std::cerr << "Failed to negotiate" << std::endl;
        return 2;
    }
    // Negotiation was successful

    // Get the codec that negotiation established
    Atlas::Codec * codec = conn.getCodec(bridge);

    // This should always be sent at the beginning of a session
    codec->streamBegin();
    
    // Say hello to the server
    helloWorld(*codec);
    connection << std::flush;

    std::cout << "Sleeping for 2 seconds... " << std::flush;
    // Sleep a little
    sleep(2);
    std::cout << "done." << std::endl;

    // iosockinet::operator bool() returns false if the connection was broken
    if (!connection) {
        std::cout << "Server exited." << std::endl;
    } else {
        // It was not broken by the server, so we'll close ourselves
        std::cout << "Closing connection... " << std::flush;
        // This should always be sent at the end of a session
        codec->streamEnd();
        connection << std::flush;
        // Close the socket
        connection.close();
        std::cout << "done." << std::endl;
    }

    return 0;
}
示例#8
0
static void testHelloWorld() {
	const char * hello;
	
	hello = helloWorld();
	TestCase_assert(!strcmp("Hello, world!", hello), "Unexpected result \"%s\" from call to helloWorld (expected \"Hello, world!\")", hello);
}
示例#9
0
文件: 5-paradox.c 项目: mabels/talks
int main() {
  // mmh where could the len be known upfront?
  HelloWorld<len> hw = helloWorld();
  printf("%s\n", hw.ret);
  return 0;
}