예제 #1
0
static kbool_t iterator_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	if(CT_Iterator == NULL) {
		kparamtype_t IteratorParam = {TY_Object};
		KDEFINE_CLASS defIterator = {0};
		SETSTRUCTNAME(defIterator, Iterator);
		defIterator.cflag  = CFLAG_Iterator;
		defIterator.init   = Iterator_Init;
		defIterator.cparamsize  = 1;
		defIterator.cParamItems = &IteratorParam;

		CT_Iterator = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defIterator, trace);
		CT_StringIterator = CT_p0(kctx, CT_Iterator, TY_String);
		CT_GenericIterator = CT_p0(kctx, CT_Iterator, TY_0);
	}

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Iterator_hasNext), TY_boolean, TY_Iterator, MN_("hasNext"), 0,
		_Public, _F(Iterator_next), TY_0, TY_Iterator, MN_("next"), 0,
		_Public, _F(Array_toIterator),  TY_GenericIterator, TY_Array, MN_("toIterator"), 0,
		_Public, _F(String_toIterator), TY_StringIterator, TY_String, MN_("toIterator"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
예제 #2
0
static	kbool_t exception_initPackage(KonohaContext *kctx, kNameSpace *ns, int argc, const char**args, kfileline_t pline)
{
	KonohaExceptionModule *mod = (KonohaExceptionModule*)KCALLOC(sizeof(KonohaExceptionModule), 1);
	mod->h.name     = "exception";
	mod->h.setup    = kModuleException_setup;
	mod->h.reftrace = kModuleException_reftrace;
	mod->h.free     = kModuleException_free;
	KLIB Konoha_setModule(kctx, MOD_exception, &mod->h, pline);
	KDEFINE_CLASS defException = {
		STRUCTNAME(Exception),
		.cflag = CFLAG_Exception,
		.init = Exception_init,
		.reftrace = Exception_reftrace,
		.p     = Exception_p,
	};
	mod->cException = KLIB Konoha_defineClass(kctx, ns->packageId, PN_konoha, NULL, &defException, pline);

	KDEFINE_METHOD MethodData[] = {
		_Public|_Hidden, _F(System_throw), TY_void,  TY_System, MN_("throw"), 1, TY_Exception, FN_("e"),
		_Public|_Hidden, _F(System_getThrownException), TY_Exception, TY_System, MN_("getThrownException"), 0,
		DEND,
	};
	KLIB kNameSpace_loadMethodData(kctx, ns, MethodData);
	return true;
}
예제 #3
0
static kbool_t bytes_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	//KImportPackageSymbol(ns, "cstyle", "$SingleQuotedChar", trace);
	if(KClass_Bytes == NULL) {
		KDEFINE_CLASS defBytes = {0};
		SETSTRUCTNAME(defBytes, Bytes);
		defBytes.cflag   = KClassFlag_Final;
		defBytes.free    = kBytes_Free;
		defBytes.init    = kBytes_Init;
		defBytes.format       = kBytes_format;
		KClass_Bytes = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defBytes, trace);
	}
	int FN_index = KFieldName_("index");
	int FN_c     = KFieldName_("c");
	int FN_size  = KFieldName_("size");
	KDEFINE_METHOD MethodData[] = {
		_Public,     _F(Bytes_new),     KType_Bytes,  KType_Bytes, KMethodName_("new"),     1, KType_Int, FN_size,
		_Public|_Im, _F(Bytes_getSize), KType_Int,    KType_Bytes, KMethodName_("getSize"), 0,
		_Public|_Im, _F(Bytes_get),     KType_Int,    KType_Bytes, KMethodName_("get"),     1, KType_Int, FN_index,
		_Public,     _F(Bytes_Set),     KType_void,   KType_Bytes, KMethodName_("set"),     2, KType_Int, FN_index, KType_Int, FN_c,
		_Public,     _F(Bytes_SetAll),  KType_void,   KType_Bytes, KMethodName_("setAll"),  1, KType_Int, FN_c,
		_Public|_Im|_Coercion, _F(String_toBytes), KType_Bytes, KType_String, KMethodName_To(KType_Bytes),   0,
		//_Public|_Im|_Coercion, _F(Bytes_toString), KType_String, KType_Bytes,  KMethodName_To(KType_String),  0,
		//_Public|_Const, _F(Bytes_encodeTo),   KType_Bytes,  KType_Bytes,  KMethodName_("encodeTo"),    1, KType_String, FN_encoding,
		//_Public|_Const, _F(Bytes_decodeFrom),   KType_String, KType_Bytes,  KMethodName_("decodeFrom"),    1, KType_String, FN_encoding,
		_Public, _F(String_new_fromBytes_withDefaultDecode),      KType_String, KType_String, KMethodName_("new"), 1, KType_Bytes, KFieldName_("ba"),
		_Public, _F(String_new_fromBytes_withSpecifiedDecode),    KType_String, KType_String, KMethodName_("new"), 2, KType_Bytes, KFieldName_("ba"), KType_String, KFieldName_("charset"),
		_Public, _F(String_new_fromSubBytes_withDefaultDecode),   KType_String, KType_String, KMethodName_("new"), 3, KType_Bytes, KFieldName_("ba"), KType_Int,    KFieldName_("offset"), KType_Int, KFieldName_("length"),
		_Public, _F(String_new_fromSubBytes_withSpecifiedDecode), KType_String, KType_String, KMethodName_("new"), 4, KType_Bytes, KFieldName_("ba"), KType_Int,    KFieldName_("offset"), KType_Int, KFieldName_("length"), KType_String, KFieldName_("charset"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
예제 #4
0
파일: gl_error.cpp 프로젝트: Kazade/KGLT
void check_and_log_error(const char *function_name) {
    GLuint error = glGetError();
    if(error != GL_NO_ERROR) {
        std::string error_string;
        switch(error) {
        case GL_INVALID_ENUM:
            error_string = "GL_INVALID_ENUM";
            break;
        case GL_INVALID_VALUE:
            error_string = "GL_INVALID_VALUE";
            break;
        case GL_INVALID_OPERATION:
            error_string = "GL_INVALID_OPERATION";
            break;
        case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
            error_string = "GL_INVALID_FRAMEBUFFER_OPERATION";
            break;
        case GL_OUT_OF_MEMORY:
            error_string = "GL_OUT_OF_MEMORY";
            break;
#ifndef __ANDROID__
        case GL_STACK_OVERFLOW:
            error_string = "GL_STACK_OVERFLOW";
            break;
        case GL_STACK_UNDERFLOW:
            error_string = "GL_STACK_UNDERFLOW";
            break;
#endif
        }

        L_ERROR(_F("An OpenGL error occurred: {0} - {1}").format(function_name, error_string));

        throw std::runtime_error(_F("GL ERROR: {0}").format(error_string));
    }
}
예제 #5
0
static kbool_t Libevent_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	/* Class Definition */
	KDEFINE_CLASS defLibevent = {0};
	SETSTRUCTNAME(defLibevent, Libevent);
	defLibevent.cflag     = KClassFlag_Final;
	defLibevent.init      = Libevent_Init;
	defLibevent.free      = Libevent_Free;
	KClass *LibeventClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defLibevent, trace);

	int KType_Libevent = LibeventClass->typeId;

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Libevent_new), KType_Libevent, KType_Libevent, KMethodName_("new"), 0,
		_Public, _F(Libevent_dispatch), KType_Libevent, KType_Libevent, KMethodName_("dispatch"), 0,
		_Public, _F(Libevent_event_add), KType_Int, KType_Libevent, KMethodName_("event_add"), 2, KType_Object, KFieldName_("timeval"),
		_Public, _F(Libevent_event_del), KType_Int, KType_Libevent, KMethodName_("event_del"), 1,



#ifdef	CUTCUT
		_Public, _F(Person_say), KType_String, KType_Person, KMethodName_("say"), 0,
#endif
		DEND, /* <= sentinel */
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	return true;
}
예제 #6
0
static kbool_t HelloWorld_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	/* Class Definition */
	/* If you want to create Generic class like Array<T>, see konoha.map package */
	KDEFINE_CLASS defPerson = {0};
	SETSTRUCTNAME(defPerson, Person);
	defPerson.cflag     = kClass_Final;
	defPerson.init      = Person_Init;
	defPerson.p         = Person_p;
	defPerson.reftrace  = Person_Reftrace;
	defPerson.free      = Person_Free;
	KonohaClass *PersonClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defPerson, trace);

	/* You can define methods with the following procedures. */
	int TY_Person = PersonClass->typeId;
	int FN_x = FN_("x");
	int FN_y = FN_("y");
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Person_new), TY_Person, TY_Person, MN_("new"), 2, TY_String, FN_x, TY_int, FN_y,
		_Public, _F(Person_say), TY_String, TY_Person, MN_("say"), 0,
		DEND, /* <= sentinel */
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	/* You can define constant variable with the following procedures. */
	KDEFINE_INT_CONST IntData[] = {
		{"NARUTO_AGE", TY_int, 18},
		{} /* <= sentinel */
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KonohaConst_(IntData), false/*isOverride*/, trace);
	return true;
}
예제 #7
0
static kbool_t konoha_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_CLASS defKonohaFactory = {0};
	SETSTRUCTNAME(defKonohaFactory, KonohaFactory);
	defKonohaFactory.init = kKonohaFactory_Init;
	defKonohaFactory.free = kKonohaFactory_Free;
	KDEFINE_CLASS defKonoha = {0};
	SETSTRUCTNAME(defKonoha, Konoha);
	defKonoha.init = kKonoha_Init;
	defKonoha.free = kKonoha_Free;

	KClass *cKonohaFactory = KLIB KClass_define(kctx, ns->packageId, NULL, &defKonohaFactory, trace);
	KClass *cKonoha =  KLIB KClass_define(kctx, ns->packageId, NULL, &defKonoha, trace);
	int KType_KonohaFactory = cKonohaFactory->typeId, KType_Konoha = cKonoha->typeId;

	KDEFINE_METHOD MethodData[] = {
		kMethod_Public, _F(KonohaFactory_new), KType_KonohaFactory, KType_KonohaFactory, KMethodName_("new"), 0,
		kMethod_Public, _F(KonohaFactory_loadModule), KType_Boolean, KType_KonohaFactory, KMethodName_("loadModule"), 1, KType_String, KFieldName_("name"),
		kMethod_Public, _F(KonohaFactory_create), KType_Konoha, KType_KonohaFactory, KMethodName_("create"), 0,
		kMethod_Public, _F(Konoha_loadScript), KType_Boolean, KType_Konoha, KMethodName_("loadScript"), 1, KType_String, KFieldName_("filename"),
		kMethod_Public, _F(Konoha_eval), KType_Konoha, KType_Konoha, KMethodName_("eval"), 1, KType_String, KFieldName_("script"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
예제 #8
0
PhysicsTest* RenderTestSelector(const GLFontRenderer& texter, float x, float text_scale, int start_index, float& y_last)
{
	int NbTests = GetNbTests();
	const int NbToGo = ICE_ARRAYSIZE(Alpha);
	float y = float(NbToGo) * text_scale;

	const float XOffset = 0.01f;
//	DrawRectangle(XOffset, 1.0f-XOffset, y + text_scale*2.0f, y - text_scale*9.0f, Point(1.0f, 0.5f, 0.2f), 0.5f);

	PhysicsTest* CandidateTest = null;

	for(int i=0;i<NbToGo;i++)
	{
		const float a = Alpha[i];
		const bool Selected = a==1.0f;
		if(Selected)
			texter.setColor(1.0f, 0.5f, 0.2f, a);
		else
			texter.setColor(1.0f, 1.0f, 1.0f, a);

		const int RealIndex = start_index % NbTests;

		PhysicsTest* Test = GetTest(RealIndex);
		if(Test)
		{
			static const char* CategoryText[] = 
			{
				"(undefined)",
				"(API)",
				"(behavior)",
				"(contact generation)",
				"(performance)",
				"(raycast)",
				"(sweep)",
				"(overlap)",
				"(CCD)",
				"(static scene)",
			};

			const TestCategory TC = Test->GetCategory();
			if(Test->IsPrivate())
			{
				texter.print(x+XOffset, y, text_scale, _F("%d: %s - %s (PRIVATE)", RealIndex, CategoryText[TC], Test->GetName()));
			}
			else
			{
				texter.print(x+XOffset, y, text_scale, _F("%d: %s - %s", RealIndex, CategoryText[TC], Test->GetName()));
			}
		}

		if(Selected)
			CandidateTest = Test;

		y -= text_scale;
		start_index++;
	}
	y_last = y;
	return CandidateTest;
}
예제 #9
0
void ProcessRepXFile_RemoveDynamics(const char* filename)
{
	ASSERT(filename);

	if(!_ProcessRepXFile_RemoveDynamics(_F("../build/%s", filename)))
		if(!_ProcessRepXFile_RemoveDynamics(_F("./%s", filename)))
			printf(_F("Failed to load '%s'\n", filename));
}
예제 #10
0
static void class_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Ignored, _F(NameSpace_AllowImplicitField), KType_void, KType_NameSpace, KMethodName_("AllowImplicitField"), 1, KType_Boolean, KFieldName_("allow"),
		_Public|_Const, _F(NameSpace_AddMethodDecl), KType_void, KType_NameSpace, KMethodName_("AddMethodDecl"), 1, KType_Node, KFieldName_("node"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #11
0
static void Syntax_defineMessageMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Node_Message), KType_Node, KType_Node, KMethodName_("Message"), 2, TP_level, TP_message,
		_Public, _F(NodeToken_Message), KType_Node, KType_Node, KMethodName_("Message"), 3, TP_level, TP_token, TP_message,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #12
0
파일: Font.cpp 프로젝트: doorxp/seed
BOOL Font::Load(const char *filename, ResourceManager *res, IMemoryPool *pool)
{
	ASSERT_NULL(filename);
	ASSERT_NULL(res);
	ASSERT_NULL(pool);

	if (this->Unload())
	{
		this->pFilename = filename;
		this->pRes = res;
		this->pPool = pool;

		stFile.Close();
		SECURITY_CHECK(pFileSystem->Open(filename, &stFile, pool), "Could not open font file.");
		const u8 *ptr = static_cast<const u8 *>(stFile.GetData());
		ObjectHeader *block = NULL;
		READ_STRUCT(block, ObjectHeader, ptr);
		SECURITY_CHECK(seed_validate_block(&stFile, block, FONT_OBJECT_MAGIC, FONT_OBJECT_VERSION), "Invalid block header for font.");

		READ_F32(this->fTracking, ptr);
		READ_F32(this->fSpacing, ptr);
		READ_F32(this->fSpaceWidth, ptr);

	/*
		const char *file = NULL;
		READ_STR(file, ptr);
		ASSERT_NULL(file);

		const char *ext = NULL;
		READ_STR(ext, ptr);
	*/
		u32 file = 0;
		READ_U32(file, ptr);

		u32 ext = 0;
		READ_U32(ext, ptr);

		if (ext != SEED_INVALID_ID /*&& pSystem->GetLanguage() != Seed::en_US*/)
		{
			File extf;
			if (pFileSystem->Open(_F(ext), &extf, pool))
			{
				extf.Close();
				this->mFontExt.Load(_F(ext), res, pool);
				this->pGlyphs = pDictionary->GetGlyphTable(&this->iTotalGlyphs);
			}
		}

		this->mFont.Load(_F(file), res, pool);
		this->fHeight	= mFont.GetHeight();
		this->fWidth	= mFont.GetWidth();

		this->bLoaded	= TRUE;
	}

	return bLoaded;
}
예제 #13
0
static void sugar_defineTokenFunc(KonohaContext *kctx, kNameSpace *ns, int TY_Symbol, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(String_AsciiAt), TY_int, TY_String, MN_("AsciiAt"), 1, TP_pos,
		_Public, _F(Token_Parse), TY_int, TY_Token, MN_("parse"), 4, TP_kw, TP_source, TP_begin, TP_end,
		_Public, _F(Token_error), TY_int, TY_Token, MN_("error"), 4, TP_message, TP_source, TP_begin, TP_end,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #14
0
static void sugar_defineMessageMethod(KonohaContext *kctx, kNameSpace *ns, int TY_Symbol, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Stmt_Message), TY_Expr, TY_Stmt, MN_("message"), 2, TP_level, TP_message,
		_Public, _F(StmtToken_Message), TY_Expr, TY_Stmt, MN_("message"), 3, TP_level, TP_token, TP_message,
		_Public, _F(StmtExpr_Message), TY_Expr, TY_Stmt, MN_("message"), 3, TP_level, TP_expr, TP_message,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #15
0
static void object_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Im|_Const|_Final, _F(Object_getTypeId), TY_int, TY_Object, MN_("getTypeId"), 0,
		_Public|_Hidden|_Im|_Const, _F(Object_instanceOf), TY_boolean, TY_Object, MN_("<:"), 1, TY_Object, FN_("type"),
		_Public|_Hidden|_Im|_Const|kMethod_SmartReturn, _F(Object_as), TY_Object, TY_Object, MN_("as"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #16
0
static void namespace_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Im, _F(NameSpace_GetNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetNameSpace"), 0,
		_Public|_Const|_Im, _F(NameSpace_GetParentNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetParentNameSpace"), 0,
		_Public, _F(NameSpace_DefineMacro2), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 2, TP_name, TP_source,
		_Public, _F(NameSpace_DefineMacro), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 3, TP_name, TP_paramsize, TP_source,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #17
0
static void prototype_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	int FN_key = KFieldName_("key"), FN_value = KFieldName_("value");
	KDEFINE_METHOD MethodData[] = {
		_Public|_Im|_Const|kMethod_SmartReturn|_Final, _F(Prototype_get), KType_Object, KType_Prototype, KMethodName_("get"), 1, KType_Symbol, FN_key,
		_Public|_Final, _F(Prototype_SetObject), KType_void, KType_Prototype, KMethodName_("set"), 2, KType_Symbol, FN_key, KType_Object, FN_value,
		_Public|_Final, _F(Prototype_SetInt), KType_void, KType_Prototype, KMethodName_("set"), 2, KType_Symbol, FN_key, KType_Int, FN_value,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
void ToolPageLayer::setLayerCount(int layer, int selected)
{
	XOJ_CHECK_TYPE(ToolPageLayer);

	this->inCbUpdate = true;

	int count = gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(this->layerComboBox)), NULL);

	for (int i = count - 1; i >= 0; i--)
	{
		gtk_combo_box_remove_text(GTK_COMBO_BOX(this->layerComboBox), i);
	}

	gtk_combo_box_append_text(GTK_COMBO_BOX(this->layerComboBox), _C("Background"));
	for (int i = 1; i <= layer; i++)
	{
		string text = FS(_F("Layer {1}") % i);
		gtk_combo_box_prepend_text(GTK_COMBO_BOX(this->layerComboBox), text.c_str());
	}

	setSelectedLayer(selected);

	this->layerCount = layer;
	this->inCbUpdate = false;
}
예제 #19
0
std::string U2L(const std::string& string)
{
	std::string locale_charset;

	if(!Glib::get_charset(locale_charset))
	{
		try
		{
			return Glib::convert_with_fallback(string, locale_charset, MLIB_UTF_CHARSET_NAME);
		}
		catch(Glib::ConvertError&)
		{
			std::string broken_string;

			for(size_t i = 0; i < string.size(); i++)
			{
				if(::isprint(string[i]))
					broken_string += string[i];
				else
					broken_string += "%" + _F(std::hex, std::uppercase, (int) (unsigned char) string[i]);
			}

			return broken_string + " " + _("[[Invalid encoding]]");
		}
	}
	else
		return string;
}
예제 #20
0
void Get_feed_list::process_current_state(void)
{
	MLIB_D("Getting Google Reader's %1 list...", this->state_list_name());

	#if GROV_OFFLINE_DEVELOPMENT
		QFile list(this->state_list_name() + ".list");

		if(list.open(QIODevice::ReadOnly))
			this->request_finished(NULL, "", list.readAll());
		else
			this->request_finished(NULL, _F("Error while reading '%1'.", list.fileName()), "");
	#else
		QString url;

		switch(this->state)
		{
			case STATE_GETTING_TAG_LIST:
			case STATE_GETTING_STREAM_PREFERENCE_LIST:
			case STATE_GETTING_SUBSCRIPTION_LIST:
				url = "https://www.google.com/reader/api/0/" + this->state_list_name() + "/list";
				break;

			default:
				this->failed(tr("Logical error."));
				return;
				break;
		}

		this->get( url + "?output=xml&client=" + QUrl::toPercentEncoding(get_user_agent()) );
	#endif
}
double model::deltaF(const char METHOD, const char FUNCTION, const double XK_1, const double XK, double EPS){

    double ans;

    switch(METHOD){
    case 'n':
        {
            double denominator = _F(FUNCTION, XK);

            if(fabs(denominator) <= EPS)
                ans = 0.00001;
            else
                ans = F(FUNCTION, XK) / denominator;

            break;
        }

    case 's':
        {
            double denominator = F(FUNCTION, XK) - F(FUNCTION, XK_1);

            if(fabs(denominator) <= EPS)
                ans = 0.00001;
            else
                ans = ( (XK - XK_1) * F(FUNCTION, XK) ) / denominator;

            break;
        }
    }

    return ans;
}
예제 #22
0
파일: abnf.cpp 프로젝트: semenovf/cwt-abnf
static bool begin_rule(const String & rulename, bool incremental, void *userContext)
{
	AbnfContext *ctx = __CAST_USER_CTX(userContext);

	if (incremental) {
		AbnfRulesHash::iterator it = ctx->rules.find(rulename);
		if (it == ctx->rules.end()) { // rule for incremental alternative not initialized before
			Logger::error(_Fr("%s: rule for incremental alternative not initialized before") % rulename);
			return false;
		}
		ctx->nodestack.push(it.value());
		AbnfNode *alt = it.value()->m_nodes.first();
		CWT_ASSERT(alt);
		ctx->nodestack.push(alt);
		ctx->isIncrementalAlternation = true;
	} else {
		AbnfNodeRule *rule = new AbnfNodeRule(rulename);
		ctx->rules.insert(rulename, rule);
		ctx->nodestack.push(rule);

		AbnfRulesDefsHash::iterator it = ctx->rulesdefs.find(rulename);

		if (it != ctx->rulesdefs.end()) {
			it.value() = true;
		} else {
			ctx->rulesdefs.insert(rulename, false);
		}
	}

	std::cout << String(_F("RN{%s}%s") % rulename % (incremental ? "=/" : "="));
	return true;
}
예제 #23
0
파일: loader.cpp 프로젝트: Kazade/KGLT
void BaseTextureLoader::into(Loadable& resource, const LoaderOptions& options) {
    Loadable* res_ptr = &resource;
    Texture* tex = dynamic_cast<Texture*>(res_ptr);
    assert(tex && "You passed a Resource that is not a texture to the texture loader");

    std::vector<unsigned char> buffer(
        (std::istreambuf_iterator<char>(*this->data_)),
        std::istreambuf_iterator<char>()
    );

    auto result = do_load(buffer);

    /* Respect the auto_upload option if it exists*/
    bool auto_upload = true;
    if(options.count("auto_upload")) {
        auto_upload = smlt::any_cast<bool>(options.at("auto_upload"));
    }

    if (result.data.empty()) {
        L_ERROR(_F("Unable to load texture with name: {0}").format(filename_));
        throw std::runtime_error("Couldn't load the file: " + filename_.encode());
    } else {
        tex->set_source(filename_);
        tex->set_format(result.format, result.texel_type);
        tex->resize(result.width, result.height);
        tex->data().assign(result.data.begin(), result.data.end());
        tex->set_auto_upload(auto_upload);

        if(format_stored_upside_down()) {
            tex->flip_vertically();
        }
    }
}
예제 #24
0
void WINAPI GetOpenPanelInfoW(struct OpenPanelInfo *Info)
{
	
	if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel)
		return;

	fardroid * android = (fardroid *)Info->hPanel;
	Info->StructSize=sizeof(*Info);
	Info->Flags = OPIF_ADDDOTS | OPIF_SHOWPRESERVECASE;

	Info->StartSortMode = (OPENPANELINFO_SORTMODES)	conf.SortMode;
	Info->StartSortOrder = conf.SortOrder;

	Info->CurDir = NULL;
	Info->Format= GetMsg(MTitle);

	android->PreparePanel(Info);

	Info->DescrFiles=NULL;
	Info->DescrFilesNumber=0;

	Info->StartPanelMode = _F('0')+conf.PanelMode;
	Info->PanelModesArray=NULL;
	Info->PanelModesNumber=0;

	Info->KeyBar=&KeyBar;
}
예제 #25
0
파일: abnf.cpp 프로젝트: semenovf/cwt-abnf
static bool begin_repetition(int from, int to, void * userContext)
{
	std::cout << String(_F("{%d*%d") % from % to);
	AbnfContext *ctx = __CAST_USER_CTX(userContext);
	ctx->nodestack.push(new AbnfNodeRpt(from, to));
	return true;
}
예제 #26
0
  inline double Normalize(int N, _F *X, int INCX) {

    double norm = TwoNorm<double>(N,X,INCX);
    Scale(N,_F(1.)/norm,X,INCX);

    return norm;

  }
예제 #27
0
파일: abnf.cpp 프로젝트: semenovf/cwt-abnf
static bool prose_val(const String & prose, void * userContext)
{
	std::cout << String(_F("PV{%s}") % prose);
	AbnfContext *ctx = __CAST_USER_CTX(userContext);
	CWT_ASSERT(ctx->nodestack.size() > 0);
	ctx->nodestack.top()->addNode(new AbnfNodeProseVal(prose));
	return true;
}
예제 #28
0
static void class_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Ignored, _F(NameSpace_AllowImplicitField), TY_void, TY_NameSpace, MN_("AllowImplicitField"), 1, TY_boolean, FN_("allow"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
예제 #29
0
bool Web_page::shouldInterruptJavaScript(void)
{
	MLIB_SW(_F(
		tr("A JavaScript program at '%1' is running for a long period of time. Interrupting it."),
		this->mainFrame()->url().toString()
	));
	return true;
}
예제 #30
0
파일: abnf.cpp 프로젝트: semenovf/cwt-abnf
static bool num_val(const String & num, void * userContext)
{
	std::cout << String(_F("NV{%s}") % num);
	AbnfContext *ctx = __CAST_USER_CTX(userContext);
	CWT_ASSERT(ctx->nodestack.size() > 0);
	ctx->nodestack.top()->addNode(new AbnfNodeNumVal(num));
	return true;
}