Exemple #1
0
int parseAndComputeMsParamArrayToEnv( msParamArray_t *var, Env *env, ruleExecInfo_t *rei, int reiSaveFlag, rError_t *errmsg, Region *r ) {
    int i;
    for ( i = 0; i < var->len; i++ ) {
        Res *res = newRes( r );
        int ret = convertMsParamToRes( var->msParam[i], res, r );
        if ( ret != 0 ) {
            return ret;
        }
        char *varName = var->msParam[i]->label;
        if ( TYPE( res ) == T_UNSPECED ) {
            if ( varName != NULL ) {
                updateInEnv( env, varName, res );
            }
            continue;
        }
        if ( TYPE( res ) != T_STRING ) {
            return -1;
        }

        char *expr = res->text;
        res = parseAndComputeExpression( expr, env, rei, reiSaveFlag, errmsg, r );
        if ( getNodeType( res )  ==  N_ERROR ) {
            return RES_ERR_CODE( res );
        }
        if ( varName != NULL ) {
            updateInEnv( env, varName, res );
        }
    }
    return 0;

}
Exemple #2
0
/* used in cpRes only */
Res* newCollRes2(int size, Region *r) {
	Res *res1 = newRes(r);
        res1->exprType = NULL;
        res1->degree = size;
        res1->subtrees = (Res **)region_alloc(r, sizeof(Res *)*size);
	return res1;
}
Exemple #3
0
Res* newCollRes(int size, ExprType *elemType, Region *r) {
	Res *res1 = newRes(r);
        res1->exprType = newCollType(elemType, r);
        res1->degree = size;
        res1->subtrees = (Res **)region_alloc(r, sizeof(Res *)*size);
	return res1;
}
Exemple #4
0
Res* convertMsParamToRes( msParam_t* myArgv, Region* r ) {
    Res* res = newRes( r ); /* we need to create a new res here to make keep all res'es immutable */
    int ret = convertMsParamToResAndFreeNonIRODSType( myArgv, res, r );
    if ( ret != 0 ) {
        res = newErrorRes( r, ret );
    }
    return res;
}
Exemple #5
0
FunctionDesc *newFuncSymLink(char *fn , int nArgs, Region *r) {
    Res *desc = newRes(r);
    setNodeType(desc, N_SYM_LINK);
    desc->text = cpStringExt(fn ,r);
    RES_FUNC_N_ARGS(desc) = nArgs;
    desc->exprType = newSimpType(T_DYNAMIC, r);
    return desc;
}
Exemple #6
0
Res* newStringBasedRes(Region *r, char *s) {
	Res *res1 = newRes(r);
        RES_STRING_STR_LEN(res1) = strlen(s);
        int size = (RES_STRING_STR_LEN(res1)+1)*sizeof(char);
        res1->text = (char *)region_alloc(r, size);
        memcpy(res1->text, s, size);
	return res1;
}
Exemple #7
0
/**
 * adapted from reHelpers2.c
 * input
 *     typ: collection type
 *     inPtr: collection value
 *     inx: index of the element
 * output
 *     value: element value (new on heap)
 *     inx: index of the next element
 *     outtyp: the type of the element (new on heap)
 * return
 *     0
 * 	   NO_VALUES_FOUND
 *     USER_PARAM_TYPE_ERR
 */
Res* getValueFromCollection( char *typ, void *inPtr, int inx, Region *r ) {
    Res *res;
    int i, j;

    if ( !strcmp( typ, StrArray_MS_T ) ) {
        strArray_t *strA;
        /* ->size size of an element */
        /* ->len  length of the array */
        strA = ( strArray_t  * ) inPtr;
        if ( inx >= strA->len ) {
            return NULL;
        }
        res = newStringRes( r, strA->value + inx * strA->size );
        return res;
    }
    else if ( !strcmp( typ, IntArray_MS_T ) ) {
        res = newRes( r );
        res->exprType = newSimpType( T_INT, r );
        intArray_t *intA;
        intA = ( intArray_t * ) inPtr;
        if ( inx >= intA->len ) {
            return NULL;
        }
        RES_INT_VAL_LVAL( res ) = intA->value[inx];
        return res;
    }
    else if ( !strcmp( typ, GenQueryOut_MS_T ) ) {
        keyValPair_t *k; /* element value */
        genQueryOut_t *g = ( genQueryOut_t * ) inPtr; /* the result set */
        char *cname, *aval; /* key and value */
        sqlResult_t *v; /* a result row */
        if ( g->rowCnt == 0 || inx >= g->rowCnt ) {
            return NULL;
        }
        k = ( keyValPair_t * )malloc( sizeof( keyValPair_t ) );
        k->len = 0;
        k->keyWord = NULL;
        k->value = NULL;
        for ( i = 0; i < g->attriCnt; i++ ) {
            v = g->sqlResult + i;
            cname = ( char * ) getAttrNameFromAttrId( v->attriInx );
            aval = v->value + v->len * inx;
            j  = addKeyVal( k, cname, aval ); /* addKeyVal duplicates the strings */
            if ( j < 0 ) {
                return NULL;
            }
        }
        res = newUninterpretedRes( r, KeyValPair_MS_T, k, NULL );
        return res;
    }
    else if ( strcmp( typ, KeyValPair_MS_T ) == 0 ) {
        return newStringRes( r, ( ( keyValPair_t * ) inPtr )->keyWord[inx] );
    }
    else {
        return NULL;
    }
}
Exemple #8
0
Node *newPartialApplication(Node *func, Node *arg, int nArgsLeft, Region *r) {
    Res *res1 = newRes(r);
    setNodeType(res1, N_PARTIAL_APPLICATION);
    RES_FUNC_N_ARGS(res1) = nArgsLeft;
    res1->degree = 2;
    res1->subtrees = (Res **)region_alloc(r, sizeof(Res *)*2);
    res1->subtrees[0] = func;
    res1->subtrees[1] = arg;
    return res1;
}
Exemple #9
0
quint32 Model::addReservation(quint32 &itemID, QDateTimeSpan &timePeriod, QMoney &price, quint8 &paymentMethod,
                              quint8 &location, quint16 &employeeID, quint32 customerID)
{
    Reservation newRes(itemID, timePeriod, price, paymentMethod, location, employeeID, customerID);
    quint32 resID = newRes.getID();
    resMap.insert(resID, newRes);

    emit reservationModelChanged();
    return resID;
}
Exemple #10
0
Node *newTupleRes(int arity, Res **comps, Region *r) {
	Res *res1 = newRes(r);
	setNodeType(res1, N_TUPLE);
	res1->subtrees = comps;
	res1->degree = arity;
	ExprType **compTypes = (ExprType **)region_alloc(r, sizeof(ExprType *) * arity);
	int i;
	for(i=0;i<arity;i++) {
		compTypes[i] = comps[i]->exprType;
	}
	res1->exprType = newTupleType(arity, compTypes, r);
	return res1;
}
Exemple #11
0
int updateMsParamArrayToEnvAndFreeNonIRODSType(msParamArray_t *var, Env *env, rError_t *errmsg, Region *r) {
	int i;
	for(i=0;i<var->len;i++) {
		Res *res = newRes(r);
		int ret = convertMsParamToResAndFreeNonIRODSType(var->msParam[i], res, errmsg, r);
        if(ret != 0) {
            return ret;
        }
		char *varName = var->msParam[i]->label;
        if(varName!=NULL) {
            updateInEnv(env, varName, res);
        }
	}
        return 0;
}
Exemple #12
0
bool OpenGLApp::initAPI(){
	initialMode = CGDisplayCurrentMode(kCGDirectMainDisplay);

	dmodes = CGDisplayAvailableModes(kCGDirectMainDisplay);
	int count = CFArrayGetCount(dmodes);

	Array <DispRes> modes;
	int foundMode = -1;
	for (int i = 0; i < count; i++){
		CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, i);

		long bitsPerPixel = GetDictionaryLong(mode, kCGDisplayBitsPerPixel);
		Boolean safeForHardware = GetDictionaryBoolean(mode, kCGDisplayModeIsSafeForHardware);
		Boolean stretched = GetDictionaryBoolean(mode, kCGDisplayModeIsStretched);

		if (bitsPerPixel < colorBits || !safeForHardware || stretched) continue;

		long width  = GetDictionaryLong(mode, kCGDisplayWidth);
		long height = GetDictionaryLong(mode, kCGDisplayHeight);
		long refreshRate = GetDictionaryLong(mode, kCGDisplayRefreshRate);

//		printf("Mode: %dx%dx%d @ %d\n", width, height, bitsPerPixel, refreshRate);

		if (width >= 640 && height >= 480){
			modes.add(newRes(width, height, i));

			if (width == fullscreenWidth && height == fullscreenHeight){
				foundMode = i;
			}
		}
	}

	resolution->clear();
	modes.sort(dComp);
	char str[64];
	for (uint i = 0; i < modes.getCount(); i++){
		sprintf(str, "%dx%d", modes[i].w, modes[i].h);
		int index = resolution->addItemUnique(str);
		if (modes[i].index == foundMode) resolution->selectItem(index);
	}

	if (fullscreen){
		if (foundMode < 0 || CGDisplaySwitchToMode(kCGDirectMainDisplay, (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, foundMode)) != kCGErrorSuccess){
			sprintf(str, "Couldn't set fullscreen to %dx%d.", fullscreenWidth, fullscreenHeight);
			ErrorMsg(str);
			fullscreen = false;
		}
	}


	Rect rect;
	if (fullscreen){
		rect.left = 0;
		rect.top  = 0;
	} else {
		long w = GetDictionaryLong(initialMode, kCGDisplayWidth);
		long h = GetDictionaryLong(initialMode, kCGDisplayHeight);

		rect.left = (w - width) / 2;
		rect.top  = (h - height) / 2;
	}
	rect.right = rect.left + width;
	rect.bottom = rect.top + height;

	WindowAttributes attributes = fullscreen? (kWindowNoTitleBarAttribute | kWindowNoShadowAttribute) : (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute);

	OSStatus error = CreateNewWindow(kDocumentWindowClass, attributes, &rect, &window);
	if (error != noErr || window == NULL){
		ErrorMsg("Couldn't create window");
		return false;
	}

    GDHandle screen = GetGWorldDevice(GetWindowPort(window));
    if (screen == NULL){
        ErrorMsg("Couldn't get device");
        ReleaseWindow(window);
        return false;
    }

	AGLPixelFormat pixelFormat;
	while (true){
		GLint attributes[] = {
			fullscreen? AGL_FULLSCREEN : AGL_WINDOW,
			AGL_RGBA,
			AGL_DOUBLEBUFFER,
			AGL_RED_SIZE,            8,
			AGL_GREEN_SIZE,          8,
			AGL_BLUE_SIZE,           8,
			AGL_ALPHA_SIZE,         (colorBits > 24)? 8 : 0,
			AGL_DEPTH_SIZE,          depthBits,
			AGL_STENCIL_SIZE,        stencilBits,
			AGL_SAMPLE_BUFFERS_ARB, (antiAliasSamples > 0),
			AGL_SAMPLES_ARB,         antiAliasSamples,
			AGL_NONE
		};

		pixelFormat = aglChoosePixelFormat(&screen, 1, attributes);
		if (pixelFormat != NULL) break;

		antiAliasSamples -= 2;
		if (antiAliasSamples < 0){
			ErrorMsg("No suitable pixel format");
			ReleaseWindow(window);
			return false;
		}
	}

	glContext = aglCreateContext(pixelFormat, NULL);
    aglDestroyPixelFormat(pixelFormat);

	if (glContext == NULL){
		ErrorMsg("Couldn't create context");
		ReleaseWindow(window);
		return false;
	}

	if (fullscreen){
		CGCaptureAllDisplays();
		aglSetFullScreen(glContext, 0, 0, 0, 0);
	} else {
		if (!aglSetDrawable(glContext, GetWindowPort(window))){
			ErrorMsg("Couldn't set drawable");
			aglDestroyContext(glContext);
			ReleaseWindow(window);
			return false;
		}
	}

	if (!aglSetCurrentContext(glContext)){
		ErrorMsg("Couldn't make context current");
		aglDestroyContext(glContext);
		ReleaseWindow(window);
		return false;
	}

	setWindowTitle(getTitle());
    ShowWindow(window);

	initExtensions();

	if (antiAliasSamples > 0){
		glEnable(GL_MULTISAMPLE_ARB);
	}

	if (fullscreen) captureMouse(!configDialog->isVisible());

	renderer = new OpenGLRenderer(glContext);
	renderer->setViewport(width, height);

	antiAlias->selectItem(antiAliasSamples / 2);

	linearClamp = renderer->addSamplerState(LINEAR, CLAMP, CLAMP, CLAMP);
	defaultFont = renderer->addFont("../Textures/Fonts/Future.dds", "../Textures/Fonts/Future.font", linearClamp);
	blendSrcAlpha = renderer->addBlendState(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
	noDepthTest  = renderer->addDepthState(false, false);
	noDepthWrite = renderer->addDepthState(true,  false);
	cullNone  = renderer->addRasterizerState(CULL_NONE);
	cullBack  = renderer->addRasterizerState(CULL_BACK);
	cullFront = renderer->addRasterizerState(CULL_FRONT);

	return true;
}
Exemple #13
0
Res* newUninterpretedRes(Region *r, char *typeName, void *ioStruct, bytesBuf_t *ioBuf) {
	Res *res1 = newRes(r);
        res1->exprType = newIRODSType(typeName, r);
        res1->param = newMsParam(typeName, ioStruct, ioBuf, r);
	return res1;
}
Exemple #14
0
Res* newIntRes(Region *r, int n) {
	Res *res1 = newRes(r);
        res1->exprType = newSimpType(T_INT,r);
        RES_INT_VAL_LVAL(res1) = n;
	return res1;
}
Exemple #15
0
bool OpenGLApp::initAPI(){
	screen = DefaultScreen(display);

	int nModes;
    XF86VidModeGetAllModeLines(display, screen, &nModes, &dmodes);

	Array <DispRes> modes;

	char str[64];
	int foundMode = -1;
	for (int i = 0; i < nModes; i++){
		if (dmodes[i]->hdisplay >= 640 && dmodes[i]->vdisplay >= 480){
			modes.add(newRes(dmodes[i]->hdisplay, dmodes[i]->vdisplay, i));

			if (dmodes[i]->hdisplay == fullscreenWidth && dmodes[i]->vdisplay == fullscreenHeight){
				foundMode = i;
			}
		}
	}

	resolution->clear();
	modes.sort(dComp);
	for (uint i = 0; i < modes.getCount(); i++){
		sprintf(str, "%dx%d", modes[i].w, modes[i].h);
		int index = resolution->addItemUnique(str);
		if (modes[i].index == foundMode) resolution->selectItem(index);
	}


	if (fullscreen){
		if (foundMode >= 0 && XF86VidModeSwitchToMode(display, screen, dmodes[foundMode])){
			XF86VidModeSetViewPort(display, screen, 0, 0);
		} else {
			char str[128];
			sprintf(str, "Couldn't set fullscreen at %dx%d.", fullscreenWidth, fullscreenHeight);
			ErrorMsg(str);
			fullscreen = false;
		}
	}

	XVisualInfo *vi;
	while (true){
		int attribs[] = {
			GLX_RGBA,
			GLX_DOUBLEBUFFER,
			GLX_RED_SIZE,      8,
			GLX_GREEN_SIZE,    8,
			GLX_BLUE_SIZE,     8,
			GLX_ALPHA_SIZE,    (colorBits > 24)? 8 : 0,
			GLX_DEPTH_SIZE,    depthBits,
			GLX_STENCIL_SIZE,  stencilBits,
			GLX_SAMPLE_BUFFERS_ARB, (antiAliasSamples > 0),
			GLX_SAMPLES_ARB,         antiAliasSamples,
			None,
		};

		vi = glXChooseVisual(display, screen, attribs);
		if (vi != NULL) break;

		antiAliasSamples -= 2;
		if (antiAliasSamples < 0){
			char str[256];
			sprintf(str, "No Visual matching colorBits=%d, depthBits=%d and stencilBits=%d", colorBits, depthBits, stencilBits);
			ErrorMsg(str);
			return false;
		}
	}


	//printf("Selected visual = 0x%x\n",(unsigned int) (vi->visualid));
	glContext = glXCreateContext(display, vi, None, True);


	XSetWindowAttributes attr;
	attr.colormap = XCreateColormap(display, RootWindow(display, screen), vi->visual, AllocNone);

	attr.border_pixel = 0;
	attr.override_redirect = fullscreen;
    attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
		PointerMotionMask | StructureNotifyMask;

	window = XCreateWindow(display, RootWindow(display, vi->screen),
			0, 0, width, height, 0, vi->depth, InputOutput, vi->visual,
			CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attr);

	if (!fullscreen){
	    Atom wmDelete;
        wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
        XSetWMProtocols(display, window, &wmDelete, 1);
		char *title = "OpenGL";
        XSetStandardProperties(display, window, title, title, None, NULL, 0, NULL);
	}
    XMapRaised(display, window);

	// Create a blank cursor for cursor hiding
	XColor dummy;
	char data = 0;
	Pixmap blank = XCreateBitmapFromData(display, window, &data, 1, 1);
	blankCursor = XCreatePixmapCursor(display, blank, blank, &dummy, &dummy, 0, 0);
	XFreePixmap(display, blank);


	XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);


	glXMakeCurrent(display, window, glContext);

	initExtensions(display);

	if (antiAliasSamples > 0){
		glEnable(GL_MULTISAMPLE_ARB);
	}

	if (fullscreen) captureMouse(!configDialog->isVisible());

	renderer = new OpenGLRenderer(window, glContext, display, screen);
	renderer->setViewport(width, height);

	antiAlias->selectItem(antiAliasSamples / 2);

	linearClamp = renderer->addSamplerState(LINEAR, CLAMP, CLAMP, CLAMP);
	defaultFont = renderer->addFont("../Textures/Fonts/Future.dds", "../Textures/Fonts/Future.font", linearClamp);
	blendSrcAlpha = renderer->addBlendState(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
	noDepthTest  = renderer->addDepthState(false, false);
	noDepthWrite = renderer->addDepthState(true,  false);
	cullNone  = renderer->addRasterizerState(CULL_NONE);
	cullBack  = renderer->addRasterizerState(CULL_BACK);
	cullFront = renderer->addRasterizerState(CULL_FRONT);

	return true;
}
Exemple #16
0
Res* newErrorRes(Region *r, int errcode) {
	Res *res1 = newRes(r);
        setNodeType(res1, N_ERROR);
        RES_ERR_CODE(res1) = errcode;
	return res1;
}
Exemple #17
0
Res* newDatetimeRes(Region *r, long dt) {
	Res *res1 = newRes(r);
        res1->exprType = newSimpType(T_DATETIME,r);
    RES_TIME_VAL(res1) = dt;
	return res1;
}
Exemple #18
0
Res* newUnspecifiedRes(Region *r) {
	Res *res1 = newRes(r);
        res1->exprType = newSimpType(T_UNSPECED,r);
        res1->text = cpStringExt("", r);
	return res1;
}
Exemple #19
0
Res* newDoubleRes(Region *r, double a) {
	Res *res1 = newRes(r);
        res1->exprType = newSimpType(T_DOUBLE,r);
        RES_DOUBLE_VAL_LVAL(res1) = a;
	return res1;
}
Exemple #20
0
Res* newBoolRes(Region *r, int n) {
	Res *res1 = newRes(r);
        res1->exprType = newSimpType(T_BOOL,r);
        RES_BOOL_VAL_LVAL(res1) = n;
	return res1;
}