Changeset 516 for cpp/frams/vm
- Timestamp:
- 06/22/16 16:34:36 (9 years ago)
- Location:
- cpp/frams/vm/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/vm/classes/genoobj.cpp
r420 r516 15 15 { "rawgenotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "Raw genotype", "s 1", GETONLY(genotype), "Genotype, excluding the format specifier" }, 16 16 { "info", 0, PARAM_NOSTATIC, "Info", "s 1", GETSET(info), "Additional information or comments", }, 17 { "format", 0, PARAM_NOSTATIC | PARAM_READONLY, "Format", " d", GETONLY(format), "Genotype format", },17 { "format", 0, PARAM_NOSTATIC | PARAM_READONLY, "Format", "s", GETONLY(format), "Genotype format", }, 18 18 { "genotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "Genotype", "s 1", GETONLY(string), "Genes as a string of characters", }, 19 19 { "isValid", 0, PARAM_NOSTATIC | PARAM_READONLY | PARAM_DEPRECATED, "Valid", "d 0 1", GETONLY(isvalid), "Use 'is_valid' instead of 'isValid'." }, … … 23 23 "-1 = validity is not known. This is a transient state. The value of \"is_valid\" will never be -1 when read. It is safe to treat is_valid as boolean in statements like \"if (g.is_valid) ...\". Setting \"is_valid=-1\" will make it 0 or 1 again. This third state (-1) is only needed for loading Genotype objects from files where the \"is_valid\" field might not be present." 24 24 }, 25 { "getConverted", 0, PARAM_NOSTATIC, "get converted genotype", "p oGeno( dformat)", PROCEDURE(p_getconvert), },25 { "getConverted", 0, PARAM_NOSTATIC, "get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert), }, 26 26 { "f0genotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "f0 genotype", "s 1", GETONLY(f0genotype), "converted to f0 genotype", }, 27 27 { "new", 0, 0, "create new empty object", "p oGeno()", PROCEDURE(p_new), }, 28 28 { "newFromString", 0, 0, "create new object from supplied string argument", "p oGeno(s genotype)", PROCEDURE(p_newfromstring), }, 29 { "newFrom", 0, 0, "create new object", "p oGeno(s genotype, dformat,s name,s description)", PROCEDURE(p_newfrom), },29 { "newFrom", 0, 0, "create new object", "p oGeno(s genotype,s format,s name,s description)", PROCEDURE(p_newfrom), }, 30 30 { "autoname", 0, PARAM_NOSTATIC | PARAM_READONLY, "Autogenerated name", "s", GETONLY(autoname), }, 31 31 { "toVector", 0, PARAM_READONLY | PARAM_NOSTATIC, "serialization support", "oVector", GETONLY(toVector), }, … … 85 85 void GenoObj::get_format(ExtValue *ret) 86 86 { 87 ret->setInt(getFormat()); 87 char format_as_string[2]={getFormat(),0}; 88 ret->setString(format_as_string); 88 89 } 89 90 … … 99 100 } 100 101 102 char GenoObj::formatFromExtValue(ExtValue& v) 103 { 104 if (v.getType()==TInt) 105 return v.getInt(); 106 if (v.getType()==TString) 107 { 108 SString s=v.getString(); 109 if (s.len()==1) 110 return s.charAt(0); 111 } 112 return Geno::INVALID_FORMAT; 113 } 114 101 115 void GenoObj::p_getconvert(ExtValue *args, ExtValue *ret) 102 116 { 103 *ret = makeDynamicObjectAndDecRef(new Geno(getConverted( (char)args[0].getInt())));117 *ret = makeDynamicObjectAndDecRef(new Geno(getConverted(formatFromExtValue(args[0])))); 104 118 } 105 119 … … 116 130 void GenoObj::p_newfrom(ExtValue *args, ExtValue *ret) 117 131 { 118 *ret = makeDynamicObjectAndDecRef(new Geno(args[3].getString(), (char)args[2].getInt(),132 *ret = makeDynamicObjectAndDecRef(new Geno(args[3].getString(), formatFromExtValue(args[2]), 119 133 args[1].getString(), args[0].getString())); 120 134 } -
cpp/frams/vm/classes/genoobj.h
r420 r516 38 38 static Geno* fromObject(const ExtValue& v, bool warn = true); 39 39 static ParamInterface* getInterface(); 40 static char formatFromExtValue(ExtValue& v); 40 41 41 42 static Param& getStaticParam();
Note: See TracChangeset
for help on using the changeset viewer.