티스토리 툴바


"native 메소드 이름은 대문자로 시작한다."  이것은 개인적인 규칙으로 자주 사용하지 않기에 잊어먹는 것을 방지하기 위해서 나를 위해서 쓰는 포스트입니다.

[소스 1]
	static {
		System.loadLibrary("libFrameBuffer");	
	}
	
	private static native int CreateObject();
	private static native int ReleaseObject(int handle);
	
	private static native void Clear(int handle);
	private static native void AddPackage(int handle, int framePackage);
	
	private static native int GetFrame(int handle);
	private static native void FreeFrame(int frame);

	private static native void SkipFrame(int handle);

	private static native boolean GetIsEmpty(int handle);
	private static native int GetPositon(int handle);
	
	
	private int _Handle = CreateObject();
	
	protected void finalize() throws Throwable {
		ReleaseObject(_Handle);
		
		super.finalize(); 
	}
	
	public void clear() {
		Clear(_Handle);
	}
[소스 1]은 델파이를 통해서 만들어진 클래스를 안드로이드로 포팅하기 위해서 C로 함수별로 클래스의 메소드를 구현하고, 이것을 다시 자바의 클래스로 래핑하는 과정에서 나온 소스입니다.

08: 라인과 28: 라인의 메소드 이름을 같게 할 수 없기 때문에 한 쪽에는 이름이 달라야 합니다.  이를 위해서 native 메소드는 대문자로 시작하면서 구별하고 있습니다.  특수 문자 또는 "jni" 등의 접두사를 붙일까 고민했었지만, 개인적으로 마음에 들지 않아서 위와 같이 결정하였습니다.


 
저작자 표시 비영리 변경 금지
Posted by 류종택