Project

Profile

Help

Revision 6304fb8b

Added by O'Neil Delpratt 5 months ago

Saxon/C bug fixes and development work

View differences:

latest10/hec/Saxon.C.API/HEC/SaxonCGlue.c
41 41
	size_t rDir_len = strlen(tempResources_dir);
42 42
	char * env = getenv("SAXONC_HOME");
43 43
	size_t env_len;
44
	if (env != NULL) {
44
	if (env != nullptr) {
45 45

  
46 46

  
47 47
		env_len = strlen(env);
......
68 68
		resources_dir = malloc(sizeof(char)*rbufSize);
69 69

  
70 70
#ifdef DEBUG
71
		if (dllname == NULL || resources_dir == NULL)
71
		if (dllname == nullptr || resources_dir == nullptr)
72 72
		{
73 73
			// error
74 74
			printf("Error in allocation of Dllname\n");
......
119 119
 * Recommended method to use to load library
120 120
 */
121 121
HANDLE loadDefaultDll() {
122
	return loadDll(NULL);
122
	return loadDll(nullptr);
123 123
}
124 124

  
125 125

  
......
128 128
 */
129 129
HANDLE loadDll(char* name)
130 130
{
131
	if (name == NULL) {
131
	if (name == nullptr) {
132 132
		setDllname();
133 133
		name = getDllname();
134 134
		//perror("Error1: ");
......
244 244

  
245 245
	if (!clazz) {
246 246
		printf("Unable to find class %s\n", name);
247
		return NULL;
247
		return nullptr;
248 248
	}
249 249
#ifdef DEBUG
250 250
	printf("Class %s found\n", name);
......
334 334
	MID_initi = (jmethodID)(*(penv))->GetMethodID(penv, myClassInDll, "<init>", arguments);
335 335
	if (!MID_initi) {
336 336
		printf("Error: MyClassInDll.<init>() not found\n");
337
		return NULL;
337
		return nullptr;
338 338
	}
339 339

  
340 340
	if (argument1) {
......
347 347
	}
348 348
	if (!obj) {
349 349
		printf("Error: failed to allocate an object\n");
350
		return NULL;
350
		return nullptr;
351 351
	}
352 352
	return obj;
353 353
}
......
365 365
	MID_initi = (jmethodID)(*(penv))->GetMethodID(penv, myClassInDll, "<init>", arguments);
366 366
	if (!MID_initi) {
367 367
		printf("Error: MyClassInDll.<init>() not found\n");
368
		return NULL;
368
		return nullptr;
369 369
	}
370 370

  
371 371
	if (argument1) {
......
378 378
	}
379 379
	if (!obj) {
380 380
		printf("Error: failed to allocate an object\n");
381
		return NULL;
381
		return nullptr;
382 382
	}
383 383
	return obj;
384 384
}
......
406 406

  
407 407
		jmethodID getName = (jmethodID)(*(environii->env))->GetMethodID(environii->env, clscls, "getName", "()Ljava/lang/String;");
408 408
		jstring name = (jstring)((*(environii->env))->CallObjectMethod(environii->env, exccls, getName));
409
		char const* utfName = (*(environii->env))->GetStringUTFChars(environii->env, name, NULL);
409
		char const* utfName = (*(environii->env))->GetStringUTFChars(environii->env, name, nullptr);
410 410

  
411
		//if(callingObject != NULL && strcmp(utfName, "net.sf.saxon.s9api.SaxonApiException") == 0){
411
		//if(callingObject != nullptr && strcmp(utfName, "net.sf.saxon.s9api.SaxonApiException") == 0){
412 412

  
413 413
		jmethodID  getMessage = (jmethodID)(*(environii->env))->GetMethodID(environii->env, exccls, "getMessage", "()Ljava/lang/String;");
414 414

  
......
421 421
				(*(environii->env))->ExceptionClear(environii->env);
422 422
				return 0;
423 423
			}
424
			char const* utfMessage = (*(environii->env))->GetStringUTFChars(environii->env, message, NULL);
424
			char const* utfMessage = (*(environii->env))->GetStringUTFChars(environii->env, message, nullptr);
425 425

  
426
			if (utfMessage != NULL) {
426
			if (utfMessage != nullptr) {
427 427
				(*(environii->env))->ReleaseStringUTFChars(environii->env, name, utfName);
428 428
			}
429 429

  
......
456 456
 */
457 457
jobject getParameter(sxnc_parameter *parameters, int parLen, const char* namespacei, const char * name) {
458 458
	int i = 0;
459
	namespacei = NULL; // variable not used yet
460
	if (namespacei == NULL) {} // avoiding warning. In next release fix this
459
	namespacei = nullptr; // variable not used yet
460
	if (namespacei == nullptr) {} // avoiding warning. In next release fix this
461 461
	for (i = 0; i < parLen; i++) {
462 462
		if (strcmp(parameters[i].name, name) == 0)
463 463
			return (jobject)parameters[i].value;
464 464
	}
465
	return NULL;
465
	return nullptr;
466 466
}
467 467

  
468 468

  
......
471 471
 */
472 472
char* getProperty(sxnc_property * properties, int propLen, const char* namespacei, const char * name) {
473 473
	int i = 0;
474
	namespacei = NULL; // variable not used yet
475
	if (namespacei == NULL) {} // avoiding warning. In next release fix this
474
	namespacei = nullptr; // variable not used yet
475
	if (namespacei == nullptr) {} // avoiding warning. In next release fix this
476 476
	for (i = 0; i < propLen; i++) {
477 477
		if (strcmp(properties[i].name, name) == 0)
478 478
			return properties[i].value;
......
486 486
 */
487 487
void setParameter(sxnc_parameter **parameters, int * parLen, int * parCap, const char * namespacei, const char * name, jobject value) {
488 488

  
489
	namespacei = NULL;
489
	namespacei = nullptr;
490 490
	if (getParameter(*parameters, (*parLen), "", name) != 0) {
491 491
		return;
492 492
	}
......
559 559

  
560 560
const char * stringValue(sxnc_environment *environi, jobject value) {
561 561
	jclass  objClass = lookForClass(environi->env, "java/lang/Object");
562
	static jmethodID strMID = NULL;
562
	static jmethodID strMID = nullptr;
563 563
	if (!strMID) {
564 564
		strMID = (jmethodID)(*(environi->env))->GetMethodID(environi->env, objClass, "toString", "()Ljava/lang/String;");
565 565
		if (!strMID) {
566 566
			printf("\nError: Object %s() not found\n", "toString");
567 567
			fflush(stdout);
568
			return NULL;
568
			return nullptr;
569 569
		}
570 570
	}
571 571
	jstring result = (jstring)((*(environi->env))->CallObjectMethod(environi->env, value, strMID));
572 572
	if (result) {
573
		const char * str = (*(environi->env))->GetStringUTFChars(environi->env, result, NULL);
573
		const char * str = (*(environi->env))->GetStringUTFChars(environi->env, result, nullptr);
574 574
		return str;
575 575
	}
576 576

  

Also available in: Unified diff