function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
        /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
        if (field.resolvedType) {
          if (field.resolvedType instanceof Enum) {
            gen("switch(d%s){", prop);
            for (
              var values = field.resolvedType.values,
                keys = Object.keys(values),
                i = 0;
              i < keys.length;
              ++i
            ) {
              if (field.repeated && values[keys[i]] === field.typeDefault)
                gen("default:");
              gen("case%j:", keys[i])("case %i:", values[keys[i]])(
                "m%s=%j",
                prop,
                values[keys[i]]
              )("break");
            }
            gen("}");
          } else
            gen('if(typeof d%s!=="object")', prop)(
              "throw TypeError(%j)",
              field.fullName + ": object expected"
            )("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop);
        } else {
          var isUnsigned = false;
          switch (field.type) {
            case "double":
            case "float":
              gen("m%s=Number(d%s)", prop, prop); // also catches "NaN", "Infinity"
              break;
            case "uint32":
            case "fixed32":
              gen("m%s=d%s>>>0", prop, prop);
              break;
            case "int32":
            case "sint32":
            case "sfixed32":
              gen("m%s=d%s|0", prop, prop);
              break;
            case "uint64":
              isUnsigned = true;
            // eslint-disable-line no-fallthrough
            case "int64":
            case "sint64":
            case "fixed64":
            case "sfixed64":
              gen("if(util.Long)")(
                "(m%s=util.Long.fromValue(d%s)).unsigned=%j",
                prop,
                prop,
                isUnsigned
              )('else if(typeof d%s==="string")', prop)(
                "m%s=parseInt(d%s,10)",
                prop,
                prop
              )('else if(typeof d%s==="number")', prop)(
                "m%s=d%s",
                prop,
                prop
              )('else if(typeof d%s==="object")', prop)(
                "m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",
                prop,
                prop,
                prop,
                isUnsigned ? "true" : ""
              );
              break;
            case "bytes":
              gen('if(typeof d%s==="string")', prop)(
                "util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",
                prop,
                prop,
                prop
              )("else if(d%s.length)", prop)("m%s=d%s", prop, prop);
              break;
            case "string":
              gen("m%s=String(d%s)", prop, prop);
              break;
            case "bool":
              gen("m%s=Boolean(d%s)", prop, prop);
              break;
            /* default: gen
                ("m%s=d%s", prop, prop);
                break; */
          }
        }
        return gen;
        /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */
      }
/**
       * Generates a partial value fromObject conveter.
       * @param {Codegen} gen Codegen instance
       * @param {Field} field Reflected field
       * @param {number} fieldIndex Field index
       * @param {string} prop Property reference
       * @returns {Codegen} Codegen instance
       * @ignore
       */
Generates a partial value fromObject conveter.
Generates a partial value fromObject conveter .
function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
        if (field.resolvedType) {
          if (field.resolvedType instanceof Enum) {
            gen("switch(d%s){", prop);
            for (
              var values = field.resolvedType.values,
                keys = Object.keys(values),
                i = 0;
              i < keys.length;
              ++i
            ) {
              if (field.repeated && values[keys[i]] === field.typeDefault)
                gen("default:");
              gen("case%j:", keys[i])("case %i:", values[keys[i]])(
                "m%s=%j",
                prop,
                values[keys[i]]
              )("break");
            }
            gen("}");
          } else
            gen('if(typeof d%s!=="object")', prop)(
              "throw TypeError(%j)",
              field.fullName + ": object expected"
            )("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop);
        } else {
          var isUnsigned = false;
          switch (field.type) {
            case "double":
            case "float":
              gen("m%s=Number(d%s)", prop, prop); 
              break;
            case "uint32":
            case "fixed32":
              gen("m%s=d%s>>>0", prop, prop);
              break;
            case "int32":
            case "sint32":
            case "sfixed32":
              gen("m%s=d%s|0", prop, prop);
              break;
            case "uint64":
              isUnsigned = true;
            case "int64":
            case "sint64":
            case "fixed64":
            case "sfixed64":
              gen("if(util.Long)")(
                "(m%s=util.Long.fromValue(d%s)).unsigned=%j",
                prop,
                prop,
                isUnsigned
              )('else if(typeof d%s==="string")', prop)(
                "m%s=parseInt(d%s,10)",
                prop,
                prop
              )('else if(typeof d%s==="number")', prop)(
                "m%s=d%s",
                prop,
                prop
              )('else if(typeof d%s==="object")', prop)(
                "m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",
                prop,
                prop,
                prop,
                isUnsigned ? "true" : ""
              );
              break;
            case "bytes":
              gen('if(typeof d%s==="string")', prop)(
                "util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",
                prop,
                prop,
                prop
              )("else if(d%s.length)", prop)("m%s=d%s", prop, prop);
              break;
            case "string":
              gen("m%s=String(d%s)", prop, prop);
              break;
            case "bool":
              gen("m%s=Boolean(d%s)", prop, prop);
              break;
          }
        }
        return gen;
      }
function genValuePartial_fromObject ( gen , field , fieldIndex , prop ) { if ( field . resolvedType ) { if ( field . resolvedType instanceof Enum ) { gen ( "switch(d%s){" , prop ) ; for ( var values = field . resolvedType . values , keys = Object . keys ( values ) , i = 0 ; i < keys . length ; ++ i ) { if ( field . repeated && values [ keys [ i ] ] === field . typeDefault ) gen ( "default:" ) ; gen ( "case%j:" , keys [ i ] ) ( "case %i:" , values [ keys [ i ] ] ) ( "m%s=%j" , prop , values [ keys [ i ] ] ) ( "break" ) ; } gen ( "}" ) ; } else gen ( 'if(typeof d%s!=="object")' , prop ) ( "throw TypeError(%j)" , field . fullName + ": object expected" ) ( "m%s=types[%i].fromObject(d%s)" , prop , fieldIndex , prop ) ; } else { var isUnsigned = false ; switch ( field . type ) { case "double" : case "float" : gen ( "m%s=Number(d%s)" , prop , prop ) ; break ; case "uint32" : case "fixed32" : gen ( "m%s=d%s>>>0" , prop , prop ) ; break ; case "int32" : case "sint32" : case "sfixed32" : gen ( "m%s=d%s|0" , prop , prop ) ; break ; case "uint64" : isUnsigned = true ; case "int64" : case "sint64" : case "fixed64" : case "sfixed64" : gen ( "if(util.Long)" ) ( "(m%s=util.Long.fromValue(d%s)).unsigned=%j" , prop , prop , isUnsigned ) ( 'else if(typeof d%s==="string")' , prop ) ( "m%s=parseInt(d%s,10)" , prop , prop ) ( 'else if(typeof d%s==="number")' , prop ) ( "m%s=d%s" , prop , prop ) ( 'else if(typeof d%s==="object")' , prop ) ( "m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)" , prop , prop , prop , isUnsigned ? "true" : "" ) ; break ; case "bytes" : gen ( 'if(typeof d%s==="string")' , prop ) ( "util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)" , prop , prop , prop ) ( "else if(d%s.length)" , prop ) ( "m%s=d%s" , prop , prop ) ; break ; case "string" : gen ( "m%s=String(d%s)" , prop , prop ) ; break ; case "bool" : gen ( "m%s=Boolean(d%s)" , prop , prop ) ; break ; } } return gen ; }
Generates a partial value fromObject conveter.
Generates a partial value fromObject conveter .
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ // also catches "NaN", "Infinity" // eslint-disable-line no-fallthrough /* default: gen
                ("m%s=d%s", prop, prop);
                break; */ /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */