<commit_before>//
// Copyright (c) XSharp B.V.  All Rights Reserved.  
// Licensed under the Apache License, Version 2.0.  
// See License.txt in the project root for license information.
//

USING System.Diagnostics
USING System.Reflection
USING System.Runtime.Remoting
USING System.Runtime.InteropServices
USING System.Runtime.CompilerServices
USING XSharp.Internal
USING System.Collections.Generic
/// <summary>VO Compatible OLE Automation class</summary>
[AllowLateBinding];
[DebuggerDisplay( "Type= {__ComObject}", Type := "OleAutoObject" )];
CLASS XSharp.OleAutoObject IMPLEMENTS IDynamicProperties
	PROTECTED oComObject AS OBJECT
	PROTECTED lOk        AS LOGIC
	PROTECTED _liFuncs   AS LONG
	PROTECTED _liVars    AS LONG
	PROTECTED oType      AS System.Type	
	PROTECTED lDateTimeAsDate   AS LOGIC
	
	
	#region Constructors
	INTERNAL CONSTRUCTOR
		_liFuncs                := _liVars := -1 
		lOk                     := FALSE
		oComObject              := NULL
		oType                   := NULL 
		SELF:lDateTimeAsDate    := OleDateTimeAsDate()
		RETURN
			
   /// <summary>Construct an OleAutoObject</summary>
	CONSTRUCTOR(cProgId AS STRING)
		SELF()
		oComObject        := OleCreateObject(cProgId)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
			
		RETURN
			
   /// <summary>Construct an OleAutoObject</summary>
	CONSTRUCTOR(cProgId AS STRING, fRotCheck AS LOGIC)
		SELF()
		IF fRotCheck
			oComObject := OleGetObject(cProgId)
		ENDIF
		IF oComObject == NULL
			oComObject := OleCreateObject(cProgId)
		ENDIF
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN
			
			
	// Builds an OleAutoObject on Any OBJECT (including another AutoObject)
   /// <summary>Construct an OleAutoObject</summary> 
	CONSTRUCTOR(oObject AS OBJECT)
		SELF()
		oComObject :=  OleUnWrapObject(oObject)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
			
		RETURN
			
		// Builds an OleAutoObject on Any OBJECT (including another AutoObject). Type already known
   /// <summary>Construct an OleAutoObject</summary> 
	CONSTRUCTOR(oObject AS OBJECT, _type AS System.Type)
		SELF()
		oComObject	:=  OleUnWrapObject(oObject)
		oType		:= _type
		lOk			:= oComObject != NULL
		RETURN
			
	#endregion
		
	#region No..() EntryPoints
			
	// ? oObject:Property
	    /// <exclude />   
    VIRTUAL METHOD NoIvarGet(cName AS STRING ) AS USUAL 
		LOCAL oRet AS OBJECT
		oRet := OleAutoObject.__OleIvarGet(oComObject,oType, cName, NULL)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)
			
		// oObject:Property := Value
	    /// <exclude />   
	VIRTUAL METHOD NoIvarPut(cName AS STRING, uValue AS USUAL) AS VOID
		OleAutoObject.__OleIVarPut(oComObject, oType, cName , uValue, NULL)
		RETURN 

    VIRTUAL METHOD GetPropertyNames() AS STRING[]
        var props := oType:GetProperties()
        var names := List<string>{}
        FOREACH VAR prop in props
            names:Add(prop:Name)
        NEXT
        return names:ToArray()

	    /// <exclude />   
	METHOD NoMethod( ) AS USUAL CLIPPER
		LOCAL cName AS STRING
		LOCAL args  AS USUAL[]
		LOCAL nArg, nArgs  AS INT
		LOCAL oRet  AS OBJECT
		nArgs := PCOUNT()
        IF RuntimeState.Dialect == XSharpDialect.Vulcan
		    cName := NoMethod()
		    args  := USUAL[]{nArgs-1}
		    FOR nArg := 2 TO nArgs
			    args[nArg-1] :=  _GetMParam(nArg)
            NEXT
        ELSE
		    cName := NoMethod()
		    args  := USUAL[]{nArgs}
		    FOR nArg := 1 TO nArgs
			    args[nArg] :=  _GetMParam(nArg)
            NEXT
        ENDIF
		oRet := OleAutoObject.OleSend(oComObject, oType, cName, args)
			<commit_msg>[Runtime] Fix to the OleAutoObject class, so its own properties (fInit, dwVars, dwFuncs) can be read.<commit_after>//
// Copyright (c) XSharp B.V.  All Rights Reserved.  
// Licensed under the Apache License, Version 2.0.  
// See License.txt in the project root for license information.
//

USING System.Diagnostics
USING System.Reflection
USING System.Runtime.Remoting
USING System.Runtime.InteropServices
USING System.Runtime.CompilerServices
USING XSharp.Internal
USING System.Collections.Generic
/// <summary>VO Compatible OLE Automation class</summary>
[AllowLateBinding];
[DebuggerDisplay( "Type= {__ComObject}", Type := "OleAutoObject" )];
CLASS XSharp.OleAutoObject IMPLEMENTS IDynamicProperties
	PROTECTED oComObject AS OBJECT
	PROTECTED lOk        AS LOGIC
	PROTECTED _liFuncs   AS LONG
	PROTECTED _liVars    AS LONG
	PROTECTED oType      AS System.Type	
	PROTECTED lDateTimeAsDate   AS LOGIC
	
	
	#region Constructors
	INTERNAL CONSTRUCTOR
		_liFuncs                := _liVars := -1 
		lOk                     := FALSE
		oComObject              := NULL
		oType                   := NULL 
		SELF:lDateTimeAsDate    := OleDateTimeAsDate()
		RETURN
			
   /// <summary>Construct an OleAutoObject</summary>
	CONSTRUCTOR(cProgId AS STRING)
		SELF()
		oComObject        := OleCreateObject(cProgId)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN
			
   /// <summary>Construct an OleAutoObject</summary>
	CONSTRUCTOR(cProgId AS STRING, fRotCheck AS LOGIC)
		SELF()
		IF fRotCheck
			oComObject := OleGetObject(cProgId)
		ENDIF
		IF oComObject == NULL
			oComObject := OleCreateObject(cProgId)
		ENDIF
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN
			
			
	// Builds an OleAutoObject on Any OBJECT (including another AutoObject)
   /// <summary>Construct an OleAutoObject</summary> 
	CONSTRUCTOR(oObject AS OBJECT)
		SELF()
		oComObject :=  OleUnWrapObject(oObject)
		lOk := oComObject != NULL
		IF lOk
			oType := oComObject:GetType()
		ENDIF
		RETURN
			
		// Builds an OleAutoObject on Any OBJECT (including another AutoObject). Type already known
   /// <summary>Construct an OleAutoObject</summary> 
	CONSTRUCTOR(oObject AS OBJECT, _type AS System.Type)
		SELF()
		oComObject	:=  OleUnWrapObject(oObject)
		oType		:= _type
		lOk			:= oComObject != NULL
		RETURN
			
	#endregion
		
	#region No..() EntryPoints
			
	    /// <exclude />
    PRIVATE METHOD GetOurFieldInfo(cName AS STRING, result OUT USUAL) AS LOGIC
        SWITCH cName:ToLower()
        CASE "finit"
            result := SELF:lOk
            return TRUE
        CASE "dwfuncs"
            result := SELF:_liFuncs
            return TRUE
        CASE "dwVars"
            result := SELF:_liVars
            return TRUE
        OTHERWISE
            result := NIL
            RETURN FALSE
        END SWITCH 

    PRIVATE METHOD SetOurFieldInfo(cName AS STRING, newvalue AS USUAL) AS LOGIC
        SWITCH cName:ToLower()
        CASE "dwfuncs"
            SELF:_liFuncs := newvalue
            return TRUE
        END SWITCH
        RETURN FALSE
            
	/// <exclude />
    // ? oObject:Property
    VIRTUAL METHOD NoIvarGet(cName AS STRING ) AS USUAL 
		LOCAL oRet AS OBJECT
        IF SELF:GetOurFieldInfo(cName, OUT VAR result)
            return result
        ENDIF
		oRet := OleAutoObject.__OleIvarGet(oComObject,oType, cName, NULL)
		RETURN OleAutoObject.OleWrapObject(oRet, lDateTimeAsDate)
			
		// oObject:Property := Value
	    /// <exclude />   
	VIRTUAL METHOD NoIvarPut(cName AS STRING, uValue AS USUAL) AS VOID
        IF SELF:SetOurFieldInfo(cName, uValue)
            return 
        ENDIF
		OleAutoObject.__OleIVarPut(oComObject, oType, cName , uValue, NULL)
		RETURN 

    VIRTUAL METHOD GetPropertyNames() AS STRING[]
        var props := oType:GetProperties()
        var names := List<string>{}
        FOREACH VAR prop in props
            names:Add(prop:Name)
        NEXT
        return names:ToArray()

	    /// <exclude />   
	METHOD NoMethod( ) AS USUAL CLIPPER
		LOCAL cName AS STRING
		LOCAL args  AS USUAL[]
		LOCAL nArg, nArgs  AS INT
		LOCAL oRet  AS OBJECT
		nArgs := PCOUNT()
		cName := NoMethod()
        IF RuntimeState.Dialect == XSharpDialect.Vulcan
		    args  := USUAL[]{nArgs-1}
		    FOR nArg := 2 TO nArgs
			    args[nArg-1] :=  _GetMParam(nArg)
            NEXT
        ELSE
		    args  := USUAL[]{nArgs}
		    FOR nArg := 1 TO nArgs
			    args[nArg] :=  _GetMParam(nArg)
            NEXT
        ENDIF
		oRet := OleAutoObject.OleSend(oComObject, oType, cName, args)
{'fraction_non_alphanumeric': 0.08714703018500487, 'fraction_numerical': 0.0017039922103213243, 'mean_word_length': 2.621419127368885, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1201674', 'n_tokens_mistral': 3026, 'n_tokens_neox': 2662, 'n_words': 726}