1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
21 #include "functiontypes.h"
27 class MethodBaseBase
: public Lang::Function
32 MethodBaseBase( const Ast::FileID
* title
, bool forceAll
)
33 : Lang::Function( new Kernel::EvaluatedFormals( title
, forceAll
) ),
34 title_( title
->name( ) )
36 MethodBaseBase( const Ast::FileID
* title
)
37 : Lang::Function( new Kernel::EvaluatedFormals( title
) ),
38 title_( title
->name( ) )
40 virtual ~MethodBaseBase( )
49 class MethodBase
: public Kernel::MethodBaseBase
54 RefCountPtr
< const T
> self_
;
57 MethodBase( RefCountPtr
< const T
> self
, const Ast::FileID
* title
, bool transforming
);
58 MethodBase( RefCountPtr
< const T
> self
, const Ast::FileID
* title
, bool transforming
, bool forceAll
);
59 virtual ~MethodBase( );
60 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
61 virtual bool isTransforming( ) const;
69 class MethodFactoryBase
74 MethodFactoryBase( const char * field
)
77 virtual ~MethodFactoryBase( )
79 const char * field( ) const { return field_
; }
80 virtual Kernel::VariableHandle
build( const RefCountPtr
< const Lang::Value
> self
) const = 0;
83 template< class ValueType
, class Method
>
84 class MethodFactory
: public MethodFactoryBase
86 RefCountPtr
< const char > fullMethodID_mem_
;
87 const Ast::FileID
* fullMethodID_
;
90 : MethodFactoryBase( Method::staticFieldID( ) ),
91 fullMethodID_mem_( Kernel::MethodId( ValueType::TypeID
, Method::staticFieldID( ) ).prettyName( ) ),
92 fullMethodID_( Ast::FileID::build_internal( fullMethodID_mem_
.getPtr( ) ) )
94 virtual ~MethodFactory( )
96 virtual Kernel::VariableHandle
build( const RefCountPtr
< const Lang::Value
> self
) const
98 return Helpers::newValHandle( new Method( Helpers::down_cast_internal
< const ValueType
>( self
), fullMethodID_
) );
105 #include "methodbase_impl.h"