ov-dld-fcn.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include "oct-shlib.h"
00028 
00029 #include <defaults.h>
00030 #include "dynamic-ld.h"
00031 #include "error.h"
00032 #include "oct-obj.h"
00033 #include "ov-dld-fcn.h"
00034 #include "ov.h"
00035 
00036 DEFINE_OCTAVE_ALLOCATOR (octave_dld_function);
00037 
00038 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_dld_function,
00039                                      "dynamically-linked function",
00040                                      "dynamically-linked function");
00041 
00042 
00043 octave_dld_function::octave_dld_function
00044   (octave_builtin::fcn ff, const octave_shlib& shl,
00045    const std::string& nm, const std::string& ds)
00046   : octave_builtin (ff, nm, ds), sh_lib (shl)
00047 {
00048   mark_fcn_file_up_to_date (time_parsed ());
00049 
00050   std::string file_name = fcn_file_name ();
00051 
00052   system_fcn_file
00053     = (! file_name.empty ()
00054        && Voct_file_dir == file_name.substr (0, Voct_file_dir.length ()));
00055 }
00056 
00057 octave_dld_function::~octave_dld_function (void)
00058 {
00059   octave_dynamic_loader::remove_oct (my_name, sh_lib);
00060 }
00061 
00062 std::string
00063 octave_dld_function::fcn_file_name (void) const
00064 {
00065   return sh_lib.file_name ();
00066 }
00067 
00068 octave_time
00069 octave_dld_function::time_parsed (void) const
00070 {
00071   return sh_lib.time_loaded ();
00072 }
00073 
00074 // Note: this wrapper around the octave_dld_function constructor is
00075 //       necessary to work around a MSVC limitation handling in
00076 //       virtual destructors that prevents unloading a dynamic module
00077 //       before *all* objects (of class using a virtual dtor) have
00078 //       been fully deleted; indeed, MSVC attaches auto-generated code
00079 //       (scalar deleting destructor) to objects created in a dynamic
00080 //       module, and this code will be executed in the dynamic module
00081 //       context at object deletion; unloading the dynamic module
00082 //       before objects have been deleted will make the "delete" code
00083 //       of objects to point to an invalid code segment.
00084 
00085 octave_dld_function*
00086 octave_dld_function::create (octave_builtin::fcn ff, const octave_shlib& shl,
00087                              const std::string& nm, const std::string& ds)
00088 {
00089   return new octave_dld_function (ff, shl, nm, ds);
00090 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines