From d7a22185d5c2d30fae5c2b22824aa48c18dc47ee Mon Sep 17 00:00:00 2001 From: Jean-Francois Lefebvre Date: Fri, 19 Jun 2009 09:00:16 +0000 Subject: [PATCH] 2009-06-19 10:56 UTC+0200 Jean lefebvre (jfl at mafact dot com) * vm/runner.c FIXED ; ../../runner.c:413: error: '_HB_SYMB' undeclared (first use in this function) + include/hbhrb.ch: HB_HRBLOAD() mode #define new file + tests/testhrb.prg: test program fro new params + tests/exthrb.prg: test program to be compiled as .HRB using /gh option --- harbour/ChangeLog | 9 +++ harbour/include/hbhrb.ch | 119 +++++++++++++++++++++++++++++++++++++ harbour/source/vm/runner.c | 4 +- harbour/tests/exthrb.prg | 13 ++++ harbour/tests/testhrb.prg | 55 +++++++++++++++++ 5 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 harbour/include/hbhrb.ch create mode 100644 harbour/tests/exthrb.prg create mode 100644 harbour/tests/testhrb.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0bd0e6068c..540b9cbe24 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-19 10:56 UTC+0200 Jean lefebvre (jfl at mafact dot com) + * vm/runner.c + FIXED ; + ../../runner.c:413: error: '_HB_SYMB' undeclared (first use in this function) + + include/hbhrb.ch: HB_HRBLOAD() mode #define new file + + tests/testhrb.prg: test program fro new params + + tests/exthrb.prg: test program to be compiled as .HRB using /gh option + 2009-06-19 00:36 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/vm/runner.c * Formatted. @@ -51,6 +59,7 @@ * Reverted to r11403 for Pritpal. (now for real) +>>>>>>> .r11422 2009-06-18 21:18 UTC+0200 Jean lefebvre (jfl at mafact dot com) * vm/runner.c + Added options to HB_HRBLOAD() : diff --git a/harbour/include/hbhrb.ch b/harbour/include/hbhrb.ch new file mode 100644 index 0000000000..4ae60fa742 --- /dev/null +++ b/harbour/include/hbhrb.ch @@ -0,0 +1,119 @@ +/* + * $Id: hbhrb.ch 0001 2009-06-18 20:20:54 j. Lefebvre $ + */ + +/* + * Harbour Project source code: + * Header file for box drawing + * + * Copyright 1999 {list of individual authors and e-mail addresses} + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +/* + * $Id: std.ch 11185 2009-05-31 16:42:46Z petr_ch $ + */ + +/* + * Harbour Project source code: + * + * + * Copyright 2006 Przemyslaw Czerpak + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#define HB_HRB_DEFAULT 0 // do not overwrite any functions, ignore + // public HRB functions if functions with + // the same names already exist in HVM + +#define HB_HRB_KEEP_LOCAL 1 // do not overwrite any functions + // but keep local references, so + // if module has public function FOO and + // this function exists also in HVM + // then the function in HRB is converted + // to STATIC one + +#define HB_HRB_KEEP_GLOBAL 2 // overload all existing public functions + // will disable HB_HRBUNLOAD() + diff --git a/harbour/source/vm/runner.c b/harbour/source/vm/runner.c index 23577b8467..5286728861 100644 --- a/harbour/source/vm/runner.c +++ b/harbour/source/vm/runner.c @@ -410,8 +410,8 @@ static PHRB_BODY hb_hrbLoad( char* szHrbBody, ULONG ulBodySize, USHORT suMode ) pHrbBody->pDynFunc = pDynFunc; /* ok to much space reserved but ... */ - pSymFuncExe = ( PHB_SYMB ) hb_xgrab( pHrbBody->ulFuncs * sizeof( _HB_SYMB ) ); - memset( pSymFuncExe, 0, pHrbBody->ulFuncs * sizeof( _HB_SYMB ) ); + pSymFuncExe = ( PHB_SYMB ) hb_xgrab( pHrbBody->ulFuncs * sizeof( HB_SYMB ) ); + memset( pSymFuncExe, 0, pHrbBody->ulFuncs * sizeof( HB_SYMB ) ); for( ul = 0; ul < pHrbBody->ulFuncs; ul++ ) { diff --git a/harbour/tests/exthrb.prg b/harbour/tests/exthrb.prg new file mode 100644 index 0000000000..4132522587 --- /dev/null +++ b/harbour/tests/exthrb.prg @@ -0,0 +1,13 @@ +// +// $Id: extmsg.prg 0001 2009-06-18 20:20:41 j. lefebvre $ +// + +// see also testhrb.prg + + +Function Msg() +? "Function called from HRB file" +Return .T. + +Function msg2() +Return Msg() diff --git a/harbour/tests/testhrb.prg b/harbour/tests/testhrb.prg new file mode 100644 index 0000000000..799861fc1a --- /dev/null +++ b/harbour/tests/testhrb.prg @@ -0,0 +1,55 @@ +// +// $Id: testhrb.prg 0001 2009-06-18 20:20:41 j. lefebvre $ +// + +// see also exthrb.prg + + +#include "hbhrb.ch" + +Procedure Main(x) +Local pHrb, cExe := "Msg2()", n + + n:=iif(x==NIL,0,val(x)) + + ? "calling Msg ... From exe here !" + Msg() + ? "=========================" + +// ? "Loading('Exthrb.hrb' )" +// pHrb := hb_HrbLoad("Exthrb.hrb" ) + +// ? "Loading(HB_HRB_DEFAULT,'Exthrb.hrb' )" +// pHrb := hb_HrbLoad(HB_HRB_DEFAULT,"Exthrb.hrb" ) + +// ? "Loading(HB_HRB_KEEP_LOCAL,'Exthrb.hrb' )" +// pHrb := hb_HrbLoad(HB_HRB_KEEP_LOCAL,"Exthrb.hrb" ) + + ? "Loading("+iif(n=0,"HB_HRB_DEFAULT",iif(n=1,"HB_HRB_KEEP_LOCAL","HB_HRB_KEEP_GLOBAL"))+",'Exthrb.hrb' )" + pHrb := hb_HrbLoad(n,"Exthrb.hrb" ) + + ? "=========================" + + ? "calling Msg ... DEFAULT=From exe, LOCAL=From exe, GLOBAL=From HRB" + Msg() + ? "=========================" + + ? "calling Msg ... DEFAULT=From exe, LOCAL=From HRB, GLOBAL=From HRB" + &cExe // + ? "=========================" + + hb_HrbUnload( pHrb ) // should do nothing in case of GLOBAL + + ? "calling Msg ... DEFAULT=From exe, LOCAL=From exe, GLOBAL=From HRB" + Msg() // test unload protection when using GLOBAL ... then Hrb not anymore unloadable + ? "=========================" + + ? "END" + +Return + + +Function Msg() +? "Function called from Exe" +Return .T. +