Patchwork [MELT] split_string_* functions now take a value

login
register
mail settings
Submitter Romain Geissler
Date July 28, 2011, 10:56 a.m.
Message ID <CAF+LTef+D+Fe-L+34y+Z177J6_Ds6v5qtQwGBfV=piMAmLWemw@mail.gmail.com>
Download mbox | patch
Permalink /patch/107242/
State New
Headers show

Comments

Romain Geissler - July 28, 2011, 10:56 a.m.
Hi,

I changed the argument type for the cs argument in split_string functions.
Indeed, there is no way to access the boxed string from a value, and sometimes
we can't avoid working with boxed strings. As we can box a :cstring in a value,
split_string_* functions are usable in all cases.

Find attach the patch. Please note that it is a git patch, thus it should be
applied with git-apply or git-am.

Romain.
Romain Geissler - Aug. 2, 2011, 8:12 a.m.
Ping for Pierre !

2011/7/28 Romain Geissler <romain.geissler@gmail.com>:
> Hi,
>
> I changed the argument type for the cs argument in split_string functions.
> Indeed, there is no way to access the boxed string from a value, and sometimes
> we can't avoid working with boxed strings. As we can box a :cstring in a value,
> split_string_* functions are usable in all cases.
>
> Find attach the patch. Please note that it is a git patch, thus it should be
> applied with git-apply or git-am.
>
> Romain.
>
Basile Starynkevitch - Aug. 2, 2011, 8:36 a.m.
On Thu, 28 Jul 2011 12:56:59 +0200
Romain Geissler <romain.geissler@gmail.com> wrote:
> 
> I changed the argument type for the cs argument in split_string functions.
> Indeed, there is no way to access the boxed string from a value, and sometimes
> we can't avoid working with boxed strings. As we can box a :cstring in a value,
> split_string_* functions are usable in all cases.


The :doc strings are wrong. Please use capitals for macrovariables in
macrostrings and try using appropriate C style or indentation so 

+#{meltgc_new_split_string (melt_string_str ($CS), ' ', (melt_ptr_t) $DIS)}#)
instead of
+#{meltgc_new_split_string(melt_string_str($cs), ' ', (melt_ptr_t) $dis)}#)


Cheers.
Romain Geissler - Aug. 2, 2011, 8:46 a.m.
2011/8/2 Basile Starynkevitch <basile@starynkevitch.net>:
> Please use capitals for macrovariables in
> macrostrings

Ok.

Can i have more details about that: is it just a Melt convention or is
it an implementation requirement (in other word, does melt awaits
macrovariables to be upper case ?)

Romain
Basile Starynkevitch - Aug. 2, 2011, 8:52 a.m.
On Tue, 2 Aug 2011 10:46:38 +0200
Romain Geissler <romain.geissler@gmail.com> wrote:

> 2011/8/2 Basile Starynkevitch <basile@starynkevitch.net>:
> > Please use capitals for macrovariables in
> > macrostrings
> 
> Ok.
> 
> Can i have more details about that: is it just a Melt convention or is
> it an implementation requirement (in other word, does melt awaits
> macrovariables to be upper case ?)


Just a coding (social) convention. Macrovariables are very important, and my editor
(emacs) and mode (lisp-mode) don't highlight them.

Since macrovariables are really MELT symbols, their case don't matter (the MELT reader
force them to upper cases). But they are more human-readable in upper cases.

Cheers.

Patch

From 41290f00ee0cb6bdeaf2254b0d6a25ebddf23a65 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@st.com>
Date: Thu, 28 Jul 2011 12:43:59 +0200
Subject: [PATCH] split_string_* functions now require a value string instead
 of a :cstring.

---
 gcc/melt/warmelt-base.melt   |   16 ++++++++--------
 gcc/melt/warmelt-outobj.melt |    4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/melt/warmelt-base.melt b/gcc/melt/warmelt-base.melt
index 8a6ff9d..c7eca3e 100644
--- a/gcc/melt/warmelt-base.melt
+++ b/gcc/melt/warmelt-base.melt
@@ -570,25 +570,25 @@  an integer $I if $I is lower than $N.}#
   #{(meltgc_string_hex_md5sum_file_sequence ((melt_ptr_t) $PATHSEQ))}#)
 
 
-(defprimitive split_string_space (dis :cstring cs) :value
+(defprimitive split_string_space (dis cs) :value
   :doc #{Split a cstring $CS into a list of space separated strings of
 discriminant $DIS.}#
-#{meltgc_new_split_string($cs, ' ', (melt_ptr_t) $dis)}#)
+#{meltgc_new_split_string(melt_string_str($cs), ' ', (melt_ptr_t) $dis)}#)
 
-(defprimitive split_string_comma (dis :cstring cs) :value
+(defprimitive split_string_comma (dis cs) :value
   :doc #{Split a cstring $CS into a list of comma separated strings of
 discriminant $DIS.}#
-#{meltgc_new_split_string($cs, ',', (melt_ptr_t) $dis)}#)
+#{meltgc_new_split_string(melt_string_str($cs), ',', (melt_ptr_t) $dis)}#)
 
-(defprimitive split_string_colon (dis :cstring cs) :value
+(defprimitive split_string_colon (dis cs) :value
   :doc #{Split a cstring $CS into a list of colon separated strings of
 discriminant $DIS.}#
-#{meltgc_new_split_string($cs, ':', (melt_ptr_t)$dis)}#)
+#{meltgc_new_split_string(melt_string_str($cs), ':', (melt_ptr_t)$dis)}#)
 
-(defprimitive split_string_equal (dis :cstring cs) :value
+(defprimitive split_string_equal (dis cs) :value
   :doc #{Split a cstring $CS into a list of equal separated strings of
 discriminant $DIS.}#
-#{meltgc_new_split_string($cs, '=', (melt_ptr_t)$dis)}#)
+#{meltgc_new_split_string(melt_string_str($cs), '=', (melt_ptr_t)$dis)}#)
 
 ;;; convert a strbuf into a string
 (defprimitive strbuf2string (dis sbuf) :value
diff --git a/gcc/melt/warmelt-outobj.melt b/gcc/melt/warmelt-outobj.melt
index dd1cdde..df4cf06 100644
--- a/gcc/melt/warmelt-outobj.melt
+++ b/gcc/melt/warmelt-outobj.melt
@@ -4671,7 +4671,7 @@  has basic debug support thru debug_msg, assert_msg..."
 	 (inarg (cond ( progarg 
 			(make_stringconst discr_string progarg))
 		      ( progarglist
-			 (split_string_comma discr_string progarglist)
+			 (split_string_comma discr_string (make_stringconst discr_string progarglist))
 			)
 		      (:else
 		       (errormsg_plain "invalid arg or arglist to translateinit mode")
@@ -5800,7 +5800,7 @@  has basic debug support thru debug_msg, assert_msg..."
   (let ( 
 	(parmodenv (parent_module_environment))
 	(curenv (if moduldata moduldata initial_environment))
-	(arglist (split_string_comma discr_string (melt_argument "arglist")))
+	(arglist (split_string_comma discr_string (make_stringconst discr_string (melt_argument "arglist"))))
 	(outarg (make_stringconst discr_string (melt_argument "output")))
 	(rlist (make_list discr_list))
 	(mdinfo 
-- 
1.7.6