⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m3gtrianglestriparray.c

📁 java 1.1 gemini 08_16
💻 C
字号:
/*****************************************************************************
 *
 * Filename:
 * ---------
 *  TriangleStripArray.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
 
/*************************************************************************
 * Include Header Files
 *************************************************************************/
#include "m3g.h"

#ifdef SUPPORT_JSR_184
/*************************************************************************
 * Function Definition
 *************************************************************************/
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_TriangleStripArray_createExplicit()
{
	st_m3g_trianglestriparray* handle = NULL;
	int i, sum = 0;

	KNI_StartHandles(2);
	KNI_DeclareHandle(index_handle);
	KNI_DeclareHandle(strips_handle);
	KNI_GetParameterAsObject(1, index_handle);
	KNI_GetParameterAsObject(2, strips_handle);

#if FAST_KNI && defined(CLDCHI)
	if(*index_handle==NULL || *strips_handle==NULL) {
		KNI_ThrowNew("java/lang/NullPointerException", "NULL target");	
	} else {
		jint_array* indices = (jint_array*)*index_handle;
		jint_array* strip_lengths = (jint_array*)*strips_handle;

		if(strip_lengths->length == 0) {
			KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid param");	
		} else {

			for(i=0; i<strip_lengths->length; i++) {
				if(strip_lengths->elements[i] < 3) {
					KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid param");	
					goto _return;
				}
				sum += strip_lengths->elements[i];
			}

			if(indices->length < sum) {
				KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid param");	
				goto _return;
			}

			for(i=0; i<indices->length; i++) {
				if(indices->elements[i]<0 || indices->elements[i]>65535) {
					KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid param");	
					goto _return;
				}
			}

			ENTER_M3D_CS;
			handle = M3G_TriangleStripArray_new_explicit(indices->elements, indices->length, 
											(kal_uint32*)strip_lengths, strip_lengths->length);
			LEAVE_M3D_CS;											
		}
	}
#else
	ASSERT(0);
#endif /* FAST_KNI */

_return:
	KNI_EndHandles();
	KNI_ReturnInt((jint)handle);
}	

KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_TriangleStripArray_createImplicit()
{
	jint first_index = KNI_GetParameterAsInt(1);
	st_m3g_trianglestriparray* handle = NULL;
	int i, sum = 0;

	if(first_index < 0) {
		KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid first");	
		KNI_ReturnInt((jint)handle);
	}

	KNI_StartHandles(1);
	KNI_DeclareHandle(strips_handle);
	KNI_GetParameterAsObject(2, strips_handle);

#if FAST_KNI && defined(CLDCHI)
	if(*strips_handle==NULL) {
		KNI_ThrowNew("java/lang/NullPointerException", "NULL target");	
	} else {
		jint_array* strip_lengths = (jint_array*)*strips_handle;

		if(strip_lengths->length == 0) {
			KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid param");	
		} else {

			for(i=0; i<strip_lengths->length; i++) {
				if(strip_lengths->elements[i] < 3) {
					KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid param");	
					goto _return;
				}
				sum += strip_lengths->elements[i];
			}
			if(first_index + sum > 65535) {
				KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid index");	
			} else {
				ENTER_M3D_CS;
				handle = M3G_TriangleStripArray_new_implicit(first_index, (kal_int32*)strip_lengths,
												strip_lengths->length);

				/* Add strip_lengths to global root which protected by gc */
				ADD_TO_GLOBAL_ROOT(handle->strip_length);
				LEAVE_M3D_CS;
			}
		}
	}
#else
	ASSERT(0);
#endif /* FAST_KNI */

_return:
	KNI_EndHandles();
	KNI_ReturnInt((jint)handle);
}
#endif /* #ifdef SUPPORT_JSR_184 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -