Skip to content

Instantly share code, notes, and snippets.

View andr1972's full-sized avatar

Andrzej Borucki andr1972

View GitHub Profile
@andr1972
andr1972 / gist:6462783
Last active December 22, 2015 10:59
demopkg.ComplexStruct
package demopkg;
public class ComplexStruct {
int fieldI;
byte[] arr;
String str;
ComplexStruct prior;
}
@andr1972
andr1972 / gist:6473673
Last active December 22, 2015 12:39
demopkg.ICallback
package demopkg;
public interface ICallback {
void onPercent(int percent);
void onPercentEx(ComplexStruct cs);
}
@andr1972
andr1972 / gist:6473741
Created September 7, 2013 07:56
demopkg.Process
package demopkg;
public class Process {
native void nativeLongOperation(ICallback callback);
}
@andr1972
andr1972 / gist:6473763
Last active December 22, 2015 12:39
demopkg.JNIdemo#main
public static void main(String[] args) {
Process process = new Process();
process.nativeLongOperation(new CallbackImpl());
}
@andr1972
andr1972 / gist:6473786
Created September 7, 2013 08:06
Process.cpp
#include <jni.h>
#include "demopkg_Process.h"
JNIEXPORT void JNICALL Java_demopkg_Process_nativeLongOperation
(JNIEnv *env, jobject owner, jobject param1)
{
jclass clsICallback = env->GetObjectClass(param1);
jmethodID method1 = env->GetMethodID(clsICallback, "onPercent", "(I)V");
jmethodID method2 = env->GetMethodID(clsICallback, "onPercentEx", "(Ldemopkg/ComplexStruct;)V");
jclass clsComplexStruct = env->FindClass("demopkg/ComplexStruct");
#include "StdAfx.h"
#include "Common/MyInitGuid.h"
#include "SevenZipJBinding.h"
#include "JNITools.h"
#include "net_sf_sevenzipjbinding_SevenZip.h"
#include "CPPToJava/CPPToJavaInStream.h"
@andr1972
andr1972 / XCB timer
Last active March 20, 2021 09:01
XCB loop and timer event
CodeBlocks config:
Build options->Linker settings: rt xcb
Properties->Build targets: GUI application
@andr1972
andr1972 / xcb-no-decoration.cpp
Last active March 17, 2019 10:44
XCB library - show window without decoration
//http://stackoverflow.com/questions/5134297/xlib-how-does-this-removing-window-decoration-work
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <inttypes.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
//xcb_event.h
@andr1972
andr1972 / setup.h
Last active December 2, 2015 23:16
Setup information from X11 protocol
#pragma once
typedef uint64_t CARD64;
typedef uint32_t CARD32;
typedef uint16_t CARD16;
typedef unsigned char CARD8;
typedef CARD8 BYTE;
typedef CARD8 BOOL;
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <exception>
#include <assert.h>
#include "yAllocator.h"
#define min(a,b) a<b?a:b
#define BITSIZE(a) (sizeof(a)*8)
#define ISBITSET(x,k) (x & (1<<k))