예제 #1
0
func (mj *AgentRender) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"agent-type":`)
	fflib.WriteJsonString(buf, string(mj.Type))
	buf.WriteString(`,"position":`)

	{

		err = mj.Pos2D.MarshalJSONBuf(buf)
		if err != nil {
			return err
		}

	}
	buf.WriteString(`,"heading":`)
	fflib.AppendFloat(buf, float64(mj.Heading), 'g', -1, 64)
	/* Struct fall back. type=colour.RGB256 kind=struct */
	buf.WriteString(`,"colour":`)
	err = buf.Encode(&mj.Colour)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
예제 #2
0
func (mj *TaskEvent) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"type":`)
	fflib.WriteJsonString(buf, string(mj.Type))
	buf.WriteString(`,"hostname":`)
	fflib.WriteJsonString(buf, string(mj.Hostname))
	buf.WriteString(`,"timestamp":`)
	fflib.AppendFloat(buf, float64(mj.Timestamp), 'g', -1, 32)
	buf.WriteString(`,"pid":`)
	fflib.FormatBits2(buf, uint64(mj.PID), 10, mj.PID < 0)
	buf.WriteString(`,"clock":`)
	fflib.FormatBits2(buf, uint64(mj.Clock), 10, mj.Clock < 0)
	buf.WriteString(`,"utcoffset":`)
	fflib.FormatBits2(buf, uint64(mj.UTCOffset), 10, mj.UTCOffset < 0)
	buf.WriteString(`,"uuid":`)
	fflib.WriteJsonString(buf, string(mj.UUID))
	buf.WriteString(`,"name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteString(`,"args":`)
	fflib.WriteJsonString(buf, string(mj.Args))
	buf.WriteString(`,"kwargs":`)
	fflib.WriteJsonString(buf, string(mj.Kwargs))
	buf.WriteString(`,"result":`)
	fflib.WriteJsonString(buf, string(mj.Result))
	buf.WriteString(`,"runtime":`)
	fflib.AppendFloat(buf, float64(mj.Runtime), 'g', -1, 32)
	buf.WriteString(`,"retries":`)
	fflib.FormatBits2(buf, uint64(mj.Retries), 10, mj.Retries < 0)
	buf.WriteString(`,"eta":`)
	fflib.FormatBits2(buf, uint64(mj.ETA), 10, mj.ETA < 0)
	buf.WriteString(`,"exception":`)
	fflib.WriteJsonString(buf, string(mj.Exception))
	buf.WriteString(`,"traceback":`)
	fflib.WriteJsonString(buf, string(mj.Traceback))
	if mj.Terminated {
		buf.WriteString(`,"terminated":true`)
	} else {
		buf.WriteString(`,"terminated":false`)
	}
	buf.WriteString(`,"signum":`)
	/* Interface types must use runtime reflection. type=interface {} kind=interface */
	err = buf.Encode(mj.Signum)
	if err != nil {
		return err
	}
	if mj.Expired {
		buf.WriteString(`,"expired":true`)
	} else {
		buf.WriteString(`,"expired":false`)
	}
	buf.WriteByte('}')
	return nil
}
예제 #3
0
func (mj *User) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteString(`,"color":`)
	fflib.WriteJsonString(buf, string(mj.Color))
	if mj.LoggedIn {
		buf.WriteString(`,"logged-in":true`)
	} else {
		buf.WriteString(`,"logged-in":false`)
	}
	/* Falling back. type=map[int]chat.voteOption kind=map */
	buf.WriteString(`,"voteMask":`)
	err = buf.Encode(mj.Votes)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
예제 #4
0
func (mj *Server) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	/* Falling back. type=map[int]*chat.Topic kind=map */
	buf.WriteString(`{"users":`)
	err = buf.Encode(mj.Topics)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
예제 #5
0
func (mj *OutMsg) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"type":`)
	fflib.WriteJsonString(buf, string(mj.Type))
	buf.WriteString(`,"data":`)
	/* Interface types must use runtime reflection. type=interface {} kind=interface */
	err = buf.Encode(mj.Data)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
예제 #6
0
func (mj *EventStream) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"Err":`)
	/* Falling back. type=chan error kind=chan */
	err = buf.Encode(mj.Err)
	if err != nil {
		return err
	}
	buf.WriteString(`,"Events":`)
	/* Falling back. type=chan census.Event kind=chan */
	err = buf.Encode(mj.Events)
	if err != nil {
		return err
	}
	buf.WriteString(`,"Closed":`)
	/* Falling back. type=chan struct {} kind=chan */
	err = buf.Encode(mj.Closed)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
예제 #7
0
func (mj *DrawList) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"cpPrey":`)
	if mj.CPP != nil {
		buf.WriteString(`[`)
		for i, v := range mj.CPP {
			if i != 0 {
				buf.WriteString(`,`)
			}

			{

				err = v.MarshalJSONBuf(buf)
				if err != nil {
					return err
				}

			}
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteString(`,"vp":`)
	if mj.VP != nil {
		buf.WriteString(`[`)
		for i, v := range mj.VP {
			if i != 0 {
				buf.WriteString(`,`)
			}

			{

				err = v.MarshalJSONBuf(buf)
				if err != nil {
					return err
				}

			}
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	/* Struct fall back. type=colour.RGB256 kind=struct */
	buf.WriteString(`,"bg":`)
	err = buf.Encode(&mj.BG)
	if err != nil {
		return err
	}
	buf.WriteString(`,"cpPrey-pop-string":`)
	fflib.WriteJsonString(buf, string(mj.CpPreyPop))
	buf.WriteString(`,"vp-pop-string":`)
	fflib.WriteJsonString(buf, string(mj.VpPop))
	buf.WriteString(`,"turncount-string":`)
	fflib.WriteJsonString(buf, string(mj.TurnCount))
	buf.WriteByte('}')
	return nil
}