/**
 * Copyright (C) 2009 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Mobile Communication Division,
 * Digital Media & Communications Business, Samsung Electronics Co., Ltd.
 *
 * This software and its documentation are confidential and proprietary
 * information of Samsung Electronics Co., Ltd.  No part of the software and
 * documents may be copied, reproduced, transmitted, translated, or reduced to
 * any electronic medium or machine-readable form without the prior written
 * consent of Samsung Electronics.
 *
 * Samsung Electronics makes no representations with respect to the contents,
 * and assumes no responsibility for any errors that might appear in the
 * software and documents. This publication and the contents hereof are subject
 * to change without notice.
 */

#include "et9hangulUtil.h"
#include "et9imuUtil.h"

#ifdef ET9_KOREAN_MODULE
/*----------------------------------------------------------------------------
 * External Variables
 *----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
 * Global Variables
 *----------------------------------------------------------------------------*/
ET9KLingInfo           g_KLingInfo;
ET9KHangulWord         g_KHangulWord;

/*----------------------------------------------------------------------------
 * Callback Functions
 *----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
 * Get Functions
 *----------------------------------------------------------------------------*/
ET9STATUS ET9FARCALL ET9K_GetHangulWord(JNIEnv *env, jclass jcls, ET9KHangulWord *hangulWord, jobject jobj)
{
	jclass cls;

	if(env == NULL || hangulWord == NULL)
		return ET9STATUS_INVALID_MEMORY;

	cls = (*env)->GetObjectClass(env, jobj);

	hangulWord->wLen      = (*env)->GetShortField(env, jobj, (*env)->GetFieldID(env, cls, "wLen",      "S"));
	hangulWord->wComplete = (*env)->GetShortField(env, jobj, (*env)->GetFieldID(env, cls, "wComplete", "S"));

	GetShortObjectArray(env, jcls, hangulWord->sString,
		(*env)->GetObjectField(env, jobj, (*env)->GetFieldID(env, cls, "sString",     "[S")), ET9MAXWORDSIZE);

	GetShortObjectArray(env, jcls, hangulWord->sJamoCounts,
		(*env)->GetObjectField(env, jobj, (*env)->GetFieldID(env, cls, "pSymbCounts", "[S")), ET9MAXWORDSIZE);

	return ET9STATUS_NONE;
}

/*----------------------------------------------------------------------------
 * Set Functions
 *----------------------------------------------------------------------------*/
ET9STATUS ET9FARCALL ET9K_SetHangulWord(JNIEnv *env, jclass jcls, jobject *jobj, ET9KHangulWord hangulWord)
{
	jclass cls;

	if(env == NULL || jobj == NULL)
		return ET9STATUS_INVALID_MEMORY;

	cls = (*env)->GetObjectClass(env, *jobj);

	(*env)->SetShortField(env, *jobj, (*env)->GetFieldID(env, cls, "wLen",      "S"), hangulWord.wLen);
	(*env)->SetShortField(env, *jobj, (*env)->GetFieldID(env, cls, "wComplete", "S"), hangulWord.wComplete);

	SetShortObjectArray(env, jcls, 
		(*env)->GetObjectField(env, *jobj, (*env)->GetFieldID(env, cls, "sString",     "[S")), hangulWord.sString, ET9MAXWORDSIZE);

	SetShortObjectArray(env, jcls, 
		(*env)->GetObjectField(env, *jobj, (*env)->GetFieldID(env, cls, "pSymbCounts", "[S")), hangulWord.sJamoCounts, ET9MAXWORDSIZE);

	return ET9STATUS_NONE;
}

#endif // ET9_KOREAN_MODULE
