Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PIRC: Really use headerizer

git-svn-id: https://svn.parrot.org/parrot/trunk@44007 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit d5a8e078d2eac3c92344414aea6ae7f685d5f9e7 1 parent 2e43780
@bacek bacek authored
Showing with 128 additions and 39 deletions.
  1. +21 −12 src/pirmacro.c
  2. +107 −27 src/pirmacro.h
View
33 src/pirmacro.c
@@ -9,7 +9,7 @@
#include "pircompiler.h"
#include "parrot/parrot.h"
-/* HEADERIZER HFILE: none */
+/* HEADERIZER HFILE: compilers/pirc/src/pirmacro.h */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
@@ -50,8 +50,9 @@ PARROT_MALLOC
PARROT_IGNORABLE_RESULT
PARROT_CAN_RETURN_NULL
macro_def *
-new_macro(macro_table * const table, char const * const name, int lineno, int takes_args,
- unsigned initsize)
+new_macro(ARGIN(macro_table * const table),
+ ARGIN(char const * const name), int lineno, int takes_args,
+ unsigned initsize)
{
macro_def *macro = (macro_def *)mem_sys_allocate(sizeof (macro_def));
@@ -96,7 +97,8 @@ new_macro_param(ARGIN(char const * const value))
/*
-=item C<void add_macro_param(macro_def * const macro, char const * const name)>
+=item C<void add_macro_param(ARGIN*macro_def * const macro), char const * const
+name)>
Add a macro parameter by name of C<name> to the macro definition C<macro>.
@@ -104,7 +106,8 @@ Add a macro parameter by name of C<name> to the macro definition C<macro>.
*/
void
-add_macro_param(macro_def * const macro, char const * const name)
+add_macro_param(ARGIN*macro_def * const macro),
+ ARGIN(char const * const name))
{
macro_param *param = new_macro_param(name);
param->next = macro->parameters;
@@ -124,8 +127,9 @@ const is entered in the macro_table C<table>
*/
void
-new_macro_const(macro_table * const table, char const * const name, char const * const value,
- int lineno)
+new_macro_const(ARGIN(macro_table * const table),
+ ARGIN(char const * const name),
+ ARGIN(char const * const value), int lineno)
{
/* macro constants are just macros, but they have no body; the value is already
* parsed and allocated in memory.
@@ -199,7 +203,9 @@ beforehand how much space we need in the buffer due to the var. arg. list.
*/
void
-store_macro_string(macro_def * const macro, char const * const str, ...)
+store_macro_string(ARGIN(macro_def * const macro),
+ ARGIN(char const * const str),
+ ...)
{
va_list arg_ptr;
@@ -228,7 +234,8 @@ NULL is returned.
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
macro_def *
-find_macro(macro_table * const table, char const * const name)
+find_macro(ARGIN(macro_table * const table),
+ ARGIN(char const * const name))
{
macro_def *iter = table->definitions;
@@ -289,7 +296,7 @@ Free resources allocated for the macro_table C<table>.
*/
void
-delete_macro_table(macro_table * table)
+delete_macro_table(ARGMOD(macro_table * table))
{
mem_sys_free(table);
}
@@ -305,7 +312,8 @@ Declare C<name> as a C<.macro_local> for the macro definition C<macro>.
*/
void
-declare_macro_local(macro_def * const macro, char const * const name)
+declare_macro_local(ARGIN(macro_def * const macro),
+ ARGIN(char const * const name))
{
macro_param * param = new_macro_param(name);
param->next = macro->macrolocals;
@@ -325,7 +333,8 @@ definition C<macro>.
*/
PARROT_WARN_UNUSED_RESULT
int
-is_macro_local(macro_def * const macro, char const * const name)
+is_macro_local(ARGIN(macro_def * const macro),
+ ARGIN(char const * const name))
{
macro_param *iter = macro->macrolocals;
View
134 src/pirmacro.h
@@ -80,33 +80,113 @@ typedef struct macro_table {
} macro_table;
-
-
-
-macro_def *new_macro(macro_table * const table, char const * const name, int lineno,
- int takes_args, unsigned initsize);
-
-void add_macro_param(macro_def * const macro, char const * const name);
-
-void new_macro_const(macro_table * const table, char const * const name,
- char const * const value, int lineno);
-
-
-macro_def *find_macro(macro_table * const table, char const * const name);
-
-macro_table * new_macro_table(macro_table * const current);
-
-void store_macro_char(macro_def * const macro, char c) ;
-
-void store_macro_string(macro_def * const macro, char const * const str, ...);
-
-macro_param * new_macro_param(char const * const value);
-
-void declare_macro_local(macro_def * const macro, char const * const name);
-
-int is_macro_local(macro_def * const macro, char const * const name);
-
-void delete_macro_table(macro_table * table);
+/* HEADERIZER BEGIN: compilers/pirc/src/pirmacro.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+
+void add_macro_param(
+ ARGIN*macro_def * const macro),
+ ARGIN(char const * const name))
+ __attribute__nonnull__(2);
+
+void declare_macro_local(
+ ARGIN(macro_def * const macro),
+ ARGIN(char const * const name))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void delete_macro_table(ARGMOD(macro_table * table))
+ __attribute__nonnull__(1)
+ FUNC_MODIFIES(* table);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+macro_def * find_macro(
+ ARGIN(macro_table * const table),
+ ARGIN(char const * const name))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+int is_macro_local(
+ ARGIN(macro_def * const macro),
+ ARGIN(char const * const name))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_MALLOC
+PARROT_IGNORABLE_RESULT
+PARROT_CAN_RETURN_NULL
+macro_def * new_macro(
+ ARGIN(macro_table * const table),
+ ARGIN(char const * const name),
+ int lineno,
+ int takes_args,
+ unsigned initsize)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void new_macro_const(
+ ARGIN(macro_table * const table),
+ ARGIN(char const * const name),
+ ARGIN(char const * const value),
+ int lineno)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+PARROT_MALLOC
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+macro_param * new_macro_param(ARGIN(char const * const value))
+ __attribute__nonnull__(1);
+
+PARROT_MALLOC
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+macro_table * new_macro_table(ARGIN(macro_table * const current))
+ __attribute__nonnull__(1);
+
+void store_macro_char(ARGIN(macro_def * const macro), char c)
+ __attribute__nonnull__(1);
+
+void store_macro_string(
+ ARGIN(macro_def * const macro),
+ ARGIN(char const * const str),
+ ...)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+#define ASSERT_ARGS_add_macro_param __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_declare_macro_local __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(macro) \
+ , PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_delete_macro_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(table))
+#define ASSERT_ARGS_find_macro __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(table) \
+ , PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_is_macro_local __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(macro) \
+ , PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_new_macro __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(table) \
+ , PARROT_ASSERT_ARG(name))
+#define ASSERT_ARGS_new_macro_const __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(table) \
+ , PARROT_ASSERT_ARG(name) \
+ , PARROT_ASSERT_ARG(value))
+#define ASSERT_ARGS_new_macro_param __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(value))
+#define ASSERT_ARGS_new_macro_table __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(current))
+#define ASSERT_ARGS_store_macro_char __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(macro))
+#define ASSERT_ARGS_store_macro_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(macro) \
+ , PARROT_ASSERT_ARG(str))
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+/* HEADERIZER END: compilers/pirc/src/pirmacro.c */
#endif /* PARROT_PIR_PIRMACRO_H_GUARD */
Please sign in to comment.
Something went wrong with that request. Please try again.