I just noticed that the class designations "Protected" and "Hidden" are not working in xHarbour 1.2.1. Both Protected and Hidden vars ARE visible outside the class and they should not be. Below is a simple test program. Can anyone test this under the latest xHarbour for me? Both msgInfo()'s should error out. I note that the preprocessor shows them with different scopes, but they are still visible.
Regards,
James
Test program:
Preprossor output:
Regards,
James
Test program:
/*
Purpose : Test protected and hidden variables in a class
Notes : Neither protected nor hidden vars should be visible outside the class
Compiler: xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6717)
Author : James Bott
Date : 5/1/2013
*/
#include "fivewin.ch"
function main()
local oTest
oTest:= TTest():new()
msgInfo( oTest:cProtectedText,"This should not be visible:" )
msgInfo( oTest:cHiddenText,"This should not be visible:" )
return nil
class TTest
exported:
method new()
protected:
data cProtectedText
hidden:
data cHiddenText
endclass
method new()
::cProtectedText:="Protected text"
::cHiddenText:= "Hidden text"
return selfPreprossor output:
#line 112 "hbclass.ch"
DYNAMIC DivertConstructorCall
DECLARE HBClass New( cName AS String, OPTIONAL SuperParams ) AS CLASS HBClass Create() AS Object Instance() AS Object AddClsMethod( cName AS String, @MethodName(), nScope AS Numeric, n2 AS Numeric, n3 AS Numeric ) AddDelegate( cName AS String, cDelegate AS String, cObject AS String, nScope AS Numeric, lPersistent AS LOGICAL ) AddMultiClsData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String ) AddMultiData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String, x AS LOGICAL, lPer AS LOGICAL ) AddMethod( cName AS String, @MethodName(), nScope AS Numeric, lPersistent AS LOGICAL ) AddInLine( cName AS String, bBlock AS CodeBlock, nScope AS Numeric, lPersistent AS LOGICAL ) AddVirtual( cName AS String ) ModMethod( cName AS String, @MethodName(), nScope AS Numeric, lPersistent AS LOGICAL ) ModClsMethod( cName AS String, @MethodName(), nScope AS Numeric ) ModInline( cName AS String, bBlock AS CodeBlock, nScope AS Numeric, lPersistent AS LOGICAL ) SetOnError( @MethodName() )
#line 86 "c:\fwh\include\fivewin.ch"
EXTERNAL GetProcAdd
EXTERNAL TActiveX
extern errorsys
#line 11 "TTest.prg"
function main()
local oTest
oTest:= TTest():new()
msgInfo( oTest:cProtectedText,"This should not be visible:" )
msgInfo( oTest:cHiddenText,"This should not be visible:" )
return nil
_HB_CLASS TTest ; UTILITY FUNCTION TTest(...); static s_oClass ; local oClassInstance ; local nScope ; nScope := 1 ; if s_oClass == NIL ; s_oClass := IIF(.F.,, HBClass():New( "TTest" , { HBObject():Classh } ) ) ;
nScope := 1
_HB_MEMBER new(); IIF( .F., s_oClass:ModMethod( "new", @TTest_new(), nScope + IIF( .F., 16, 0 ) + IIF( .F., 1024, 0 ), .F. ), s_oClass:AddMethod( "new", @TTest_new(), nScope + IIF( .F., 16, 0 ) + IIF( .F., 1024, 0 ), .F. ));
nScope := 4
_HB_MEMBER { cProtectedText} ; IIF( !.F., s_oClass:AddMultiData(,, nScope + IIF( .F., 32, 0 ), { "cProtectedText" }, .F., .F. ), )
nScope := 8
_HB_MEMBER { cHiddenText} ; IIF( !.F., s_oClass:AddMultiData(,, nScope + IIF( .F., 32, 0 ), { "cHiddenText" }, .F., .F. ), )
; IF .F. ; __clsActive(s_oClass:hClass) ; s_oClass:Refresh() ; ELSE ; s_oClass:Create() ; END ; oClassInstance := __clsInst( s_oClass:hClass ) ; IF __ObjHasMsg( oClassInstance, "InitClass" ); oClassInstance:InitClass( hb_aParams() ) ; END ; ELSE ; oClassInstance := __clsInst( s_oClass:hClass ) ; END ; IF PCount() > 0 ; DIVERT TO (@DivertConstructorCall()) OF s_oClass ; END ; RETURN oClassInstance AS CLASS TTest ;
UTILITY STATIC function TTest_new() ; local Self AS CLASS TTest := QSelf() AS CLASS TTest
::cProtectedText:="Protected text"
::cHiddenText:= "Hidden text"
return selfFWH 18.05/xHarbour 1.2.3/BCC7/Windows 10