comparison src/dynamic-ld.cc @ 10315:57a59eae83cc

untabify src C++ source files
author John W. Eaton <jwe@octave.org>
date Thu, 11 Feb 2010 12:41:46 -0500
parents 7c7685cc0676
children fd0a3ac60b0e
comparison
equal deleted inserted replaced
10314:07ebe522dac2 10315:57a59eae83cc
99 lib_list.push_back (shl); 99 lib_list.push_back (shl);
100 } 100 }
101 101
102 void 102 void
103 octave_shlib_list::do_remove (octave_shlib& shl, 103 octave_shlib_list::do_remove (octave_shlib& shl,
104 octave_shlib::close_hook cl_hook) 104 octave_shlib::close_hook cl_hook)
105 { 105 {
106 for (iterator p = lib_list.begin (); p != lib_list.end (); p++) 106 for (iterator p = lib_list.begin (); p != lib_list.end (); p++)
107 { 107 {
108 if (*p == shl) 108 if (*p == shl)
109 { 109 {
110 // Erase first to avoid potentially invalidating the pointer by the 110 // Erase first to avoid potentially invalidating the pointer by the
111 // following hooks. 111 // following hooks.
112 lib_list.erase (p); 112 lib_list.erase (p);
113 113
114 shl.close (cl_hook); 114 shl.close (cl_hook);
115 115
116 break; 116 break;
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 octave_shlib 121 octave_shlib
122 octave_shlib_list::do_find_file (const std::string& file_name) const 122 octave_shlib_list::do_find_file (const std::string& file_name) const
124 octave_shlib retval; 124 octave_shlib retval;
125 125
126 for (const_iterator p = lib_list.begin (); p != lib_list.end (); p++) 126 for (const_iterator p = lib_list.begin (); p != lib_list.end (); p++)
127 { 127 {
128 if (p->file_name () == file_name) 128 if (p->file_name () == file_name)
129 { 129 {
130 retval = *p; 130 retval = *p;
131 break; 131 break;
132 } 132 }
133 } 133 }
134 134
135 return retval; 135 return retval;
136 } 136 }
137 137
168 instance->do_append (shl); 168 instance->do_append (shl);
169 } 169 }
170 170
171 void 171 void
172 octave_shlib_list::remove (octave_shlib& shl, 172 octave_shlib_list::remove (octave_shlib& shl,
173 octave_shlib::close_hook cl_hook) 173 octave_shlib::close_hook cl_hook)
174 { 174 {
175 if (instance_ok ()) 175 if (instance_ok ())
176 instance->do_remove (shl, cl_hook); 176 instance->do_remove (shl, cl_hook);
177 } 177 }
178 178
234 file_list.push_back (shl); 234 file_list.push_back (shl);
235 } 235 }
236 236
237 void 237 void
238 octave_mex_file_list::do_remove (octave_shlib& shl, 238 octave_mex_file_list::do_remove (octave_shlib& shl,
239 octave_shlib::close_hook cl_hook) 239 octave_shlib::close_hook cl_hook)
240 { 240 {
241 for (iterator p = file_list.begin (); p != file_list.end (); p++) 241 for (iterator p = file_list.begin (); p != file_list.end (); p++)
242 { 242 {
243 if (*p == shl) 243 if (*p == shl)
244 { 244 {
245 // Erase first to avoid potentially invalidating the pointer by the 245 // Erase first to avoid potentially invalidating the pointer by the
246 // following hooks. 246 // following hooks.
247 file_list.erase (p); 247 file_list.erase (p);
248 248
249 shl.close (cl_hook); 249 shl.close (cl_hook);
250 250
251 break; 251 break;
252 } 252 }
253 } 253 }
254 } 254 }
255 255
256 bool 256 bool
257 octave_mex_file_list::instance_ok (void) 257 octave_mex_file_list::instance_ok (void)
278 instance->do_append (shl); 278 instance->do_append (shl);
279 } 279 }
280 280
281 void 281 void
282 octave_mex_file_list::remove (octave_shlib& shl, 282 octave_mex_file_list::remove (octave_shlib& shl,
283 octave_shlib::close_hook cl_hook) 283 octave_shlib::close_hook cl_hook)
284 { 284 {
285 if (instance_ok ()) 285 if (instance_ok ())
286 instance->do_remove (shl, cl_hook); 286 instance->do_remove (shl, cl_hook);
287 } 287 }
288 288
331 octave_shlib_list::remove (oct_file, symbol_table::clear_dld_function); 331 octave_shlib_list::remove (oct_file, symbol_table::clear_dld_function);
332 } 332 }
333 333
334 octave_function * 334 octave_function *
335 octave_dynamic_loader::do_load_oct (const std::string& fcn_name, 335 octave_dynamic_loader::do_load_oct (const std::string& fcn_name,
336 const std::string& file_name, 336 const std::string& file_name,
337 bool relative) 337 bool relative)
338 { 338 {
339 octave_function *retval = 0; 339 octave_function *retval = 0;
340 340
341 unwind_protect frame; 341 unwind_protect frame;
342 342
358 } 358 }
359 359
360 if (! error_state) 360 if (! error_state)
361 { 361 {
362 if (oct_file) 362 if (oct_file)
363 { 363 {
364 void *function = oct_file.search (fcn_name, name_mangler); 364 void *function = oct_file.search (fcn_name, name_mangler);
365 365
366 if (! function) 366 if (! function)
367 { 367 {
368 // FIXME -- can we determine this C mangling scheme 368 // FIXME -- can we determine this C mangling scheme
369 // automatically at run time or configure time? 369 // automatically at run time or configure time?
370 370
371 function = oct_file.search (fcn_name, name_uscore_mangler); 371 function = oct_file.search (fcn_name, name_uscore_mangler);
372 } 372 }
373 373
374 if (function) 374 if (function)
375 { 375 {
376 octave_dld_fcn_getter f 376 octave_dld_fcn_getter f
377 = FCN_PTR_CAST (octave_dld_fcn_getter, function); 377 = FCN_PTR_CAST (octave_dld_fcn_getter, function);
378 378
379 retval = f (oct_file, relative); 379 retval = f (oct_file, relative);
380 380
381 if (! retval) 381 if (! retval)
382 ::error ("failed to install .oct file function `%s'", 382 ::error ("failed to install .oct file function `%s'",
383 fcn_name.c_str ()); 383 fcn_name.c_str ());
384 } 384 }
385 } 385 }
386 else 386 else
387 ::error ("%s is not a valid shared library", 387 ::error ("%s is not a valid shared library",
388 file_name.c_str ()); 388 file_name.c_str ());
389 } 389 }
390 390
391 return retval; 391 return retval;
392 } 392 }
393 393
394 octave_function * 394 octave_function *
395 octave_dynamic_loader::do_load_mex (const std::string& fcn_name, 395 octave_dynamic_loader::do_load_mex (const std::string& fcn_name,
396 const std::string& file_name, 396 const std::string& file_name,
397 bool /*relative*/) 397 bool /*relative*/)
398 { 398 {
399 octave_function *retval = 0; 399 octave_function *retval = 0;
400 400
401 unwind_protect frame; 401 unwind_protect frame;
402 402
418 } 418 }
419 419
420 if (! error_state) 420 if (! error_state)
421 { 421 {
422 if (mex_file) 422 if (mex_file)
423 { 423 {
424 void *function = 0; 424 void *function = 0;
425 425
426 bool have_fmex = false; 426 bool have_fmex = false;
427 427
428 octave_mex_file_list::append (mex_file); 428 octave_mex_file_list::append (mex_file);
429 429
430 function = mex_file.search (fcn_name, mex_mangler); 430 function = mex_file.search (fcn_name, mex_mangler);
431 431
432 if (! function) 432 if (! function)
433 { 433 {
434 // FIXME -- can we determine this C mangling scheme 434 // FIXME -- can we determine this C mangling scheme
435 // automatically at run time or configure time? 435 // automatically at run time or configure time?
436 436
437 function = mex_file.search (fcn_name, mex_uscore_mangler); 437 function = mex_file.search (fcn_name, mex_uscore_mangler);
438 438
439 if (! function) 439 if (! function)
440 { 440 {
441 function = mex_file.search (fcn_name, mex_f77_mangler); 441 function = mex_file.search (fcn_name, mex_f77_mangler);
442 442
443 if (function) 443 if (function)
444 have_fmex = true; 444 have_fmex = true;
445 } 445 }
446 } 446 }
447 447
448 if (function) 448 if (function)
449 retval = new octave_mex_function (function, have_fmex, 449 retval = new octave_mex_function (function, have_fmex,
450 mex_file, fcn_name); 450 mex_file, fcn_name);
451 else 451 else
452 ::error ("failed to install .mex file function `%s'", 452 ::error ("failed to install .mex file function `%s'",
453 fcn_name.c_str ()); 453 fcn_name.c_str ());
454 } 454 }
455 else 455 else
456 ::error ("%s is not a valid shared library", 456 ::error ("%s is not a valid shared library",
457 file_name.c_str ()); 457 file_name.c_str ());
458 } 458 }
459 459
460 return retval; 460 return retval;
461 } 461 }
462 462
463 bool 463 bool
464 octave_dynamic_loader::do_remove_oct (const std::string& fcn_name, 464 octave_dynamic_loader::do_remove_oct (const std::string& fcn_name,
465 octave_shlib& shl) 465 octave_shlib& shl)
466 { 466 {
467 bool retval = false; 467 bool retval = false;
468 468
469 // We don't need to do anything if this is called because we are in 469 // We don't need to do anything if this is called because we are in
470 // the process of reloading a .oct file that has changed. 470 // the process of reloading a .oct file that has changed.
472 if (! doing_load) 472 if (! doing_load)
473 { 473 {
474 retval = shl.remove (fcn_name); 474 retval = shl.remove (fcn_name);
475 475
476 if (shl.number_of_functions_loaded () == 0) 476 if (shl.number_of_functions_loaded () == 0)
477 octave_shlib_list::remove (shl); 477 octave_shlib_list::remove (shl);
478 } 478 }
479 479
480 return retval; 480 return retval;
481 } 481 }
482 482
483 bool 483 bool
484 octave_dynamic_loader::do_remove_mex (const std::string& fcn_name, 484 octave_dynamic_loader::do_remove_mex (const std::string& fcn_name,
485 octave_shlib& shl) 485 octave_shlib& shl)
486 { 486 {
487 bool retval = false; 487 bool retval = false;
488 488
489 // We don't need to do anything if this is called because we are in 489 // We don't need to do anything if this is called because we are in
490 // the process of reloading a .oct file that has changed. 490 // the process of reloading a .oct file that has changed.
492 if (! doing_load) 492 if (! doing_load)
493 { 493 {
494 retval = shl.remove (fcn_name); 494 retval = shl.remove (fcn_name);
495 495
496 if (shl.number_of_functions_loaded () == 0) 496 if (shl.number_of_functions_loaded () == 0)
497 octave_mex_file_list::remove (shl); 497 octave_mex_file_list::remove (shl);
498 } 498 }
499 499
500 return retval; 500 return retval;
501 } 501 }
502 502
503 octave_function * 503 octave_function *
504 octave_dynamic_loader::load_oct (const std::string& fcn_name, 504 octave_dynamic_loader::load_oct (const std::string& fcn_name,
505 const std::string& file_name, 505 const std::string& file_name,
506 bool relative) 506 bool relative)
507 { 507 {
508 return (instance_ok ()) 508 return (instance_ok ())
509 ? instance->do_load_oct (fcn_name, file_name, relative) : 0; 509 ? instance->do_load_oct (fcn_name, file_name, relative) : 0;
510 } 510 }
511 511
512 octave_function * 512 octave_function *
513 octave_dynamic_loader::load_mex (const std::string& fcn_name, 513 octave_dynamic_loader::load_mex (const std::string& fcn_name,
514 const std::string& file_name, 514 const std::string& file_name,
515 bool relative) 515 bool relative)
516 { 516 {
517 return (instance_ok ()) 517 return (instance_ok ())
518 ? instance->do_load_mex (fcn_name, file_name, relative) : 0; 518 ? instance->do_load_mex (fcn_name, file_name, relative) : 0;
519 } 519 }
520 520
521 bool 521 bool
522 octave_dynamic_loader::remove_oct (const std::string& fcn_name, 522 octave_dynamic_loader::remove_oct (const std::string& fcn_name,
523 octave_shlib& shl) 523 octave_shlib& shl)
524 { 524 {
525 return (instance_ok ()) ? instance->do_remove_oct (fcn_name, shl) : false; 525 return (instance_ok ()) ? instance->do_remove_oct (fcn_name, shl) : false;
526 } 526 }
527 527
528 bool 528 bool
529 octave_dynamic_loader::remove_mex (const std::string& fcn_name, 529 octave_dynamic_loader::remove_mex (const std::string& fcn_name,
530 octave_shlib& shl) 530 octave_shlib& shl)
531 { 531 {
532 return (instance_ok ()) ? instance->do_remove_mex (fcn_name, shl) : false; 532 return (instance_ok ()) ? instance->do_remove_mex (fcn_name, shl) : false;
533 } 533 }
534 534
535 std::string 535 std::string