Beispiel #1
0
void Sample::setupEngine()
{
    // Create root node and load plugins which are defined inside our plugin.cfg
    mRoot = new Ogre::Root(PLUGIN_CFG);
    if (!mRoot->restoreConfig()) {
        mRoot->showConfigDialog();
    }

    // Create our main window
    mWindow = mRoot->initialise(true, "noesisGUI: Basic Ogre Sample");

    // Parse resources
    parseResources();

    // start script parsing
    Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

    // Create the scenemanger
    mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
    mCamera = mSceneMgr->createCamera("MyCam");

    // Setup NoesisGUI
    Noesis_Init();

    Noesis_LoadXAML(&mUIRoot, &mUIRenderer, "Time.xaml");
    //Noesis_LoadXAML(&mUIRoot, &mUIRenderer, "Menu.xaml", "Themes/NoesisStyle.xaml");
    Noesis_RendererAntialiasingMode(mUIRenderer, NsAntialiasingMode_PPAA);
    Noesis_RendererTessQuality(mUIRenderer, NsTessellationQuality_High);

    // Setup input
    setupInput();

    // Add frame listener
    mRoot->addFrameListener(this);
}
Beispiel #2
0
DnsLayer::DnsLayer(const DnsLayer& other) : Layer(other)
{
	m_Protocol = DNS;

	m_ResourceList = NULL;

	m_FirstQuery = NULL;
	m_FirstAnswer = NULL;
	m_FirstAuthority = NULL;
	m_FirstAdditional = NULL;

	parseResources();
}
Beispiel #3
0
DnsLayer::DnsLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
	: Layer(data, dataLen, prevLayer, packet)
{
	m_Protocol = DNS;
	m_ResourceList = NULL;

	m_FirstQuery = NULL;
	m_FirstAnswer = NULL;
	m_FirstAuthority = NULL;
	m_FirstAdditional = NULL;

	parseResources();
}
com::typesafe::config::Config* com::typesafe::config::ConfigFactory::parseApplicationConfig(ConfigParseOptions* parseOptions)
{
    clinit();
    auto loader = npc(parseOptions)->getClassLoader();
    if(loader == nullptr)
        throw new ConfigException_BugOrBroken(::java::lang::StringBuilder().append(u"ClassLoader should have been set here; bug in ConfigFactory. "_j)->append(u"(You can probably work around this bug by passing in a class loader or calling currentThread().setContextClassLoader() though.)"_j)->toString());

    auto specified = int32_t(0);
    auto resource = ::java::lang::System::getProperty(u"config.resource"_j);
    if(resource != nullptr)
        specified += 1;

    auto file = ::java::lang::System::getProperty(u"config.file"_j);
    if(file != nullptr)
        specified += 1;

    auto url = ::java::lang::System::getProperty(u"config.url"_j);
    if(url != nullptr)
        specified += 1;

    if(specified == 0) {
        return ConfigFactory::parseResourcesAnySyntax(u"application"_j, parseOptions);
    } else if(specified > 1) {
        throw new ConfigException_Generic(::java::lang::StringBuilder().append(u"You set more than one of config.file='"_j)->append(file)
            ->append(u"', config.url='"_j)
            ->append(url)
            ->append(u"', config.resource='"_j)
            ->append(resource)
            ->append(u"'; don't know which one to use!"_j)->toString());
    } else {
        auto overrideOptions = npc(parseOptions)->setAllowMissing(false);
        if(resource != nullptr) {
            if(npc(resource)->startsWith(u"/"_j))
                resource = npc(resource)->substring(1);

            return parseResources(loader, resource, overrideOptions);
        } else if(file != nullptr) {
            return parseFile(new ::java::io::File(file), overrideOptions);
        } else {
            try {
                return parseURL(new ::java::net::URL(url), overrideOptions);
            } catch (::java::net::MalformedURLException* e) {
                throw new ConfigException_Generic(::java::lang::StringBuilder().append(u"Bad URL in config.url system property: '"_j)->append(url)
                    ->append(u"': "_j)
                    ->append(npc(e)->getMessage())->toString(), e);
            }
        }
    }
}
Beispiel #5
0
BOOL	R_constant_table::parse	(void* _desc, u16 destination)
{
	ID3D10ShaderReflection *pReflection = (ID3D10ShaderReflection *)_desc;

	D3D10_SHADER_DESC	ShaderDesc;
	pReflection->GetDesc(&ShaderDesc);

	if (ShaderDesc.ConstantBuffers)
	{
		m_CBTable.reserve(ShaderDesc.ConstantBuffers);
		//	Parse single constant table
		ID3D10ShaderReflectionConstantBuffer *pTable=0;

		for (u16 iBuf = 0; iBuf<ShaderDesc.ConstantBuffers; ++iBuf)
		{
			pTable = pReflection->GetConstantBufferByIndex(iBuf);
			if (pTable)
			{
				//	Encode buffer index into destination
				u16	updatedDest = destination;
				updatedDest |= iBuf << ((destination&RC_dest_pixel)
					? RC_dest_pixel_cb_index_shift : (destination&RC_dest_vertex)
					? RC_dest_vertex_cb_index_shift : RC_dest_geometry_cb_index_shift);

				//	Encode bind dest (pixel/vertex buffer) and bind point index
				u32	uiBufferIndex = iBuf;
				uiBufferIndex |= (destination&RC_dest_pixel) 
					? CB_BufferPixelShader : (destination&RC_dest_vertex)
					? CB_BufferVertexShader : CB_BufferGeometryShader;

				parseConstants(pTable,updatedDest);
				ref_cbuffer	tempBuffer = dxRenderDeviceRender::Instance().Resources->_CreateConstantBuffer(pTable);
				m_CBTable.push_back(cb_table_record(uiBufferIndex, tempBuffer));
			}
		}
	}

	if (ShaderDesc.BoundResources)
	{
		parseResources(pReflection, ShaderDesc.BoundResources, destination);
	}

	std::sort	(table.begin(),table.end(),p_sort);
	return		TRUE;
}
Beispiel #6
0
DnsLayer& DnsLayer::operator=(const DnsLayer& other)
{
	Layer::operator=(other);

	IDnsResource* curResource = m_ResourceList;
	while (curResource != NULL)
	{
		IDnsResource* temp = curResource->getNextResource();
		delete curResource;
		curResource = temp;
	}

	m_ResourceList = NULL;

	m_FirstQuery = NULL;
	m_FirstAnswer = NULL;
	m_FirstAuthority = NULL;
	m_FirstAdditional = NULL;

	parseResources();

	return (*this);
}
com::typesafe::config::Config* com::typesafe::config::ConfigFactory::parseResources(::java::lang::String* resource)
{
    clinit();
    return parseResources(resource, ConfigParseOptions::defaults());
}
com::typesafe::config::Config* com::typesafe::config::ConfigFactory::parseResources(::java::lang::ClassLoader* loader, ::java::lang::String* resource, ConfigParseOptions* options)
{
    clinit();
    return parseResources(resource, npc(options)->setClassLoader(loader));
}
com::typesafe::config::Config* com::typesafe::config::ConfigFactory::parseResources(::java::lang::Class* klass, ::java::lang::String* resource)
{
    clinit();
    return parseResources(static_cast< ::java::lang::Class* >(klass), resource, ConfigParseOptions::defaults());
}
Beispiel #10
0
static struct host
parseHost
(json_value *hostObj, int *ret)
{
  json_value *jName = json_find(hostObj, "name", json_string);
  json_value *jMac  = json_find(hostObj, "mac",  json_string);

  if ((NULL == jName) || (NULL == jMac))
    return (*ret = 1), (struct host) {0};

  struct host result = {
    .name       = utilStringDup(jName->u.string.ptr),
    .macAddress = utilStringDup(jMac->u.string.ptr)
  };

  return result;
}

static struct host *
parseHosts
(json_value *root, size_t *numHosts)
{
  json_value *jHosts = json_find(root, "hosts", json_array);
  if (NULL == jHosts)
    return NULL;

  const size_t numJHosts     = jHosts->u.array.length;
  struct host *result = calloc(numJHosts, sizeof(*result));

  for (size_t i=0; i<numJHosts; i++)
  {
    json_value *jHostObj = jHosts->u.array.values[i];

    int ret   = 0;
    result[i] = parseHost(jHostObj, &ret);
    
    if (ret)
    {
      free(result);
      return NULL;
    }
  }

  *numHosts = numJHosts;
  return result;
}

static struct resource
parseResource
(json_value *jResource, int *ret)
{
  json_value *jName = json_find(jResource, "name", json_string);
  json_value *jHost = json_find(jResource, "host", json_string);
  json_value *jVars = json_find(jResource, "vars", json_array);
  
  if ((NULL == jName) || (NULL == jHost) || (NULL == jVars))
    return (*ret = 1), (struct resource) {0};

  const size_t numVars = jVars->u.array.length;
  char **keyMap = calloc(numVars, sizeof(char *));
  char **valMap = calloc(numVars, sizeof(char *));

  for (size_t i=0; i<numVars; i++)
  {
    json_value *jVar = jVars->u.array.values[i];
    if (jVar->type != json_array)
      return (*ret = 1), (struct resource) {0};

    if (jVar->u.array.length != 2)
      return (*ret = 1), (struct resource) {0};

    json_value *jKey = jVar->u.array.values[0];
    json_value *jVal = jVar->u.array.values[1];

    if (jKey->type != json_string)
      return (*ret = 1), (struct resource) {0};

    if (jVal->type != json_string)
      return (*ret = 1), (struct resource) {0};

    keyMap[i] = utilStringDup(jKey->u.string.ptr);
    valMap[i] = utilStringDup(jVal->u.string.ptr);
  }

  struct resource result = {
    .name     = utilStringDup(jName->u.string.ptr),
    .host     = utilStringDup(jHost->u.string.ptr),
    .numVars  = numVars,
    .keyMap   = keyMap,
    .valMap   = valMap,
  };

  return result;
}

struct resource *
parseResources
(json_value *root, size_t *numResources)
{
  json_value *jResources = json_find(root, "resources", json_array);
  if (NULL == jResources)
    return NULL;

  const size_t numJResources  = jResources->u.array.length;
  struct resource *result     = calloc(numJResources, sizeof(*result));
  
  for (size_t i=0; i<numJResources; i++)
  {
    json_value *jResource = jResources->u.array.values[i];

    int ret       = 0;
    result[i]     = parseResource(jResource, &ret);
    result[i].id  = i;

    #if defined(CLUSTERD_BUILD)
      result[i].mutex = calloc(1, sizeof(pthread_mutex_t));
      result[i].inUse = calloc(1, sizeof(bool));
      pthread_mutex_init(result[i].mutex, NULL);
    #endif
  }

  *numResources = numJResources;
  return result;
}

configuration *
parseConfiguration
(void)
{
  char *jsonConfig = readFile(_configPath);
  if (NULL == jsonConfig)
  {
    fprintf(stderr, "Error: Unable to read configuration file\n");
    fprintf(stderr, "Does %s exist?\n", _configPath);
    return NULL;
  }

  json_value *root = json_parse(jsonConfig, strlen(jsonConfig));
  free(jsonConfig);
  if (NULL == root)
  {
    fprintf(stderr, "Error: Configuration file %s is malformed\n", _configPath);
    fprintf(stderr, "Unable to parse json\n");
    return NULL;
  }

  configuration *result = calloc(1, sizeof(configuration));
  result->hosts = parseHosts(root, &result->numHosts);
  if (NULL == result->hosts)
  {
    fprintf(stderr, "Error: Configuration file %s is malformed\n", _configPath);
    fprintf(stderr, "Unable to parse hosts\n");
    return NULL;
  }

  result->resources = parseResources(root, &result->numResources);
  if (NULL == result->hosts)
  {
    fprintf(stderr, "Error: Configuration file %s is malformed\n", _configPath);
    fprintf(stderr, "Unable to parse resources\n");
    return NULL;
  }

  json_value *jMaster = json_find(root, "master", json_string);
  if (NULL == jMaster)
  {
    fprintf(stderr, "Error: No master hostname set\n");
    return NULL;
  }

  if (jMaster->type != json_string)
  {
    fprintf(stderr, "Error: Master feild is not a string\n");
    return NULL;
  }

  result->master = utilStringDup(jMaster->u.string.ptr);

  json_value_free(root);

  return result;
}
Beispiel #11
0
/*ARGSUSED*/
extern int
main(int argc, char *argv[]) {
    XEvent ev;
    struct sigaction sa;
    int dpy_fd, max_fd;

    argv0 = argv[0];

    mode = wm_initialising;

    setlocale(LC_ALL, "");

    /* Open a connection to the X server. */
    dpy = XOpenDisplay(NULL);
    if (dpy == 0)
        panic("can't open display.");

    parseResources();

    /* Set up an error handler. */
    XSetErrorHandler(errorHandler);

    /* Set up signal handlers. */
    signal(SIGTERM, Terminate);
    signal(SIGINT, Terminate);
    signal(SIGHUP, Terminate);

    /* Ignore SIGCHLD. */
    sa.sa_handler = SIG_IGN;
#ifdef SA_NOCLDWAIT
    sa.sa_flags = SA_NOCLDWAIT;
#else
    sa.sa_flags = 0;
#endif
    sigemptyset(&sa.sa_mask);
    sigaction(SIGCHLD, &sa, 0);

    /* Internalize useful atoms. */
    wm_state = XInternAtom(dpy, "WM_STATE", False);
    wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);
    wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
    wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
    wm_take_focus = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
    wm_colormaps = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
    compound_text = XInternAtom(dpy, "COMPOUND_TEXT", False);

    _mozilla_url = XInternAtom(dpy, "_MOZILLA_URL", False);

    motif_wm_hints = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);

    ewmh_init();

    /*
     * Get fonts for our titlebar and our popup window. We try to
     * get Lucida, but if we can't we make do with fixed because everyone
     * has that.
     */
    {
        /* FIXME: do these need to be freed? */
        char **missing;
        char *def;
        int missing_count;

        font_set = XCreateFontSet(dpy, font_name,
                                  &missing, &missing_count, &def);
        if (font_set == NULL)
            font_set = XCreateFontSet(dpy, "fixed",
                                      &missing, &missing_count, &def);
        if (font_set == NULL)
            panic("unable to create font set for title font");
        if (missing_count > 0)
            fprintf(stderr,"%s: warning: missing %d charset"
                    "%s for title font\n", argv0, missing_count,
                    (missing_count == 1)?"":"s");
        font_set_ext = XExtentsOfFontSet(font_set);

        popup_font_set = XCreateFontSet(dpy, popup_font_name,
                                        &missing, &missing_count, &def);
        if (popup_font_set == NULL)
            popup_font_set = XCreateFontSet(dpy, "fixed",
                                            &missing, &missing_count, &def);
        if (popup_font_set == NULL)
            panic("unable to create font set for popup font");
        if (missing_count > 0)
            fprintf(stderr,"%s: warning: missing %d charset"
                    "%s for popup font\n", argv0, missing_count,
                    (missing_count == 1)?"":"s");
        popup_font_set_ext = XExtentsOfFontSet(popup_font_set);
    }

    initScreens();
    ewmh_init_screens();
    session_init(argc, argv);

    /* See if the server has the Shape Window extension. */
    shape = serverSupportsShapes();

    /*
     * Initialisation is finished, but we start off not interacting with the
     * user.
     */
    mode = wm_idle;

    /*
     * The main event loop.
     */
    dpy_fd = ConnectionNumber(dpy);
    max_fd = dpy_fd + 1;
    if (ice_fd > dpy_fd) max_fd = ice_fd + 1;
    for (;;) {
        fd_set readfds;

        FD_ZERO(&readfds);
        FD_SET(dpy_fd, &readfds);
        if (ice_fd > 0) FD_SET(ice_fd, &readfds);
        if (select(max_fd, &readfds, NULL, NULL, NULL) > -1) {
            if (FD_ISSET(dpy_fd, &readfds)) {
                while (XPending(dpy)) {
                    XNextEvent(dpy, &ev);
                    dispatch(&ev);
                }
            }
            if (ice_fd > 0 && FD_ISSET(ice_fd, &readfds)) {
                session_process();
            }
        }
    }
}