add support for inline methods
authorJuerg Billeter <j@bitron.ch>
Wed, 28 Nov 2007 16:28:30 +0000 (16:28 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 28 Nov 2007 16:28:30 +0000 (16:28 +0000)
2007-11-28  Juerg Billeter  <j@bitron.ch>

* vala/parser.y, vala/scanner.l, vala/valamethod.vala,
  ccode/valaccodefunction.vala, ccode/valaccodemodifiers.vala,
  gobject/valaccodegeneratormethod.vala: add support for inline methods

svn path=/trunk/; revision=734

ChangeLog
ccode/valaccodefunction.vala
ccode/valaccodemodifiers.vala
gobject/valaccodegeneratormethod.vala
vala/parser.y
vala/scanner.l
vala/valamethod.vala

index 4f5778b..13d1a91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,18 @@
 2007-11-28  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y, vala/scanner.l, vala/valamethod.vala,
+         ccode/valaccodefunction.vala, ccode/valaccodemodifiers.vala,
+         gobject/valaccodegeneratormethod.vala: add support for inline methods
+
+2007-11-28  Jürg Billeter  <j@bitron.ch>
+
        * vapi/glib-2.0.vapi: bind atomic operations, fixes bug 499970
 
 2007-11-28  Jürg Billeter  <j@bitron.ch>
 
        * vala/parser.y, vala/scanner.l, vala/valafield.vala,
          gobject/valaccodegenerator.vala: add support for volatile fields,
-         fixes bug #499960
+         fixes bug 499960
 
 2007-11-27  Jürg Billeter  <j@bitron.ch>
 
index eeeccc8..e3dfcf4 100644 (file)
@@ -83,9 +83,12 @@ public class Vala.CCodeFunction : CCodeNode {
        
        public override void write (CCodeWriter! writer) {
                writer.write_indent (line);
-               if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
+               if (CCodeModifiers.STATIC in modifiers) {
                        writer.write_string ("static ");
                }
+               if (CCodeModifiers.INLINE in modifiers) {
+                       writer.write_string ("inline ");
+               }
                writer.write_string (return_type);
                writer.write_string (" ");
                writer.write_string (name);
index c34393d..d1a4a7a 100644 (file)
@@ -28,5 +28,6 @@ public enum Vala.CCodeModifiers {
        NONE,
        STATIC,
        REGISTER,
-       EXTERN
+       EXTERN,
+       INLINE
 }
index ed89308..ce0b830 100644 (file)
@@ -108,6 +108,11 @@ public class Vala.CCodeGenerator {
 
                function = new CCodeFunction (m.get_real_cname (), m.return_type.get_cname ());
                m.ccodenode = function;
+
+               if (m.is_inline) {
+                       function.modifiers |= CCodeModifiers.INLINE;
+               }
+
                CCodeFunctionDeclarator vdeclarator = null;
                
                CCodeFormalParameter instance_param = null;
index 1db5cab..f389dcc 100644 (file)
@@ -46,7 +46,8 @@ typedef enum {
        VALA_MODIFIER_OVERRIDE = 1 << 1,
        VALA_MODIFIER_STATIC = 1 << 2,
        VALA_MODIFIER_VIRTUAL = 1 << 3,
-       VALA_MODIFIER_VOLATILE = 1 << 4
+       VALA_MODIFIER_VOLATILE = 1 << 4,
+       VALA_MODIFIER_INLINE = 1 << 5
 } ValaModifier;
 
 int yylex (YYSTYPE *yylval_param, YYLTYPE *yylloc_param, ValaParser *parser);
@@ -173,6 +174,7 @@ static gboolean check_is_struct (ValaSymbol *symbol, ValaSourceReference *src);
 %token GET "get"
 %token IF "if"
 %token IN "in"
+%token INLINE "inline"
 %token INTERFACE "interface"
 %token IS "is"
 %token LOCK "lock"
@@ -2641,6 +2643,10 @@ modifier
          {
                $$ = VALA_MODIFIER_VOLATILE;
          }
+       | INLINE
+         {
+               $$ = VALA_MODIFIER_INLINE;
+         }
        ;
 
 opt_class_base
@@ -2940,6 +2946,9 @@ method_header
                        vala_report_error (vala_code_node_get_source_reference (VALA_CODE_NODE ($$)), "Only one of `abstract', `virtual', and `override' may be specified.");
                        vala_code_node_set_error (VALA_CODE_NODE ($$), TRUE);
                }
+               if (($4 & VALA_MODIFIER_INLINE) == VALA_MODIFIER_INLINE) {
+                       vala_method_set_is_inline ($$, TRUE);
+               }
                VALA_CODE_NODE($$)->attributes = $2;
                
                for (l = $8; l != NULL; l = l->next) {
index 90febb1..fdab188 100644 (file)
@@ -151,6 +151,7 @@ literal                             ({integer_literal}|{real_literal}|{character_literal}|{string_literal
 "get"          { uploc; return GET; }
 "if"           { uploc; return IF; }
 "in"           { uploc; return IN; }
+"inline"       { uploc; return INLINE; }
 "interface"    { uploc; return INTERFACE; }
 "is"           { uploc; return IS; }
 "lock"         { uploc; return LOCK; }
index 2fb7346..c0eb4b4 100644 (file)
@@ -100,6 +100,11 @@ public class Vala.Method : Member, Invokable {
         * of a base type.
         */
        public bool overrides { get; set; }
+       
+       /**
+        * Specifies whether this method should be inlined.
+        */
+       public bool is_inline { get; set; }
 
        /**
         * Specifies whether the C method returns a new instance pointer which