Macro: PROPERTY

Module location: FMACDD line 9834 (view source)

changes: 1. Allow New syntax: Property type Name {dflt} public|private is optional 2. Check placement as follows: 2.1. Must be in class or object 2.2. Cannot be in a child object defined by a class 2.3. If in class, must be in procedure (constructor) 2.4. If in object, must not be in procedure. 3. Check for Property Name conflicts (Get_name conflict) 3.1. If defined as object access - error 3.2. If defined as global method - error 3.3. If defined with different param list - error (already does this)

  #IFSAME !3 PRIVATE
    PROPERTY !1 !$.!2 PUBLIC !4
  #ELSE
    #IFSAME !3 PUBLIC

      // Check property for proper placement
      // 1. Must be in class or object
      // 2. Cannot be in a child object defined by a class
      // 3. If in class, must be in procedure (constructor)
      // 4. If in object, must not be in procedure.

      #IF ((!Zl & 1) = 0)
        #IF (!b & 3 ) // Within class or object? It should be
          #IF ((!b & 3)=3 ) // but not both....Error
            #ERROR 302 Property cannot be defined in an object within a class
          #ELSE
            #IF (!b & 2)        // in-class: Must be within a method (constructor)
              #IF ( (!b & 4)=0) // in-class and not in method...bad
                #ERROR 302 Class Property must be defined within a constructor procedure
              #ENDIF
            #ELSE // in-object: Cannot be in method
              #IF (!b & 4)  // if within object and within method...an error
                #ERROR 302 Object Property should .not. be in a method
              #ENDIF
            #ENDIF
          #ENDIF
        #ELSE
          #ERROR 302 Property can only be defined within a class or object
        #ENDIF
      #ENDIF

      #IF (!b & 1 ) // if within object
        !A [] CLONE$CLASS     // Create a new class
      #ENDIF

      #IF ( (!Zl & 1)=0)
        #IFSAME FN$!2  __F__
          #ERROR 4330 !2 is an internal function name
        #ENDIF
      #ENDIF

      // Check for GET_ name conflicts as follows:
      //  1. If defined as object access - error
      //  2. If defined as global method - error
      //  3. If defined with different param list - error
      #IFDEF GET_!2
        #IF (GET_!2>$40000000)
          #ERROR 4332 !1 is already defined as an object name
        #ELSE
          #IF (GET_!2<0)
            #ERROR 4332 !2 is already defined as a global function
          #ENDIF
          // if >0 and less that $4000000 it is a valid address if
          // if registers ok
        #ENDIF
      #ELSE
        MESSAGE$ADDRESS GET_!2
      #ENDIF

      #DATA           // Start the property

      #DPUSH GET_!2       // Push the get property id
      #FREG GET_!2 RETURNS !1
      MESSAGE$ADDRESS SET_!2
      #DPUSH SET_!2       // Push the set property id
      #DTYPE Q$ !1        // get the property type in q
      #DPUSH |CI!q        // push the type
      #IF (!0 > 3)
        #DPUSH !4
      #ELSE                // 10/30/1997: If no default param is passed force
        #IFSAME !1 STRING  // a default value. String types require
          #DPUSH |CS''     // a string, all others are numeric. This
        #ELSE              // fixes a problem in the runtime where
          #DPUSH |CI0      // dates and numbers did not initialize properly
        #ENDIF             // when no initial param was passed in the command
      #ENDIF
      !A [] CREATE$PROPERTY |CI0 |VL
    #ELSE
      // this supports syntax of "property Integer Prop 10"
      PROPERTY !1 !2 PUBLIC !3
    #ENDIF
  #ENDIF