==========================
methodmap with inheritance
==========================

methodmap AdtArray < Handle {}

---

(source_file
  (methodmap
    name: (identifier)
    inherits: (identifier)
  )
)


=======================
methodmap with nullable
=======================

methodmap AdtArray __nullable__ {}

---

(source_file
  (methodmap
    name: (identifier)
  )
)


===========================
methodmap with method alias
===========================

methodmap Handle {
    public Clone() = CloneHandle;
    public Close() = CloseHandle;
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_alias
      name: (identifier)
      function: (identifier)
    )
    (methodmap_alias
      name: (identifier)
      function: (identifier)
    )
  )
)


============================
methodmap with native method
============================

methodmap AdminId {
  public native void GetUsername(char[] name, int maxlength);
  public native bool GetPassword(char[] buffer="", int maxlength=0);
  public native bool Format(const char[] format, any ...);
	public static native Cookie Find(const char[] name);
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_native
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
        )
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
        )
      )
    )
    (methodmap_native
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
          defaultValue: (string_literal)
        )
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
          defaultValue: (int_literal)
        )
      )
    )
    (methodmap_native
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          storage_class: (variable_storage_class)
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
        )
        (rest_parameter
          type: (type
            (any_type)
          )
        )
      )
    )
    (methodmap_native
      returnType: (type
        (identifier)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          storage_class: (variable_storage_class)
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
        )
      )
    )
  )
)


============================================
methodmap with native con-/destructor method
============================================

methodmap AdminId {
    public native AdminId(int id);
    public native ~AdminId();
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_native_constructor
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
        )
      )
    )
    (methodmap_native_destructor
      name: (identifier)
    )
  )
)


============================
methodmap with inline method
============================

methodmap PerkContainerIter {
    public bool DisplayVoteToAll(int time, int flags=0) {
        return false;
    }

    public void Format(const char[] format, any ...) {
    }

    public char[] Format(const char[] format, any ...) {
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_method
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
        )
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
          defaultValue: (int_literal)
        )
      )
      body: (block
        (return_statement
          expression: (bool_literal)
        )
      )
    )
    (methodmap_method
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          storage_class: (variable_storage_class)
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
        )
        (rest_parameter
          type: (type
            (any_type)
          )
        )
      )
      body: (block)
    )
    (methodmap_method
      returnType: (type
        (builtin_type)
      )
      returnType: (dimension)
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          storage_class: (variable_storage_class)
          type: (array_type
            (type
              (builtin_type)
            )
            (dimension)
          )
          name: (identifier)
        )
        (rest_parameter
          type: (type
            (any_type)
          )
        )
      )
      body: (block)
    )
  )
)


============================================
methodmap with inline con-/destructor method
============================================

methodmap AdminId {
    public AdminId(int id) {
        return id;
    }
    public ~AdminId() {
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_method_constructor
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
        )
      )
      body: (block
        (return_statement
          expression: (identifier)
        )
      )
    )
    (methodmap_method_destructor
      name: (identifier)
      body: (block)
    )
  )
)


===================================
methodmap with static inline method
===================================

methodmap PerkContainerIter {
    public static bool DisplayVoteToAll(int time, int flags=0) {
        return false;
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_method
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
        )
        (parameter_declaration
          type: (type
            (builtin_type)
          )
          name: (identifier)
          defaultValue: (int_literal)
        )
      )
      body: (block
        (return_statement
          expression: (bool_literal)
        )
      )
    )
  )
)


===================================
methodmap with inline method - this
===================================

methodmap MyValue {
    public int JustTheValue() {
        return this;
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_method
      returnType: (type
        (builtin_type)
      )
      name: (identifier)
      parameters: (parameter_declarations)
      body: (block
        (return_statement
          expression: (this)
        )
      )
    )
  )
)


===============================
methodmap with property - alias
===============================

methodmap AdtArray {
    property int Size {
        public get() = GetArraySize;
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_property
      type: (type
        (builtin_type)
      )
      name: (identifier)
      (methodmap_property_alias
        (methodmap_property_getter)
        function: (identifier)
      )
    )
  )
)


================================
methodmap with property - native
================================

methodmap Player {
  property int Health {
    public native get();
    public native set(int health);
  }

  // Connect timeout in seconds. Defaults to 10.
	#pragma deprecated Use HTTPRequest.ConnectTimeout instead.
	property int ConnectTimeout {
		public native get();
		public native set(const int connectTimeout);
	}
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_property
      type: (type
        (builtin_type)
      )
      name: (identifier)
      (methodmap_property_native
        (methodmap_property_getter)
      )
      (methodmap_property_native
        (methodmap_property_setter
          parameter: (parameter_declaration
            type: (type
              (builtin_type)
            )
            name: (identifier)
          )
        )
      )
    )
    (comment)
    (preproc_pragma
      (preproc_arg)
    )
    (methodmap_property
      type: (type
        (builtin_type)
      )
      name: (identifier)
      (methodmap_property_native
        (methodmap_property_getter)
      )
      (methodmap_property_native
        (methodmap_property_setter
          parameter: (parameter_declaration
            storage_class: (variable_storage_class)
            type: (type
              (builtin_type)
            )
            name: (identifier)
          )
        )
      )
    )
  )
)


=======================================
methodmap with property - inline method
=======================================

methodmap Player {
    property bool Good {
        public get() {
            return true;
        }
        public set(bool bVal) {
            return;
        }
    }
}

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_property
      type: (type
        (builtin_type)
      )
      name: (identifier)
      (methodmap_property_method
        (methodmap_property_getter)
        body: (block
          (return_statement
            expression: (bool_literal)
          )
        )
      )
      (methodmap_property_method
        (methodmap_property_setter
          parameter: (parameter_declaration
            type: (type
              (builtin_type)
            )
            name: (identifier)
          )
        )
        body: (block
          (return_statement)
        )
      )
    )
  )
)


==============================
methodmap - optional semicolon
==============================

methodmap Handle {
    public Clone() = CloneHandle;
    public Close() = CloseHandle;
};

---

(source_file
  (methodmap
    name: (identifier)
    (methodmap_alias
      name: (identifier)
      function: (identifier)
    )
    (methodmap_alias
      name: (identifier)
      function: (identifier)
    )
  )
)
