static void RlistAppendContainerPrimitive(Rlist **list, const JsonElement *primitive) { assert(JsonGetElementType(primitive) == JSON_ELEMENT_TYPE_PRIMITIVE); switch (JsonGetPrimitiveType(primitive)) { case JSON_PRIMITIVE_TYPE_BOOL: RlistAppendScalar(list, JsonPrimitiveGetAsBool(primitive) ? "true" : "false"); break; case JSON_PRIMITIVE_TYPE_INTEGER: { char *str = StringFromLong(JsonPrimitiveGetAsInteger(primitive)); RlistAppendScalar(list, str); free(str); } break; case JSON_PRIMITIVE_TYPE_REAL: { char *str = StringFromDouble(JsonPrimitiveGetAsReal(primitive)); RlistAppendScalar(list, str); free(str); } break; case JSON_PRIMITIVE_TYPE_STRING: RlistAppendScalar(list, JsonPrimitiveGetAsString(primitive)); break; case JSON_PRIMITIVE_TYPE_NULL: break; } }
static bool RenderVariablePrimitive(Buffer *out, const JsonElement *primitive, const bool escaped, const bool key_mode) { if (key_mode && JsonElementGetPropertyName(primitive)) { if (escaped) { RenderHTMLContent(out, JsonElementGetPropertyName(primitive), strlen(JsonElementGetPropertyName(primitive))); } else { BufferAppendString(out, JsonElementGetPropertyName(primitive)); } return true; } switch (JsonGetPrimitiveType(primitive)) { case JSON_PRIMITIVE_TYPE_STRING: if (escaped) { RenderHTMLContent(out, JsonPrimitiveGetAsString(primitive), strlen(JsonPrimitiveGetAsString(primitive))); } else { BufferAppendString(out, JsonPrimitiveGetAsString(primitive)); } return true; case JSON_PRIMITIVE_TYPE_INTEGER: { char *str = StringFromLong(JsonPrimitiveGetAsInteger(primitive)); BufferAppendString(out, str); free(str); } return true; case JSON_PRIMITIVE_TYPE_REAL: { char *str = StringFromDouble(JsonPrimitiveGetAsReal(primitive)); BufferAppendString(out, str); free(str); } return true; case JSON_PRIMITIVE_TYPE_BOOL: BufferAppendString(out, JsonPrimitiveGetAsBool(primitive) ? "true" : "false"); return true; case JSON_PRIMITIVE_TYPE_NULL: return true; default: assert(!"Unrecognised JSON primitive type"); } return false; }
void Constant::SetValue(double value) { m_value = value; wxString text = StringFromDouble(m_value); if(m_glText) m_glText->SetText(text); else m_glText = new OpenGLText(text); m_width = m_glText->GetWidth() + 6 + 2 * m_borderSize; m_height = m_glText->GetHeight() + 6 + 2 * m_borderSize; UpdatePoints(); }