-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathcell.go
45 lines (36 loc) · 832 Bytes
/
cell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018 The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Cell object
//
// In the Go implementation this is just a pointer to an Object which
// can be nil
package py
// A python Cell object
type Cell struct {
obj *Object
}
var CellType = NewType("cell", "cell object")
// Type of this object
func (o *Cell) Type() *Type {
return CellType
}
// Define a new cell
func NewCell(obj Object) *Cell {
return &Cell{&obj}
}
// Fetch the contents of the Cell or nil if not set
func (c *Cell) Get() Object {
if c.obj == nil {
return nil
}
return *c.obj
}
// Set the contents of the Cell
func (c *Cell) Set(obj Object) {
c.obj = &obj
}
// Delete the contents of the Cell
func (c *Cell) Delete() {
c.obj = nil
}