1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <VideoEditorClasses.h> 18 #include <VideoEditorJava.h> 19 #include <VideoEditorLogging.h> 20 #include <VideoEditorOsal.h> 21 22 extern "C" { 23 #include <M4OSA_CharStar.h> 24 }; 25 26 27 void 28 videoEditJava_checkAndThrowIllegalArgumentExceptionFunc( 29 bool* pResult, 30 JNIEnv* pEnv, 31 bool condition, 32 const char* pMessage, 33 const char* pFile, 34 int lineNo) 35 { 36 // Check if the previous action succeeded. 37 if (*pResult) 38 { 39 // Check if the condition is true. 40 if (condition) 41 { 42 // Log the exception. 43 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",\ 44 "videoEditJava_checkAndThrowIllegalArgumentException, %s (%s:%d)", 45 pMessage, pFile, lineNo); 46 47 // Reset the result flag. 48 (*pResult) = false; 49 50 // Throw an exception. 51 jniThrowException(pEnv, "java/lang/IllegalArgumentException", pMessage); 52 } 53 } 54 } 55 56 void 57 videoEditJava_checkAndThrowRuntimeExceptionFunc( 58 bool* pResult, 59 JNIEnv* pEnv, 60 bool condition, 61 M4OSA_ERR result, 62 const char* pFile, 63 int lineNo 64 ) 65 { 66 const char* pMessage = NULL; 67 68 // Check if the previous action succeeded. 69 if (*pResult) 70 { 71 // Check if the condition is true. 72 if (condition) 73 { 74 // Get the error string. 75 pMessage = videoEditJava_getErrorName(result); 76 77 // Log the exception. 78 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 79 "videoEditJava_checkAndThrowRuntimeException, %s (%s:%d)", 80 pMessage, pFile, lineNo); 81 82 // Reset the result flag. 83 (*pResult) = false; 84 85 // Throw an exception. 86 jniThrowException(pEnv, "java/lang/RuntimeException", pMessage); 87 } 88 } 89 } 90 91 void 92 videoEditJava_checkAndThrowIllegalStateExceptionFunc( 93 bool* pResult, 94 JNIEnv* pEnv, 95 bool condition, 96 const char* pMessage, 97 const char* pFile, 98 int lineNo 99 ) 100 { 101 // Check if the previous action succeeded. 102 if (*pResult) 103 { 104 // Check if the condition is true. 105 if (condition) 106 { 107 // Log the exception. 108 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 109 "videoEditJava_checkAndThrowIllegalStateException, %s (%s:%d)", 110 pMessage, pFile, lineNo); 111 112 // Reset the result flag. 113 (*pResult) = false; 114 115 // Throw an exception. 116 jniThrowException(pEnv, "java/lang/IllegalStateException", pMessage); 117 } 118 } 119 } 120 121 void 122 videoEditJava_getClass( 123 bool* pResult, 124 JNIEnv* pEnv, 125 const char* pName, 126 jclass* pClazz) 127 { 128 // Only look for the class if locating the previous action succeeded. 129 if (*pResult) 130 { 131 // Log the function call. 132 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 133 "videoEditJava_getClass(%s)", pName); 134 135 // Look up the class. 136 jclass clazz = pEnv->FindClass(pName); 137 138 // Clear any resulting exceptions. 139 pEnv->ExceptionClear(); 140 141 // Check if the class could be located. 142 if (NULL != clazz) 143 { 144 // Return the class. 145 (*pClazz) = clazz; 146 } 147 else 148 { 149 // Reset the result flag. 150 (*pResult) = false; 151 152 // Log the error. 153 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 154 "videoEditJava_getClass, error: unable to locate class %s", pName); 155 156 // Throw an exception. 157 jniThrowException(pEnv, "java/lang/ClassNotFoundException", 158 "unable to locate class"); 159 } 160 } 161 } 162 163 void 164 videoEditJava_getMethodId( 165 bool* pResult, 166 JNIEnv* pEnv, 167 jclass clazz, 168 const char* pName, 169 const char* pType, 170 jmethodID* pMethodId) 171 { 172 // Only look for the class if locating the previous action succeeded. 173 if (*pResult) 174 { 175 // Log the function call. 176 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 177 "videoEditJava_getMethodId(%s,%s)", pName, pType); 178 179 // Look up the method id. 180 jmethodID methodId = pEnv->GetMethodID(clazz, pName, pType); 181 182 // Clear any resulting exceptions. 183 pEnv->ExceptionClear(); 184 185 // Check if the method could be located. 186 if (NULL != methodId) 187 { 188 // Return the method id. 189 (*pMethodId) = methodId; 190 } 191 else 192 { 193 // Reset the result flag. 194 (*pResult) = false; 195 196 // Log the error. 197 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 198 "videoEditJava_getMethodId, error: unable to locate method %s with type %s", 199 pName, pType); 200 201 // Throw an exception. 202 jniThrowException(pEnv, "java/lang/NoSuchMethodException", "unable to locate method"); 203 } 204 } 205 } 206 207 void 208 videoEditJava_getFieldId( 209 bool* pResult, 210 JNIEnv* pEnv, 211 jclass clazz, 212 const char* pName, 213 const char* pType, 214 jfieldID* pFieldId) 215 { 216 // Only look for the class if locating the previous action succeeded. 217 if (*pResult) 218 { 219 // Log the function call. 220 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 221 "videoEditJava_getFieldId(%s,%s)", pName, pType); 222 223 // Look up the field id. 224 jfieldID fieldId = pEnv->GetFieldID(clazz, pName, pType); 225 226 // Clear any resulting exceptions. 227 pEnv->ExceptionClear(); 228 229 // Check if the field could be located. 230 if (NULL != fieldId) 231 { 232 // Return the field id. 233 (*pFieldId) = fieldId; 234 } 235 else 236 { 237 // Reset the result flag. 238 (*pResult) = false; 239 240 // Log the error. 241 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 242 "videoEditJava_getFieldId, error: unable to locate field %s with type %s", 243 pName, pType); 244 245 // Throw an exception. 246 jniThrowException(pEnv, "java/lang/NoSuchFieldException", "unable to locate field"); 247 } 248 } 249 } 250 251 void 252 videoEditJava_getObject( 253 bool* pResult, 254 JNIEnv* pEnv, 255 jobject object, 256 jfieldID objectFieldId, 257 jobject* pObject) 258 { 259 // Only retrieve the array object and size if the previous action succeeded. 260 if (*pResult) 261 { 262 // Log the function call. 263 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 264 "videoEditJava_getObject()"); 265 266 // Retrieve the object. 267 (*pObject) = pEnv->GetObjectField(object, objectFieldId); 268 269 // Clear any resulting exceptions. 270 pEnv->ExceptionClear(); 271 } 272 } 273 274 void 275 videoEditJava_getArray( 276 bool* pResult, 277 JNIEnv* pEnv, 278 jobject object, 279 jfieldID arrayFieldId, 280 jobjectArray* pArray, 281 jsize* pArraySize) 282 { 283 // Only retrieve the array object and size if the previous action succeeded. 284 if (*pResult) 285 { 286 // Log the function call. 287 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", "videoEditJava_getArray()"); 288 289 // Retrieve the array object. 290 jobjectArray array = (jobjectArray)pEnv->GetObjectField(object, arrayFieldId); 291 jsize arraySize = 0; 292 293 // Clear any resulting exceptions. 294 pEnv->ExceptionClear(); 295 296 // Check if the array could be retrieved. 297 if (NULL != array) 298 { 299 // Retrieve the array size. 300 arraySize = pEnv->GetArrayLength(array); 301 } 302 303 // Return the array and its size. 304 (*pArray) = array; 305 (*pArraySize) = arraySize; 306 } 307 } 308 309 void* 310 videoEditJava_getString( 311 bool* pResult, 312 JNIEnv* pEnv, 313 jobject object, 314 jfieldID stringFieldId, 315 M4OSA_UInt32* pLength) 316 { 317 void* pString = M4OSA_NULL; 318 jstring string = NULL; 319 M4OSA_UInt32 length = 0; 320 M4OSA_Char* pLocal = M4OSA_NULL; 321 M4OSA_ERR result = M4NO_ERROR; 322 323 // Check if the previous action succeeded. 324 if (*pResult) 325 { 326 // Log the function call. 327 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", "videoEditJava_getString()"); 328 329 // Check if an object containing a string was specified. 330 if (NULL != stringFieldId) 331 { 332 // Retrieve the string object. 333 string = (jstring)pEnv->GetObjectField(object, stringFieldId); 334 335 // Clear any resulting exceptions. 336 pEnv->ExceptionClear(); 337 } 338 else 339 { 340 // The string itself was specified. 341 string = (jstring)object; 342 } 343 344 // Check if the string could be retrieved. 345 if (NULL != string) 346 { 347 // Get a local copy of the string. 348 pLocal = (M4OSA_Char*)pEnv->GetStringUTFChars(string, M4OSA_NULL); 349 if (M4OSA_NULL != pLocal) 350 { 351 // Determine the length of the path 352 // (add one extra character for the zero terminator). 353 length = strlen((const char *)pLocal) + 1; 354 355 // Allocate memory for the string. 356 pString = videoEditOsal_alloc(pResult, pEnv, length, "String"); 357 if (*pResult) 358 { 359 // Copy the string. 360 result = M4OSA_chrNCopy((M4OSA_Char*)pString, pLocal, length); 361 362 // Check if the copy succeeded. 363 videoEditJava_checkAndThrowRuntimeException(pResult, pEnv, 364 (M4NO_ERROR != result), result); 365 366 // Check if the string could not be copied. 367 if (!(*pResult)) 368 { 369 // Free the allocated memory. 370 videoEditOsal_free(pString); 371 pString = M4OSA_NULL; 372 } 373 } 374 375 // Release the local copy of the string. 376 pEnv->ReleaseStringUTFChars(string, (const char *)pLocal); 377 } 378 } 379 380 // Check if the string was empty or could be copied. 381 if (*pResult) 382 { 383 // Check if the length was requested. 384 if (M4OSA_NULL != pLength) 385 { 386 // Return the length. 387 (*pLength) = length; 388 } 389 } 390 } 391 392 // Return the string. 393 return(pString); 394 } 395 396 void 397 videoEditJava_getStaticIntField( 398 bool* pResult, 399 JNIEnv* pEnv, 400 jclass clazz, 401 const char* pName, 402 int* pValue) 403 { 404 // Only look for the class if locating the previous action succeeded. 405 if (*pResult) 406 { 407 // Log the function call. 408 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 409 "videoEditJava_getStaticIntField(%s)", pName); 410 411 // Look up the field id. 412 jfieldID fieldId = pEnv->GetStaticFieldID(clazz, pName, "I"); 413 414 // Clear any resulting exceptions. 415 pEnv->ExceptionClear(); 416 417 // Check if the field could be located. 418 if (NULL != fieldId) 419 { 420 // Retrieve the field value. 421 (*pValue) = pEnv->GetStaticIntField(clazz, fieldId); 422 423 // Log the value. 424 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 425 "videoEditJava_getStaticIntField, %s = %d", pName, (*pValue)); 426 } 427 else 428 { 429 // Reset the result flag. 430 (*pResult) = false; 431 432 // Log the error. 433 VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA", 434 "videoEditJava_getStaticIntField, error: unable to locate field %s", pName); 435 436 // Throw an exception. 437 jniThrowException(pEnv, "java/lang/NoSuchFieldException", 438 "unable to locate static field"); 439 } 440 } 441 } 442 443 void 444 videoEditJava_initConstantClass( 445 bool* pResult, 446 JNIEnv* pEnv, 447 VideoEditJava_ConstantsClass* pClass) 448 { 449 bool gotten = true; 450 jclass clazz = NULL; 451 int index = 0; 452 453 // Check if the previous action succeeded. 454 if (*pResult) 455 { 456 // Log the function call. 457 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 458 "videoEditJava_initConstantClass(%s)", pClass->pName); 459 460 // Only initialize the class once. 461 if (!pClass->initialized) 462 { 463 // Look up the class. 464 videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz); 465 466 // Loop over the constants. 467 for (index = 0; index < pClass->count; index++) 468 { 469 // Look up the constant. 470 videoEditJava_getStaticIntField(pResult, pEnv, clazz, 471 pClass->pConstants[index].pName, 472 &pClass->pConstants[index].java); 473 } 474 475 // Check if all constants could be located. 476 if (*pResult) 477 { 478 // Set the initialized flag. 479 pClass->initialized = true; 480 } 481 } 482 } 483 } 484 485 const char* 486 videoEditJava_getConstantClassName( 487 const VideoEditJava_ConstantsClass* pClass, 488 int value, 489 VideoEditJava_UnknownConstant unknown) 490 { 491 const char* pName = M4OSA_NULL; 492 int index = 0; 493 494 // Loop over the list with constants. 495 for (index = 0; 496 ((M4OSA_NULL == pName) && (index < pClass->count)); 497 index++) 498 { 499 // Check if the specified value matches the c value of the constant. 500 if (value == pClass->pConstants[index].c) 501 { 502 // Set the name. 503 pName = pClass->pConstants[index].pName; 504 } 505 } 506 507 // Check if no constant was found. 508 if (M4OSA_NULL == pName) 509 { 510 // Check if a function was specified to handle this case. 511 if (M4OSA_NULL != unknown) 512 { 513 // Pass the constant to the specified unknown function. 514 pName = unknown(value); 515 } 516 else 517 { 518 // Set the description to a default value. 519 pName = "<unknown>"; 520 } 521 } 522 523 // Return the result. 524 return(pName); 525 } 526 527 const char* 528 videoEditJava_getConstantClassString( 529 const VideoEditJava_ConstantsClass* pClass, 530 int value, 531 VideoEditJava_UnknownConstant unknown) 532 { 533 const char* pString = M4OSA_NULL; 534 int index = 0; 535 536 // Loop over the list with constants. 537 for (index = 0; 538 ((M4OSA_NULL == pString) && (index < pClass->count)); 539 index++) 540 { 541 // Check if the specified value matches the c value of the constant. 542 if (value == pClass->pConstants[index].c) 543 { 544 // Set the description. 545 pString = pClass->pConstants[index].pDescription; 546 } 547 } 548 549 // Check if no constant was found. 550 if (M4OSA_NULL == pString) 551 { 552 // Check if a function was specified to handle this case. 553 if (M4OSA_NULL != unknown) 554 { 555 // Pass the constant to the specified unknown function. 556 pString = unknown(value); 557 } 558 else 559 { 560 // Set the description to a default value. 561 pString = "<unknown>"; 562 } 563 } 564 565 // Return the result. 566 return(pString); 567 } 568 569 int 570 videoEditJava_getConstantClassJavaToC( 571 bool* pResult, 572 const VideoEditJava_ConstantsClass* pClass, 573 int value) 574 { 575 bool gotten = false; 576 int index = 0; 577 578 // Check if the previous action succeeded. 579 if (*pResult) 580 { 581 // Loop over the list with constants. 582 for (index = 0; ((!gotten) && (index < pClass->count)); index++) 583 { 584 // Check if the specified value matches the java value of the constant. 585 if (value == pClass->pConstants[index].java) 586 { 587 // Set the value to the c value. 588 value = pClass->pConstants[index].c; 589 590 // Set the gotten flag. 591 gotten = true; 592 } 593 } 594 595 // Check if the value was not found. 596 if (!gotten) 597 { 598 (*pResult) = false; 599 } 600 } 601 602 // Return the translated value. 603 return(value); 604 } 605 606 int 607 videoEditJava_getConstantClassJavaToC( 608 bool* pResult, 609 const VideoEditJava_ConstantsClass* pClass, 610 int value, 611 int unknown) 612 { 613 bool gotten = false; 614 int index = 0; 615 616 // Check if the previous action succeeded. 617 if (*pResult) 618 { 619 // Loop over the list with constants. 620 for (index = 0; ((!gotten) && (index < pClass->count)); index++) 621 { 622 // Check if the specified value matches the java value of the constant. 623 if (value == pClass->pConstants[index].java) 624 { 625 // Set the value to the c value. 626 value = pClass->pConstants[index].c; 627 628 // Set the gotten flag. 629 gotten = true; 630 } 631 } 632 633 // If the constant was not found, look for the specified unknown. 634 if (!gotten) 635 { 636 // Set the value to the c value. 637 value = unknown; 638 } 639 } 640 641 // Return the translated value. 642 return(value); 643 } 644 645 int 646 videoEditJava_getConstantClassCToJava( 647 const VideoEditJava_ConstantsClass* pClass, 648 int value) 649 { 650 bool gotten = false; 651 int index = 0; 652 653 // Loop over the list with constants. 654 for (index = 0; ((!gotten) && (index < pClass->count)); index++) 655 { 656 // Check if the specified value matches the c value of the constant. 657 if (value == pClass->pConstants[index].c) 658 { 659 // Set the value to the java value. 660 value = pClass->pConstants[index].java; 661 662 // Set the gotten flag. 663 gotten = true; 664 } 665 } 666 667 // Return the translated value. 668 return(value); 669 } 670 671 int 672 videoEditJava_getConstantClassCToJava( 673 const VideoEditJava_ConstantsClass* pClass, 674 int value, 675 int unknown) 676 { 677 bool gotten = false; 678 int index = 0; 679 680 // Loop over the list with constants. 681 for (index = 0; ((!gotten) && (index < pClass->count)); index++) 682 { 683 // Check if the specified value matches the c value of the constant. 684 if (value == pClass->pConstants[index].c) 685 { 686 // Set the value to the java value. 687 value = pClass->pConstants[index].java; 688 689 // Set the gotten flag. 690 gotten = true; 691 } 692 } 693 694 // If the constant was not found, look for the specified unknown. 695 if (!gotten) 696 { 697 // Loop over the list with constants. 698 for (index = 0; ((!gotten) && (index < pClass->count)); index++) 699 { 700 // Check if the specified value matches the java value of the constant. 701 if (unknown == pClass->pConstants[index].c) 702 { 703 // Set the value to the c value. 704 value = pClass->pConstants[index].java; 705 706 // Set the gotten flag. 707 gotten = true; 708 } 709 } 710 } 711 712 // Return the translated value. 713 return(value); 714 } 715 716 void 717 videoEditJava_initFieldClass( 718 bool* pResult, 719 JNIEnv* pEnv, 720 VideoEditJava_FieldsClass* pClass) 721 { 722 bool gotten = true; 723 jclass clazz = NULL; 724 int index = 0; 725 726 // Check if the previous action succeeded. 727 if (*pResult) 728 { 729 // Log the function call. 730 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 731 "videoEditJava_initFieldClass(%s)", pClass->pName); 732 733 // Only initialize the class once. 734 if (!pClass->initialized) 735 { 736 // Look up the class. 737 videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz); 738 739 // Loop over the fields. 740 for (index = 0; index < pClass->count; index++) 741 { 742 // Look up the field id. 743 videoEditJava_getFieldId( 744 pResult, 745 pEnv, 746 clazz, 747 pClass->pFields[index].pName, 748 pClass->pFields[index].pType, 749 &pClass->pFields[index].fieldId); 750 } 751 752 // Check if all fields could be located. 753 if (*pResult) 754 { 755 // Set the initialized flag. 756 pClass->initialized = true; 757 } 758 } 759 } 760 } 761 762 void 763 videoEditJava_fieldClassClass( 764 bool* pResult, 765 JNIEnv* pEnv, 766 const VideoEditJava_FieldsClass* pClass, 767 jclass* pClazz) 768 { 769 // Check if the previous action succeeded. 770 if (*pResult) 771 { 772 // Check if the class is initialized. 773 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized), 774 "field class not initialized"); 775 776 // Get the class. 777 videoEditJava_getClass(pResult, pEnv, pClass->pName, pClazz); 778 } 779 } 780 781 void 782 videoEditJava_fieldClassFieldIds( 783 bool* pResult, 784 JNIEnv* pEnv, 785 const VideoEditJava_FieldsClass* pClass, 786 int count, 787 VideoEditJava_FieldIds* pIds) 788 { 789 int index = 0; 790 791 // Check if the previous action succeeded. 792 if (*pResult) 793 { 794 // Check if the class is initialized. 795 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized), 796 "field class not initialized"); 797 798 // Check if the number of fields matches. 799 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, 800 (pClass->count != count), 801 "field class type mismatch"); 802 803 // Check if the class and object are valid. 804 if (*pResult) 805 { 806 // Loop over the class fields. 807 for (index = 0; index < count; index++) 808 { 809 // Copy the field ids. 810 pIds->fieldIds[index] = pClass->pFields[index].fieldId; 811 } 812 } 813 } 814 } 815 816 void 817 videoEditJava_initMethodClass( 818 bool* pResult, 819 JNIEnv* pEnv, 820 VideoEditJava_MethodsClass* pClass) 821 { 822 bool gotten = true; 823 jclass clazz = NULL; 824 int index = 0; 825 826 // Check if the previous action succeeded. 827 if (*pResult) 828 { 829 // Log the function call. 830 VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", 831 "videoEditJava_initMethodClass(%s)", pClass->pName); 832 833 // Only initialize the class once. 834 if (!pClass->initialized) 835 { 836 // Look up the class. 837 videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz); 838 839 // Loop over the methods. 840 for (index = 0; index < pClass->count; index++) 841 { 842 // Look up the method id. 843 videoEditJava_getMethodId( 844 pResult, 845 pEnv, 846 clazz, 847 pClass->pMethods[index].pName, 848 pClass->pMethods[index].pType, 849 &pClass->pMethods[index].methodId); 850 } 851 852 // Check if all methods could be located. 853 if (*pResult) 854 { 855 // Set the initialized flag. 856 pClass->initialized = true; 857 } 858 } 859 } 860 } 861 862 void 863 videoEditJava_methodClassMethodIds( 864 bool* pResult, 865 JNIEnv* pEnv, 866 const VideoEditJava_MethodsClass* pClass, 867 int count, 868 VideoEditJava_MethodIds* pIds) 869 { 870 int index = 0; 871 872 // Check if the previous action succeeded. 873 if (*pResult) 874 { 875 // Check if the class is initialized. 876 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized), 877 "method class not initialized"); 878 879 // Check if the number of methods matches. 880 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,\ 881 (pClass->count != count), 882 "method class type mismatch"); 883 884 // Check if the class and object are valid. 885 if (*pResult) 886 { 887 // Loop over the class methods. 888 for (index = 0; index < count; index++) 889 { 890 // Copy the method ids. 891 pIds->methodIds[index] = pClass->pMethods[index].methodId; 892 } 893 } 894 } 895 } 896 897