#ifndef __X10_LANG_CELL_H
#define __X10_LANG_CELL_H

#include <x10rt.h>


#define X10_LANG_OBJECT_H_NODEPS
#include <x10/lang/Object.h>
#undef X10_LANG_OBJECT_H_NODEPS
namespace x10 { namespace lang { 
class String;
} } 
namespace x10 { namespace lang { 
class Any;
} } 
namespace x10 { namespace lang { 

template<class TPMGL(T)> class Cell;
template <> class Cell<void>;
template<class TPMGL(T)> class Cell : public x10::lang::Object   {
    public:
    RTT_H_DECLS_CLASS
    
    TPMGL(T) FMGL(value);
    
    void _constructor(TPMGL(T) x);
    
    static x10aux::ref<x10::lang::Cell<TPMGL(T)> > _make(TPMGL(T) x);
    
    virtual x10aux::ref<x10::lang::String> toString();
    virtual TPMGL(T) __apply();
    virtual void __apply(TPMGL(T) x);
    virtual void __set(TPMGL(T) x);
    virtual TPMGL(T) set(TPMGL(T) x);
    virtual x10aux::ref<x10::lang::Cell<TPMGL(T)> > x10__lang__Cell____x10__lang__Cell__this(
      );
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: x10aux::serialization_id_t _get_serialization_id() {
         return _serialization_id;
    }
    
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: static x10aux::ref<x10::lang::Reference> _deserializer(x10aux::deserialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};
template <> class Cell<void> : public x10::lang::Object {
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    template<class TPMGL(T)> static x10aux::ref<x10::lang::Cell<TPMGL(T)> >
      make(TPMGL(T) x);
    
    template<class TPMGL(W)> static x10aux::ref<x10::lang::Cell<TPMGL(W)> >
      __implicit_convert(TPMGL(W) x);
    
    
};

} } 
#endif // X10_LANG_CELL_H

namespace x10 { namespace lang { 
template<class TPMGL(T)> class Cell;
} } 

#ifndef X10_LANG_CELL_H_NODEPS
#define X10_LANG_CELL_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/lang/String.h>
#include <x10/lang/Any.h>
#ifndef X10_LANG_CELL_H_GENERICS
#define X10_LANG_CELL_H_GENERICS
#endif // X10_LANG_CELL_H_GENERICS
#ifndef X10_LANG_CELL_H_IMPLEMENTATION
#define X10_LANG_CELL_H_IMPLEMENTATION
#include <x10/lang/Cell.h>


//#line 25 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10FieldDecl_c
/**
     * The value stored in this cell.
     */

//#line 32 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::_constructor(TPMGL(T) x) {
    
    //#line 32 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 32 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.AssignPropertyCall_c
    
    //#line 32 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->FMGL(value) = x;
}
template<class TPMGL(T)> x10aux::ref<x10::lang::Cell<TPMGL(T)> > x10::lang::Cell<TPMGL(T)>::_make(
                           TPMGL(T) x) {
    x10aux::ref<x10::lang::Cell<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::lang::Cell<TPMGL(T)> >(), 0, sizeof(x10::lang::Cell<TPMGL(T)>))) x10::lang::Cell<TPMGL(T)>();
    this_->_constructor(x);
    return this_;
}



//#line 42 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::lang::String> x10::lang::Cell<TPMGL(T)>::toString(
  ) {
    
    //#line 43 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
    return ((((x10aux::string_utils::lit("Cell(")) + (x10aux::to_string(((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->
                                                                          FMGL(value))))) + (x10aux::string_utils::lit(")")));
    
}

//#line 53 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::lang::Cell<TPMGL(T)>::__apply(
  ) {
    
    //#line 53 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->
             FMGL(value);
    
}

//#line 61 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::__apply(
  TPMGL(T) x) {
    
    //#line 61 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->FMGL(value) =
      x;
}

//#line 70 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::__set(
  TPMGL(T) x) {
    
    //#line 70 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": Eval of x10.ast.X10Call_c
    ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->x10::lang::Cell<TPMGL(T)>::set(
      x);
}

//#line 71 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::lang::Cell<TPMGL(T)>::set(
  TPMGL(T) x) {
    
    //#line 71 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this)->FMGL(value) =
      x;
    
    //#line 71 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
    return x;
    
}

//#line 81 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c

//#line 90 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c

//#line 20 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::lang::Cell<TPMGL(T)> >
  x10::lang::Cell<TPMGL(T)>::x10__lang__Cell____x10__lang__Cell__this(
  ) {
    
    //#line 20 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::lang::Cell<TPMGL(T)> >)this);
    
}
template<class TPMGL(T)> const x10aux::serialization_id_t x10::lang::Cell<TPMGL(T)>::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10::lang::Cell<TPMGL(T)>::_deserializer, x10aux::CLOSURE_KIND_NOT_ASYNC);

template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    x10::lang::Object::_serialize_body(buf);
    buf.write(this->FMGL(value));
    
}

template<class TPMGL(T)> x10aux::ref<x10::lang::Reference> x10::lang::Cell<TPMGL(T)>::_deserializer(x10aux::deserialization_buffer& buf) {
    x10aux::ref<x10::lang::Cell<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::lang::Cell<TPMGL(T)> >(), 0, sizeof(x10::lang::Cell<TPMGL(T)>))) x10::lang::Cell<TPMGL(T)>();
    buf.record_reference(this_);
    this_->_deserialize_body(buf);
    return this_;
}

template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    x10::lang::Object::_deserialize_body(buf);
    FMGL(value) = buf.read<TPMGL(T)>();
}

template<class TPMGL(T)> x10aux::RuntimeType x10::lang::Cell<TPMGL(T)>::rtt;
template<class TPMGL(T)> void x10::lang::Cell<TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::lang::Cell<void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[1] = { x10aux::getRTT<x10::lang::Object>()};
    const x10aux::RuntimeType* params[1] = { x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[1] = { x10aux::RuntimeType::invariant};
    const char *baseName = "x10.lang.Cell";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 1, parents, 1, params, variances);
}
template<class TPMGL(T)> x10aux::ref<x10::lang::Cell<TPMGL(T)> >
  x10::lang::Cell<void>::make(TPMGL(T) x) {
                                              
                                              //#line 81 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
                                              return x10::lang::Cell<TPMGL(T)>::_make(x);
                                              
                                          }
template<class TPMGL(W)> x10aux::ref<x10::lang::Cell<TPMGL(W)> >
  x10::lang::Cell<void>::__implicit_convert(TPMGL(W) x) {
                                                            
                                                            //#line 90 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Cell.x10": x10.ast.X10Return_c
                                                            return x10::lang::Cell<void>::template make<TPMGL(W) >(
                                                                     x);
                                                            
                                                        }
#endif // X10_LANG_CELL_H_IMPLEMENTATION
#endif // __X10_LANG_CELL_H_NODEPS
