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/EEC/SaxonCGlue.c
40 40
	size_t rDir_len = strlen(tempResources_dir);
41 41
	char * env = getenv("SAXONC_HOME");
42 42
	size_t env_len;
43
	if (env != NULL) {
43
	if (env != nullptr) {
44 44

  
45 45

  
46 46
		env_len = strlen(env);
......
67 67
		resources_dir = malloc(sizeof(char)*rbufSize);
68 68

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

  
124 124

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

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

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

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

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

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

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

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

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

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

  
467 467

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

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

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

  

Also available in: Unified diff