Ignore:
Timestamp:
06/03/16 10:05:11 (9 years ago)
Author:
Mathieu Morlighem
Message:

NEW: marhsall strings instead of enums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/solve/WriteData.js

    r20361 r20690  
    1 function WriteData(fid){
     1function WriteData(fid,prefix){
    22//WRITEDATA - write model field into binary buffer
    33//
     
    1717                obj       = options.getfieldvalue('object');
    1818                fieldname = options.getfieldvalue('fieldname');
    19                 if (options.exist('enum')){
    20                         enumm = options.getfieldvalue('enum');
     19                name      = options.getfieldvalue('name',[prefix+'.'+fieldname ]);
     20                if (options.exist('data')){
     21                        data = options.getfieldvalue('data');
    2122                }
    2223                else{
    23                         classname = options.getfieldvalue('class',obj.classname());
    24                         enumm = BuildEnum(classname  + '_' + fieldname);
    25                 }
    26                 dataini  = obj[fieldname];
     24                        dataini  = obj[fieldname];
     25                }
    2726        }
    2827        else{
    2928                //No processing required
    3029                dataini = options.getfieldvalue('data');
    31                 enumm = options.getfieldvalue('enum');
     30                namem = options.getfieldvalue('name');
    3231        }
    3332        if (IsArray(dataini)){
     
    7372        }
    7473
    75         //Step 1: write the enum to identify this record uniquely
    76         fid.fwrite(enumm,'int');
     74        //Step 1: write the name to identify this record uniquely
     75        fid.fwrite(name.length,'int');
     76        fid.fwrite(name,'char');
    7777
    7878        //Step 2: write the data itself.
     
    278278}
    279279
    280 function BuildEnum(string){ // {{{
    281         //BUILDENUM - build enum out of string
    282         //
    283         //   Usage:
    284         //      enumm=BuildEnum(string)
    285 
    286         var index;
    287         while( string.indexOf('_') !=-1){
    288                 index=string.indexOf('_');
    289                 string=string.slice(0,index)+string[index+1].toUpperCase() + string.slice(index+2);
    290         }
    291 
    292         //take first letter of string and make it uppercase:
    293         string = string.charAt(0).toUpperCase() + string.slice(1);
    294 
    295         //Get Enum
    296         enumm=StringToEnum(string);
    297 
    298         return enumm;
    299 } // }}}
    300280function FormatToCode(format){ // {{{
    301281        //This routine takes the format string, and hardcodes it into an integer, which
Note: See TracChangeset for help on using the changeset viewer.