Project

Profile

Help

Revision 5401a5ae

Added by O'Neil Delpratt almost 2 years ago

Saxon/C Development

View differences:

latest9.9/hec/Saxon.C.API/XsltExecutable.cpp
83 83
        properties[propIter->first] = propIter->second;
84 84
        propIter++;
85 85
    }
86
	jitCompilation = other.jitCompilation;
87 86

  
88 87
}
89 88

  
......
93 92
}
94 93

  
95 94
const char * XsltExecutable::getErrorCode(int i) {
96
 if(proc->exception == NULL) {return NULL;}
97
 return proc->exception->getErrorCode(i);
95
 if(exception == NULL) {return NULL;}
96
 return exception->getErrorCode(i);
98 97
 }
99 98

  
100 99

  
......
187 186
	return (bool)(parameters.erase("param:"+std::string(name)));
188 187
}
189 188

  
190
void XsltExecutable::setJustInTimeCompilation(bool jit){
191
    jitCompilation = jit;
192
}
193 189

  
194 190
void XsltExecutable::setResultAsRawValue(bool option) {
195 191
	if(option) {
......
271 267
}
272 268

  
273 269
void XsltExecutable::exceptionClear(){
274
 if(proc->exception != NULL) {
275
 	delete proc->exception;
276
 	proc->exception = NULL;
270
 if(exception != NULL) {
271
 	delete exception;
272
 	exception = NULL;
277 273
	SaxonProcessor::sxn_environ->env->ExceptionClear();
278 274
 }
279 275

  
......
290 286
	 proc->exception = proc->checkForException(environi, cpp);
291 287
	 }
292 288
	 return proc->exception;*/
293
	return proc->checkException(cppXT);
289
	return SaxonProcessor::checkException(NULL);
294 290
}
295 291

  
296
int XsltExecutable::exceptionCount(){
297
 if(proc->exception != NULL){
298
 return proc->exception->count();
292
/*int XsltExecutable::exceptionCount(){
293
 if(exception != NULL){
294
 return exception->count();
299 295
 }
300 296
 return 0;
301
 }
297
 }      */
302 298

  
303 299

  
304 300
    void XsltExecutable::export(const char * filename) {
305
        jclass cppClass = lookForClass(SaxonProcessor::sxn_environ->env,
306
        			"net/sf/saxon/option/cpp/Xslt30Processor");
301

  
307 302

  
308 303
        static jmethodID exportmID == NULL;
309 304

  
......
333 328
	static jmethodID atmID = NULL;
334 329

  
335 330
	if(atmID == NULL) {
336
			(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
331
			(jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
337 332
					"applyTemplatesReturningFile",
338 333
					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
339 334

  
......
346 341
	} else {
347 342
        JParameters comboArrays;
348 343
		comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
349
		SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, atmID,
344
		SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atmID,
350 345
						SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()), executableObject ,selection,
351 346
						(output_filename != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(
352 347
                                       						output_filename) : NULL),
......
371 366

  
372 367
	setProperty("resources", proc->getResourcesDirectory());
373 368
	jmethodID atsmID =
374
			(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
369
			(jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
375 370
					"applyTemplatesReturningString",
376 371
					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
377 372
	if (!atsmID) {
......
383 378
		comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
384 379

  
385 380
	jstring result = NULL;
386
	jobject obj = (SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, atsmID,
381
	jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsmID,
387 382
								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()), executableObject
388 383
								selection,
389 384
								comboArrays.stringArray, comboArrays.objectArray));
......
420 415
	setProperty("resources", proc->getResourcesDirectory());
421 416
	static jmethodID atsmID = NULL;
422 417
	if (atsmID == NULL) {
423
	    atsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
418
	    atsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
424 419
					"applyTemplatesReturningValue",
425 420
					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
426 421
	}
......
434 429

  
435 430

  
436 431
	   // jstring result = NULL;
437
	    jobject result = (jobject)(SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, atsmID,
432
	    jobject result = (jobject)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsmID,
438 433
								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()),
439 434
								executableObject, selection,
440 435
								comboArrays.stringArray, comboArrays.objectArray));
......
495 490
        	static jmethodID afmID = NULL;
496 491

  
497 492
        	if(afmID == NULL) {
498
        			afmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
493
        			afmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
499 494
        					"callFunctionReturningFile",
500 495
        					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)V");
501 496
        	}
......
510 505

  
511 506
        		jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
512 507

  
513
        		SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, afmID,
508
        		SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afmID,
514 509
        						SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()),
515 510
        						executableObject,
516 511
        						(functionName != NULL ?
......
541 536

  
542 537
    	setProperty("resources", proc->getResourcesDirectory());
543 538
    	static jmethodID afsmID =
544
    			(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
539
    			(jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
545 540
    					"callFunctionReturningString",
546 541
    					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
547 542
    	if (!afsmID) {
......
554 549
            jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
555 550

  
556 551
    	jstring result = NULL;
557
    	jobject obj = (SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, afsmID,
552
    	jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afsmID,
558 553
    								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()),  executableObject
559 554
    								(functionName != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(functionName) : NULL),
560 555
    								argumentJArray, comboArrays.stringArray, comboArrays.objectArray));
......
585 580
          	setProperty("resources", proc->getResourcesDirectory());
586 581
          	static jmethodID cfvmID = NULL;
587 582
          	if(cfvmID == NULL) {
588
          	    cfvmId = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
583
          	    cfvmId = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
589 584
          					"callFunctionReturningValue",
590 585
          					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
591 586
          	}
......
598 593
          		comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
599 594
                jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
600 595

  
601
          	    jobject result = (jobject)(SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, cfvmID,
596
          	    jobject result = (jobject)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, cfvmID,
602 597
          								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()),executableObject,
603 598
                                        (functionName != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(functionName) : NULL),
604 599
          								argumentJArray, comboArrays.stringArray, comboArrays.objectArray));
......
667 662

  
668 663
	setProperty("resources", proc->getResourcesDirectory());
669 664
	static jmethodID ctmID =
670
			(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
665
			(jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
671 666
					"callTemplateReturningFile",
672
					"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
667
					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
673 668
	if (!ctmID) {
674 669
		std::cerr << "Error: "<< getDllname() << "callTemplateReturningFile" << " not found\n"
675 670
				<< std::endl;
......
677 672
	} else {
678 673
        JParameters comboArrays;
679 674
		comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
680
		SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, ctmID,
675
		SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppclass, ctmID,
681 676
						SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()),
682
						(stylesheetfile != NULL ?
683
								SaxonProcessor::sxn_environ->env->NewStringUTF(
684
										stylesheetfile) :
685
								NULL),
686
						(templateName != NULL ?
687
								SaxonProcessor::sxn_environ->env->NewStringUTF(templateName) :
688
								NULL),
689
								(outfile != NULL ?
690
                                			SaxonProcessor::sxn_environ->env->NewStringUTF(outfile) :
691
                     					NULL),
677
						(stylesheetfile != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(stylesheetfile) : NULL), executableObject,
678
						(templateName != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(templateName) : NULL),
679
								(outfile != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(outfile) : NULL),
692 680
								comboArrays.stringArray, comboArrays.objectArray);
693 681
		if (comboArrays.stringArray != NULL) {
694 682
			SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
......
709 697

  
710 698
	setProperty("resources", proc->getResourcesDirectory());
711 699
	jmethodID ctsmID =
712
			(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
700
			(jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
713 701
					"callTemplateReturningString",
714 702
					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
715 703
	if (!ctsmID) {
......
722 710

  
723 711

  
724 712
	jstring result = NULL;
725
	jobject obj =(jobject)(SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, ctsmID,
713
	jobject obj =(jobject)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsmID,
726 714
								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()), executableObject,
727 715
								(templateName != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(templateName) : NULL),
728 716
								comboArrays.stringArray, comboArrays.objectArray));
......
753 741
          	setProperty("resources", proc->getResourcesDirectory());
754 742
          	static jmethodID ctsmID = NULL;
755 743
          	if (ctsmID == NULL) {
756
          	    ctsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
744
          	    ctsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
757 745
          					"callTemplateReturningValue",
758 746
          					"(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
759 747
          	}
......
767 755

  
768 756

  
769 757
          	    jstring result = NULL;
770
          	    jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->CallObjectMethod(cppXT, ctsmID,
758
          	    jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsmID,
771 759
          								SaxonProcessor::sxn_environ->env->NewStringUTF(cwdXE.c_str()), executableObject,
772 760
                                        (templateName != NULL ? SaxonProcessor::sxn_environ->env->NewStringUTF(templateName) : NULL),
773 761
          								comboArrays.stringArray, comboArrays.objectArray));
......
796 784
					    xdmItem->setProcessor(proc);
797 785
					    SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
798 786
					    return xdmItem;
799

  
787
#if CVERSION_API_NO >= 123
800 788
          			} else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
801 789
                        xdmItem =  new XdmFunctionItem(result);
802 790
                        xdmItem->setProcessor(proc);
803 791
                        SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
804 792
                        return xdmItem;
793
#endif
805 794
          			} else {
806 795
					value = new XdmValue(result, true);
807 796
					value->setProcessor(proc);
......
817 806
          		SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
818 807
          		return value;
819 808
         	} else  {
820
          		proc->checkAndCreateException(cppClass);
809
          		exception = proc->checkAndCreateException(cppClass);
821 810
               	}
822 811
          }
823 812
        return NULL;
......
899 888
          		return value;
900 889
		}else {
901 890

  
902
			proc->checkAndCreateException(cppClass);
891
			exception = proc->checkAndCreateException(cppClass);
903 892

  
904 893
     		}
905 894
	}
......
936 925
			SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
937 926
		}
938 927
		}
939
		proc->checkAndCreateException(cppClass);
928
		exception = proc->checkAndCreateException(cppClass);
940 929
	}
941 930

  
942 931

  
......
991 980
			SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
992 981
			return str;
993 982
		} else  {
994
			proc->checkAndCreateException(cppClass);
983
			exception = proc->checkAndCreateException(cppClass);
995 984

  
996 985
     		}
997 986
	}
......
1028 1017
   }
1029 1018

  
1030 1019
const char * XsltExecutable::getErrorMessage(int i ){
1031
 	if(proc->exception == NULL) {return NULL;}
1032
 	return proc->exception->getErrorMessage(i);
1020
 	if(exception == NULL) {return NULL;}
1021
 	return exception->getErrorMessage(i);
1033 1022
 }

Also available in: Unified diff