Пример #1
0
ThinConsole& ThinConsole::WriteToConsole(string_type const& outputString, console_location_type const& location, console_color_type const& foreground, console_color_type const& background) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	std::vector<console_attribute_type> outputAttributes(outputString.size(), foregroundColorMap[foreground] | backgroundColorMap[background]);
	console_information_type charsWritten;
	ExceptionCheck(WriteConsoleOutputCharacter(outputHandle, std::wstring(outputString.begin(), outputString.end()).c_str(), outputString.size(), location, &charsWritten), __FUNCTION__, __LINE__);
	ExceptionCheck(WriteConsoleOutputAttribute(outputHandle, outputAttributes.data(), outputAttributes.size(), location, &charsWritten), __FUNCTION__, __LINE__);
	return *this;
}
Пример #2
0
ThinConsole& ThinConsole::SetBufferSize(console_length_type const& columns, console_length_type const& rows) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	console_location_type bufferSize;
	bufferSize.X = columns;
	bufferSize.Y = rows;
	ExceptionCheck(SetConsoleScreenBufferSize(outputHandle, bufferSize), __FUNCTION__, __LINE__);
	return *this;
}
Пример #3
0
ThinConsole::input_events ThinConsole::GetInputEvents(size_t const& numToCapture) {
	assert(inputHandle != NULL && "Input Handle Not Initialized");
	input_events capturedEvents(numToCapture);
	console_information_type eventsCaptured;
	ExceptionCheck(ReadConsoleInput(inputHandle, capturedEvents.data(), static_cast<console_information_type>(capturedEvents.size()), &eventsCaptured), __FUNCTION__, __LINE__);
	capturedEvents.resize(eventsCaptured);
	return capturedEvents;
}
Пример #4
0
ThinConsole& ThinConsole::SetWindowSize(console_length_type const& columns, console_length_type const& rows) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	console_window_type window{ 0 };
	window.Right = columns;
	window.Bottom = rows;
	ExceptionCheck(SetConsoleWindowInfo(outputHandle, true, &window), __FUNCTION__, __LINE__);
	return *this;
}
Пример #5
0
ThinConsole& ThinConsole::SetupCursorInfo(BOOL const& isVisible, console_information_type const& cursorSize) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	console_cursor_type cursor;
	cursor.bVisible = isVisible;
	cursor.dwSize = cursorSize;
	ExceptionCheck(SetConsoleCursorInfo(outputHandle, &cursor), __FUNCTION__, __LINE__);
	return *this;
}
Пример #6
0
void generateJavaLangClassInstances() {
	// Allocate Class[] containing only those classes that are referenced:
	javaLangClassArray = NewObjectArray((jint) numberOfAllClassInstanceInfo,
			CLASS_ID_java_lang_Class, NULL);

	if (javaLangClassArray != NULL) {
		// Don't GC our array of classes:
		heapProtect(javaLangClassArray, TRUE);

		int i;
		for (i = 0; i < numberOfAllClassInstanceInfo; i++) {
			// Simulate: Class cl  = new Class();
			// TODO NewObject !!!
			// TODO Lazy load?
			u2 size;
			getClassSize(CLASS_ID_java_lang_Class, &size);
			jobject jc = heapAllocObjectByStackableSize(size, CLASS_ID_java_lang_Class);
			SetIntField(jc, LINK_ID_java_lang_Class_aClassId_I, i);
			if (ExceptionCheck()) {
				break;
			}

			SetObjectArrayElement(javaLangClassArray, i, jc);
			if (ExceptionCheck()) {
				break;
			}
		}

		// Set the aAllClasses in java.lang.Class:
		jclass classInstance = getJavaLangClass(CLASS_ID_java_lang_Class);
		SetStaticObjectField(classInstance, LINK_ID_java_lang_Class_aAllClasses__Ljava_lang_Class_,
				javaLangClassArray);

		// No need of protection:
		heapProtect(javaLangClassArray, FALSE);
	}
	// consout("class init done\n");

}
Пример #7
0
void JniFirebase::SetJson(const char *value) {
    auto env = getEnv();
    
    if (s_objectMapperInstance == NULL) {
        lock<std::mutex> lock(s_objectMapperLock);
        if (s_objectMapperInstance == NULL) {
            if (!GetClass(env, "java/util/HashMap", &s_objectClass)) {
                return;
            }

            if (!GetClass(env, s_objectMapperClassName, &s_objectMapperClass)) {
                return;
            }

            jmethodID ctor = NULL;
            if (!GetMethod(env, s_objectMapperClass, "<init>", "()V", &ctor))
            {
                return;
            }

            if (!GetMethod(env, s_objectMapperClass, s_objectMapperReadValueName, s_objectMapperReadValueSig, &s_objectMapperReadValue)) {
                return;
            }

            JOBJECT localRef = JOBJECT(env, env->NewObject(s_objectMapperClass, ctor));
            s_objectMapperInstance = env->NewGlobalRef(localRef);
        }
    }
    
    JOBJECT localValue = JOBJECT(env,
                                env->CallObjectMethod(s_objectMapperInstance, s_objectMapperReadValue,
                                                      (jstring)JSTRING(env, env->NewStringUTF(value)), s_objectClass));

    if (env->ExceptionCheck() == JNI_TRUE) {
        SetString(GetJNIExceptionDescription(env, env->ExceptionOccurred()));
        return;
    }
    
    if (!GetMethod(env, s_firebaseClass, s_firebaseSetValueName, s_firebaseSetValueSig, &s_firebaseSetValue)) {
        return;
    }
    
    env->CallVoidMethod(m_firebase, s_firebaseSetValue, (jobject)localValue);
}
Пример #8
0
jobject JPJavaEnv::NewObject(jclass a0, jmethodID a1)
{     jobject res;
    JNIEnv* env = getJNIEnv();
    void* _save = JPEnv::getHost()->gotoExternal();

	res = env->functions->AllocObject(env, a0);
	JAVA_CHECK("NewObject");

	env->functions->CallVoidMethod(env, res, a1);

	if (ExceptionCheck())
	{
		DeleteLocalRef(res);
	}

    JPEnv::getHost()->returnExternal(_save);
    JAVA_CHECK("NewObject");
    return res;
}
Пример #9
0
ThinConsole& ThinConsole::SetInputTypes(console_information_type const& consoleMode) {
	assert(inputHandle != NULL && "Input Handle Not Initialized");
	ExceptionCheck(SetConsoleMode(inputHandle, consoleMode), __FUNCTION__, __LINE__);
	return *this;
}
Пример #10
0
ThinConsole::list_buffer_data ThinConsole::GetBufferData(console_buffer_type const& buffer, console_window_type& window, console_location_type const& coords) const {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	list_buffer_data bufferData(buffer.dwSize.X * buffer.dwSize.Y);
	ExceptionCheck(ReadConsoleOutput(outputHandle, bufferData.data(), buffer.dwSize, { 0 }, &window), __FUNCTION__, __LINE__);
	return std::move(bufferData);
}
Пример #11
0
void ThinConsole::SetWindowInformation(console_window_type const& window) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	ExceptionCheck(SetConsoleWindowInfo(outputHandle, TRUE, &window), __FUNCTION__, __LINE__);
}
Пример #12
0
ThinConsole::console_information_type ThinConsole::GetConsoleInputType() const {
	assert(inputHandle != NULL && "Input Handle Not Initialized");
	console_information_type consoleMode;
	ExceptionCheck(GetConsoleMode(inputHandle, &consoleMode), __FUNCTION__, __LINE__);
	return consoleMode;
}
Пример #13
0
ThinConsole::string_type ThinConsole::GetWindowTitle() const {
	wchar_t charArray[25];
	ExceptionCheck(GetConsoleTitle(charArray, 25), __FUNCTION__, __LINE__);
	return string_type(charArray);
}
Пример #14
0
ThinConsole::console_buffer_type ThinConsole::GetConsoleBuffer() const {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	console_buffer_type oldBuffer;
	ExceptionCheck(GetConsoleScreenBufferInfo(outputHandle, &oldBuffer), __FUNCTION__, __LINE__);
	return oldBuffer;
}
Пример #15
0
ThinConsole::console_cursor_type ThinConsole::GetConsoleCursor() const {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	console_cursor_type oldCursor;
	ExceptionCheck(GetConsoleCursorInfo(outputHandle, &oldCursor), __FUNCTION__, __LINE__);
	return oldCursor;
}
Пример #16
0
void ThinConsole::SetWindowTitle(string_type const& title) {
	ExceptionCheck(SetConsoleTitle(title.c_str()), __FUNCTION__, __LINE__);
}
Пример #17
0
void ThinConsole::SetCursorPosition(console_location_type const& cursorLocation) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	ExceptionCheck(SetConsoleCursorPosition(outputHandle, cursorLocation), __FUNCTION__, __LINE__);
}
Пример #18
0
void ThinConsole::SetBufferData(list_buffer_data const& bufferData, console_location_type const& windowSize, console_window_type window, console_location_type const& coords) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	ExceptionCheck(WriteConsoleOutput(outputHandle, bufferData.data(), windowSize, coords, &window), __FUNCTION__, __LINE__);
}
Пример #19
0
ThinConsole& ThinConsole::SetCtrlHandler() {
	ExceptionCheck(SetConsoleCtrlHandler((PHANDLER_ROUTINE)(CtrlHandler), TRUE), __FUNCTION__, __LINE__);
	return *this;
}
Пример #20
0
ThinConsole::~ThinConsole() {
	ExceptionCheck(CloseHandle(inputHandle), __FUNCTION__ ,__LINE__);
	ExceptionCheck(CloseHandle(outputHandle), __FUNCTION__ ,__LINE__);
}
Пример #21
0
void deprecated_generateJavaLangClassInstances() {
	int i;
	int j;
	int arrayLength = 0;

	// Calculate the length of the Class[] to generate:
	for (i = 0; i < numberOfAllClassReferences; i++) {
		// The candidate for java.lang.Class generation:
		u2 classId = allClassReferences[i].targetClassId;

		// Verify that it hasn't been generated before:
		BOOL found = FALSE;
		for (j = 0; j < i - 1 && !found; j++) {
			found = allClassReferences[j].targetClassId == classId;
		}

		if (!found) {
			arrayLength++;
		}
	}

	consoutli("arrayLength: %d\n", arrayLength);
	// Allocate Class[] containing only those classes that are referenced:
	javaLangClassArray = NewObjectArray((jint) arrayLength, CLASS_ID_java_lang_Class, NULL);

	if (javaLangClassArray != NULL) {
		// Don't GC our array of classes:
		heapProtect(javaLangClassArray, TRUE);

		int arrayIndex = 0;
		u2 aClassIdLinkId = LINK_ID_java_lang_Class_aClassId_I;

		jclass classInstance = NULL;

		for (i = 0; i < numberOfAllClassReferences; i++) {
			// The candidate for java.lang.Class generation:
			u2 classId = allClassReferences[i].targetClassId;

			// Verify that it hasn't been generated before:
			BOOL found = FALSE;
			for (j = 0; j < i - 1 && !found; j++) {
				found = allClassReferences[j].targetClassId == classId;
			}

			if (!found) {
				// The class instance does not exist yet:
				// Simulate: Class cl  = new Class();
				u2 size;
				getClassSize(CLASS_ID_java_lang_Class, &size);
				jobject jc = heapAllocObjectByStackableSize(size, CLASS_ID_java_lang_Class);
				SetIntField(jc, aClassIdLinkId, classId);
				if (ExceptionCheck()) {
					break;
				}

				consoutli("class id: %d\n", classId);
				if (classId == CLASS_ID_java_lang_Class) {
					classInstance = jc;
					consoutli("class: \n");
				}
				SetObjectArrayElement(javaLangClassArray, arrayIndex, jc);
				arrayIndex++;
			}
		}

		// Set the aAllClasses in java.lang.Class:
		SetStaticObjectField(classInstance, LINK_ID_java_lang_Class_aAllClasses__Ljava_lang_Class_,
				javaLangClassArray);
	}
	// consout("class init done\n");
}
Пример #22
0
void ThinConsole::SetConsoleCursor(ThinConsole::console_cursor_type const& cursor) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	ExceptionCheck(SetConsoleCursorInfo(outputHandle, &cursor), __FUNCTION__, __LINE__);
}