repo_name
stringlengths 4
116
| path
stringlengths 3
942
| size
stringlengths 1
7
| content
stringlengths 3
1.05M
| license
stringclasses 15
values |
---|---|---|---|---|
tmatsuya/milkymist-linux | net/ipv4/netfilter/nf_nat_snmp_basic.c | 29804 | /*
* nf_nat_snmp_basic.c
*
* Basic SNMP Application Layer Gateway
*
* This IP NAT module is intended for use with SNMP network
* discovery and monitoring applications where target networks use
* conflicting private address realms.
*
* Static NAT is used to remap the networks from the view of the network
* management system at the IP layer, and this module remaps some application
* layer addresses to match.
*
* The simplest form of ALG is performed, where only tagged IP addresses
* are modified. The module does not need to be MIB aware and only scans
* messages at the ASN.1/BER level.
*
* Currently, only SNMPv1 and SNMPv2 are supported.
*
* More information on ALG and associated issues can be found in
* RFC 2962
*
* The ASB.1/BER parsing code is derived from the gxsnmp package by Gregory
* McLean & Jochen Friedrich, stripped down for use in the kernel.
*
* Copyright (c) 2000 RP Internet (www.rpi.net.au).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: James Morris <[email protected]>
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <net/checksum.h>
#include <net/udp.h>
#include <net/netfilter/nf_nat.h>
#include <net/netfilter/nf_conntrack_helper.h>
#include <net/netfilter/nf_nat_helper.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("James Morris <[email protected]>");
MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
MODULE_ALIAS("ip_nat_snmp_basic");
#define SNMP_PORT 161
#define SNMP_TRAP_PORT 162
#define NOCT1(n) (*(u8 *)n)
static int debug;
static DEFINE_SPINLOCK(snmp_lock);
/*
* Application layer address mapping mimics the NAT mapping, but
* only for the first octet in this case (a more flexible system
* can be implemented if needed).
*/
struct oct1_map
{
u_int8_t from;
u_int8_t to;
};
/*****************************************************************************
*
* Basic ASN.1 decoding routines (gxsnmp author Dirk Wisse)
*
*****************************************************************************/
/* Class */
#define ASN1_UNI 0 /* Universal */
#define ASN1_APL 1 /* Application */
#define ASN1_CTX 2 /* Context */
#define ASN1_PRV 3 /* Private */
/* Tag */
#define ASN1_EOC 0 /* End Of Contents */
#define ASN1_BOL 1 /* Boolean */
#define ASN1_INT 2 /* Integer */
#define ASN1_BTS 3 /* Bit String */
#define ASN1_OTS 4 /* Octet String */
#define ASN1_NUL 5 /* Null */
#define ASN1_OJI 6 /* Object Identifier */
#define ASN1_OJD 7 /* Object Description */
#define ASN1_EXT 8 /* External */
#define ASN1_SEQ 16 /* Sequence */
#define ASN1_SET 17 /* Set */
#define ASN1_NUMSTR 18 /* Numerical String */
#define ASN1_PRNSTR 19 /* Printable String */
#define ASN1_TEXSTR 20 /* Teletext String */
#define ASN1_VIDSTR 21 /* Video String */
#define ASN1_IA5STR 22 /* IA5 String */
#define ASN1_UNITIM 23 /* Universal Time */
#define ASN1_GENTIM 24 /* General Time */
#define ASN1_GRASTR 25 /* Graphical String */
#define ASN1_VISSTR 26 /* Visible String */
#define ASN1_GENSTR 27 /* General String */
/* Primitive / Constructed methods*/
#define ASN1_PRI 0 /* Primitive */
#define ASN1_CON 1 /* Constructed */
/*
* Error codes.
*/
#define ASN1_ERR_NOERROR 0
#define ASN1_ERR_DEC_EMPTY 2
#define ASN1_ERR_DEC_EOC_MISMATCH 3
#define ASN1_ERR_DEC_LENGTH_MISMATCH 4
#define ASN1_ERR_DEC_BADVALUE 5
/*
* ASN.1 context.
*/
struct asn1_ctx
{
int error; /* Error condition */
unsigned char *pointer; /* Octet just to be decoded */
unsigned char *begin; /* First octet */
unsigned char *end; /* Octet after last octet */
};
/*
* Octet string (not null terminated)
*/
struct asn1_octstr
{
unsigned char *data;
unsigned int len;
};
static void asn1_open(struct asn1_ctx *ctx,
unsigned char *buf,
unsigned int len)
{
ctx->begin = buf;
ctx->end = buf + len;
ctx->pointer = buf;
ctx->error = ASN1_ERR_NOERROR;
}
static unsigned char asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch)
{
if (ctx->pointer >= ctx->end) {
ctx->error = ASN1_ERR_DEC_EMPTY;
return 0;
}
*ch = *(ctx->pointer)++;
return 1;
}
static unsigned char asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
{
unsigned char ch;
*tag = 0;
do
{
if (!asn1_octet_decode(ctx, &ch))
return 0;
*tag <<= 7;
*tag |= ch & 0x7F;
} while ((ch & 0x80) == 0x80);
return 1;
}
static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
unsigned int *cls,
unsigned int *con,
unsigned int *tag)
{
unsigned char ch;
if (!asn1_octet_decode(ctx, &ch))
return 0;
*cls = (ch & 0xC0) >> 6;
*con = (ch & 0x20) >> 5;
*tag = (ch & 0x1F);
if (*tag == 0x1F) {
if (!asn1_tag_decode(ctx, tag))
return 0;
}
return 1;
}
static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
unsigned int *def,
unsigned int *len)
{
unsigned char ch, cnt;
if (!asn1_octet_decode(ctx, &ch))
return 0;
if (ch == 0x80)
*def = 0;
else {
*def = 1;
if (ch < 0x80)
*len = ch;
else {
cnt = (unsigned char) (ch & 0x7F);
*len = 0;
while (cnt > 0) {
if (!asn1_octet_decode(ctx, &ch))
return 0;
*len <<= 8;
*len |= ch;
cnt--;
}
}
}
return 1;
}
static unsigned char asn1_header_decode(struct asn1_ctx *ctx,
unsigned char **eoc,
unsigned int *cls,
unsigned int *con,
unsigned int *tag)
{
unsigned int def, len;
if (!asn1_id_decode(ctx, cls, con, tag))
return 0;
def = len = 0;
if (!asn1_length_decode(ctx, &def, &len))
return 0;
if (def)
*eoc = ctx->pointer + len;
else
*eoc = NULL;
return 1;
}
static unsigned char asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc)
{
unsigned char ch;
if (eoc == 0) {
if (!asn1_octet_decode(ctx, &ch))
return 0;
if (ch != 0x00) {
ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
return 0;
}
if (!asn1_octet_decode(ctx, &ch))
return 0;
if (ch != 0x00) {
ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
return 0;
}
return 1;
} else {
if (ctx->pointer != eoc) {
ctx->error = ASN1_ERR_DEC_LENGTH_MISMATCH;
return 0;
}
return 1;
}
}
static unsigned char asn1_null_decode(struct asn1_ctx *ctx, unsigned char *eoc)
{
ctx->pointer = eoc;
return 1;
}
static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
unsigned char *eoc,
long *integer)
{
unsigned char ch;
unsigned int len;
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer = (signed char) ch;
len = 1;
while (ctx->pointer < eoc) {
if (++len > sizeof (long)) {
ctx->error = ASN1_ERR_DEC_BADVALUE;
return 0;
}
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer <<= 8;
*integer |= ch;
}
return 1;
}
static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
unsigned char *eoc,
unsigned int *integer)
{
unsigned char ch;
unsigned int len;
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer = ch;
if (ch == 0) len = 0;
else len = 1;
while (ctx->pointer < eoc) {
if (++len > sizeof (unsigned int)) {
ctx->error = ASN1_ERR_DEC_BADVALUE;
return 0;
}
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer <<= 8;
*integer |= ch;
}
return 1;
}
static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
unsigned char *eoc,
unsigned long *integer)
{
unsigned char ch;
unsigned int len;
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer = ch;
if (ch == 0) len = 0;
else len = 1;
while (ctx->pointer < eoc) {
if (++len > sizeof (unsigned long)) {
ctx->error = ASN1_ERR_DEC_BADVALUE;
return 0;
}
if (!asn1_octet_decode(ctx, &ch))
return 0;
*integer <<= 8;
*integer |= ch;
}
return 1;
}
static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
unsigned char *eoc,
unsigned char **octets,
unsigned int *len)
{
unsigned char *ptr;
*len = 0;
*octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC);
if (*octets == NULL) {
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
ptr = *octets;
while (ctx->pointer < eoc) {
if (!asn1_octet_decode(ctx, (unsigned char *)ptr++)) {
kfree(*octets);
*octets = NULL;
return 0;
}
(*len)++;
}
return 1;
}
static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
unsigned long *subid)
{
unsigned char ch;
*subid = 0;
do {
if (!asn1_octet_decode(ctx, &ch))
return 0;
*subid <<= 7;
*subid |= ch & 0x7F;
} while ((ch & 0x80) == 0x80);
return 1;
}
static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
unsigned char *eoc,
unsigned long **oid,
unsigned int *len)
{
unsigned long subid;
unsigned int size;
unsigned long *optr;
size = eoc - ctx->pointer + 1;
*oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
if (*oid == NULL) {
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
optr = *oid;
if (!asn1_subid_decode(ctx, &subid)) {
kfree(*oid);
*oid = NULL;
return 0;
}
if (subid < 40) {
optr [0] = 0;
optr [1] = subid;
} else if (subid < 80) {
optr [0] = 1;
optr [1] = subid - 40;
} else {
optr [0] = 2;
optr [1] = subid - 80;
}
*len = 2;
optr += 2;
while (ctx->pointer < eoc) {
if (++(*len) > size) {
ctx->error = ASN1_ERR_DEC_BADVALUE;
kfree(*oid);
*oid = NULL;
return 0;
}
if (!asn1_subid_decode(ctx, optr++)) {
kfree(*oid);
*oid = NULL;
return 0;
}
}
return 1;
}
/*****************************************************************************
*
* SNMP decoding routines (gxsnmp author Dirk Wisse)
*
*****************************************************************************/
/* SNMP Versions */
#define SNMP_V1 0
#define SNMP_V2C 1
#define SNMP_V2 2
#define SNMP_V3 3
/* Default Sizes */
#define SNMP_SIZE_COMM 256
#define SNMP_SIZE_OBJECTID 128
#define SNMP_SIZE_BUFCHR 256
#define SNMP_SIZE_BUFINT 128
#define SNMP_SIZE_SMALLOBJECTID 16
/* Requests */
#define SNMP_PDU_GET 0
#define SNMP_PDU_NEXT 1
#define SNMP_PDU_RESPONSE 2
#define SNMP_PDU_SET 3
#define SNMP_PDU_TRAP1 4
#define SNMP_PDU_BULK 5
#define SNMP_PDU_INFORM 6
#define SNMP_PDU_TRAP2 7
/* Errors */
#define SNMP_NOERROR 0
#define SNMP_TOOBIG 1
#define SNMP_NOSUCHNAME 2
#define SNMP_BADVALUE 3
#define SNMP_READONLY 4
#define SNMP_GENERROR 5
#define SNMP_NOACCESS 6
#define SNMP_WRONGTYPE 7
#define SNMP_WRONGLENGTH 8
#define SNMP_WRONGENCODING 9
#define SNMP_WRONGVALUE 10
#define SNMP_NOCREATION 11
#define SNMP_INCONSISTENTVALUE 12
#define SNMP_RESOURCEUNAVAILABLE 13
#define SNMP_COMMITFAILED 14
#define SNMP_UNDOFAILED 15
#define SNMP_AUTHORIZATIONERROR 16
#define SNMP_NOTWRITABLE 17
#define SNMP_INCONSISTENTNAME 18
/* General SNMP V1 Traps */
#define SNMP_TRAP_COLDSTART 0
#define SNMP_TRAP_WARMSTART 1
#define SNMP_TRAP_LINKDOWN 2
#define SNMP_TRAP_LINKUP 3
#define SNMP_TRAP_AUTFAILURE 4
#define SNMP_TRAP_EQPNEIGHBORLOSS 5
#define SNMP_TRAP_ENTSPECIFIC 6
/* SNMPv1 Types */
#define SNMP_NULL 0
#define SNMP_INTEGER 1 /* l */
#define SNMP_OCTETSTR 2 /* c */
#define SNMP_DISPLAYSTR 2 /* c */
#define SNMP_OBJECTID 3 /* ul */
#define SNMP_IPADDR 4 /* uc */
#define SNMP_COUNTER 5 /* ul */
#define SNMP_GAUGE 6 /* ul */
#define SNMP_TIMETICKS 7 /* ul */
#define SNMP_OPAQUE 8 /* c */
/* Additional SNMPv2 Types */
#define SNMP_UINTEGER 5 /* ul */
#define SNMP_BITSTR 9 /* uc */
#define SNMP_NSAP 10 /* uc */
#define SNMP_COUNTER64 11 /* ul */
#define SNMP_NOSUCHOBJECT 12
#define SNMP_NOSUCHINSTANCE 13
#define SNMP_ENDOFMIBVIEW 14
union snmp_syntax
{
unsigned char uc[0]; /* 8 bit unsigned */
char c[0]; /* 8 bit signed */
unsigned long ul[0]; /* 32 bit unsigned */
long l[0]; /* 32 bit signed */
};
struct snmp_object
{
unsigned long *id;
unsigned int id_len;
unsigned short type;
unsigned int syntax_len;
union snmp_syntax syntax;
};
struct snmp_request
{
unsigned long id;
unsigned int error_status;
unsigned int error_index;
};
struct snmp_v1_trap
{
unsigned long *id;
unsigned int id_len;
unsigned long ip_address; /* pointer */
unsigned int general;
unsigned int specific;
unsigned long time;
};
/* SNMP types */
#define SNMP_IPA 0
#define SNMP_CNT 1
#define SNMP_GGE 2
#define SNMP_TIT 3
#define SNMP_OPQ 4
#define SNMP_C64 6
/* SNMP errors */
#define SERR_NSO 0
#define SERR_NSI 1
#define SERR_EOM 2
static inline void mangle_address(unsigned char *begin,
unsigned char *addr,
const struct oct1_map *map,
__sum16 *check);
struct snmp_cnv
{
unsigned int class;
unsigned int tag;
int syntax;
};
static struct snmp_cnv snmp_conv [] =
{
{ASN1_UNI, ASN1_NUL, SNMP_NULL},
{ASN1_UNI, ASN1_INT, SNMP_INTEGER},
{ASN1_UNI, ASN1_OTS, SNMP_OCTETSTR},
{ASN1_UNI, ASN1_OTS, SNMP_DISPLAYSTR},
{ASN1_UNI, ASN1_OJI, SNMP_OBJECTID},
{ASN1_APL, SNMP_IPA, SNMP_IPADDR},
{ASN1_APL, SNMP_CNT, SNMP_COUNTER}, /* Counter32 */
{ASN1_APL, SNMP_GGE, SNMP_GAUGE}, /* Gauge32 == Unsigned32 */
{ASN1_APL, SNMP_TIT, SNMP_TIMETICKS},
{ASN1_APL, SNMP_OPQ, SNMP_OPAQUE},
/* SNMPv2 data types and errors */
{ASN1_UNI, ASN1_BTS, SNMP_BITSTR},
{ASN1_APL, SNMP_C64, SNMP_COUNTER64},
{ASN1_CTX, SERR_NSO, SNMP_NOSUCHOBJECT},
{ASN1_CTX, SERR_NSI, SNMP_NOSUCHINSTANCE},
{ASN1_CTX, SERR_EOM, SNMP_ENDOFMIBVIEW},
{0, 0, -1}
};
static unsigned char snmp_tag_cls2syntax(unsigned int tag,
unsigned int cls,
unsigned short *syntax)
{
struct snmp_cnv *cnv;
cnv = snmp_conv;
while (cnv->syntax != -1) {
if (cnv->tag == tag && cnv->class == cls) {
*syntax = cnv->syntax;
return 1;
}
cnv++;
}
return 0;
}
static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
struct snmp_object **obj)
{
unsigned int cls, con, tag, len, idlen;
unsigned short type;
unsigned char *eoc, *end, *p;
unsigned long *lp, *id;
unsigned long ul;
long l;
*obj = NULL;
id = NULL;
if (!asn1_header_decode(ctx, &eoc, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
return 0;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
return 0;
if (!asn1_oid_decode(ctx, end, &id, &idlen))
return 0;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag)) {
kfree(id);
return 0;
}
if (con != ASN1_PRI) {
kfree(id);
return 0;
}
type = 0;
if (!snmp_tag_cls2syntax(tag, cls, &type)) {
kfree(id);
return 0;
}
l = 0;
switch (type) {
case SNMP_INTEGER:
len = sizeof(long);
if (!asn1_long_decode(ctx, end, &l)) {
kfree(id);
return 0;
}
*obj = kmalloc(sizeof(struct snmp_object) + len,
GFP_ATOMIC);
if (*obj == NULL) {
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
(*obj)->syntax.l[0] = l;
break;
case SNMP_OCTETSTR:
case SNMP_OPAQUE:
if (!asn1_octets_decode(ctx, end, &p, &len)) {
kfree(id);
return 0;
}
*obj = kmalloc(sizeof(struct snmp_object) + len,
GFP_ATOMIC);
if (*obj == NULL) {
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
memcpy((*obj)->syntax.c, p, len);
kfree(p);
break;
case SNMP_NULL:
case SNMP_NOSUCHOBJECT:
case SNMP_NOSUCHINSTANCE:
case SNMP_ENDOFMIBVIEW:
len = 0;
*obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC);
if (*obj == NULL) {
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
if (!asn1_null_decode(ctx, end)) {
kfree(id);
kfree(*obj);
*obj = NULL;
return 0;
}
break;
case SNMP_OBJECTID:
if (!asn1_oid_decode(ctx, end, (unsigned long **)&lp, &len)) {
kfree(id);
return 0;
}
len *= sizeof(unsigned long);
*obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
if (*obj == NULL) {
kfree(lp);
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
memcpy((*obj)->syntax.ul, lp, len);
kfree(lp);
break;
case SNMP_IPADDR:
if (!asn1_octets_decode(ctx, end, &p, &len)) {
kfree(id);
return 0;
}
if (len != 4) {
kfree(p);
kfree(id);
return 0;
}
*obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
if (*obj == NULL) {
kfree(p);
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
memcpy((*obj)->syntax.uc, p, len);
kfree(p);
break;
case SNMP_COUNTER:
case SNMP_GAUGE:
case SNMP_TIMETICKS:
len = sizeof(unsigned long);
if (!asn1_ulong_decode(ctx, end, &ul)) {
kfree(id);
return 0;
}
*obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
if (*obj == NULL) {
kfree(id);
if (net_ratelimit())
printk("OOM in bsalg (%d)\n", __LINE__);
return 0;
}
(*obj)->syntax.ul[0] = ul;
break;
default:
kfree(id);
return 0;
}
(*obj)->syntax_len = len;
(*obj)->type = type;
(*obj)->id = id;
(*obj)->id_len = idlen;
if (!asn1_eoc_decode(ctx, eoc)) {
kfree(id);
kfree(*obj);
*obj = NULL;
return 0;
}
return 1;
}
static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
struct snmp_request *request)
{
unsigned int cls, con, tag;
unsigned char *end;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
return 0;
if (!asn1_ulong_decode(ctx, end, &request->id))
return 0;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
return 0;
if (!asn1_uint_decode(ctx, end, &request->error_status))
return 0;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
return 0;
if (!asn1_uint_decode(ctx, end, &request->error_index))
return 0;
return 1;
}
/*
* Fast checksum update for possibly oddly-aligned UDP byte, from the
* code example in the draft.
*/
static void fast_csum(__sum16 *csum,
const unsigned char *optr,
const unsigned char *nptr,
int offset)
{
unsigned char s[4];
if (offset & 1) {
s[0] = s[2] = 0;
s[1] = ~*optr;
s[3] = *nptr;
} else {
s[1] = s[3] = 0;
s[0] = ~*optr;
s[2] = *nptr;
}
*csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum)));
}
/*
* Mangle IP address.
* - begin points to the start of the snmp messgae
* - addr points to the start of the address
*/
static inline void mangle_address(unsigned char *begin,
unsigned char *addr,
const struct oct1_map *map,
__sum16 *check)
{
if (map->from == NOCT1(addr)) {
u_int32_t old;
if (debug)
memcpy(&old, (unsigned char *)addr, sizeof(old));
*addr = map->to;
/* Update UDP checksum if being used */
if (*check) {
fast_csum(check,
&map->from, &map->to, addr - begin);
}
if (debug)
printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
"%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
}
}
static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
struct snmp_v1_trap *trap,
const struct oct1_map *map,
__sum16 *check)
{
unsigned int cls, con, tag, len;
unsigned char *end;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
return 0;
if (!asn1_oid_decode(ctx, end, &trap->id, &trap->id_len))
return 0;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
goto err_id_free;
if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_IPA) ||
(cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_OTS)))
goto err_id_free;
if (!asn1_octets_decode(ctx, end, (unsigned char **)&trap->ip_address, &len))
goto err_id_free;
/* IPv4 only */
if (len != 4)
goto err_addr_free;
mangle_address(ctx->begin, ctx->pointer - 4, map, check);
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
goto err_addr_free;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
goto err_addr_free;
if (!asn1_uint_decode(ctx, end, &trap->general))
goto err_addr_free;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
goto err_addr_free;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
goto err_addr_free;
if (!asn1_uint_decode(ctx, end, &trap->specific))
goto err_addr_free;
if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
goto err_addr_free;
if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_TIT) ||
(cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_INT)))
goto err_addr_free;
if (!asn1_ulong_decode(ctx, end, &trap->time))
goto err_addr_free;
return 1;
err_addr_free:
kfree((unsigned long *)trap->ip_address);
err_id_free:
kfree(trap->id);
return 0;
}
/*****************************************************************************
*
* Misc. routines
*
*****************************************************************************/
static void hex_dump(unsigned char *buf, size_t len)
{
size_t i;
for (i = 0; i < len; i++) {
if (i && !(i % 16))
printk("\n");
printk("%02x ", *(buf + i));
}
printk("\n");
}
/*
* Parse and mangle SNMP message according to mapping.
* (And this is the fucking 'basic' method).
*/
static int snmp_parse_mangle(unsigned char *msg,
u_int16_t len,
const struct oct1_map *map,
__sum16 *check)
{
unsigned char *eoc, *end;
unsigned int cls, con, tag, vers, pdutype;
struct asn1_ctx ctx;
struct asn1_octstr comm;
struct snmp_object **obj;
if (debug > 1)
hex_dump(msg, len);
asn1_open(&ctx, msg, len);
/*
* Start of SNMP message.
*/
if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
return 0;
/*
* Version 1 or 2 handled.
*/
if (!asn1_header_decode(&ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
return 0;
if (!asn1_uint_decode (&ctx, end, &vers))
return 0;
if (debug > 1)
printk(KERN_DEBUG "bsalg: snmp version: %u\n", vers + 1);
if (vers > 1)
return 1;
/*
* Community.
*/
if (!asn1_header_decode (&ctx, &end, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OTS)
return 0;
if (!asn1_octets_decode(&ctx, end, &comm.data, &comm.len))
return 0;
if (debug > 1) {
unsigned int i;
printk(KERN_DEBUG "bsalg: community: ");
for (i = 0; i < comm.len; i++)
printk("%c", comm.data[i]);
printk("\n");
}
kfree(comm.data);
/*
* PDU type
*/
if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &pdutype))
return 0;
if (cls != ASN1_CTX || con != ASN1_CON)
return 0;
if (debug > 1) {
unsigned char *pdus[] = {
[SNMP_PDU_GET] = "get",
[SNMP_PDU_NEXT] = "get-next",
[SNMP_PDU_RESPONSE] = "response",
[SNMP_PDU_SET] = "set",
[SNMP_PDU_TRAP1] = "trapv1",
[SNMP_PDU_BULK] = "bulk",
[SNMP_PDU_INFORM] = "inform",
[SNMP_PDU_TRAP2] = "trapv2"
};
if (pdutype > SNMP_PDU_TRAP2)
printk(KERN_DEBUG "bsalg: bad pdu type %u\n", pdutype);
else
printk(KERN_DEBUG "bsalg: pdu: %s\n", pdus[pdutype]);
}
if (pdutype != SNMP_PDU_RESPONSE &&
pdutype != SNMP_PDU_TRAP1 && pdutype != SNMP_PDU_TRAP2)
return 1;
/*
* Request header or v1 trap
*/
if (pdutype == SNMP_PDU_TRAP1) {
struct snmp_v1_trap trap;
unsigned char ret = snmp_trap_decode(&ctx, &trap, map, check);
if (ret) {
kfree(trap.id);
kfree((unsigned long *)trap.ip_address);
} else
return ret;
} else {
struct snmp_request req;
if (!snmp_request_decode(&ctx, &req))
return 0;
if (debug > 1)
printk(KERN_DEBUG "bsalg: request: id=0x%lx error_status=%u "
"error_index=%u\n", req.id, req.error_status,
req.error_index);
}
/*
* Loop through objects, look for IP addresses to mangle.
*/
if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
return 0;
if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
return 0;
obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC);
if (obj == NULL) {
if (net_ratelimit())
printk(KERN_WARNING "OOM in bsalg(%d)\n", __LINE__);
return 0;
}
while (!asn1_eoc_decode(&ctx, eoc)) {
unsigned int i;
if (!snmp_object_decode(&ctx, obj)) {
if (*obj) {
kfree((*obj)->id);
kfree(*obj);
}
kfree(obj);
return 0;
}
if (debug > 1) {
printk(KERN_DEBUG "bsalg: object: ");
for (i = 0; i < (*obj)->id_len; i++) {
if (i > 0)
printk(".");
printk("%lu", (*obj)->id[i]);
}
printk(": type=%u\n", (*obj)->type);
}
if ((*obj)->type == SNMP_IPADDR)
mangle_address(ctx.begin, ctx.pointer - 4 , map, check);
kfree((*obj)->id);
kfree(*obj);
}
kfree(obj);
if (!asn1_eoc_decode(&ctx, eoc))
return 0;
return 1;
}
/*****************************************************************************
*
* NAT routines.
*
*****************************************************************************/
/*
* SNMP translation routine.
*/
static int snmp_translate(struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
struct sk_buff **pskb)
{
struct iphdr *iph = ip_hdr(*pskb);
struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
u_int16_t udplen = ntohs(udph->len);
u_int16_t paylen = udplen - sizeof(struct udphdr);
int dir = CTINFO2DIR(ctinfo);
struct oct1_map map;
/*
* Determine mappping for application layer addresses based
* on NAT manipulations for the packet.
*/
if (dir == IP_CT_DIR_ORIGINAL) {
/* SNAT traps */
map.from = NOCT1(&ct->tuplehash[dir].tuple.src.u3.ip);
map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip);
} else {
/* DNAT replies */
map.from = NOCT1(&ct->tuplehash[dir].tuple.src.u3.ip);
map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip);
}
if (map.from == map.to)
return NF_ACCEPT;
if (!snmp_parse_mangle((unsigned char *)udph + sizeof(struct udphdr),
paylen, &map, &udph->check)) {
if (net_ratelimit())
printk(KERN_WARNING "bsalg: parser failed\n");
return NF_DROP;
}
return NF_ACCEPT;
}
/* We don't actually set up expectations, just adjust internal IP
* addresses if this is being NATted */
static int help(struct sk_buff **pskb, unsigned int protoff,
struct nf_conn *ct,
enum ip_conntrack_info ctinfo)
{
int dir = CTINFO2DIR(ctinfo);
unsigned int ret;
struct iphdr *iph = ip_hdr(*pskb);
struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl);
/* SNMP replies and originating SNMP traps get mangled */
if (udph->source == htons(SNMP_PORT) && dir != IP_CT_DIR_REPLY)
return NF_ACCEPT;
if (udph->dest == htons(SNMP_TRAP_PORT) && dir != IP_CT_DIR_ORIGINAL)
return NF_ACCEPT;
/* No NAT? */
if (!(ct->status & IPS_NAT_MASK))
return NF_ACCEPT;
/*
* Make sure the packet length is ok. So far, we were only guaranteed
* to have a valid length IP header plus 8 bytes, which means we have
* enough room for a UDP header. Just verify the UDP length field so we
* can mess around with the payload.
*/
if (ntohs(udph->len) != (*pskb)->len - (iph->ihl << 2)) {
if (net_ratelimit())
printk(KERN_WARNING "SNMP: dropping malformed packet "
"src=%u.%u.%u.%u dst=%u.%u.%u.%u\n",
NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
return NF_DROP;
}
if (!skb_make_writable(pskb, (*pskb)->len))
return NF_DROP;
spin_lock_bh(&snmp_lock);
ret = snmp_translate(ct, ctinfo, pskb);
spin_unlock_bh(&snmp_lock);
return ret;
}
static struct nf_conntrack_helper snmp_helper __read_mostly = {
.max_expected = 0,
.timeout = 180,
.me = THIS_MODULE,
.help = help,
.name = "snmp",
.tuple.src.l3num = AF_INET,
.tuple.src.u.udp.port = __constant_htons(SNMP_PORT),
.tuple.dst.protonum = IPPROTO_UDP,
};
static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {
.max_expected = 0,
.timeout = 180,
.me = THIS_MODULE,
.help = help,
.name = "snmp_trap",
.tuple.src.l3num = AF_INET,
.tuple.src.u.udp.port = __constant_htons(SNMP_TRAP_PORT),
.tuple.dst.protonum = IPPROTO_UDP,
};
/*****************************************************************************
*
* Module stuff.
*
*****************************************************************************/
static int __init nf_nat_snmp_basic_init(void)
{
int ret = 0;
ret = nf_conntrack_helper_register(&snmp_helper);
if (ret < 0)
return ret;
ret = nf_conntrack_helper_register(&snmp_trap_helper);
if (ret < 0) {
nf_conntrack_helper_unregister(&snmp_helper);
return ret;
}
return ret;
}
static void __exit nf_nat_snmp_basic_fini(void)
{
nf_conntrack_helper_unregister(&snmp_helper);
nf_conntrack_helper_unregister(&snmp_trap_helper);
}
module_init(nf_nat_snmp_basic_init);
module_exit(nf_nat_snmp_basic_fini);
module_param(debug, int, 0600);
| gpl-2.0 |
Fe-Pi/linux | drivers/media/usb/dvb-usb/af9005.c | 28361 | /* DVB USB compliant Linux driver for the Afatech 9005
* USB1.1 DVB-T receiver.
*
* Copyright (C) 2007 Luca Olivetti ([email protected])
*
* Thanks to Afatech who kindly provided information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* see Documentation/media/dvb-drivers/dvb-usb.rst for more information
*/
#include "af9005.h"
/* debug */
int dvb_usb_af9005_debug;
module_param_named(debug, dvb_usb_af9005_debug, int, 0644);
MODULE_PARM_DESC(debug,
"set debugging level (1=info,xfer=2,rc=4,reg=8,i2c=16,fw=32 (or-able))."
DVB_USB_DEBUG_STATUS);
/* enable obnoxious led */
bool dvb_usb_af9005_led = true;
module_param_named(led, dvb_usb_af9005_led, bool, 0644);
MODULE_PARM_DESC(led, "enable led (default: 1).");
/* eeprom dump */
static int dvb_usb_af9005_dump_eeprom;
module_param_named(dump_eeprom, dvb_usb_af9005_dump_eeprom, int, 0);
MODULE_PARM_DESC(dump_eeprom, "dump contents of the eeprom.");
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
/* remote control decoder */
static int (*rc_decode) (struct dvb_usb_device *d, u8 *data, int len,
u32 *event, int *state);
static void *rc_keys;
static int *rc_keys_size;
u8 regmask[8] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
struct af9005_device_state {
u8 sequence;
int led_state;
unsigned char data[256];
};
static int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg,
int readwrite, int type, u8 * values, int len)
{
struct af9005_device_state *st = d->priv;
u8 command, seq;
int i, ret;
if (len < 1) {
err("generic read/write, less than 1 byte. Makes no sense.");
return -EINVAL;
}
if (len > 8) {
err("generic read/write, more than 8 bytes. Not supported.");
return -EINVAL;
}
mutex_lock(&d->data_mutex);
st->data[0] = 14; /* rest of buffer length low */
st->data[1] = 0; /* rest of buffer length high */
st->data[2] = AF9005_REGISTER_RW; /* register operation */
st->data[3] = 12; /* rest of buffer length */
st->data[4] = seq = st->sequence++; /* sequence number */
st->data[5] = (u8) (reg >> 8); /* register address */
st->data[6] = (u8) (reg & 0xff);
if (type == AF9005_OFDM_REG) {
command = AF9005_CMD_OFDM_REG;
} else {
command = AF9005_CMD_TUNER;
}
if (len > 1)
command |=
AF9005_CMD_BURST | AF9005_CMD_AUTOINC | (len - 1) << 3;
command |= readwrite;
if (readwrite == AF9005_CMD_WRITE)
for (i = 0; i < len; i++)
st->data[8 + i] = values[i];
else if (type == AF9005_TUNER_REG)
/* read command for tuner, the first byte contains the i2c address */
st->data[8] = values[0];
st->data[7] = command;
ret = dvb_usb_generic_rw(d, st->data, 16, st->data, 17, 0);
if (ret)
goto ret;
/* sanity check */
if (st->data[2] != AF9005_REGISTER_RW_ACK) {
err("generic read/write, wrong reply code.");
ret = -EIO;
goto ret;
}
if (st->data[3] != 0x0d) {
err("generic read/write, wrong length in reply.");
ret = -EIO;
goto ret;
}
if (st->data[4] != seq) {
err("generic read/write, wrong sequence in reply.");
ret = -EIO;
goto ret;
}
/*
* In thesis, both input and output buffers should have
* identical values for st->data[5] to st->data[8].
* However, windows driver doesn't check these fields, in fact
* sometimes the register in the reply is different that what
* has been sent
*/
if (st->data[16] != 0x01) {
err("generic read/write wrong status code in reply.");
ret = -EIO;
goto ret;
}
if (readwrite == AF9005_CMD_READ)
for (i = 0; i < len; i++)
values[i] = st->data[8 + i];
ret:
mutex_unlock(&d->data_mutex);
return ret;
}
int af9005_read_ofdm_register(struct dvb_usb_device *d, u16 reg, u8 * value)
{
int ret;
deb_reg("read register %x ", reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_OFDM_REG,
value, 1);
if (ret)
deb_reg("failed\n");
else
deb_reg("value %x\n", *value);
return ret;
}
int af9005_read_ofdm_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
int ret;
deb_reg("read %d registers %x ", len, reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_OFDM_REG,
values, len);
if (ret)
deb_reg("failed\n");
else
debug_dump(values, len, deb_reg);
return ret;
}
int af9005_write_ofdm_register(struct dvb_usb_device *d, u16 reg, u8 value)
{
int ret;
u8 temp = value;
deb_reg("write register %x value %x ", reg, value);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE, AF9005_OFDM_REG,
&temp, 1);
if (ret)
deb_reg("failed\n");
else
deb_reg("ok\n");
return ret;
}
int af9005_write_ofdm_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
int ret;
deb_reg("write %d registers %x values ", len, reg);
debug_dump(values, len, deb_reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE, AF9005_OFDM_REG,
values, len);
if (ret)
deb_reg("failed\n");
else
deb_reg("ok\n");
return ret;
}
int af9005_read_register_bits(struct dvb_usb_device *d, u16 reg, u8 pos,
u8 len, u8 * value)
{
u8 temp;
int ret;
deb_reg("read bits %x %x %x", reg, pos, len);
ret = af9005_read_ofdm_register(d, reg, &temp);
if (ret) {
deb_reg(" failed\n");
return ret;
}
*value = (temp >> pos) & regmask[len - 1];
deb_reg(" value %x\n", *value);
return 0;
}
int af9005_write_register_bits(struct dvb_usb_device *d, u16 reg, u8 pos,
u8 len, u8 value)
{
u8 temp, mask;
int ret;
deb_reg("write bits %x %x %x value %x\n", reg, pos, len, value);
if (pos == 0 && len == 8)
return af9005_write_ofdm_register(d, reg, value);
ret = af9005_read_ofdm_register(d, reg, &temp);
if (ret)
return ret;
mask = regmask[len - 1] << pos;
temp = (temp & ~mask) | ((value << pos) & mask);
return af9005_write_ofdm_register(d, reg, temp);
}
static int af9005_usb_read_tuner_registers(struct dvb_usb_device *d,
u16 reg, u8 * values, int len)
{
return af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_TUNER_REG,
values, len);
}
static int af9005_usb_write_tuner_registers(struct dvb_usb_device *d,
u16 reg, u8 * values, int len)
{
return af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE,
AF9005_TUNER_REG, values, len);
}
int af9005_write_tuner_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
/* don't let the name of this function mislead you: it's just used
as an interface from the firmware to the i2c bus. The actual
i2c addresses are contained in the data */
int ret, i, done = 0, fail = 0;
u8 temp;
ret = af9005_usb_write_tuner_registers(d, reg, values, len);
if (ret)
return ret;
if (reg != 0xffff) {
/* check if write done (0xa40d bit 1) or fail (0xa40d bit 2) */
for (i = 0; i < 200; i++) {
ret =
af9005_read_ofdm_register(d,
xd_I2C_i2c_m_status_wdat_done,
&temp);
if (ret)
return ret;
done = temp & (regmask[i2c_m_status_wdat_done_len - 1]
<< i2c_m_status_wdat_done_pos);
if (done)
break;
fail = temp & (regmask[i2c_m_status_wdat_fail_len - 1]
<< i2c_m_status_wdat_fail_pos);
if (fail)
break;
msleep(50);
}
if (i == 200)
return -ETIMEDOUT;
if (fail) {
/* clear write fail bit */
af9005_write_register_bits(d,
xd_I2C_i2c_m_status_wdat_fail,
i2c_m_status_wdat_fail_pos,
i2c_m_status_wdat_fail_len,
1);
return -EIO;
}
/* clear write done bit */
ret =
af9005_write_register_bits(d,
xd_I2C_i2c_m_status_wdat_fail,
i2c_m_status_wdat_done_pos,
i2c_m_status_wdat_done_len, 1);
if (ret)
return ret;
}
return 0;
}
int af9005_read_tuner_registers(struct dvb_usb_device *d, u16 reg, u8 addr,
u8 * values, int len)
{
/* don't let the name of this function mislead you: it's just used
as an interface from the firmware to the i2c bus. The actual
i2c addresses are contained in the data */
int ret, i;
u8 temp, buf[2];
buf[0] = addr; /* tuner i2c address */
buf[1] = values[0]; /* tuner register */
values[0] = addr + 0x01; /* i2c read address */
if (reg == APO_REG_I2C_RW_SILICON_TUNER) {
/* write tuner i2c address to tuner, 0c00c0 undocumented, found by sniffing */
ret = af9005_write_tuner_registers(d, 0x00c0, buf, 2);
if (ret)
return ret;
}
/* send read command to ofsm */
ret = af9005_usb_read_tuner_registers(d, reg, values, 1);
if (ret)
return ret;
/* check if read done */
for (i = 0; i < 200; i++) {
ret = af9005_read_ofdm_register(d, 0xa408, &temp);
if (ret)
return ret;
if (temp & 0x01)
break;
msleep(50);
}
if (i == 200)
return -ETIMEDOUT;
/* clear read done bit (by writing 1) */
ret = af9005_write_ofdm_register(d, xd_I2C_i2c_m_data8, 1);
if (ret)
return ret;
/* get read data (available from 0xa400) */
for (i = 0; i < len; i++) {
ret = af9005_read_ofdm_register(d, 0xa400 + i, &temp);
if (ret)
return ret;
values[i] = temp;
}
return 0;
}
static int af9005_i2c_write(struct dvb_usb_device *d, u8 i2caddr, u8 reg,
u8 * data, int len)
{
int ret, i;
u8 buf[3];
deb_i2c("i2c_write i2caddr %x, reg %x, len %d data ", i2caddr,
reg, len);
debug_dump(data, len, deb_i2c);
for (i = 0; i < len; i++) {
buf[0] = i2caddr;
buf[1] = reg + (u8) i;
buf[2] = data[i];
ret =
af9005_write_tuner_registers(d,
APO_REG_I2C_RW_SILICON_TUNER,
buf, 3);
if (ret) {
deb_i2c("i2c_write failed\n");
return ret;
}
}
deb_i2c("i2c_write ok\n");
return 0;
}
static int af9005_i2c_read(struct dvb_usb_device *d, u8 i2caddr, u8 reg,
u8 * data, int len)
{
int ret, i;
u8 temp;
deb_i2c("i2c_read i2caddr %x, reg %x, len %d\n ", i2caddr, reg, len);
for (i = 0; i < len; i++) {
temp = reg + i;
ret =
af9005_read_tuner_registers(d,
APO_REG_I2C_RW_SILICON_TUNER,
i2caddr, &temp, 1);
if (ret) {
deb_i2c("i2c_read failed\n");
return ret;
}
data[i] = temp;
}
deb_i2c("i2c data read: ");
debug_dump(data, len, deb_i2c);
return 0;
}
static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
int num)
{
/* only implements what the mt2060 module does, don't know how
to make it really generic */
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret;
u8 reg, addr;
u8 *value;
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
if (num > 2)
warn("more than 2 i2c messages at a time is not handled yet. TODO.");
if (num == 2) {
/* reads a single register */
reg = *msg[0].buf;
addr = msg[0].addr;
value = msg[1].buf;
ret = af9005_i2c_read(d, addr, reg, value, 1);
if (ret == 0)
ret = 2;
} else {
/* write one or more registers */
reg = msg[0].buf[0];
addr = msg[0].addr;
value = &msg[0].buf[1];
ret = af9005_i2c_write(d, addr, reg, value, msg[0].len - 1);
if (ret == 0)
ret = 1;
}
mutex_unlock(&d->i2c_mutex);
return ret;
}
static u32 af9005_i2c_func(struct i2c_adapter *adapter)
{
return I2C_FUNC_I2C;
}
static struct i2c_algorithm af9005_i2c_algo = {
.master_xfer = af9005_i2c_xfer,
.functionality = af9005_i2c_func,
};
int af9005_send_command(struct dvb_usb_device *d, u8 command, u8 * wbuf,
int wlen, u8 * rbuf, int rlen)
{
struct af9005_device_state *st = d->priv;
int ret, i, packet_len;
u8 seq;
if (wlen < 0) {
err("send command, wlen less than 0 bytes. Makes no sense.");
return -EINVAL;
}
if (wlen > 54) {
err("send command, wlen more than 54 bytes. Not supported.");
return -EINVAL;
}
if (rlen > 54) {
err("send command, rlen more than 54 bytes. Not supported.");
return -EINVAL;
}
packet_len = wlen + 5;
mutex_lock(&d->data_mutex);
st->data[0] = (u8) (packet_len & 0xff);
st->data[1] = (u8) ((packet_len & 0xff00) >> 8);
st->data[2] = 0x26; /* packet type */
st->data[3] = wlen + 3;
st->data[4] = seq = st->sequence++;
st->data[5] = command;
st->data[6] = wlen;
for (i = 0; i < wlen; i++)
st->data[7 + i] = wbuf[i];
ret = dvb_usb_generic_rw(d, st->data, wlen + 7, st->data, rlen + 7, 0);
if (st->data[2] != 0x27) {
err("send command, wrong reply code.");
ret = -EIO;
} else if (st->data[4] != seq) {
err("send command, wrong sequence in reply.");
ret = -EIO;
} else if (st->data[5] != 0x01) {
err("send command, wrong status code in reply.");
ret = -EIO;
} else if (st->data[6] != rlen) {
err("send command, invalid data length in reply.");
ret = -EIO;
}
if (!ret) {
for (i = 0; i < rlen; i++)
rbuf[i] = st->data[i + 7];
}
mutex_unlock(&d->data_mutex);
return ret;
}
int af9005_read_eeprom(struct dvb_usb_device *d, u8 address, u8 * values,
int len)
{
struct af9005_device_state *st = d->priv;
u8 seq;
int ret, i;
mutex_lock(&d->data_mutex);
memset(st->data, 0, sizeof(st->data));
st->data[0] = 14; /* length of rest of packet low */
st->data[1] = 0; /* length of rest of packer high */
st->data[2] = 0x2a; /* read/write eeprom */
st->data[3] = 12; /* size */
st->data[4] = seq = st->sequence++;
st->data[5] = 0; /* read */
st->data[6] = len;
st->data[7] = address;
ret = dvb_usb_generic_rw(d, st->data, 16, st->data, 14, 0);
if (st->data[2] != 0x2b) {
err("Read eeprom, invalid reply code");
ret = -EIO;
} else if (st->data[3] != 10) {
err("Read eeprom, invalid reply length");
ret = -EIO;
} else if (st->data[4] != seq) {
err("Read eeprom, wrong sequence in reply ");
ret = -EIO;
} else if (st->data[5] != 1) {
err("Read eeprom, wrong status in reply ");
ret = -EIO;
}
if (!ret) {
for (i = 0; i < len; i++)
values[i] = st->data[6 + i];
}
mutex_unlock(&d->data_mutex);
return ret;
}
static int af9005_boot_packet(struct usb_device *udev, int type, u8 *reply,
u8 *buf, int size)
{
u16 checksum;
int act_len = 0, i, ret;
memset(buf, 0, size);
buf[0] = (u8) (FW_BULKOUT_SIZE & 0xff);
buf[1] = (u8) ((FW_BULKOUT_SIZE >> 8) & 0xff);
switch (type) {
case FW_CONFIG:
buf[2] = 0x11;
buf[3] = 0x04;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x03;
checksum = buf[4] + buf[5];
buf[6] = (u8) ((checksum >> 8) & 0xff);
buf[7] = (u8) (checksum & 0xff);
break;
case FW_CONFIRM:
buf[2] = 0x11;
buf[3] = 0x04;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x01;
checksum = buf[4] + buf[5];
buf[6] = (u8) ((checksum >> 8) & 0xff);
buf[7] = (u8) (checksum & 0xff);
break;
case FW_BOOT:
buf[2] = 0x10;
buf[3] = 0x08;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x97;
buf[6] = 0xaa;
buf[7] = 0x55;
buf[8] = 0xa5;
buf[9] = 0x5a;
checksum = 0;
for (i = 4; i <= 9; i++)
checksum += buf[i];
buf[10] = (u8) ((checksum >> 8) & 0xff);
buf[11] = (u8) (checksum & 0xff);
break;
default:
err("boot packet invalid boot packet type");
return -EINVAL;
}
deb_fw(">>> ");
debug_dump(buf, FW_BULKOUT_SIZE + 2, deb_fw);
ret = usb_bulk_msg(udev,
usb_sndbulkpipe(udev, 0x02),
buf, FW_BULKOUT_SIZE + 2, &act_len, 2000);
if (ret)
err("boot packet bulk message failed: %d (%d/%d)", ret,
FW_BULKOUT_SIZE + 2, act_len);
else
ret = act_len != FW_BULKOUT_SIZE + 2 ? -1 : 0;
if (ret)
return ret;
memset(buf, 0, 9);
ret = usb_bulk_msg(udev,
usb_rcvbulkpipe(udev, 0x01), buf, 9, &act_len, 2000);
if (ret) {
err("boot packet recv bulk message failed: %d", ret);
return ret;
}
deb_fw("<<< ");
debug_dump(buf, act_len, deb_fw);
checksum = 0;
switch (type) {
case FW_CONFIG:
if (buf[2] != 0x11) {
err("boot bad config header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad config size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad config sequence.");
return -EIO;
}
if (buf[5] != 0x04) {
err("boot bad config subtype.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad config checksum.");
return -EIO;
}
*reply = buf[6];
break;
case FW_CONFIRM:
if (buf[2] != 0x11) {
err("boot bad confirm header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad confirm size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad confirm sequence.");
return -EIO;
}
if (buf[5] != 0x02) {
err("boot bad confirm subtype.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad confirm checksum.");
return -EIO;
}
*reply = buf[6];
break;
case FW_BOOT:
if (buf[2] != 0x10) {
err("boot bad boot header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad boot size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad boot sequence.");
return -EIO;
}
if (buf[5] != 0x01) {
err("boot bad boot pattern 01.");
return -EIO;
}
if (buf[6] != 0x10) {
err("boot bad boot pattern 10.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad boot checksum.");
return -EIO;
}
break;
}
return 0;
}
static int af9005_download_firmware(struct usb_device *udev, const struct firmware *fw)
{
int i, packets, ret, act_len;
u8 *buf;
u8 reply;
buf = kmalloc(FW_BULKOUT_SIZE + 2, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply, buf,
FW_BULKOUT_SIZE + 2);
if (ret)
goto err;
if (reply != 0x01) {
err("before downloading firmware, FW_CONFIG expected 0x01, received 0x%x", reply);
ret = -EIO;
goto err;
}
packets = fw->size / FW_BULKOUT_SIZE;
buf[0] = (u8) (FW_BULKOUT_SIZE & 0xff);
buf[1] = (u8) ((FW_BULKOUT_SIZE >> 8) & 0xff);
for (i = 0; i < packets; i++) {
memcpy(&buf[2], fw->data + i * FW_BULKOUT_SIZE,
FW_BULKOUT_SIZE);
deb_fw(">>> ");
debug_dump(buf, FW_BULKOUT_SIZE + 2, deb_fw);
ret = usb_bulk_msg(udev,
usb_sndbulkpipe(udev, 0x02),
buf, FW_BULKOUT_SIZE + 2, &act_len, 1000);
if (ret) {
err("firmware download failed at packet %d with code %d", i, ret);
goto err;
}
}
ret = af9005_boot_packet(udev, FW_CONFIRM, &reply,
buf, FW_BULKOUT_SIZE + 2);
if (ret)
goto err;
if (reply != (u8) (packets & 0xff)) {
err("after downloading firmware, FW_CONFIRM expected 0x%x, received 0x%x", packets & 0xff, reply);
ret = -EIO;
goto err;
}
ret = af9005_boot_packet(udev, FW_BOOT, &reply, buf,
FW_BULKOUT_SIZE + 2);
if (ret)
goto err;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply, buf,
FW_BULKOUT_SIZE + 2);
if (ret)
goto err;
if (reply != 0x02) {
err("after downloading firmware, FW_CONFIG expected 0x02, received 0x%x", reply);
ret = -EIO;
goto err;
}
err:
kfree(buf);
return ret;
}
int af9005_led_control(struct dvb_usb_device *d, int onoff)
{
struct af9005_device_state *st = d->priv;
int temp, ret;
if (onoff && dvb_usb_af9005_led)
temp = 1;
else
temp = 0;
if (st->led_state != temp) {
ret =
af9005_write_register_bits(d, xd_p_reg_top_locken1,
reg_top_locken1_pos,
reg_top_locken1_len, temp);
if (ret)
return ret;
ret =
af9005_write_register_bits(d, xd_p_reg_top_lock1,
reg_top_lock1_pos,
reg_top_lock1_len, temp);
if (ret)
return ret;
st->led_state = temp;
}
return 0;
}
static int af9005_frontend_attach(struct dvb_usb_adapter *adap)
{
u8 buf[8];
int i;
/* without these calls the first commands after downloading
the firmware fail. I put these calls here to simulate
what it is done in dvb-usb-init.c.
*/
struct usb_device *udev = adap->dev->udev;
usb_clear_halt(udev, usb_sndbulkpipe(udev, 2));
usb_clear_halt(udev, usb_rcvbulkpipe(udev, 1));
if (dvb_usb_af9005_dump_eeprom) {
printk("EEPROM DUMP\n");
for (i = 0; i < 255; i += 8) {
af9005_read_eeprom(adap->dev, i, buf, 8);
debug_dump(buf, 8, printk);
}
}
adap->fe_adap[0].fe = af9005_fe_attach(adap->dev);
return 0;
}
static int af9005_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
{
struct af9005_device_state *st = d->priv;
int ret, len;
u8 seq;
*state = REMOTE_NO_KEY_PRESSED;
if (rc_decode == NULL) {
/* it shouldn't never come here */
return 0;
}
mutex_lock(&d->data_mutex);
/* deb_info("rc_query\n"); */
st->data[0] = 3; /* rest of packet length low */
st->data[1] = 0; /* rest of packet lentgh high */
st->data[2] = 0x40; /* read remote */
st->data[3] = 1; /* rest of packet length */
st->data[4] = seq = st->sequence++; /* sequence number */
ret = dvb_usb_generic_rw(d, st->data, 5, st->data, 256, 0);
if (ret) {
err("rc query failed");
goto ret;
}
if (st->data[2] != 0x41) {
err("rc query bad header.");
ret = -EIO;
goto ret;
} else if (st->data[4] != seq) {
err("rc query bad sequence.");
ret = -EIO;
goto ret;
}
len = st->data[5];
if (len > 246) {
err("rc query invalid length");
ret = -EIO;
goto ret;
}
if (len > 0) {
deb_rc("rc data (%d) ", len);
debug_dump((st->data + 6), len, deb_rc);
ret = rc_decode(d, &st->data[6], len, event, state);
if (ret) {
err("rc_decode failed");
goto ret;
} else {
deb_rc("rc_decode state %x event %x\n", *state, *event);
if (*state == REMOTE_KEY_REPEAT)
*event = d->last_event;
}
}
ret:
mutex_unlock(&d->data_mutex);
return ret;
}
static int af9005_power_ctrl(struct dvb_usb_device *d, int onoff)
{
return 0;
}
static int af9005_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
{
int ret;
deb_info("pid filter control onoff %d\n", onoff);
if (onoff) {
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);
if (ret)
return ret;
ret =
af9005_write_register_bits(adap->dev,
XD_MP2IF_DMX_CTRL, 1, 1, 1);
if (ret)
return ret;
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);
} else
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 0);
if (ret)
return ret;
deb_info("pid filter control ok\n");
return 0;
}
static int af9005_pid_filter(struct dvb_usb_adapter *adap, int index,
u16 pid, int onoff)
{
u8 cmd = index & 0x1f;
int ret;
deb_info("set pid filter, index %d, pid %x, onoff %d\n", index,
pid, onoff);
if (onoff) {
/* cannot use it as pid_filter_ctrl since it has to be done
before setting the first pid */
if (adap->feedcount == 1) {
deb_info("first pid set, enable pid table\n");
ret = af9005_pid_filter_control(adap, onoff);
if (ret)
return ret;
}
ret =
af9005_write_ofdm_register(adap->dev,
XD_MP2IF_PID_DATA_L,
(u8) (pid & 0xff));
if (ret)
return ret;
ret =
af9005_write_ofdm_register(adap->dev,
XD_MP2IF_PID_DATA_H,
(u8) (pid >> 8));
if (ret)
return ret;
cmd |= 0x20 | 0x40;
} else {
if (adap->feedcount == 0) {
deb_info("last pid unset, disable pid table\n");
ret = af9005_pid_filter_control(adap, onoff);
if (ret)
return ret;
}
}
ret = af9005_write_ofdm_register(adap->dev, XD_MP2IF_PID_IDX, cmd);
if (ret)
return ret;
deb_info("set pid ok\n");
return 0;
}
static int af9005_identify_state(struct usb_device *udev,
struct dvb_usb_device_properties *props,
struct dvb_usb_device_description **desc,
int *cold)
{
int ret;
u8 reply, *buf;
buf = kmalloc(FW_BULKOUT_SIZE + 2, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply,
buf, FW_BULKOUT_SIZE + 2);
if (ret)
goto err;
deb_info("result of FW_CONFIG in identify state %d\n", reply);
if (reply == 0x01)
*cold = 1;
else if (reply == 0x02)
*cold = 0;
else
ret = -EIO;
if (!ret)
deb_info("Identify state cold = %d\n", *cold);
err:
kfree(buf);
return ret;
}
static struct dvb_usb_device_properties af9005_properties;
static int af9005_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
return dvb_usb_device_init(intf, &af9005_properties,
THIS_MODULE, NULL, adapter_nr);
}
enum af9005_usb_table_entry {
AFATECH_AF9005,
TERRATEC_AF9005,
ANSONIC_AF9005,
};
static struct usb_device_id af9005_usb_table[] = {
[AFATECH_AF9005] = {USB_DEVICE(USB_VID_AFATECH,
USB_PID_AFATECH_AF9005)},
[TERRATEC_AF9005] = {USB_DEVICE(USB_VID_TERRATEC,
USB_PID_TERRATEC_CINERGY_T_USB_XE)},
[ANSONIC_AF9005] = {USB_DEVICE(USB_VID_ANSONIC,
USB_PID_ANSONIC_DVBT_USB)},
{ }
};
MODULE_DEVICE_TABLE(usb, af9005_usb_table);
static struct dvb_usb_device_properties af9005_properties = {
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
.usb_ctrl = DEVICE_SPECIFIC,
.firmware = "af9005.fw",
.download_firmware = af9005_download_firmware,
.no_reconnect = 1,
.size_of_priv = sizeof(struct af9005_device_state),
.num_adapters = 1,
.adapter = {
{
.num_frontends = 1,
.fe = {{
.caps =
DVB_USB_ADAP_HAS_PID_FILTER |
DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
.pid_filter_count = 32,
.pid_filter = af9005_pid_filter,
/* .pid_filter_ctrl = af9005_pid_filter_control, */
.frontend_attach = af9005_frontend_attach,
/* .tuner_attach = af9005_tuner_attach, */
/* parameter for the MPEG2-data transfer */
.stream = {
.type = USB_BULK,
.count = 10,
.endpoint = 0x04,
.u = {
.bulk = {
.buffersize = 4096, /* actual size seen is 3948 */
}
}
},
}},
}
},
.power_ctrl = af9005_power_ctrl,
.identify_state = af9005_identify_state,
.i2c_algo = &af9005_i2c_algo,
.rc.legacy = {
.rc_interval = 200,
.rc_map_table = NULL,
.rc_map_size = 0,
.rc_query = af9005_rc_query,
},
.generic_bulk_ctrl_endpoint = 2,
.generic_bulk_ctrl_endpoint_response = 1,
.num_device_descs = 3,
.devices = {
{.name = "Afatech DVB-T USB1.1 stick",
.cold_ids = {&af9005_usb_table[AFATECH_AF9005], NULL},
.warm_ids = {NULL},
},
{.name = "TerraTec Cinergy T USB XE",
.cold_ids = {&af9005_usb_table[TERRATEC_AF9005], NULL},
.warm_ids = {NULL},
},
{.name = "Ansonic DVB-T USB1.1 stick",
.cold_ids = {&af9005_usb_table[ANSONIC_AF9005], NULL},
.warm_ids = {NULL},
},
{NULL},
}
};
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver af9005_usb_driver = {
.name = "dvb_usb_af9005",
.probe = af9005_usb_probe,
.disconnect = dvb_usb_device_exit,
.id_table = af9005_usb_table,
};
/* module stuff */
static int __init af9005_usb_module_init(void)
{
int result;
if ((result = usb_register(&af9005_usb_driver))) {
err("usb_register failed. (%d)", result);
return result;
}
#if IS_MODULE(CONFIG_DVB_USB_AF9005) || defined(CONFIG_DVB_USB_AF9005_REMOTE)
/* FIXME: convert to todays kernel IR infrastructure */
rc_decode = symbol_request(af9005_rc_decode);
rc_keys = symbol_request(rc_map_af9005_table);
rc_keys_size = symbol_request(rc_map_af9005_table_size);
#endif
if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) {
err("af9005_rc_decode function not found, disabling remote");
af9005_properties.rc.legacy.rc_query = NULL;
} else {
af9005_properties.rc.legacy.rc_map_table = rc_keys;
af9005_properties.rc.legacy.rc_map_size = *rc_keys_size;
}
return 0;
}
static void __exit af9005_usb_module_exit(void)
{
/* release rc decode symbols */
if (rc_decode != NULL)
symbol_put(af9005_rc_decode);
if (rc_keys != NULL)
symbol_put(rc_map_af9005_table);
if (rc_keys_size != NULL)
symbol_put(rc_map_af9005_table_size);
/* deregister this driver from the USB subsystem */
usb_deregister(&af9005_usb_driver);
}
module_init(af9005_usb_module_init);
module_exit(af9005_usb_module_exit);
MODULE_AUTHOR("Luca Olivetti <[email protected]>");
MODULE_DESCRIPTION("Driver for Afatech 9005 DVB-T USB1.1 stick");
MODULE_VERSION("1.0");
MODULE_LICENSE("GPL");
| gpl-2.0 |
binhqnguyen/lena | nsc/linux-2.6.26/net/core/net-sysfs.c | 12824 | /*
* net-sysfs.c - network device class and attributes
*
* Copyright (c) 2003 Stephen Hemminger <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <net/sock.h>
#include <linux/rtnetlink.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>
#include "net-sysfs.h"
#ifdef CONFIG_SYSFS
static const char fmt_hex[] = "%#x\n";
static const char fmt_long_hex[] = "%#lx\n";
static const char fmt_dec[] = "%d\n";
static const char fmt_ulong[] = "%lu\n";
static inline int dev_isalive(const struct net_device *dev)
{
return dev->reg_state <= NETREG_REGISTERED;
}
/* use same locking rules as GIF* ioctl's */
static ssize_t netdev_show(const struct device *dev,
struct device_attribute *attr, char *buf,
ssize_t (*format)(const struct net_device *, char *))
{
struct net_device *net = to_net_dev(dev);
ssize_t ret = -EINVAL;
read_lock(&dev_base_lock);
if (dev_isalive(net))
ret = (*format)(net, buf);
read_unlock(&dev_base_lock);
return ret;
}
/* generate a show function for simple field */
#define NETDEVICE_SHOW(field, format_string) \
static ssize_t format_##field(const struct net_device *net, char *buf) \
{ \
return sprintf(buf, format_string, net->field); \
} \
static ssize_t show_##field(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
return netdev_show(dev, attr, buf, format_##field); \
}
/* use same locking and permission rules as SIF* ioctl's */
static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t len,
int (*set)(struct net_device *, unsigned long))
{
struct net_device *net = to_net_dev(dev);
char *endp;
unsigned long new;
int ret = -EINVAL;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
new = simple_strtoul(buf, &endp, 0);
if (endp == buf)
goto err;
rtnl_lock();
if (dev_isalive(net)) {
if ((ret = (*set)(net, new)) == 0)
ret = len;
}
rtnl_unlock();
err:
return ret;
}
NETDEVICE_SHOW(dev_id, fmt_hex);
NETDEVICE_SHOW(addr_len, fmt_dec);
NETDEVICE_SHOW(iflink, fmt_dec);
NETDEVICE_SHOW(ifindex, fmt_dec);
NETDEVICE_SHOW(features, fmt_long_hex);
NETDEVICE_SHOW(type, fmt_dec);
NETDEVICE_SHOW(link_mode, fmt_dec);
/* use same locking rules as GIFHWADDR ioctl's */
static ssize_t show_address(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct net_device *net = to_net_dev(dev);
ssize_t ret = -EINVAL;
read_lock(&dev_base_lock);
if (dev_isalive(net))
ret = sysfs_format_mac(buf, net->dev_addr, net->addr_len);
read_unlock(&dev_base_lock);
return ret;
}
static ssize_t show_broadcast(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *net = to_net_dev(dev);
if (dev_isalive(net))
return sysfs_format_mac(buf, net->broadcast, net->addr_len);
return -EINVAL;
}
static ssize_t show_carrier(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
if (netif_running(netdev)) {
return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
}
return -EINVAL;
}
static ssize_t show_dormant(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
if (netif_running(netdev))
return sprintf(buf, fmt_dec, !!netif_dormant(netdev));
return -EINVAL;
}
static const char *operstates[] = {
"unknown",
"notpresent", /* currently unused */
"down",
"lowerlayerdown",
"testing", /* currently unused */
"dormant",
"up"
};
static ssize_t show_operstate(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct net_device *netdev = to_net_dev(dev);
unsigned char operstate;
read_lock(&dev_base_lock);
operstate = netdev->operstate;
if (!netif_running(netdev))
operstate = IF_OPER_DOWN;
read_unlock(&dev_base_lock);
if (operstate >= ARRAY_SIZE(operstates))
return -EINVAL; /* should not happen */
return sprintf(buf, "%s\n", operstates[operstate]);
}
/* read-write attributes */
NETDEVICE_SHOW(mtu, fmt_dec);
static int change_mtu(struct net_device *net, unsigned long new_mtu)
{
return dev_set_mtu(net, (int) new_mtu);
}
static ssize_t store_mtu(struct device *dev, struct device_attribute *attr,
const char *buf, size_t len)
{
return netdev_store(dev, attr, buf, len, change_mtu);
}
NETDEVICE_SHOW(flags, fmt_hex);
static int change_flags(struct net_device *net, unsigned long new_flags)
{
return dev_change_flags(net, (unsigned) new_flags);
}
static ssize_t store_flags(struct device *dev, struct device_attribute *attr,
const char *buf, size_t len)
{
return netdev_store(dev, attr, buf, len, change_flags);
}
NETDEVICE_SHOW(tx_queue_len, fmt_ulong);
static int change_tx_queue_len(struct net_device *net, unsigned long new_len)
{
net->tx_queue_len = new_len;
return 0;
}
static ssize_t store_tx_queue_len(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
return netdev_store(dev, attr, buf, len, change_tx_queue_len);
}
static struct device_attribute net_class_attributes[] = {
__ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
__ATTR(dev_id, S_IRUGO, show_dev_id, NULL),
__ATTR(iflink, S_IRUGO, show_iflink, NULL),
__ATTR(ifindex, S_IRUGO, show_ifindex, NULL),
__ATTR(features, S_IRUGO, show_features, NULL),
__ATTR(type, S_IRUGO, show_type, NULL),
__ATTR(link_mode, S_IRUGO, show_link_mode, NULL),
__ATTR(address, S_IRUGO, show_address, NULL),
__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
__ATTR(carrier, S_IRUGO, show_carrier, NULL),
__ATTR(dormant, S_IRUGO, show_dormant, NULL),
__ATTR(operstate, S_IRUGO, show_operstate, NULL),
__ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu),
__ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags),
__ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len),
{}
};
/* Show a given an attribute in the statistics group */
static ssize_t netstat_show(const struct device *d,
struct device_attribute *attr, char *buf,
unsigned long offset)
{
struct net_device *dev = to_net_dev(d);
struct net_device_stats *stats;
ssize_t ret = -EINVAL;
WARN_ON(offset > sizeof(struct net_device_stats) ||
offset % sizeof(unsigned long) != 0);
read_lock(&dev_base_lock);
if (dev_isalive(dev) && dev->get_stats &&
(stats = (*dev->get_stats)(dev)))
ret = sprintf(buf, fmt_ulong,
*(unsigned long *)(((u8 *) stats) + offset));
read_unlock(&dev_base_lock);
return ret;
}
/* generate a read-only statistics attribute */
#define NETSTAT_ENTRY(name) \
static ssize_t show_##name(struct device *d, \
struct device_attribute *attr, char *buf) \
{ \
return netstat_show(d, attr, buf, \
offsetof(struct net_device_stats, name)); \
} \
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
NETSTAT_ENTRY(rx_packets);
NETSTAT_ENTRY(tx_packets);
NETSTAT_ENTRY(rx_bytes);
NETSTAT_ENTRY(tx_bytes);
NETSTAT_ENTRY(rx_errors);
NETSTAT_ENTRY(tx_errors);
NETSTAT_ENTRY(rx_dropped);
NETSTAT_ENTRY(tx_dropped);
NETSTAT_ENTRY(multicast);
NETSTAT_ENTRY(collisions);
NETSTAT_ENTRY(rx_length_errors);
NETSTAT_ENTRY(rx_over_errors);
NETSTAT_ENTRY(rx_crc_errors);
NETSTAT_ENTRY(rx_frame_errors);
NETSTAT_ENTRY(rx_fifo_errors);
NETSTAT_ENTRY(rx_missed_errors);
NETSTAT_ENTRY(tx_aborted_errors);
NETSTAT_ENTRY(tx_carrier_errors);
NETSTAT_ENTRY(tx_fifo_errors);
NETSTAT_ENTRY(tx_heartbeat_errors);
NETSTAT_ENTRY(tx_window_errors);
NETSTAT_ENTRY(rx_compressed);
NETSTAT_ENTRY(tx_compressed);
static struct attribute *netstat_attrs[] = {
&dev_attr_rx_packets.attr,
&dev_attr_tx_packets.attr,
&dev_attr_rx_bytes.attr,
&dev_attr_tx_bytes.attr,
&dev_attr_rx_errors.attr,
&dev_attr_tx_errors.attr,
&dev_attr_rx_dropped.attr,
&dev_attr_tx_dropped.attr,
&dev_attr_multicast.attr,
&dev_attr_collisions.attr,
&dev_attr_rx_length_errors.attr,
&dev_attr_rx_over_errors.attr,
&dev_attr_rx_crc_errors.attr,
&dev_attr_rx_frame_errors.attr,
&dev_attr_rx_fifo_errors.attr,
&dev_attr_rx_missed_errors.attr,
&dev_attr_tx_aborted_errors.attr,
&dev_attr_tx_carrier_errors.attr,
&dev_attr_tx_fifo_errors.attr,
&dev_attr_tx_heartbeat_errors.attr,
&dev_attr_tx_window_errors.attr,
&dev_attr_rx_compressed.attr,
&dev_attr_tx_compressed.attr,
NULL
};
static struct attribute_group netstat_group = {
.name = "statistics",
.attrs = netstat_attrs,
};
#ifdef CONFIG_WIRELESS_EXT
/* helper function that does all the locking etc for wireless stats */
static ssize_t wireless_show(struct device *d, char *buf,
ssize_t (*format)(const struct iw_statistics *,
char *))
{
struct net_device *dev = to_net_dev(d);
const struct iw_statistics *iw = NULL;
ssize_t ret = -EINVAL;
read_lock(&dev_base_lock);
if (dev_isalive(dev)) {
if (dev->wireless_handlers &&
dev->wireless_handlers->get_wireless_stats)
iw = dev->wireless_handlers->get_wireless_stats(dev);
if (iw != NULL)
ret = (*format)(iw, buf);
}
read_unlock(&dev_base_lock);
return ret;
}
/* show function template for wireless fields */
#define WIRELESS_SHOW(name, field, format_string) \
static ssize_t format_iw_##name(const struct iw_statistics *iw, char *buf) \
{ \
return sprintf(buf, format_string, iw->field); \
} \
static ssize_t show_iw_##name(struct device *d, \
struct device_attribute *attr, char *buf) \
{ \
return wireless_show(d, buf, format_iw_##name); \
} \
static DEVICE_ATTR(name, S_IRUGO, show_iw_##name, NULL)
WIRELESS_SHOW(status, status, fmt_hex);
WIRELESS_SHOW(link, qual.qual, fmt_dec);
WIRELESS_SHOW(level, qual.level, fmt_dec);
WIRELESS_SHOW(noise, qual.noise, fmt_dec);
WIRELESS_SHOW(nwid, discard.nwid, fmt_dec);
WIRELESS_SHOW(crypt, discard.code, fmt_dec);
WIRELESS_SHOW(fragment, discard.fragment, fmt_dec);
WIRELESS_SHOW(misc, discard.misc, fmt_dec);
WIRELESS_SHOW(retries, discard.retries, fmt_dec);
WIRELESS_SHOW(beacon, miss.beacon, fmt_dec);
static struct attribute *wireless_attrs[] = {
&dev_attr_status.attr,
&dev_attr_link.attr,
&dev_attr_level.attr,
&dev_attr_noise.attr,
&dev_attr_nwid.attr,
&dev_attr_crypt.attr,
&dev_attr_fragment.attr,
&dev_attr_retries.attr,
&dev_attr_misc.attr,
&dev_attr_beacon.attr,
NULL
};
static struct attribute_group wireless_group = {
.name = "wireless",
.attrs = wireless_attrs,
};
#endif
#endif /* CONFIG_SYSFS */
#ifdef CONFIG_HOTPLUG
static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
{
struct net_device *dev = to_net_dev(d);
int retval;
/* pass interface to uevent. */
retval = add_uevent_var(env, "INTERFACE=%s", dev->name);
if (retval)
goto exit;
/* pass ifindex to uevent.
* ifindex is useful as it won't change (interface name may change)
* and is what RtNetlink uses natively. */
retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
exit:
return retval;
}
#endif
/*
* netdev_release -- destroy and free a dead device.
* Called when last reference to device kobject is gone.
*/
static void netdev_release(struct device *d)
{
struct net_device *dev = to_net_dev(d);
BUG_ON(dev->reg_state != NETREG_RELEASED);
kfree((char *)dev - dev->padded);
}
static struct class net_class = {
.name = "net",
.dev_release = netdev_release,
#ifdef CONFIG_SYSFS
.dev_attrs = net_class_attributes,
#endif /* CONFIG_SYSFS */
#ifdef CONFIG_HOTPLUG
.dev_uevent = netdev_uevent,
#endif
};
/* Delete sysfs entries but hold kobject reference until after all
* netdev references are gone.
*/
void netdev_unregister_kobject(struct net_device * net)
{
struct device *dev = &(net->dev);
kobject_get(&dev->kobj);
device_del(dev);
}
/* Create sysfs entries for network device. */
int netdev_register_kobject(struct net_device *net)
{
struct device *dev = &(net->dev);
struct attribute_group **groups = net->sysfs_groups;
dev->class = &net_class;
dev->platform_data = net;
dev->groups = groups;
BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
strlcpy(dev->bus_id, net->name, BUS_ID_SIZE);
#ifdef CONFIG_SYSFS
if (net->get_stats)
*groups++ = &netstat_group;
#ifdef CONFIG_WIRELESS_EXT
if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
*groups++ = &wireless_group;
#endif
#endif /* CONFIG_SYSFS */
return device_add(dev);
}
void netdev_initialize_kobject(struct net_device *net)
{
struct device *device = &(net->dev);
device_initialize(device);
}
int netdev_kobject_init(void)
{
return class_register(&net_class);
}
| gpl-2.0 |
zhang3/barebox | arch/arm/boards/at91sam9261ek/init.c | 9724 | /*
* Copyright (C) 2007 Sascha Hauer, Pengutronix
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
#include <common.h>
#include <net.h>
#include <init.h>
#include <environment.h>
#include <asm/armlinux.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
#include <fcntl.h>
#include <io.h>
#include <mach/hardware.h>
#include <nand.h>
#include <linux/sizes.h>
#include <linux/mtd/nand.h>
#include <mach/at91_pmc.h>
#include <mach/board.h>
#include <gpio.h>
#include <mach/io.h>
#include <mach/iomux.h>
#include <mach/at91sam9_smc.h>
#include <dm9000.h>
#include <gpio_keys.h>
#include <readkey.h>
#include <led.h>
#include <spi/spi.h>
static struct atmel_nand_data nand_pdata = {
.ale = 22,
.cle = 21,
.det_pin = -EINVAL,
.rdy_pin = AT91_PIN_PC15,
.enable_pin = AT91_PIN_PC14,
.ecc_mode = NAND_ECC_SOFT,
#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
.bus_width_16 = 1,
#else
.bus_width_16 = 0,
#endif
.on_flash_bbt = 1,
};
static struct sam9_smc_config ek_nand_smc_config = {
.ncs_read_setup = 0,
.nrd_setup = 1,
.ncs_write_setup = 0,
.nwe_setup = 1,
.ncs_read_pulse = 3,
.nrd_pulse = 3,
.ncs_write_pulse = 3,
.nwe_pulse = 3,
.read_cycle = 5,
.write_cycle = 5,
.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
.tdf_cycles = 2,
};
static void ek_add_device_nand(void)
{
/* setup bus-width (8 or 16) */
if (nand_pdata.bus_width_16)
ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
else
ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
/* configure chip-select 3 (NAND) */
sam9_smc_configure(0, 3, &ek_nand_smc_config);
at91_add_device_nand(&nand_pdata);
}
/*
* DM9000 ethernet device
*/
#if defined(CONFIG_DRIVER_NET_DM9K)
static struct dm9000_platform_data dm9000_data = {
.srom = 0,
};
/*
* SMC timings for the DM9000.
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
*/
static struct sam9_smc_config __initdata dm9000_smc_config = {
.ncs_read_setup = 0,
.nrd_setup = 2,
.ncs_write_setup = 0,
.nwe_setup = 2,
.ncs_read_pulse = 8,
.nrd_pulse = 4,
.ncs_write_pulse = 8,
.nwe_pulse = 4,
.read_cycle = 16,
.write_cycle = 16,
.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
.tdf_cycles = 1,
};
static void __init ek_add_device_dm9000(void)
{
/* Configure chip-select 2 (DM9000) */
sam9_smc_configure(0, 2, &dm9000_smc_config);
/* Configure Reset signal as output */
at91_set_gpio_output(AT91_PIN_PC10, 0);
/* Configure Interrupt pin as input, no pull-up */
at91_set_gpio_input(AT91_PIN_PC11, 0);
add_dm9000_device(0, AT91_CHIPSELECT_2, AT91_CHIPSELECT_2 + 4,
IORESOURCE_MEM_16BIT, &dm9000_data);
}
#else
static void __init ek_add_device_dm9000(void) {}
#endif /* CONFIG_DRIVER_NET_DM9K */
#if defined(CONFIG_USB_GADGET_DRIVER_AT91)
/*
* USB Device port
*/
static struct at91_udc_data __initdata ek_udc_data = {
.vbus_pin = AT91_PIN_PB29,
.pullup_pin = 0,
};
static void ek_add_device_udc(void)
{
at91_add_device_udc(&ek_udc_data);
}
#else
static void ek_add_device_udc(void) {}
#endif
/*
* LCD Controller
*/
#if defined(CONFIG_DRIVER_VIDEO_ATMEL)
static int ek_gpio_request_output(int gpio, const char *name)
{
int ret;
ret = gpio_request(gpio, name);
if (ret) {
pr_err("%s: can not request gpio %d (%d)\n", name, gpio, ret);
return ret;
}
ret = gpio_direction_output(gpio, 1);
if (ret)
pr_err("%s: can not configure gpio %d as output (%d)\n", name, gpio, ret);
return ret;
}
/* TFT */
static struct fb_videomode at91_tft_vga_modes[] = {
{
.name = "TX09D50VM1CCA @ 60",
.refresh = 60,
.xres = 240, .yres = 320,
.pixclock = KHZ2PICOS(4965),
.left_margin = 1, .right_margin = 33,
.upper_margin = 1, .lower_margin = 0,
.hsync_len = 5, .vsync_len = 1,
.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
.vmode = FB_VMODE_NONINTERLACED,
},
};
#define AT91SAM9261_DEFAULT_TFT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
| ATMEL_LCDC_DISTYPE_TFT \
| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
static void at91_lcdc_tft_power_control(int on)
{
if (on)
gpio_set_value(AT91_PIN_PA12, 0); /* power up */
else
gpio_set_value(AT91_PIN_PA12, 1); /* power down */
}
static struct atmel_lcdfb_platform_data ek_lcdc_data = {
.lcdcon_is_backlight = true,
.default_bpp = 16,
.default_dmacon = ATMEL_LCDC_DMAEN,
.default_lcdcon2 = AT91SAM9261_DEFAULT_TFT_LCDCON2,
.guard_time = 1,
.atmel_lcdfb_power_control = at91_lcdc_tft_power_control,
.mode_list = at91_tft_vga_modes,
.num_modes = ARRAY_SIZE(at91_tft_vga_modes),
};
static int at91_lcdc_gpio(void)
{
return ek_gpio_request_output(AT91_PIN_PA12, "lcdc_tft_power");
}
static void ek_add_device_lcdc(void)
{
if (at91_lcdc_gpio())
return;
if (machine_is_at91sam9g10ek())
ek_lcdc_data.lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB;
at91_add_device_lcdc(&ek_lcdc_data);
}
#else
static void ek_add_device_lcdc(void) {}
#endif
#ifdef CONFIG_KEYBOARD_GPIO
struct gpio_keys_button keys[] = {
{
.code = BB_KEY_UP,
.gpio = AT91_PIN_PA26,
}, {
.code = BB_KEY_DOWN,
.gpio = AT91_PIN_PA25,
}, {
.code = BB_KEY_ENTER,
.gpio = AT91_PIN_PA24,
},
};
struct gpio_keys_platform_data gk_pdata = {
.buttons = keys,
.nbuttons = ARRAY_SIZE(keys),
};
static void ek_add_device_keyboard_buttons(void)
{
int i;
for (i = 0; i < gk_pdata.nbuttons; i++) {
/* user push button, pull up enabled */
keys[i].active_low = 1;
at91_set_GPIO_periph(keys[i].gpio, keys[i].active_low);
at91_set_deglitch(keys[i].gpio, 1);
}
add_gpio_keys_device(DEVICE_ID_DYNAMIC, &gk_pdata);
}
#else
static void ek_add_device_keyboard_buttons(void) {}
#endif
static void __init ek_add_device_buttons(void)
{
at91_set_gpio_input(AT91_PIN_PA27, 1);
at91_set_deglitch(AT91_PIN_PA27, 1);
export_env_ull("dfu_button", AT91_PIN_PA27);
ek_add_device_keyboard_buttons();
}
#ifdef CONFIG_LED_GPIO
struct gpio_led ek_leds[] = {
{
.gpio = AT91_PIN_PA23,
.led = {
.name = "ds1",
},
}, {
.gpio = AT91_PIN_PA14,
.active_low = 1,
.led = {
.name = "ds7",
},
}, {
.gpio = AT91_PIN_PA13,
.active_low = 1,
.led = {
.name = "ds8",
},
},
};
static void ek_device_add_leds(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(ek_leds); i++) {
at91_set_gpio_output(ek_leds[i].gpio, ek_leds[i].active_low);
led_gpio_register(&ek_leds[i]);
}
led_set_trigger(LED_TRIGGER_HEARTBEAT, &ek_leds[0].led);
}
#else
static void ek_device_add_leds(void) {}
#endif
/*
* SPI related devices
*/
#if defined(CONFIG_DRIVER_SPI_ATMEL)
/*
* SPI devices
*/
static struct spi_board_info ek_spi_devices[] = {
{ /* DataFlash chip */
.name = "mtd_dataflash",
.chip_select = 0,
.max_speed_hz = 15 * 1000 * 1000,
.bus_num = 0,
},
#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
{ /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
.name = "mtd_dataflash",
.chip_select = 1,
.max_speed_hz = 15 * 1000 * 1000,
.bus_num = 0,
},
#endif
};
static unsigned spi0_standard_cs[] = { AT91_PIN_PA3, AT91_PIN_PA6};
static struct at91_spi_platform_data spi_pdata = {
.chipselect = spi0_standard_cs,
.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
};
static void ek_add_device_spi(void)
{
spi_register_board_info(ek_spi_devices,
ARRAY_SIZE(ek_spi_devices));
at91_add_device_spi(0, &spi_pdata);
}
#else
static void ek_add_device_spi(void) {}
#endif
static int at91sam9261ek_mem_init(void)
{
at91_add_device_sdram(0);
return 0;
}
mem_initcall(at91sam9261ek_mem_init);
static int at91sam9261ek_devices_init(void)
{
u32 barebox_part_start;
u32 barebox_part_size;
ek_add_device_nand();
ek_add_device_dm9000();
ek_add_device_udc();
ek_add_device_buttons();
ek_device_add_leds();
ek_add_device_lcdc();
ek_add_device_spi();
if (IS_ENABLED(CONFIG_AT91_LOAD_BAREBOX_SRAM)) {
barebox_part_start = 0;
barebox_part_size = SZ_256K + SZ_128K;
export_env_ull("borebox_first_stage", 1);
} else {
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
barebox_part_start = SZ_128K;
barebox_part_size = SZ_256K;
}
devfs_add_partition("nand0", barebox_part_start, barebox_part_size,
DEVFS_PARTITION_FIXED, "self_raw");
dev_add_bb_dev("self_raw", "self0");
devfs_add_partition("nand0", SZ_256K + SZ_128K, SZ_128K, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
devfs_add_partition("nand0", SZ_512K, SZ_128K, DEVFS_PARTITION_FIXED, "env_raw1");
dev_add_bb_dev("env_raw1", "env1");
if (machine_is_at91sam9g10ek())
armlinux_set_architecture(MACH_TYPE_AT91SAM9G10EK);
else
armlinux_set_architecture(MACH_TYPE_AT91SAM9261EK);
return 0;
}
device_initcall(at91sam9261ek_devices_init);
static int at91sam9261ek_console_init(void)
{
if (machine_is_at91sam9g10ek()) {
barebox_set_model("Atmel at91sam9g10-ek");
barebox_set_hostname("at91sam9g10-ek");
} else {
barebox_set_model("Atmel at91sam9261-ek");
barebox_set_hostname("at91sam9261-ek");
}
at91_register_uart(0, 0);
return 0;
}
console_initcall(at91sam9261ek_console_init);
static int at91sam9261ek_main_clock(void)
{
at91_set_main_clock(18432000);
return 0;
}
pure_initcall(at91sam9261ek_main_clock);
| gpl-2.0 |
Myself5/android_kernel_sony_msm | drivers/power/smb135x-charger.c | 102624 | /* Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/i2c.h>
#include <linux/debugfs.h>
#include <linux/gpio.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/power_supply.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
#include <linux/pinctrl/consumer.h>
#define SMB135X_BITS_PER_REG 8
/* Mask/Bit helpers */
#define _SMB135X_MASK(BITS, POS) \
((unsigned char)(((1 << (BITS)) - 1) << (POS)))
#define SMB135X_MASK(LEFT_BIT_POS, RIGHT_BIT_POS) \
_SMB135X_MASK((LEFT_BIT_POS) - (RIGHT_BIT_POS) + 1, \
(RIGHT_BIT_POS))
/* Config registers */
#define CFG_3_REG 0x03
#define CHG_ITERM_50MA 0x08
#define CHG_ITERM_100MA 0x10
#define CHG_ITERM_150MA 0x18
#define CHG_ITERM_200MA 0x20
#define CHG_ITERM_250MA 0x28
#define CHG_ITERM_300MA 0x00
#define CHG_ITERM_500MA 0x30
#define CHG_ITERM_600MA 0x38
#define CHG_ITERM_MASK SMB135X_MASK(5, 3)
#define CFG_4_REG 0x04
#define CHG_INHIBIT_MASK SMB135X_MASK(7, 6)
#define CHG_INHIBIT_50MV_VAL 0x00
#define CHG_INHIBIT_100MV_VAL 0x40
#define CHG_INHIBIT_200MV_VAL 0x80
#define CHG_INHIBIT_300MV_VAL 0xC0
#define CFG_5_REG 0x05
#define RECHARGE_200MV_BIT BIT(2)
#define USB_2_3_BIT BIT(5)
#define CFG_A_REG 0x0A
#define DCIN_INPUT_MASK SMB135X_MASK(4, 0)
#define CFG_C_REG 0x0C
#define USBIN_INPUT_MASK SMB135X_MASK(4, 0)
#define CFG_D_REG 0x0D
#define CFG_E_REG 0x0E
#define POLARITY_100_500_BIT BIT(2)
#define USB_CTRL_BY_PIN_BIT BIT(1)
#define HVDCP_5_9_BIT BIT(4)
#define CFG_11_REG 0x11
#define PRIORITY_BIT BIT(7)
#define USBIN_DCIN_CFG_REG 0x12
#define USBIN_SUSPEND_VIA_COMMAND_BIT BIT(6)
#define CFG_14_REG 0x14
#define CHG_EN_BY_PIN_BIT BIT(7)
#define CHG_EN_ACTIVE_LOW_BIT BIT(6)
#define PRE_TO_FAST_REQ_CMD_BIT BIT(5)
#define DISABLE_CURRENT_TERM_BIT BIT(3)
#define DISABLE_AUTO_RECHARGE_BIT BIT(2)
#define EN_CHG_INHIBIT_BIT BIT(0)
#define CFG_16_REG 0x16
#define SAFETY_TIME_EN_BIT BIT(4)
#define SAFETY_TIME_MINUTES_MASK SMB135X_MASK(3, 2)
#define SAFETY_TIME_MINUTES_SHIFT 2
#define CFG_17_REG 0x17
#define CHG_STAT_DISABLE_BIT BIT(0)
#define CHG_STAT_ACTIVE_HIGH_BIT BIT(1)
#define CHG_STAT_IRQ_ONLY_BIT BIT(4)
#define CFG_19_REG 0x19
#define BATT_MISSING_ALGO_BIT BIT(2)
#define BATT_MISSING_THERM_BIT BIT(1)
#define CFG_1A_REG 0x1A
#define HOT_SOFT_VFLOAT_COMP_EN_BIT BIT(3)
#define COLD_SOFT_VFLOAT_COMP_EN_BIT BIT(2)
#define VFLOAT_REG 0x1E
#define VERSION1_REG 0x2A
#define VERSION1_MASK SMB135X_MASK(7, 6)
#define VERSION1_SHIFT 6
#define VERSION2_REG 0x32
#define VERSION2_MASK SMB135X_MASK(1, 0)
#define VERSION3_REG 0x34
/* Irq Config registers */
#define IRQ_CFG_REG 0x07
#define IRQ_BAT_HOT_COLD_HARD_BIT BIT(7)
#define IRQ_BAT_HOT_COLD_SOFT_BIT BIT(6)
#define IRQ_OTG_OVER_CURRENT_BIT BIT(4)
#define IRQ_USBIN_UV_BIT BIT(2)
#define IRQ_INTERNAL_TEMPERATURE_BIT BIT(0)
#define IRQ2_CFG_REG 0x08
#define IRQ2_SAFETY_TIMER_BIT BIT(7)
#define IRQ2_CHG_ERR_BIT BIT(6)
#define IRQ2_CHG_PHASE_CHANGE_BIT BIT(4)
#define IRQ2_CHG_INHIBIT_BIT BIT(3)
#define IRQ2_POWER_OK_BIT BIT(2)
#define IRQ2_BATT_MISSING_BIT BIT(1)
#define IRQ2_VBAT_LOW_BIT BIT(0)
#define IRQ3_CFG_REG 0x09
#define IRQ3_RID_DETECT_BIT BIT(4)
#define IRQ3_SRC_DETECT_BIT BIT(2)
#define IRQ3_DCIN_UV_BIT BIT(0)
#define USBIN_OTG_REG 0x0F
#define OTG_CNFG_MASK SMB135X_MASK(3, 2)
#define OTG_CNFG_PIN_CTRL 0x04
#define OTG_CNFG_COMMAND_CTRL 0x08
#define OTG_CNFG_AUTO_CTRL 0x0C
/* Command Registers */
#define CMD_I2C_REG 0x40
#define ALLOW_VOLATILE_BIT BIT(6)
#define CMD_INPUT_LIMIT 0x41
#define USB_SHUTDOWN_BIT BIT(6)
#define DC_SHUTDOWN_BIT BIT(5)
#define USE_REGISTER_FOR_CURRENT BIT(2)
#define USB_100_500_AC_MASK SMB135X_MASK(1, 0)
#define USB_100_VAL 0x02
#define USB_500_VAL 0x00
#define USB_AC_VAL 0x01
#define CMD_CHG_REG 0x42
#define CMD_CHG_EN BIT(1)
#define OTG_EN BIT(0)
/* Status registers */
#define STATUS_1_REG 0x47
#define USING_USB_BIT BIT(1)
#define USING_DC_BIT BIT(0)
#define STATUS_4_REG 0x4A
#define BATT_NET_CHG_CURRENT_BIT BIT(7)
#define BATT_LESS_THAN_2V BIT(4)
#define CHG_HOLD_OFF_BIT BIT(3)
#define CHG_TYPE_MASK SMB135X_MASK(2, 1)
#define CHG_TYPE_SHIFT 1
#define BATT_NOT_CHG_VAL 0x0
#define BATT_PRE_CHG_VAL 0x1
#define BATT_FAST_CHG_VAL 0x2
#define BATT_TAPER_CHG_VAL 0x3
#define CHG_EN_BIT BIT(0)
#define STATUS_5_REG 0x4B
#define CDP_BIT BIT(7)
#define DCP_BIT BIT(6)
#define OTHER_BIT BIT(5)
#define SDP_BIT BIT(4)
#define ACA_A_BIT BIT(3)
#define ACA_B_BIT BIT(2)
#define ACA_C_BIT BIT(1)
#define ACA_DOCK_BIT BIT(0)
#define STATUS_6_REG 0x4C
#define RID_FLOAT_BIT BIT(3)
#define RID_A_BIT BIT(2)
#define RID_B_BIT BIT(1)
#define RID_C_BIT BIT(0)
#define STATUS_8_REG 0x4E
#define USBIN_9V BIT(5)
#define USBIN_UNREG BIT(4)
#define USBIN_LV BIT(3)
#define DCIN_9V BIT(2)
#define DCIN_UNREG BIT(1)
#define DCIN_LV BIT(0)
#define STATUS_9_REG 0x4F
#define REV_MASK SMB135X_MASK(3, 0)
/* Irq Status registers */
#define IRQ_A_REG 0x50
#define IRQ_A_HOT_HARD_BIT BIT(6)
#define IRQ_A_COLD_HARD_BIT BIT(4)
#define IRQ_A_HOT_SOFT_BIT BIT(2)
#define IRQ_A_COLD_SOFT_BIT BIT(0)
#define IRQ_B_REG 0x51
#define IRQ_B_BATT_TERMINAL_BIT BIT(6)
#define IRQ_B_BATT_MISSING_BIT BIT(4)
#define IRQ_B_VBAT_LOW_BIT BIT(2)
#define IRQ_B_TEMPERATURE_BIT BIT(0)
#define IRQ_C_REG 0x52
#define IRQ_C_TERM_BIT BIT(0)
#define IRQ_C_FASTCHG_BIT BIT(6)
#define IRQ_D_REG 0x53
#define IRQ_D_TIMEOUT_BIT BIT(2)
#define IRQ_E_REG 0x54
#define IRQ_E_DC_OV_BIT BIT(6)
#define IRQ_E_DC_UV_BIT BIT(4)
#define IRQ_E_USB_OV_BIT BIT(2)
#define IRQ_E_USB_UV_BIT BIT(0)
#define IRQ_F_REG 0x55
#define IRQ_F_POWER_OK_BIT BIT(0)
#define IRQ_G_REG 0x56
#define IRQ_G_SRC_DETECT_BIT BIT(6)
enum {
WRKARND_USB100_BIT = BIT(0),
WRKARND_APSD_FAIL = BIT(1),
};
enum {
REV_1 = 1, /* Rev 1.0 */
REV_1_1 = 2, /* Rev 1.1 */
REV_2 = 3, /* Rev 2 */
REV_2_1 = 5, /* Rev 2.1 */
REV_MAX,
};
static char *revision_str[] = {
[REV_1] = "rev1",
[REV_1_1] = "rev1.1",
[REV_2] = "rev2",
[REV_2_1] = "rev2.1",
};
enum {
V_SMB1356,
V_SMB1357,
V_SMB1358,
V_SMB1359,
V_MAX,
};
static int version_data[] = {
[V_SMB1356] = V_SMB1356,
[V_SMB1357] = V_SMB1357,
[V_SMB1358] = V_SMB1358,
[V_SMB1359] = V_SMB1359,
};
static char *version_str[] = {
[V_SMB1356] = "smb1356",
[V_SMB1357] = "smb1357",
[V_SMB1358] = "smb1358",
[V_SMB1359] = "smb1359",
};
enum {
USER = BIT(0),
THERMAL = BIT(1),
CURRENT = BIT(2),
};
enum path_type {
USB,
DC,
};
static int chg_time[] = {
192,
384,
768,
1536,
};
static char *pm_batt_supplied_to[] = {
"bms",
};
struct smb135x_regulator {
struct regulator_desc rdesc;
struct regulator_dev *rdev;
};
struct smb135x_chg {
struct i2c_client *client;
struct device *dev;
struct mutex read_write_lock;
u8 revision;
int version;
bool chg_enabled;
bool chg_disabled_permanently;
bool usb_present;
bool dc_present;
bool usb_slave_present;
bool dc_ov;
bool bmd_algo_disabled;
bool iterm_disabled;
int iterm_ma;
int vfloat_mv;
int safety_time;
int resume_delta_mv;
int fake_battery_soc;
struct dentry *debug_root;
int usb_current_arr_size;
int *usb_current_table;
int dc_current_arr_size;
int *dc_current_table;
bool inhibit_disabled;
int fastchg_current_arr_size;
int *fastchg_current_table;
int fastchg_ma;
u8 irq_cfg_mask[3];
int otg_oc_count;
bool parallel_charger;
bool parallel_charger_present;
bool bms_controlled_charging;
/* psy */
struct power_supply *usb_psy;
int usb_psy_ma;
int real_usb_psy_ma;
struct power_supply batt_psy;
struct power_supply dc_psy;
struct power_supply parallel_psy;
struct power_supply *bms_psy;
int dc_psy_type;
int dc_psy_ma;
const char *bms_psy_name;
/* status tracking */
bool chg_done_batt_full;
bool batt_present;
bool batt_hot;
bool batt_cold;
bool batt_warm;
bool batt_cool;
bool resume_completed;
bool irq_waiting;
u32 usb_suspended;
u32 dc_suspended;
struct mutex path_suspend_lock;
u32 peek_poke_address;
struct smb135x_regulator otg_vreg;
int skip_writes;
int skip_reads;
u32 workaround_flags;
bool soft_vfloat_comp_disabled;
struct mutex irq_complete;
struct regulator *therm_bias_vreg;
struct regulator *usb_pullup_vreg;
struct delayed_work wireless_insertion_work;
unsigned int thermal_levels;
unsigned int therm_lvl_sel;
unsigned int *thermal_mitigation;
struct mutex current_change_lock;
const char *pinctrl_state_name;
struct pinctrl *smb_pinctrl;
};
#define RETRY_COUNT 5
int retry_sleep_ms[RETRY_COUNT] = {
10, 20, 30, 40, 50
};
static int __smb135x_read(struct smb135x_chg *chip, int reg,
u8 *val)
{
s32 ret;
int retry_count = 0;
retry:
ret = i2c_smbus_read_byte_data(chip->client, reg);
if (ret < 0 && retry_count < RETRY_COUNT) {
/* sleep for few ms before retrying */
msleep(retry_sleep_ms[retry_count++]);
goto retry;
}
if (ret < 0) {
dev_err(chip->dev,
"i2c read fail: can't read from %02x: %d\n", reg, ret);
return ret;
} else {
*val = ret;
}
return 0;
}
static int __smb135x_write(struct smb135x_chg *chip, int reg,
u8 val)
{
s32 ret;
int retry_count = 0;
retry:
ret = i2c_smbus_write_byte_data(chip->client, reg, val);
if (ret < 0 && retry_count < RETRY_COUNT) {
/* sleep for few ms before retrying */
msleep(retry_sleep_ms[retry_count++]);
goto retry;
}
if (ret < 0) {
dev_err(chip->dev,
"i2c write fail: can't write %02x to %02x: %d\n",
val, reg, ret);
return ret;
}
pr_debug("Writing 0x%02x=0x%02x\n", reg, val);
return 0;
}
static int smb135x_read(struct smb135x_chg *chip, int reg,
u8 *val)
{
int rc;
if (chip->skip_reads) {
*val = 0;
return 0;
}
mutex_lock(&chip->read_write_lock);
rc = __smb135x_read(chip, reg, val);
mutex_unlock(&chip->read_write_lock);
return rc;
}
static int smb135x_write(struct smb135x_chg *chip, int reg,
u8 val)
{
int rc;
if (chip->skip_writes)
return 0;
mutex_lock(&chip->read_write_lock);
rc = __smb135x_write(chip, reg, val);
mutex_unlock(&chip->read_write_lock);
return rc;
}
static int smb135x_masked_write(struct smb135x_chg *chip, int reg,
u8 mask, u8 val)
{
s32 rc;
u8 temp;
if (chip->skip_writes || chip->skip_reads)
return 0;
mutex_lock(&chip->read_write_lock);
rc = __smb135x_read(chip, reg, &temp);
if (rc < 0) {
dev_err(chip->dev, "read failed: reg=%03X, rc=%d\n", reg, rc);
goto out;
}
temp &= ~mask;
temp |= val & mask;
rc = __smb135x_write(chip, reg, temp);
if (rc < 0) {
dev_err(chip->dev,
"write failed: reg=%03X, rc=%d\n", reg, rc);
}
out:
mutex_unlock(&chip->read_write_lock);
return rc;
}
static int read_revision(struct smb135x_chg *chip, u8 *revision)
{
int rc;
u8 reg;
rc = smb135x_read(chip, STATUS_9_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read status 9 rc = %d\n", rc);
return rc;
}
*revision = (reg & REV_MASK);
return 0;
}
static int read_version1(struct smb135x_chg *chip, u8 *version)
{
int rc;
u8 reg;
rc = smb135x_read(chip, VERSION1_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read version 1 rc = %d\n", rc);
return rc;
}
*version = (reg & VERSION1_MASK) >> VERSION1_SHIFT;
return 0;
}
static int read_version2(struct smb135x_chg *chip, u8 *version)
{
int rc;
u8 reg;
rc = smb135x_read(chip, VERSION2_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read version 2 rc = %d\n", rc);
return rc;
}
*version = (reg & VERSION2_MASK);
return 0;
}
static int read_version3(struct smb135x_chg *chip, u8 *version)
{
int rc;
u8 reg;
rc = smb135x_read(chip, VERSION3_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read version 3 rc = %d\n", rc);
return rc;
}
*version = reg;
return 0;
}
#define TRIM_23_REG 0x23
#define CHECK_USB100_GOOD_BIT BIT(1)
static bool is_usb100_broken(struct smb135x_chg *chip)
{
int rc;
u8 reg;
rc = smb135x_read(chip, TRIM_23_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read status 9 rc = %d\n", rc);
return rc;
}
return !!(reg & CHECK_USB100_GOOD_BIT);
}
static bool is_usb_slave_present(struct smb135x_chg *chip)
{
bool usb_slave_present;
u8 reg;
int rc;
rc = smb135x_read(chip, STATUS_6_REG, ®);
if (rc < 0) {
pr_err("Couldn't read stat 6 rc = %d\n", rc);
return false;
}
if ((reg & (RID_FLOAT_BIT | RID_A_BIT | RID_B_BIT | RID_C_BIT)) == 0)
usb_slave_present = 1;
else
usb_slave_present = 0;
pr_debug("stat6= 0x%02x slave_present = %d\n", reg, usb_slave_present);
return usb_slave_present;
}
static char *usb_type_str[] = {
"ACA_DOCK", /* bit 0 */
"ACA_C", /* bit 1 */
"ACA_B", /* bit 2 */
"ACA_A", /* bit 3 */
"SDP", /* bit 4 */
"OTHER", /* bit 5 */
"DCP", /* bit 6 */
"CDP", /* bit 7 */
"NONE", /* bit 8 error case */
};
/* helper to return the string of USB type */
static char *get_usb_type_name(u8 stat_5)
{
unsigned long stat = stat_5;
return usb_type_str[find_first_bit(&stat, SMB135X_BITS_PER_REG)];
}
static enum power_supply_type usb_type_enum[] = {
POWER_SUPPLY_TYPE_USB_ACA, /* bit 0 */
POWER_SUPPLY_TYPE_USB_ACA, /* bit 1 */
POWER_SUPPLY_TYPE_USB_ACA, /* bit 2 */
POWER_SUPPLY_TYPE_USB_ACA, /* bit 3 */
POWER_SUPPLY_TYPE_USB, /* bit 4 */
POWER_SUPPLY_TYPE_UNKNOWN, /* bit 5 */
POWER_SUPPLY_TYPE_USB_DCP, /* bit 6 */
POWER_SUPPLY_TYPE_USB_CDP, /* bit 7 */
POWER_SUPPLY_TYPE_UNKNOWN, /* bit 8 error case, report UNKNWON */
};
/* helper to return enum power_supply_type of USB type */
static enum power_supply_type get_usb_supply_type(u8 stat_5)
{
unsigned long stat = stat_5;
return usb_type_enum[find_first_bit(&stat, SMB135X_BITS_PER_REG)];
}
static enum power_supply_property smb135x_battery_properties[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CHARGING_ENABLED,
POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL,
};
static int smb135x_get_prop_batt_status(struct smb135x_chg *chip)
{
int rc;
int status = POWER_SUPPLY_STATUS_DISCHARGING;
u8 reg = 0;
u8 chg_type;
if (chip->chg_done_batt_full)
return POWER_SUPPLY_STATUS_FULL;
rc = smb135x_read(chip, STATUS_4_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Unable to read STATUS_4_REG rc = %d\n", rc);
return POWER_SUPPLY_STATUS_UNKNOWN;
}
if (reg & CHG_HOLD_OFF_BIT) {
/*
* when chg hold off happens the battery is
* not charging
*/
status = POWER_SUPPLY_STATUS_NOT_CHARGING;
goto out;
}
chg_type = (reg & CHG_TYPE_MASK) >> CHG_TYPE_SHIFT;
if (chg_type == BATT_NOT_CHG_VAL)
status = POWER_SUPPLY_STATUS_DISCHARGING;
else
status = POWER_SUPPLY_STATUS_CHARGING;
out:
pr_debug("STATUS_4_REG=%x\n", reg);
return status;
}
static int smb135x_get_prop_batt_present(struct smb135x_chg *chip)
{
int rc;
u8 reg;
rc = smb135x_read(chip, STATUS_4_REG, ®);
if (rc < 0)
return 0;
/* treat battery gone if less than 2V */
if (reg & BATT_LESS_THAN_2V)
return 0;
return chip->batt_present;
}
static int smb135x_get_prop_charge_type(struct smb135x_chg *chip)
{
int rc;
u8 reg;
u8 chg_type;
rc = smb135x_read(chip, STATUS_4_REG, ®);
if (rc < 0)
return POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
chg_type = (reg & CHG_TYPE_MASK) >> CHG_TYPE_SHIFT;
if (chg_type == BATT_NOT_CHG_VAL)
return POWER_SUPPLY_CHARGE_TYPE_NONE;
else if (chg_type == BATT_FAST_CHG_VAL)
return POWER_SUPPLY_CHARGE_TYPE_FAST;
else if (chg_type == BATT_PRE_CHG_VAL)
return POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
else if (chg_type == BATT_TAPER_CHG_VAL)
return POWER_SUPPLY_CHARGE_TYPE_TAPER;
return POWER_SUPPLY_CHARGE_TYPE_NONE;
}
#define DEFAULT_BATT_CAPACITY 50
static int smb135x_get_prop_batt_capacity(struct smb135x_chg *chip)
{
union power_supply_propval ret = {0, };
if (chip->fake_battery_soc >= 0)
return chip->fake_battery_soc;
if (chip->bms_psy) {
chip->bms_psy->get_property(chip->bms_psy,
POWER_SUPPLY_PROP_CAPACITY, &ret);
return ret.intval;
}
return DEFAULT_BATT_CAPACITY;
}
static int smb135x_get_prop_batt_health(struct smb135x_chg *chip)
{
union power_supply_propval ret = {0, };
if (chip->batt_hot)
ret.intval = POWER_SUPPLY_HEALTH_OVERHEAT;
else if (chip->batt_cold)
ret.intval = POWER_SUPPLY_HEALTH_COLD;
else if (chip->batt_warm)
ret.intval = POWER_SUPPLY_HEALTH_WARM;
else if (chip->batt_cool)
ret.intval = POWER_SUPPLY_HEALTH_COOL;
else
ret.intval = POWER_SUPPLY_HEALTH_GOOD;
return ret.intval;
}
static int smb135x_enable_volatile_writes(struct smb135x_chg *chip)
{
int rc;
rc = smb135x_masked_write(chip, CMD_I2C_REG,
ALLOW_VOLATILE_BIT, ALLOW_VOLATILE_BIT);
if (rc < 0)
dev_err(chip->dev,
"Couldn't set VOLATILE_W_PERM_BIT rc=%d\n", rc);
return rc;
}
static int usb_current_table_smb1356[] = {
180,
240,
270,
285,
300,
330,
360,
390,
420,
540,
570,
600,
660,
720,
840,
900,
960,
1080,
1110,
1128,
1146,
1170,
1182,
1200,
1230,
1260,
1380,
1440,
1560,
1620,
1680,
1800
};
static int fastchg_current_table[] = {
300,
400,
450,
475,
500,
550,
600,
650,
700,
900,
950,
1000,
1100,
1200,
1400,
2700,
1500,
1600,
1800,
1850,
1880,
1910,
2800,
1950,
1970,
2000,
2050,
2100,
2300,
2400,
2500,
3000
};
static int usb_current_table_smb1357_smb1358[] = {
300,
400,
450,
475,
500,
550,
600,
650,
700,
900,
950,
1000,
1100,
1200,
1400,
1450,
1500,
1600,
1800,
1850,
1880,
1910,
1930,
1950,
1970,
2000,
2050,
2100,
2300,
2400,
2500,
3000
};
static int usb_current_table_smb1359[] = {
300,
400,
450,
475,
500,
550,
600,
650,
700,
900,
950,
1000,
1100,
1200,
1400,
1450,
1500,
1600,
1800,
1850,
1880,
1910,
1930,
1950,
1970,
2000,
2050,
2100,
2300,
2400,
2500
};
static int dc_current_table_smb1356[] = {
180,
240,
270,
285,
300,
330,
360,
390,
420,
540,
570,
600,
660,
720,
840,
870,
900,
960,
1080,
1110,
1128,
1146,
1158,
1170,
1182,
1200,
};
static int dc_current_table[] = {
300,
400,
450,
475,
500,
550,
600,
650,
700,
900,
950,
1000,
1100,
1200,
1400,
1450,
1500,
1600,
1800,
1850,
1880,
1910,
1930,
1950,
1970,
2000,
};
#define CURRENT_100_MA 100
#define CURRENT_150_MA 150
#define CURRENT_500_MA 500
#define CURRENT_900_MA 900
#define SUSPEND_CURRENT_MA 2
static int __smb135x_usb_suspend(struct smb135x_chg *chip, bool suspend)
{
int rc;
rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_SHUTDOWN_BIT, suspend ? USB_SHUTDOWN_BIT : 0);
if (rc < 0)
dev_err(chip->dev, "Couldn't set cfg 11 rc = %d\n", rc);
return rc;
}
static int __smb135x_dc_suspend(struct smb135x_chg *chip, bool suspend)
{
int rc = 0;
rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT,
DC_SHUTDOWN_BIT, suspend ? DC_SHUTDOWN_BIT : 0);
if (rc < 0)
dev_err(chip->dev, "Couldn't set cfg 11 rc = %d\n", rc);
return rc;
}
static int smb135x_path_suspend(struct smb135x_chg *chip, enum path_type path,
int reason, bool suspend)
{
int rc = 0;
int suspended;
int *path_suspended;
int (*func)(struct smb135x_chg *chip, bool suspend);
mutex_lock(&chip->path_suspend_lock);
if (path == USB) {
suspended = chip->usb_suspended;
path_suspended = &chip->usb_suspended;
func = __smb135x_usb_suspend;
} else {
suspended = chip->dc_suspended;
path_suspended = &chip->dc_suspended;
func = __smb135x_dc_suspend;
}
if (suspend == false)
suspended &= ~reason;
else
suspended |= reason;
if (*path_suspended && !suspended)
rc = func(chip, 0);
if (!(*path_suspended) && suspended)
rc = func(chip, 1);
if (rc)
dev_err(chip->dev, "Couldn't set/unset suspend for %s path rc = %d\n",
path == USB ? "usb" : "dc",
rc);
else
*path_suspended = suspended;
mutex_unlock(&chip->path_suspend_lock);
return rc;
}
static int smb135x_get_usb_chg_current(struct smb135x_chg *chip)
{
if (chip->usb_suspended)
return SUSPEND_CURRENT_MA;
else
return chip->real_usb_psy_ma;
}
#define FCC_MASK SMB135X_MASK(5, 0)
#define CFG_1C_REG 0x1C
static int smb135x_get_fastchg_current(struct smb135x_chg *chip)
{
u8 reg;
int rc;
rc = smb135x_read(chip, CFG_1C_REG, ®);
if (rc < 0) {
pr_debug("cannot read 1c rc = %d\n", rc);
return 0;
}
reg &= FCC_MASK;
if (reg < 0 || chip->fastchg_current_arr_size == 0
|| reg > chip->fastchg_current_table[
chip->fastchg_current_arr_size - 1]) {
dev_err(chip->dev, "Current table out of range\n");
return -EINVAL;
}
return chip->fastchg_current_table[reg];
}
static int smb135x_set_fastchg_current(struct smb135x_chg *chip,
int current_ma)
{
int i, rc, diff, best, best_diff;
u8 reg;
/*
* if there is no array loaded or if the smallest current limit is
* above the requested current, then do nothing
*/
if (chip->fastchg_current_arr_size == 0) {
dev_err(chip->dev, "no table loaded\n");
return -EINVAL;
} else if ((current_ma - chip->fastchg_current_table[0]) < 0) {
dev_err(chip->dev, "invalid current requested\n");
return -EINVAL;
}
/* use the closest setting under the requested current */
best = 0;
best_diff = current_ma - chip->fastchg_current_table[best];
for (i = 1; i < chip->fastchg_current_arr_size; i++) {
diff = current_ma - chip->fastchg_current_table[i];
if (diff >= 0 && diff < best_diff) {
best_diff = diff;
best = i;
}
}
i = best;
reg = i & FCC_MASK;
rc = smb135x_masked_write(chip, CFG_1C_REG, FCC_MASK, reg);
if (rc < 0)
dev_err(chip->dev, "cannot write to config c rc = %d\n", rc);
pr_debug("fastchg current set to %dma\n",
chip->fastchg_current_table[i]);
return rc;
}
static int smb135x_set_high_usb_chg_current(struct smb135x_chg *chip,
int current_ma)
{
int i, rc;
u8 usb_cur_val;
for (i = chip->usb_current_arr_size - 1; i >= 0; i--) {
if (current_ma >= chip->usb_current_table[i])
break;
}
if (i < 0) {
dev_err(chip->dev,
"Cannot find %dma current_table using %d\n",
current_ma, CURRENT_150_MA);
rc = smb135x_masked_write(chip, CFG_5_REG,
USB_2_3_BIT, USB_2_3_BIT);
rc |= smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_100_VAL);
if (rc < 0)
dev_err(chip->dev, "Couldn't set %dmA rc=%d\n",
CURRENT_150_MA, rc);
else
chip->real_usb_psy_ma = CURRENT_150_MA;
return rc;
}
usb_cur_val = i & USBIN_INPUT_MASK;
rc = smb135x_masked_write(chip, CFG_C_REG,
USBIN_INPUT_MASK, usb_cur_val);
if (rc < 0) {
dev_err(chip->dev, "cannot write to config c rc = %d\n", rc);
return rc;
}
rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_AC_VAL);
if (rc < 0)
dev_err(chip->dev, "Couldn't write cfg 5 rc = %d\n", rc);
else
chip->real_usb_psy_ma = chip->usb_current_table[i];
return rc;
}
#define MAX_VERSION 0xF
#define USB_100_PROBLEM_VERSION 0x2
/* if APSD results are used
* if SDP is detected it will look at 500mA setting
* if set it will draw 500mA
* if unset it will draw 100mA
* if CDP/DCP it will look at 0x0C setting
* i.e. values in 0x41[1, 0] does not matter
*/
static int smb135x_set_usb_chg_current(struct smb135x_chg *chip,
int current_ma)
{
int rc;
pr_debug("USB current_ma = %d\n", current_ma);
if (chip->workaround_flags & WRKARND_USB100_BIT) {
pr_info("USB requested = %dmA using %dmA\n", current_ma,
CURRENT_500_MA);
current_ma = CURRENT_500_MA;
}
if (current_ma == 0)
/* choose the lowest available value of 100mA */
current_ma = CURRENT_100_MA;
if (current_ma == SUSPEND_CURRENT_MA) {
/* force suspend bit */
rc = smb135x_path_suspend(chip, USB, CURRENT, true);
chip->real_usb_psy_ma = SUSPEND_CURRENT_MA;
goto out;
}
if (current_ma < CURRENT_150_MA) {
/* force 100mA */
rc = smb135x_masked_write(chip, CFG_5_REG, USB_2_3_BIT, 0);
rc |= smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_100_VAL);
rc |= smb135x_path_suspend(chip, USB, CURRENT, false);
chip->real_usb_psy_ma = CURRENT_100_MA;
goto out;
}
/* specific current values */
if (current_ma == CURRENT_150_MA) {
rc = smb135x_masked_write(chip, CFG_5_REG,
USB_2_3_BIT, USB_2_3_BIT);
rc |= smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_100_VAL);
rc |= smb135x_path_suspend(chip, USB, CURRENT, false);
chip->real_usb_psy_ma = CURRENT_150_MA;
goto out;
}
if (current_ma == CURRENT_500_MA) {
rc = smb135x_masked_write(chip, CFG_5_REG, USB_2_3_BIT, 0);
rc |= smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_500_VAL);
rc |= smb135x_path_suspend(chip, USB, CURRENT, false);
chip->real_usb_psy_ma = CURRENT_500_MA;
goto out;
}
if (current_ma == CURRENT_900_MA) {
rc = smb135x_masked_write(chip, CFG_5_REG,
USB_2_3_BIT, USB_2_3_BIT);
rc |= smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USB_100_500_AC_MASK, USB_500_VAL);
rc |= smb135x_path_suspend(chip, USB, CURRENT, false);
chip->real_usb_psy_ma = CURRENT_900_MA;
goto out;
}
rc = smb135x_set_high_usb_chg_current(chip, current_ma);
rc |= smb135x_path_suspend(chip, USB, CURRENT, false);
out:
if (rc < 0)
dev_err(chip->dev,
"Couldn't set %dmA rc = %d\n", current_ma, rc);
return rc;
}
static int smb135x_set_dc_chg_current(struct smb135x_chg *chip,
int current_ma)
{
int i, rc;
u8 dc_cur_val;
for (i = chip->dc_current_arr_size - 1; i >= 0; i--) {
if (chip->dc_psy_ma >= chip->dc_current_table[i])
break;
}
dc_cur_val = i & DCIN_INPUT_MASK;
rc = smb135x_masked_write(chip, CFG_A_REG,
DCIN_INPUT_MASK, dc_cur_val);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set dc charge current rc = %d\n",
rc);
return rc;
}
return 0;
}
static int smb135x_set_appropriate_current(struct smb135x_chg *chip,
enum path_type path)
{
int therm_ma, current_ma;
int path_current = (path == USB) ? chip->usb_psy_ma : chip->dc_psy_ma;
int (*func)(struct smb135x_chg *chip, int current_ma);
int rc = 0;
if (!chip->usb_psy && path == USB)
return 0;
/*
* If battery is absent do not modify the current at all, these
* would be some appropriate values set by the bootloader or default
* configuration and since it is the only source of power we should
* not change it
*/
if (!chip->batt_present) {
pr_debug("ignoring current request since battery is absent\n");
return 0;
}
if (path == USB) {
path_current = chip->usb_psy_ma;
func = smb135x_set_usb_chg_current;
} else {
path_current = chip->dc_psy_ma;
func = smb135x_set_dc_chg_current;
if (chip->dc_psy_type == -EINVAL)
func = NULL;
}
if (chip->therm_lvl_sel > 0
&& chip->therm_lvl_sel < (chip->thermal_levels - 1))
/*
* consider thermal limit only when it is active and not at
* the highest level
*/
therm_ma = chip->thermal_mitigation[chip->therm_lvl_sel];
else
therm_ma = path_current;
current_ma = min(therm_ma, path_current);
if (func != NULL)
rc = func(chip, current_ma);
if (rc < 0)
dev_err(chip->dev, "Couldn't set %s current to min(%d, %d)rc = %d\n",
path == USB ? "usb" : "dc",
therm_ma, path_current,
rc);
return rc;
}
static int smb135x_charging_enable(struct smb135x_chg *chip, int enable)
{
int rc;
rc = smb135x_masked_write(chip, CMD_CHG_REG,
CMD_CHG_EN, enable ? CMD_CHG_EN : 0);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set CHG_ENABLE_BIT enable = %d rc = %d\n",
enable, rc);
return rc;
}
return 0;
}
static int __smb135x_charging(struct smb135x_chg *chip, int enable)
{
int rc = 0;
pr_debug("charging enable = %d\n", enable);
if (chip->chg_disabled_permanently) {
pr_debug("charging is disabled permanetly\n");
return -EINVAL;
}
rc = smb135x_charging_enable(chip, enable);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't %s charging rc = %d\n",
enable ? "enable" : "disable", rc);
return rc;
}
chip->chg_enabled = enable;
/* set the suspended status */
rc = smb135x_path_suspend(chip, DC, USER, !enable);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set dc suspend to %d rc = %d\n",
enable, rc);
return rc;
}
rc = smb135x_path_suspend(chip, USB, USER, !enable);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set usb suspend to %d rc = %d\n",
enable, rc);
return rc;
}
pr_debug("charging %s\n",
enable ? "enabled" : "disabled running from batt");
return rc;
}
static int smb135x_charging(struct smb135x_chg *chip, int enable)
{
int rc = 0;
pr_debug("charging enable = %d\n", enable);
__smb135x_charging(chip, enable);
if (chip->usb_psy) {
pr_debug("usb psy changed\n");
power_supply_changed(chip->usb_psy);
}
if (chip->dc_psy_type != -EINVAL) {
pr_debug("dc psy changed\n");
power_supply_changed(&chip->dc_psy);
}
pr_debug("charging %s\n",
enable ? "enabled" : "disabled running from batt");
return rc;
}
static int smb135x_system_temp_level_set(struct smb135x_chg *chip,
int lvl_sel)
{
int rc = 0;
int prev_therm_lvl;
if (!chip->thermal_mitigation) {
pr_err("Thermal mitigation not supported\n");
return -EINVAL;
}
if (lvl_sel < 0) {
pr_err("Unsupported level selected %d\n", lvl_sel);
return -EINVAL;
}
if (lvl_sel >= chip->thermal_levels) {
pr_err("Unsupported level selected %d forcing %d\n", lvl_sel,
chip->thermal_levels - 1);
lvl_sel = chip->thermal_levels - 1;
}
if (lvl_sel == chip->therm_lvl_sel)
return 0;
mutex_lock(&chip->current_change_lock);
prev_therm_lvl = chip->therm_lvl_sel;
chip->therm_lvl_sel = lvl_sel;
if (chip->therm_lvl_sel == (chip->thermal_levels - 1)) {
/*
* Disable charging if highest value selected by
* setting the DC and USB path in suspend
*/
rc = smb135x_path_suspend(chip, DC, THERMAL, true);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set dc suspend rc %d\n", rc);
goto out;
}
rc = smb135x_path_suspend(chip, USB, THERMAL, true);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set usb suspend rc %d\n", rc);
goto out;
}
goto out;
}
smb135x_set_appropriate_current(chip, USB);
smb135x_set_appropriate_current(chip, DC);
if (prev_therm_lvl == chip->thermal_levels - 1) {
/*
* If previously highest value was selected charging must have
* been disabed. Enable charging by taking the DC and USB path
* out of suspend.
*/
rc = smb135x_path_suspend(chip, DC, THERMAL, false);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set dc suspend rc %d\n", rc);
goto out;
}
rc = smb135x_path_suspend(chip, USB, THERMAL, false);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set usb suspend rc %d\n", rc);
goto out;
}
}
out:
mutex_unlock(&chip->current_change_lock);
return rc;
}
static int smb135x_battery_set_property(struct power_supply *psy,
enum power_supply_property prop,
const union power_supply_propval *val)
{
int rc = 0, update_psy = 0;
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, batt_psy);
switch (prop) {
case POWER_SUPPLY_PROP_STATUS:
if (!chip->bms_controlled_charging) {
rc = -EINVAL;
break;
}
switch (val->intval) {
case POWER_SUPPLY_STATUS_FULL:
rc = smb135x_charging_enable(chip, false);
if (rc < 0) {
dev_err(chip->dev, "Couldn't disable charging rc = %d\n",
rc);
} else {
chip->chg_done_batt_full = true;
update_psy = 1;
dev_dbg(chip->dev, "status = FULL chg_done_batt_full = %d",
chip->chg_done_batt_full);
}
break;
case POWER_SUPPLY_STATUS_DISCHARGING:
chip->chg_done_batt_full = false;
update_psy = 1;
dev_dbg(chip->dev, "status = DISCHARGING chg_done_batt_full = %d",
chip->chg_done_batt_full);
break;
case POWER_SUPPLY_STATUS_CHARGING:
rc = smb135x_charging_enable(chip, true);
if (rc < 0) {
dev_err(chip->dev, "Couldn't enable charging rc = %d\n",
rc);
} else {
chip->chg_done_batt_full = false;
dev_dbg(chip->dev, "status = CHARGING chg_done_batt_full = %d",
chip->chg_done_batt_full);
}
break;
default:
update_psy = 0;
rc = -EINVAL;
}
break;
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
smb135x_charging(chip, val->intval);
break;
case POWER_SUPPLY_PROP_CAPACITY:
chip->fake_battery_soc = val->intval;
update_psy = 1;
break;
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
smb135x_system_temp_level_set(chip, val->intval);
break;
default:
rc = -EINVAL;
}
if (!rc && update_psy)
power_supply_changed(&chip->batt_psy);
return rc;
}
static int smb135x_battery_is_writeable(struct power_supply *psy,
enum power_supply_property prop)
{
int rc;
switch (prop) {
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
case POWER_SUPPLY_PROP_CAPACITY:
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
rc = 1;
break;
default:
rc = 0;
break;
}
return rc;
}
static int smb135x_battery_get_property(struct power_supply *psy,
enum power_supply_property prop,
union power_supply_propval *val)
{
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, batt_psy);
switch (prop) {
case POWER_SUPPLY_PROP_STATUS:
val->intval = smb135x_get_prop_batt_status(chip);
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = smb135x_get_prop_batt_present(chip);
break;
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
val->intval = chip->chg_enabled;
break;
case POWER_SUPPLY_PROP_CHARGE_TYPE:
val->intval = smb135x_get_prop_charge_type(chip);
break;
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = smb135x_get_prop_batt_capacity(chip);
break;
case POWER_SUPPLY_PROP_HEALTH:
val->intval = smb135x_get_prop_batt_health(chip);
break;
case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
break;
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
val->intval = chip->therm_lvl_sel;
break;
default:
return -EINVAL;
}
return 0;
}
static enum power_supply_property smb135x_dc_properties[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_HEALTH,
};
static int smb135x_dc_get_property(struct power_supply *psy,
enum power_supply_property prop,
union power_supply_propval *val)
{
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, dc_psy);
switch (prop) {
case POWER_SUPPLY_PROP_PRESENT:
val->intval = chip->dc_present;
break;
case POWER_SUPPLY_PROP_ONLINE:
val->intval = chip->chg_enabled ? chip->dc_present : 0;
break;
case POWER_SUPPLY_PROP_HEALTH:
val->intval = chip->dc_present;
break;
default:
return -EINVAL;
}
return 0;
}
#define MIN_FLOAT_MV 3600
#define MAX_FLOAT_MV 4500
#define MID_RANGE_FLOAT_MV_MIN 3600
#define MID_RANGE_FLOAT_MIN_VAL 0x05
#define MID_RANGE_FLOAT_STEP_MV 20
#define HIGH_RANGE_FLOAT_MIN_MV 4340
#define HIGH_RANGE_FLOAT_MIN_VAL 0x2A
#define HIGH_RANGE_FLOAT_STEP_MV 10
#define VHIGH_RANGE_FLOAT_MIN_MV 4400
#define VHIGH_RANGE_FLOAT_MIN_VAL 0x2E
#define VHIGH_RANGE_FLOAT_STEP_MV 20
static int smb135x_float_voltage_set(struct smb135x_chg *chip, int vfloat_mv)
{
u8 temp;
if ((vfloat_mv < MIN_FLOAT_MV) || (vfloat_mv > MAX_FLOAT_MV)) {
dev_err(chip->dev, "bad float voltage mv =%d asked to set\n",
vfloat_mv);
return -EINVAL;
}
if (vfloat_mv <= HIGH_RANGE_FLOAT_MIN_MV) {
/* mid range */
temp = MID_RANGE_FLOAT_MIN_VAL
+ (vfloat_mv - MID_RANGE_FLOAT_MV_MIN)
/ MID_RANGE_FLOAT_STEP_MV;
} else if (vfloat_mv < VHIGH_RANGE_FLOAT_MIN_MV) {
/* high range */
temp = HIGH_RANGE_FLOAT_MIN_VAL
+ (vfloat_mv - HIGH_RANGE_FLOAT_MIN_MV)
/ HIGH_RANGE_FLOAT_STEP_MV;
} else {
/* very high range */
temp = VHIGH_RANGE_FLOAT_MIN_VAL
+ (vfloat_mv - VHIGH_RANGE_FLOAT_MIN_MV)
/ VHIGH_RANGE_FLOAT_STEP_MV;
}
return smb135x_write(chip, VFLOAT_REG, temp);
}
static int smb135x_set_resume_threshold(struct smb135x_chg *chip,
int resume_delta_mv)
{
int rc;
u8 reg;
if (!chip->inhibit_disabled) {
if (resume_delta_mv < 100)
reg = CHG_INHIBIT_50MV_VAL;
else if (resume_delta_mv < 200)
reg = CHG_INHIBIT_100MV_VAL;
else if (resume_delta_mv < 300)
reg = CHG_INHIBIT_200MV_VAL;
else
reg = CHG_INHIBIT_300MV_VAL;
rc = smb135x_masked_write(chip, CFG_4_REG, CHG_INHIBIT_MASK,
reg);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set inhibit val rc = %d\n",
rc);
return rc;
}
}
if (resume_delta_mv < 200)
reg = 0;
else
reg = RECHARGE_200MV_BIT;
rc = smb135x_masked_write(chip, CFG_5_REG, RECHARGE_200MV_BIT, reg);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set recharge rc = %d\n", rc);
return rc;
}
return 0;
}
static enum power_supply_property smb135x_parallel_properties[] = {
POWER_SUPPLY_PROP_CHARGING_ENABLED,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CURRENT_MAX,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
};
static int smb135x_parallel_set_chg_present(struct smb135x_chg *chip,
int present)
{
u8 val;
int rc;
if (present == chip->parallel_charger_present) {
pr_debug("present %d -> %d, skipping\n",
chip->parallel_charger_present, present);
return 0;
}
if (present) {
rc = smb135x_enable_volatile_writes(chip);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't configure for volatile rc = %d\n",
rc);
return rc;
}
/* set the float voltage */
if (chip->vfloat_mv != -EINVAL) {
rc = smb135x_float_voltage_set(chip, chip->vfloat_mv);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set float voltage rc = %d\n",
rc);
return rc;
}
}
/* resume threshold */
if (chip->resume_delta_mv != -EINVAL) {
smb135x_set_resume_threshold(chip,
chip->resume_delta_mv);
}
rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT,
USE_REGISTER_FOR_CURRENT,
USE_REGISTER_FOR_CURRENT);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set input limit cmd rc=%d\n",
rc);
return rc;
}
/* set chg en by pin active low and enable auto recharge */
rc = smb135x_masked_write(chip, CFG_14_REG,
CHG_EN_BY_PIN_BIT | CHG_EN_ACTIVE_LOW_BIT
| DISABLE_AUTO_RECHARGE_BIT,
CHG_EN_BY_PIN_BIT | CHG_EN_ACTIVE_LOW_BIT);
/* set bit 0 = 100mA bit 1 = 500mA and set register control */
rc = smb135x_masked_write(chip, CFG_E_REG,
POLARITY_100_500_BIT | USB_CTRL_BY_PIN_BIT,
POLARITY_100_500_BIT);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set usbin cfg rc=%d\n",
rc);
return rc;
}
/* control USB suspend via command bits */
rc = smb135x_masked_write(chip, USBIN_DCIN_CFG_REG,
USBIN_SUSPEND_VIA_COMMAND_BIT,
USBIN_SUSPEND_VIA_COMMAND_BIT);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set cfg rc=%d\n", rc);
return rc;
}
/* set the fastchg_current to the lowest setting */
if (chip->fastchg_current_arr_size > 0)
rc = smb135x_set_fastchg_current(chip,
chip->fastchg_current_table[0]);
/*
* enforce chip->chg_enabled since this could be the first
* time we have i2c access to the charger after
* chip->chg_enabled has been modified
*/
smb135x_charging(chip, chip->chg_enabled);
}
chip->parallel_charger_present = present;
/*
* When present is being set force USB suspend, start charging
* only when CURRENT_MAX is set.
*
* Usually the chip will be shutdown (no i2c access to the chip)
* when USB is removed, however there could be situations when
* it is not. To cover for USB reinsetions in such situations
* force USB suspend when present is being unset.
* It is likely that i2c access could fail here - do not return error.
* (It is not possible to detect whether the chip is in shutdown state
* or not except for the i2c error).
*/
chip->usb_psy_ma = SUSPEND_CURRENT_MA;
rc = smb135x_path_suspend(chip, USB, CURRENT, true);
if (present) {
if (rc) {
dev_err(chip->dev,
"Couldn't set usb suspend to true rc = %d\n",
rc);
return rc;
}
/* Check if the USB is configured for suspend. If not, do it */
mutex_lock(&chip->path_suspend_lock);
rc = smb135x_read(chip, CMD_INPUT_LIMIT, &val);
if (rc) {
dev_err(chip->dev,
"Couldn't read 0x%02x rc:%d\n", CMD_INPUT_LIMIT,
rc);
mutex_unlock(&chip->path_suspend_lock);
return rc;
} else if (!(val & BIT(6))) {
rc = __smb135x_usb_suspend(chip, 1);
}
mutex_unlock(&chip->path_suspend_lock);
if (rc) {
dev_err(chip->dev,
"Couldn't set usb to suspend rc:%d\n", rc);
return rc;
}
} else {
chip->real_usb_psy_ma = SUSPEND_CURRENT_MA;
}
return 0;
}
static int smb135x_parallel_set_property(struct power_supply *psy,
enum power_supply_property prop,
const union power_supply_propval *val)
{
int rc = 0;
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, parallel_psy);
switch (prop) {
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
if (chip->parallel_charger_present)
smb135x_charging(chip, val->intval);
else
chip->chg_enabled = val->intval;
break;
case POWER_SUPPLY_PROP_PRESENT:
rc = smb135x_parallel_set_chg_present(chip, val->intval);
break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
if (chip->parallel_charger_present) {
rc = smb135x_set_fastchg_current(chip,
val->intval / 1000);
}
break;
case POWER_SUPPLY_PROP_CURRENT_MAX:
if (chip->parallel_charger_present) {
chip->usb_psy_ma = val->intval / 1000;
rc = smb135x_set_usb_chg_current(chip,
chip->usb_psy_ma);
}
break;
default:
return -EINVAL;
}
return rc;
}
static int smb135x_parallel_is_writeable(struct power_supply *psy,
enum power_supply_property prop)
{
int rc;
switch (prop) {
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
rc = 1;
break;
default:
rc = 0;
break;
}
return rc;
}
static int smb135x_parallel_get_property(struct power_supply *psy,
enum power_supply_property prop,
union power_supply_propval *val)
{
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, parallel_psy);
switch (prop) {
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
val->intval = chip->chg_enabled;
break;
case POWER_SUPPLY_PROP_CURRENT_MAX:
if (chip->parallel_charger_present)
val->intval = smb135x_get_usb_chg_current(chip) * 1000;
else
val->intval = 0;
break;
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = chip->parallel_charger_present;
break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
if (chip->parallel_charger_present)
val->intval = smb135x_get_fastchg_current(chip) * 1000;
else
val->intval = 0;
break;
case POWER_SUPPLY_PROP_STATUS:
if (chip->parallel_charger_present)
val->intval = smb135x_get_prop_batt_status(chip);
else
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break;
default:
return -EINVAL;
}
return 0;
}
static void smb135x_external_power_changed(struct power_supply *psy)
{
struct smb135x_chg *chip = container_of(psy,
struct smb135x_chg, batt_psy);
union power_supply_propval prop = {0,};
int rc, current_limit = 0;
if (!chip->usb_psy)
return;
if (chip->bms_psy_name)
chip->bms_psy =
power_supply_get_by_name((char *)chip->bms_psy_name);
rc = chip->usb_psy->get_property(chip->usb_psy,
POWER_SUPPLY_PROP_CURRENT_MAX, &prop);
if (rc < 0)
dev_err(chip->dev,
"could not read USB current_max property, rc=%d\n", rc);
else
current_limit = prop.intval / 1000;
pr_debug("current_limit = %d\n", current_limit);
if (chip->usb_psy_ma != current_limit) {
mutex_lock(&chip->current_change_lock);
chip->usb_psy_ma = current_limit;
rc = smb135x_set_appropriate_current(chip, USB);
mutex_unlock(&chip->current_change_lock);
if (rc < 0)
dev_err(chip->dev, "Couldn't set usb current rc = %d\n",
rc);
}
rc = chip->usb_psy->get_property(chip->usb_psy,
POWER_SUPPLY_PROP_ONLINE, &prop);
if (rc < 0)
dev_err(chip->dev,
"could not read USB ONLINE property, rc=%d\n", rc);
/* update online property */
rc = 0;
if (chip->usb_present && chip->chg_enabled && chip->usb_psy_ma != 0) {
if (prop.intval == 0)
rc = power_supply_set_online(chip->usb_psy, true);
} else {
if (prop.intval == 1)
rc = power_supply_set_online(chip->usb_psy, false);
}
if (rc < 0)
dev_err(chip->dev, "could not set usb online, rc=%d\n", rc);
}
static bool elapsed_msec_greater(struct timeval *start_time,
struct timeval *end_time, int ms)
{
int msec_elapsed;
msec_elapsed = (end_time->tv_sec - start_time->tv_sec) * 1000 +
DIV_ROUND_UP(end_time->tv_usec - start_time->tv_usec, 1000);
return (msec_elapsed > ms);
}
#define MAX_STEP_MS 10
static int smb135x_chg_otg_enable(struct smb135x_chg *chip)
{
int rc = 0;
int restart_count = 0;
struct timeval time_a, time_b, time_c, time_d;
if (chip->revision == REV_2) {
/*
* Workaround for a hardware bug where the OTG needs to be
* enabled disabled and enabled for it to be actually enabled.
* The time between each step should be atmost MAX_STEP_MS
*
* Note that if enable-disable executes within the timeframe
* but the final enable takes more than MAX_STEP_ME, we treat
* it as the first enable and try disabling again. We don't
* want to issue enable back to back.
*
* Notice the instances when time is captured and the
* successive steps.
* timeA-enable-timeC-disable-timeB-enable-timeD.
* When
* (timeB - timeA) < MAX_STEP_MS AND
* (timeC - timeD) < MAX_STEP_MS
* then it is guaranteed that the successive steps
* must have executed within MAX_STEP_MS
*/
do_gettimeofday(&time_a);
restart_from_enable:
/* first step - enable otg */
rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, OTG_EN);
if (rc < 0) {
dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n",
rc);
return rc;
}
restart_from_disable:
/* second step - disable otg */
do_gettimeofday(&time_c);
rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, 0);
if (rc < 0) {
dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n",
rc);
return rc;
}
do_gettimeofday(&time_b);
if (elapsed_msec_greater(&time_a, &time_b, MAX_STEP_MS)) {
restart_count++;
if (restart_count > 10) {
dev_err(chip->dev,
"Couldn't enable OTG restart_count=%d\n",
restart_count);
return -EAGAIN;
}
time_a = time_b;
pr_debug("restarting from first enable\n");
goto restart_from_enable;
}
/* third step (first step in case of a failure) - enable otg */
time_a = time_b;
rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, OTG_EN);
if (rc < 0) {
dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n",
rc);
return rc;
}
do_gettimeofday(&time_d);
if (elapsed_msec_greater(&time_c, &time_d, MAX_STEP_MS)) {
restart_count++;
if (restart_count > 10) {
dev_err(chip->dev,
"Couldn't enable OTG restart_count=%d\n",
restart_count);
return -EAGAIN;
}
pr_debug("restarting from disable\n");
goto restart_from_disable;
}
} else {
rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, OTG_EN);
if (rc < 0) {
dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n",
rc);
return rc;
}
}
return rc;
}
static int smb135x_chg_otg_regulator_enable(struct regulator_dev *rdev)
{
int rc = 0;
struct smb135x_chg *chip = rdev_get_drvdata(rdev);
chip->otg_oc_count = 0;
rc = smb135x_chg_otg_enable(chip);
if (rc)
dev_err(chip->dev, "Couldn't enable otg regulator rc=%d\n", rc);
return rc;
}
static int smb135x_chg_otg_regulator_disable(struct regulator_dev *rdev)
{
int rc = 0;
struct smb135x_chg *chip = rdev_get_drvdata(rdev);
rc = smb135x_masked_write(chip, CMD_CHG_REG, OTG_EN, 0);
if (rc < 0)
dev_err(chip->dev, "Couldn't disable OTG mode rc=%d\n", rc);
return rc;
}
static int smb135x_chg_otg_regulator_is_enable(struct regulator_dev *rdev)
{
int rc = 0;
u8 reg = 0;
struct smb135x_chg *chip = rdev_get_drvdata(rdev);
rc = smb135x_read(chip, CMD_CHG_REG, ®);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't read OTG enable bit rc=%d\n", rc);
return rc;
}
return (reg & OTG_EN) ? 1 : 0;
}
struct regulator_ops smb135x_chg_otg_reg_ops = {
.enable = smb135x_chg_otg_regulator_enable,
.disable = smb135x_chg_otg_regulator_disable,
.is_enabled = smb135x_chg_otg_regulator_is_enable,
};
static int smb135x_set_current_tables(struct smb135x_chg *chip)
{
switch (chip->version) {
case V_SMB1356:
chip->usb_current_table = usb_current_table_smb1356;
chip->usb_current_arr_size
= ARRAY_SIZE(usb_current_table_smb1356);
chip->dc_current_table = dc_current_table_smb1356;
chip->dc_current_arr_size
= ARRAY_SIZE(dc_current_table_smb1356);
chip->fastchg_current_table = NULL;
chip->fastchg_current_arr_size = 0;
break;
case V_SMB1357:
chip->usb_current_table = usb_current_table_smb1357_smb1358;
chip->usb_current_arr_size
= ARRAY_SIZE(usb_current_table_smb1357_smb1358);
chip->dc_current_table = dc_current_table;
chip->dc_current_arr_size = ARRAY_SIZE(dc_current_table);
chip->fastchg_current_table = fastchg_current_table;
chip->fastchg_current_arr_size
= ARRAY_SIZE(fastchg_current_table);
break;
case V_SMB1358:
chip->usb_current_table = usb_current_table_smb1357_smb1358;
chip->usb_current_arr_size
= ARRAY_SIZE(usb_current_table_smb1357_smb1358);
chip->dc_current_table = dc_current_table;
chip->dc_current_arr_size = ARRAY_SIZE(dc_current_table);
chip->fastchg_current_table = NULL;
chip->fastchg_current_arr_size = 0;
break;
case V_SMB1359:
chip->usb_current_table = usb_current_table_smb1359;
chip->usb_current_arr_size
= ARRAY_SIZE(usb_current_table_smb1359);
chip->dc_current_table = dc_current_table;
chip->dc_current_arr_size = ARRAY_SIZE(dc_current_table);
chip->fastchg_current_table = NULL;
chip->fastchg_current_arr_size = 0;
break;
}
return 0;
}
#define SMB1356_VERSION3_BIT BIT(7)
#define SMB1357_VERSION1_VAL 0x01
#define SMB1358_VERSION1_VAL 0x02
#define SMB1359_VERSION1_VAL 0x00
#define SMB1357_VERSION2_VAL 0x01
#define SMB1358_VERSION2_VAL 0x02
#define SMB1359_VERSION2_VAL 0x00
static int smb135x_chip_version_and_revision(struct smb135x_chg *chip)
{
int rc;
u8 version1, version2, version3;
/* read the revision */
rc = read_revision(chip, &chip->revision);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read revision rc = %d\n", rc);
return rc;
}
if (chip->revision >= REV_MAX || revision_str[chip->revision] == NULL) {
dev_err(chip->dev, "Bad revision found = %d\n", chip->revision);
return -EINVAL;
}
/* check if it is smb1356 */
rc = read_version3(chip, &version3);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read version3 rc = %d\n", rc);
return rc;
}
if (version3 & SMB1356_VERSION3_BIT) {
chip->version = V_SMB1356;
goto wrkarnd_and_input_current_values;
}
/* check if it is smb1357, smb1358 or smb1359 based on revision */
if (chip->revision <= REV_1_1) {
rc = read_version1(chip, &version1);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't read version 1 rc = %d\n", rc);
return rc;
}
switch (version1) {
case SMB1357_VERSION1_VAL:
chip->version = V_SMB1357;
break;
case SMB1358_VERSION1_VAL:
chip->version = V_SMB1358;
break;
case SMB1359_VERSION1_VAL:
chip->version = V_SMB1359;
break;
default:
dev_err(chip->dev,
"Unknown version 1 = 0x%02x rc = %d\n",
version1, rc);
return rc;
}
} else {
rc = read_version2(chip, &version2);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't read version 2 rc = %d\n", rc);
return rc;
}
switch (version2) {
case SMB1357_VERSION2_VAL:
chip->version = V_SMB1357;
break;
case SMB1358_VERSION2_VAL:
chip->version = V_SMB1358;
break;
case SMB1359_VERSION2_VAL:
chip->version = V_SMB1359;
break;
default:
dev_err(chip->dev,
"Unknown version 2 = 0x%02x rc = %d\n",
version2, rc);
return rc;
}
}
wrkarnd_and_input_current_values:
if (is_usb100_broken(chip))
chip->workaround_flags |= WRKARND_USB100_BIT;
/*
* Rev v1.0 and v1.1 of SMB135x fails charger type detection
* (apsd) due to interference on the D+/- lines by the USB phy.
* Set the workaround flag to disable charger type reporting
* for this revision.
*/
if (chip->revision <= REV_1_1)
chip->workaround_flags |= WRKARND_APSD_FAIL;
pr_debug("workaround_flags = %x\n", chip->workaround_flags);
return smb135x_set_current_tables(chip);
}
static int smb135x_regulator_init(struct smb135x_chg *chip)
{
int rc = 0;
struct regulator_init_data *init_data;
struct regulator_config cfg = {};
init_data = of_get_regulator_init_data(chip->dev, chip->dev->of_node);
if (!init_data) {
dev_err(chip->dev, "Unable to allocate memory\n");
return -ENOMEM;
}
if (init_data->constraints.name) {
chip->otg_vreg.rdesc.owner = THIS_MODULE;
chip->otg_vreg.rdesc.type = REGULATOR_VOLTAGE;
chip->otg_vreg.rdesc.ops = &smb135x_chg_otg_reg_ops;
chip->otg_vreg.rdesc.name = init_data->constraints.name;
cfg.dev = chip->dev;
cfg.init_data = init_data;
cfg.driver_data = chip;
cfg.of_node = chip->dev->of_node;
init_data->constraints.valid_ops_mask
|= REGULATOR_CHANGE_STATUS;
chip->otg_vreg.rdev = regulator_register(
&chip->otg_vreg.rdesc, &cfg);
if (IS_ERR(chip->otg_vreg.rdev)) {
rc = PTR_ERR(chip->otg_vreg.rdev);
chip->otg_vreg.rdev = NULL;
if (rc != -EPROBE_DEFER)
dev_err(chip->dev,
"OTG reg failed, rc=%d\n", rc);
}
}
return rc;
}
static void smb135x_regulator_deinit(struct smb135x_chg *chip)
{
if (chip->otg_vreg.rdev)
regulator_unregister(chip->otg_vreg.rdev);
}
static void wireless_insertion_work(struct work_struct *work)
{
struct smb135x_chg *chip =
container_of(work, struct smb135x_chg,
wireless_insertion_work.work);
/* unsuspend dc */
smb135x_path_suspend(chip, DC, CURRENT, false);
}
static int hot_hard_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
chip->batt_hot = !!rt_stat;
return 0;
}
static int cold_hard_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
chip->batt_cold = !!rt_stat;
return 0;
}
static int hot_soft_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
chip->batt_warm = !!rt_stat;
return 0;
}
static int cold_soft_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
chip->batt_cool = !!rt_stat;
return 0;
}
static int battery_missing_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
chip->batt_present = !rt_stat;
return 0;
}
static int vbat_low_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_warn("vbat low\n");
return 0;
}
static int chg_hot_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_warn("chg hot\n");
return 0;
}
static int chg_term_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
/*
* This handler gets called even when the charger based termination
* is disabled (due to change in RT status). However, in a bms
* controlled design the battery status should not be updated.
*/
if (!chip->iterm_disabled)
chip->chg_done_batt_full = !!rt_stat;
return 0;
}
static int taper_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
return 0;
}
static int fast_chg_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
if (rt_stat & IRQ_C_FASTCHG_BIT)
chip->chg_done_batt_full = false;
return 0;
}
static int recharge_handler(struct smb135x_chg *chip, u8 rt_stat)
{
int rc;
pr_debug("rt_stat = 0x%02x\n", rt_stat);
if (chip->bms_controlled_charging) {
rc = smb135x_charging_enable(chip, true);
if (rc < 0)
dev_err(chip->dev, "Couldn't enable charging rc = %d\n",
rc);
}
return 0;
}
static int safety_timeout_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_warn("safety timeout rt_stat = 0x%02x\n", rt_stat);
return 0;
}
/**
* power_ok_handler() - called when the switcher turns on or turns off
* @chip: pointer to smb135x_chg chip
* @rt_stat: the status bit indicating switcher turning on or off
*/
static int power_ok_handler(struct smb135x_chg *chip, u8 rt_stat)
{
pr_debug("rt_stat = 0x%02x\n", rt_stat);
return 0;
}
static int rid_handler(struct smb135x_chg *chip, u8 rt_stat)
{
bool usb_slave_present;
usb_slave_present = is_usb_slave_present(chip);
if (chip->usb_slave_present ^ usb_slave_present) {
chip->usb_slave_present = usb_slave_present;
if (chip->usb_psy) {
pr_debug("setting usb psy usb_otg = %d\n",
chip->usb_slave_present);
power_supply_set_usb_otg(chip->usb_psy,
chip->usb_slave_present);
}
}
return 0;
}
#define MAX_OTG_RETRY 3
static int otg_oc_handler(struct smb135x_chg *chip, u8 rt_stat)
{
int rc;
++chip->otg_oc_count;
if (chip->otg_oc_count < MAX_OTG_RETRY) {
rc = smb135x_chg_otg_enable(chip);
if (rc < 0)
dev_err(chip->dev, "Couldn't enable OTG mode rc=%d\n",
rc);
} else {
pr_warn_ratelimited("Tried enabling OTG %d times, the USB slave is nonconformant.\n",
chip->otg_oc_count);
}
pr_debug("rt_stat = 0x%02x\n", rt_stat);
return 0;
}
static int handle_dc_removal(struct smb135x_chg *chip)
{
if (chip->dc_psy_type == POWER_SUPPLY_TYPE_WIRELESS) {
cancel_delayed_work_sync(&chip->wireless_insertion_work);
smb135x_path_suspend(chip, DC, CURRENT, true);
}
if (chip->dc_psy_type != -EINVAL)
power_supply_set_online(&chip->dc_psy, chip->dc_present);
return 0;
}
#define DCIN_UNSUSPEND_DELAY_MS 1000
static int handle_dc_insertion(struct smb135x_chg *chip)
{
if (chip->dc_psy_type == POWER_SUPPLY_TYPE_WIRELESS)
schedule_delayed_work(&chip->wireless_insertion_work,
msecs_to_jiffies(DCIN_UNSUSPEND_DELAY_MS));
if (chip->dc_psy_type != -EINVAL)
power_supply_set_online(&chip->dc_psy,
chip->dc_present);
return 0;
}
/**
* dcin_uv_handler() - called when the dc voltage crosses the uv threshold
* @chip: pointer to smb135x_chg chip
* @rt_stat: the status bit indicating whether dc voltage is uv
*/
static int dcin_uv_handler(struct smb135x_chg *chip, u8 rt_stat)
{
/*
* rt_stat indicates if dc is undervolted. If so dc_present
* should be marked removed
*/
bool dc_present = !rt_stat;
pr_debug("chip->dc_present = %d dc_present = %d\n",
chip->dc_present, dc_present);
if (chip->dc_present && !dc_present) {
/* dc removed */
chip->dc_present = dc_present;
handle_dc_removal(chip);
}
if (!chip->dc_present && dc_present) {
/* dc inserted */
chip->dc_present = dc_present;
handle_dc_insertion(chip);
}
return 0;
}
static int dcin_ov_handler(struct smb135x_chg *chip, u8 rt_stat)
{
/*
* rt_stat indicates if dc is overvolted. If so dc_present
* should be marked removed
*/
bool dc_present = !rt_stat;
pr_debug("chip->dc_present = %d dc_present = %d\n",
chip->dc_present, dc_present);
chip->dc_ov = !!rt_stat;
if (chip->dc_present && !dc_present) {
/* dc removed */
chip->dc_present = dc_present;
handle_dc_removal(chip);
}
if (!chip->dc_present && dc_present) {
/* dc inserted */
chip->dc_present = dc_present;
handle_dc_insertion(chip);
}
return 0;
}
static int handle_usb_removal(struct smb135x_chg *chip)
{
if (chip->usb_psy) {
pr_debug("setting usb psy type = %d\n",
POWER_SUPPLY_TYPE_UNKNOWN);
power_supply_set_supply_type(chip->usb_psy,
POWER_SUPPLY_TYPE_UNKNOWN);
pr_debug("setting usb psy present = %d\n", chip->usb_present);
power_supply_set_present(chip->usb_psy, chip->usb_present);
}
return 0;
}
static int handle_usb_insertion(struct smb135x_chg *chip)
{
u8 reg;
int rc;
char *usb_type_name = "null";
enum power_supply_type usb_supply_type;
/* usb inserted */
rc = smb135x_read(chip, STATUS_5_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read status 5 rc = %d\n", rc);
return rc;
}
/*
* Report the charger type as UNKNOWN if the
* apsd-fail flag is set. This nofifies the USB driver
* to initiate a s/w based charger type detection.
*/
if (chip->workaround_flags & WRKARND_APSD_FAIL)
reg = 0;
usb_type_name = get_usb_type_name(reg);
usb_supply_type = get_usb_supply_type(reg);
pr_debug("inserted %s, usb psy type = %d stat_5 = 0x%02x\n",
usb_type_name, usb_supply_type, reg);
if (chip->usb_psy) {
if (chip->bms_controlled_charging) {
/* enable charging on USB insertion */
rc = smb135x_charging_enable(chip, true);
if (rc < 0)
dev_err(chip->dev, "Couldn't enable charging rc = %d\n",
rc);
}
pr_debug("setting usb psy type = %d\n", usb_supply_type);
power_supply_set_supply_type(chip->usb_psy, usb_supply_type);
pr_debug("setting usb psy present = %d\n", chip->usb_present);
power_supply_set_present(chip->usb_psy, chip->usb_present);
}
return 0;
}
/**
* usbin_uv_handler() - this is called when USB charger is removed
* @chip: pointer to smb135x_chg chip
* @rt_stat: the status bit indicating chg insertion/removal
*/
static int usbin_uv_handler(struct smb135x_chg *chip, u8 rt_stat)
{
/*
* rt_stat indicates if usb is undervolted. If so usb_present
* should be marked removed
*/
bool usb_present = !rt_stat;
pr_debug("chip->usb_present = %d usb_present = %d\n",
chip->usb_present, usb_present);
if (chip->usb_present && !usb_present) {
/* USB removed */
chip->usb_present = usb_present;
handle_usb_removal(chip);
}
return 0;
}
static int usbin_ov_handler(struct smb135x_chg *chip, u8 rt_stat)
{
/*
* rt_stat indicates if usb is overvolted. If so usb_present
* should be marked removed
*/
bool usb_present = !rt_stat;
int health;
pr_debug("chip->usb_present = %d usb_present = %d\n",
chip->usb_present, usb_present);
if (chip->usb_present && !usb_present) {
/* USB removed */
chip->usb_present = usb_present;
handle_usb_removal(chip);
}
if (chip->usb_psy) {
health = rt_stat ? POWER_SUPPLY_HEALTH_OVERVOLTAGE
: POWER_SUPPLY_HEALTH_GOOD;
power_supply_set_health_state(chip->usb_psy, health);
}
return 0;
}
/**
* src_detect_handler() - this is called when USB charger type is detected, use
* it for handling USB charger insertion/removal
* @chip: pointer to smb135x_chg chip
* @rt_stat: the status bit indicating chg insertion/removal
*/
static int src_detect_handler(struct smb135x_chg *chip, u8 rt_stat)
{
bool usb_present = !!rt_stat;
pr_debug("chip->usb_present = %d usb_present = %d\n",
chip->usb_present, usb_present);
if (!chip->usb_present && usb_present) {
/* USB inserted */
chip->usb_present = usb_present;
handle_usb_insertion(chip);
}
return 0;
}
static int chg_inhibit_handler(struct smb135x_chg *chip, u8 rt_stat)
{
/*
* charger is inserted when the battery voltage is high
* so h/w won't start charging just yet. Treat this as
* battery full
*/
pr_debug("rt_stat = 0x%02x\n", rt_stat);
if (!chip->inhibit_disabled)
chip->chg_done_batt_full = !!rt_stat;
return 0;
}
struct smb_irq_info {
const char *name;
int (*smb_irq)(struct smb135x_chg *chip,
u8 rt_stat);
int high;
int low;
};
struct irq_handler_info {
u8 stat_reg;
u8 val;
u8 prev_val;
struct smb_irq_info irq_info[4];
};
static struct irq_handler_info handlers[] = {
{IRQ_A_REG, 0, 0,
{
{
.name = "cold_soft",
.smb_irq = cold_soft_handler,
},
{
.name = "hot_soft",
.smb_irq = hot_soft_handler,
},
{
.name = "cold_hard",
.smb_irq = cold_hard_handler,
},
{
.name = "hot_hard",
.smb_irq = hot_hard_handler,
},
},
},
{IRQ_B_REG, 0, 0,
{
{
.name = "chg_hot",
.smb_irq = chg_hot_handler,
},
{
.name = "vbat_low",
.smb_irq = vbat_low_handler,
},
{
.name = "battery_missing",
.smb_irq = battery_missing_handler,
},
{
.name = "battery_missing",
.smb_irq = battery_missing_handler,
},
},
},
{IRQ_C_REG, 0, 0,
{
{
.name = "chg_term",
.smb_irq = chg_term_handler,
},
{
.name = "taper",
.smb_irq = taper_handler,
},
{
.name = "recharge",
.smb_irq = recharge_handler,
},
{
.name = "fast_chg",
.smb_irq = fast_chg_handler,
},
},
},
{IRQ_D_REG, 0, 0,
{
{
.name = "prechg_timeout",
},
{
.name = "safety_timeout",
.smb_irq = safety_timeout_handler,
},
{
.name = "aicl_done",
},
{
.name = "battery_ov",
},
},
},
{IRQ_E_REG, 0, 0,
{
{
.name = "usbin_uv",
.smb_irq = usbin_uv_handler,
},
{
.name = "usbin_ov",
.smb_irq = usbin_ov_handler,
},
{
.name = "dcin_uv",
.smb_irq = dcin_uv_handler,
},
{
.name = "dcin_ov",
.smb_irq = dcin_ov_handler,
},
},
},
{IRQ_F_REG, 0, 0,
{
{
.name = "power_ok",
.smb_irq = power_ok_handler,
},
{
.name = "rid",
.smb_irq = rid_handler,
},
{
.name = "otg_fail",
},
{
.name = "otg_oc",
.smb_irq = otg_oc_handler,
},
},
},
{IRQ_G_REG, 0, 0,
{
{
.name = "chg_inhibit",
.smb_irq = chg_inhibit_handler,
},
{
.name = "chg_error",
},
{
.name = "wd_timeout",
},
{
.name = "src_detect",
.smb_irq = src_detect_handler,
},
},
},
};
static int smb135x_irq_read(struct smb135x_chg *chip)
{
int rc, i;
/*
* When dcin path is suspended the irq triggered status is not cleared
* causing a storm. To prevent this situation unsuspend dcin path while
* reading interrupts and restore its status back.
*/
mutex_lock(&chip->path_suspend_lock);
if (chip->dc_suspended)
__smb135x_dc_suspend(chip, false);
for (i = 0; i < ARRAY_SIZE(handlers); i++) {
rc = smb135x_read(chip, handlers[i].stat_reg,
&handlers[i].val);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read %d rc = %d\n",
handlers[i].stat_reg, rc);
handlers[i].val = 0;
continue;
}
}
if (chip->dc_suspended)
__smb135x_dc_suspend(chip, true);
mutex_unlock(&chip->path_suspend_lock);
return rc;
}
#define IRQ_LATCHED_MASK 0x02
#define IRQ_STATUS_MASK 0x01
#define BITS_PER_IRQ 2
static irqreturn_t smb135x_chg_stat_handler(int irq, void *dev_id)
{
struct smb135x_chg *chip = dev_id;
int i, j;
u8 triggered;
u8 changed;
u8 rt_stat, prev_rt_stat;
int rc;
int handler_count = 0;
mutex_lock(&chip->irq_complete);
chip->irq_waiting = true;
if (!chip->resume_completed) {
dev_dbg(chip->dev, "IRQ triggered before device-resume\n");
disable_irq_nosync(irq);
mutex_unlock(&chip->irq_complete);
return IRQ_HANDLED;
}
chip->irq_waiting = false;
smb135x_irq_read(chip);
for (i = 0; i < ARRAY_SIZE(handlers); i++) {
for (j = 0; j < ARRAY_SIZE(handlers[i].irq_info); j++) {
triggered = handlers[i].val
& (IRQ_LATCHED_MASK << (j * BITS_PER_IRQ));
rt_stat = handlers[i].val
& (IRQ_STATUS_MASK << (j * BITS_PER_IRQ));
prev_rt_stat = handlers[i].prev_val
& (IRQ_STATUS_MASK << (j * BITS_PER_IRQ));
changed = prev_rt_stat ^ rt_stat;
if (triggered || changed)
rt_stat ? handlers[i].irq_info[j].high++ :
handlers[i].irq_info[j].low++;
if ((triggered || changed)
&& handlers[i].irq_info[j].smb_irq != NULL) {
handler_count++;
rc = handlers[i].irq_info[j].smb_irq(chip,
rt_stat);
if (rc < 0)
dev_err(chip->dev,
"Couldn't handle %d irq for reg 0x%02x rc = %d\n",
j, handlers[i].stat_reg, rc);
}
}
handlers[i].prev_val = handlers[i].val;
}
pr_debug("handler count = %d\n", handler_count);
if (handler_count) {
pr_debug("batt psy changed\n");
power_supply_changed(&chip->batt_psy);
if (chip->usb_psy) {
pr_debug("usb psy changed\n");
power_supply_changed(chip->usb_psy);
}
if (chip->dc_psy_type != -EINVAL) {
pr_debug("dc psy changed\n");
power_supply_changed(&chip->dc_psy);
}
}
mutex_unlock(&chip->irq_complete);
return IRQ_HANDLED;
}
#define LAST_CNFG_REG 0x1F
static int show_cnfg_regs(struct seq_file *m, void *data)
{
struct smb135x_chg *chip = m->private;
int rc;
u8 reg;
u8 addr;
for (addr = 0; addr <= LAST_CNFG_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (!rc)
seq_printf(m, "0x%02x = 0x%02x\n", addr, reg);
}
return 0;
}
static int cnfg_debugfs_open(struct inode *inode, struct file *file)
{
struct smb135x_chg *chip = inode->i_private;
return single_open(file, show_cnfg_regs, chip);
}
static const struct file_operations cnfg_debugfs_ops = {
.owner = THIS_MODULE,
.open = cnfg_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#define FIRST_CMD_REG 0x40
#define LAST_CMD_REG 0x42
static int show_cmd_regs(struct seq_file *m, void *data)
{
struct smb135x_chg *chip = m->private;
int rc;
u8 reg;
u8 addr;
for (addr = FIRST_CMD_REG; addr <= LAST_CMD_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (!rc)
seq_printf(m, "0x%02x = 0x%02x\n", addr, reg);
}
return 0;
}
static int cmd_debugfs_open(struct inode *inode, struct file *file)
{
struct smb135x_chg *chip = inode->i_private;
return single_open(file, show_cmd_regs, chip);
}
static const struct file_operations cmd_debugfs_ops = {
.owner = THIS_MODULE,
.open = cmd_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#define FIRST_STATUS_REG 0x46
#define LAST_STATUS_REG 0x56
static int show_status_regs(struct seq_file *m, void *data)
{
struct smb135x_chg *chip = m->private;
int rc;
u8 reg;
u8 addr;
for (addr = FIRST_STATUS_REG; addr <= LAST_STATUS_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (!rc)
seq_printf(m, "0x%02x = 0x%02x\n", addr, reg);
}
return 0;
}
static int status_debugfs_open(struct inode *inode, struct file *file)
{
struct smb135x_chg *chip = inode->i_private;
return single_open(file, show_status_regs, chip);
}
static const struct file_operations status_debugfs_ops = {
.owner = THIS_MODULE,
.open = status_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int show_irq_count(struct seq_file *m, void *data)
{
int i, j, total = 0;
for (i = 0; i < ARRAY_SIZE(handlers); i++)
for (j = 0; j < 4; j++) {
seq_printf(m, "%s=%d\t(high=%d low=%d)\n",
handlers[i].irq_info[j].name,
handlers[i].irq_info[j].high
+ handlers[i].irq_info[j].low,
handlers[i].irq_info[j].high,
handlers[i].irq_info[j].low);
total += (handlers[i].irq_info[j].high
+ handlers[i].irq_info[j].low);
}
seq_printf(m, "\n\tTotal = %d\n", total);
return 0;
}
static int irq_count_debugfs_open(struct inode *inode, struct file *file)
{
struct smb135x_chg *chip = inode->i_private;
return single_open(file, show_irq_count, chip);
}
static const struct file_operations irq_count_debugfs_ops = {
.owner = THIS_MODULE,
.open = irq_count_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int get_reg(void *data, u64 *val)
{
struct smb135x_chg *chip = data;
int rc;
u8 temp;
rc = smb135x_read(chip, chip->peek_poke_address, &temp);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't read reg %x rc = %d\n",
chip->peek_poke_address, rc);
return -EAGAIN;
}
*val = temp;
return 0;
}
static int set_reg(void *data, u64 val)
{
struct smb135x_chg *chip = data;
int rc;
u8 temp;
temp = (u8) val;
rc = smb135x_write(chip, chip->peek_poke_address, temp);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't write 0x%02x to 0x%02x rc= %d\n",
chip->peek_poke_address, temp, rc);
return -EAGAIN;
}
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(poke_poke_debug_ops, get_reg, set_reg, "0x%02llx\n");
static int force_irq_set(void *data, u64 val)
{
struct smb135x_chg *chip = data;
smb135x_chg_stat_handler(chip->client->irq, data);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(force_irq_ops, NULL, force_irq_set, "0x%02llx\n");
static int force_rechg_set(void *data, u64 val)
{
int rc = 0;
struct smb135x_chg *chip = data;
if (!chip->chg_enabled) {
pr_debug("Charging Disabled force recharge not allowed\n");
return -EINVAL;
}
if (!chip->inhibit_disabled) {
rc = smb135x_masked_write(chip, CFG_14_REG, EN_CHG_INHIBIT_BIT,
0);
if (rc)
dev_err(chip->dev,
"Couldn't disable charge-inhibit rc=%d\n", rc);
/* delay for charge-inhibit to take affect */
msleep(500);
}
rc |= smb135x_charging(chip, false);
rc |= smb135x_charging(chip, true);
if (!chip->inhibit_disabled) {
rc |= smb135x_masked_write(chip, CFG_14_REG,
EN_CHG_INHIBIT_BIT, EN_CHG_INHIBIT_BIT);
if (rc)
dev_err(chip->dev,
"Couldn't enable charge-inhibit rc=%d\n", rc);
}
return rc;
}
DEFINE_SIMPLE_ATTRIBUTE(force_rechg_ops, NULL, force_rechg_set, "0x%02llx\n");
#ifdef DEBUG
static void dump_regs(struct smb135x_chg *chip)
{
int rc;
u8 reg;
u8 addr;
for (addr = 0; addr <= LAST_CNFG_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (rc < 0)
dev_err(chip->dev, "Couldn't read 0x%02x rc = %d\n",
addr, rc);
else
pr_debug("0x%02x = 0x%02x\n", addr, reg);
}
for (addr = FIRST_STATUS_REG; addr <= LAST_STATUS_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (rc < 0)
dev_err(chip->dev, "Couldn't read 0x%02x rc = %d\n",
addr, rc);
else
pr_debug("0x%02x = 0x%02x\n", addr, reg);
}
for (addr = FIRST_CMD_REG; addr <= LAST_CMD_REG; addr++) {
rc = smb135x_read(chip, addr, ®);
if (rc < 0)
dev_err(chip->dev, "Couldn't read 0x%02x rc = %d\n",
addr, rc);
else
pr_debug("0x%02x = 0x%02x\n", addr, reg);
}
}
#else
static void dump_regs(struct smb135x_chg *chip)
{
}
#endif
static int determine_initial_status(struct smb135x_chg *chip)
{
int rc;
u8 reg;
/*
* It is okay to read the interrupt status here since
* interrupts aren't requested. reading interrupt status
* clears the interrupt so be careful to read interrupt
* status only in interrupt handling code
*/
chip->batt_present = true;
rc = smb135x_read(chip, IRQ_B_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read irq b rc = %d\n", rc);
return rc;
}
if (reg & IRQ_B_BATT_TERMINAL_BIT || reg & IRQ_B_BATT_MISSING_BIT)
chip->batt_present = false;
rc = smb135x_read(chip, STATUS_4_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read status 4 rc = %d\n", rc);
return rc;
}
/* treat battery gone if less than 2V */
if (reg & BATT_LESS_THAN_2V)
chip->batt_present = false;
rc = smb135x_read(chip, IRQ_A_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read irq A rc = %d\n", rc);
return rc;
}
if (reg & IRQ_A_HOT_HARD_BIT)
chip->batt_hot = true;
if (reg & IRQ_A_COLD_HARD_BIT)
chip->batt_cold = true;
if (reg & IRQ_A_HOT_SOFT_BIT)
chip->batt_warm = true;
if (reg & IRQ_A_COLD_SOFT_BIT)
chip->batt_cool = true;
rc = smb135x_read(chip, IRQ_C_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read irq A rc = %d\n", rc);
return rc;
}
if (reg & IRQ_C_TERM_BIT)
chip->chg_done_batt_full = true;
rc = smb135x_read(chip, IRQ_E_REG, ®);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read irq E rc = %d\n", rc);
return rc;
}
chip->usb_present = !(reg & IRQ_E_USB_OV_BIT)
&& !(reg & IRQ_E_USB_UV_BIT);
chip->dc_present = !(reg & IRQ_E_DC_OV_BIT) && !(reg & IRQ_E_DC_UV_BIT);
if (chip->usb_present)
handle_usb_insertion(chip);
else
handle_usb_removal(chip);
if (chip->dc_psy_type != -EINVAL) {
if (chip->dc_psy_type == POWER_SUPPLY_TYPE_WIRELESS) {
/*
* put the dc path in suspend state if it is powered
* by wireless charger
*/
if (chip->dc_present)
smb135x_path_suspend(chip, DC, CURRENT, false);
else
smb135x_path_suspend(chip, DC, CURRENT, true);
}
}
chip->usb_slave_present = is_usb_slave_present(chip);
if (chip->usb_psy) {
pr_debug("setting usb psy usb_otg = %d\n",
chip->usb_slave_present);
power_supply_set_usb_otg(chip->usb_psy,
chip->usb_slave_present);
}
return 0;
}
static int smb135x_hw_init(struct smb135x_chg *chip)
{
int rc;
int i;
u8 reg, mask;
if (chip->pinctrl_state_name) {
chip->smb_pinctrl = pinctrl_get_select(chip->dev,
chip->pinctrl_state_name);
if (IS_ERR(chip->smb_pinctrl)) {
pr_err("Could not get/set %s pinctrl state rc = %ld\n",
chip->pinctrl_state_name,
PTR_ERR(chip->smb_pinctrl));
return PTR_ERR(chip->smb_pinctrl);
}
}
if (chip->therm_bias_vreg) {
rc = regulator_enable(chip->therm_bias_vreg);
if (rc) {
pr_err("Couldn't enable therm-bias rc = %d\n", rc);
return rc;
}
}
/*
* Enable USB data line pullup regulator this is needed for the D+
* line to be at proper voltage for HVDCP charger detection.
*/
if (chip->usb_pullup_vreg) {
rc = regulator_enable(chip->usb_pullup_vreg);
if (rc) {
pr_err("Unable to enable data line pull-up regulator rc=%d\n",
rc);
if (chip->therm_bias_vreg)
regulator_disable(chip->therm_bias_vreg);
return rc;
}
}
rc = smb135x_enable_volatile_writes(chip);
if (rc < 0) {
dev_err(chip->dev, "Couldn't configure for volatile rc = %d\n",
rc);
goto free_regulator;
}
/*
* force using current from the register i.e. ignore auto
* power source detect (APSD) mA ratings
*/
mask = USE_REGISTER_FOR_CURRENT;
if (chip->workaround_flags & WRKARND_USB100_BIT)
reg = 0;
else
/* this ignores APSD results */
reg = USE_REGISTER_FOR_CURRENT;
rc = smb135x_masked_write(chip, CMD_INPUT_LIMIT, mask, reg);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set input limit cmd rc=%d\n", rc);
goto free_regulator;
}
/* set bit 0 = 100mA bit 1 = 500mA and set register control */
rc = smb135x_masked_write(chip, CFG_E_REG,
POLARITY_100_500_BIT | USB_CTRL_BY_PIN_BIT,
POLARITY_100_500_BIT);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set usbin cfg rc=%d\n", rc);
goto free_regulator;
}
/*
* set chg en by cmd register, set chg en by writing bit 1,
* enable auto pre to fast, enable current termination, enable
* auto recharge, enable chg inhibition based on the dt flag
*/
if (chip->inhibit_disabled)
reg = 0;
else
reg = EN_CHG_INHIBIT_BIT;
rc = smb135x_masked_write(chip, CFG_14_REG,
CHG_EN_BY_PIN_BIT | CHG_EN_ACTIVE_LOW_BIT
| PRE_TO_FAST_REQ_CMD_BIT | DISABLE_AUTO_RECHARGE_BIT
| EN_CHG_INHIBIT_BIT, reg);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set cfg 14 rc=%d\n", rc);
goto free_regulator;
}
/* control USB suspend via command bits */
rc = smb135x_masked_write(chip, USBIN_DCIN_CFG_REG,
USBIN_SUSPEND_VIA_COMMAND_BIT, USBIN_SUSPEND_VIA_COMMAND_BIT);
/* set the float voltage */
if (chip->vfloat_mv != -EINVAL) {
rc = smb135x_float_voltage_set(chip, chip->vfloat_mv);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set float voltage rc = %d\n", rc);
goto free_regulator;
}
}
/* set iterm */
if (chip->iterm_ma != -EINVAL) {
if (chip->iterm_disabled) {
dev_err(chip->dev, "Error: Both iterm_disabled and iterm_ma set\n");
rc = -EINVAL;
goto free_regulator;
} else {
if (chip->iterm_ma <= 50)
reg = CHG_ITERM_50MA;
else if (chip->iterm_ma <= 100)
reg = CHG_ITERM_100MA;
else if (chip->iterm_ma <= 150)
reg = CHG_ITERM_150MA;
else if (chip->iterm_ma <= 200)
reg = CHG_ITERM_200MA;
else if (chip->iterm_ma <= 250)
reg = CHG_ITERM_250MA;
else if (chip->iterm_ma <= 300)
reg = CHG_ITERM_300MA;
else if (chip->iterm_ma <= 500)
reg = CHG_ITERM_500MA;
else
reg = CHG_ITERM_600MA;
rc = smb135x_masked_write(chip, CFG_3_REG,
CHG_ITERM_MASK, reg);
if (rc) {
dev_err(chip->dev,
"Couldn't set iterm rc = %d\n", rc);
goto free_regulator;
}
rc = smb135x_masked_write(chip, CFG_14_REG,
DISABLE_CURRENT_TERM_BIT, 0);
if (rc) {
dev_err(chip->dev,
"Couldn't enable iterm rc = %d\n", rc);
goto free_regulator;
}
}
} else if (chip->iterm_disabled) {
rc = smb135x_masked_write(chip, CFG_14_REG,
DISABLE_CURRENT_TERM_BIT,
DISABLE_CURRENT_TERM_BIT);
if (rc) {
dev_err(chip->dev, "Couldn't set iterm rc = %d\n",
rc);
goto free_regulator;
}
}
/* set the safety time voltage */
if (chip->safety_time != -EINVAL) {
if (chip->safety_time == 0) {
/* safety timer disabled */
rc = smb135x_masked_write(chip, CFG_16_REG,
SAFETY_TIME_EN_BIT, 0);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't disable safety timer rc = %d\n",
rc);
goto free_regulator;
}
} else {
for (i = 0; i < ARRAY_SIZE(chg_time); i++) {
if (chip->safety_time <= chg_time[i]) {
reg = i << SAFETY_TIME_MINUTES_SHIFT;
break;
}
}
rc = smb135x_masked_write(chip, CFG_16_REG,
SAFETY_TIME_EN_BIT | SAFETY_TIME_MINUTES_MASK,
SAFETY_TIME_EN_BIT | reg);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't set safety timer rc = %d\n",
rc);
goto free_regulator;
}
}
}
/* battery missing detection */
rc = smb135x_masked_write(chip, CFG_19_REG,
BATT_MISSING_ALGO_BIT | BATT_MISSING_THERM_BIT,
chip->bmd_algo_disabled ? BATT_MISSING_THERM_BIT :
BATT_MISSING_ALGO_BIT);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set batt_missing config = %d\n",
rc);
goto free_regulator;
}
/* set maximum fastchg current */
if (chip->fastchg_ma != -EINVAL) {
rc = smb135x_set_fastchg_current(chip, chip->fastchg_ma);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set fastchg current = %d\n",
rc);
goto free_regulator;
}
}
if (chip->usb_pullup_vreg) {
/* enable 9V HVDCP adapter support */
rc = smb135x_masked_write(chip, CFG_E_REG, HVDCP_5_9_BIT,
HVDCP_5_9_BIT);
if (rc < 0) {
dev_err(chip->dev,
"Couldn't request for 5 or 9V rc=%d\n", rc);
goto free_regulator;
}
}
__smb135x_charging(chip, chip->chg_enabled);
/* interrupt enabling - active low */
if (chip->client->irq) {
mask = CHG_STAT_IRQ_ONLY_BIT | CHG_STAT_ACTIVE_HIGH_BIT
| CHG_STAT_DISABLE_BIT;
reg = CHG_STAT_IRQ_ONLY_BIT;
rc = smb135x_masked_write(chip, CFG_17_REG, mask, reg);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set irq config rc = %d\n",
rc);
goto free_regulator;
}
/* enabling only interesting interrupts */
rc = smb135x_write(chip, IRQ_CFG_REG,
IRQ_BAT_HOT_COLD_HARD_BIT
| IRQ_BAT_HOT_COLD_SOFT_BIT
| IRQ_OTG_OVER_CURRENT_BIT
| IRQ_INTERNAL_TEMPERATURE_BIT
| IRQ_USBIN_UV_BIT);
rc |= smb135x_write(chip, IRQ2_CFG_REG,
IRQ2_SAFETY_TIMER_BIT
| IRQ2_CHG_ERR_BIT
| IRQ2_CHG_PHASE_CHANGE_BIT
| IRQ2_POWER_OK_BIT
| IRQ2_BATT_MISSING_BIT
| IRQ2_VBAT_LOW_BIT);
rc |= smb135x_write(chip, IRQ3_CFG_REG, IRQ3_SRC_DETECT_BIT
| IRQ3_DCIN_UV_BIT | IRQ3_RID_DETECT_BIT);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set irq enable rc = %d\n",
rc);
goto free_regulator;
}
}
/* resume threshold */
if (chip->resume_delta_mv != -EINVAL) {
smb135x_set_resume_threshold(chip, chip->resume_delta_mv);
}
/* DC path current settings */
if (chip->dc_psy_type != -EINVAL) {
rc = smb135x_set_dc_chg_current(chip, chip->dc_psy_ma);
if (rc < 0) {
dev_err(chip->dev, "Couldn't set dc charge current rc = %d\n",
rc);
goto free_regulator;
}
}
/*
* on some devices the battery is powered via external sources which
* could raise its voltage above the float voltage. smb135x chips go
* in to reverse boost in such a situation and the workaround is to
* disable float voltage compensation (note that the battery will appear
* hot/cold when powered via external source).
*/
if (chip->soft_vfloat_comp_disabled) {
mask = HOT_SOFT_VFLOAT_COMP_EN_BIT
| COLD_SOFT_VFLOAT_COMP_EN_BIT;
rc = smb135x_masked_write(chip, CFG_1A_REG, mask, 0);
if (rc < 0) {
dev_err(chip->dev, "Couldn't disable soft vfloat rc = %d\n",
rc);
goto free_regulator;
}
}
/*
* Command mode for OTG control. This gives us RID interrupts but keeps
* enabling the 5V OTG via i2c register control
*/
rc = smb135x_masked_write(chip, USBIN_OTG_REG, OTG_CNFG_MASK,
OTG_CNFG_COMMAND_CTRL);
if (rc < 0) {
dev_err(chip->dev, "Couldn't write to otg cfg reg rc = %d\n",
rc);
goto free_regulator;
}
return 0;
free_regulator:
if (chip->therm_bias_vreg)
regulator_disable(chip->therm_bias_vreg);
if (chip->usb_pullup_vreg)
regulator_disable(chip->usb_pullup_vreg);
return rc;
}
static struct of_device_id smb135x_match_table[] = {
{
.compatible = "qcom,smb1356-charger",
.data = &version_data[V_SMB1356],
},
{
.compatible = "qcom,smb1357-charger",
.data = &version_data[V_SMB1357],
},
{
.compatible = "qcom,smb1358-charger",
.data = &version_data[V_SMB1358],
},
{
.compatible = "qcom,smb1359-charger",
.data = &version_data[V_SMB1359],
},
{ },
};
#define DC_MA_MIN 300
#define DC_MA_MAX 2000
static int smb_parse_dt(struct smb135x_chg *chip)
{
int rc;
struct device_node *node = chip->dev->of_node;
const char *dc_psy_type;
if (!node) {
dev_err(chip->dev, "device tree info. missing\n");
return -EINVAL;
}
rc = of_property_read_u32(node, "qcom,float-voltage-mv",
&chip->vfloat_mv);
if (rc < 0)
chip->vfloat_mv = -EINVAL;
rc = of_property_read_u32(node, "qcom,charging-timeout",
&chip->safety_time);
if (rc < 0)
chip->safety_time = -EINVAL;
if (!rc &&
(chip->safety_time > chg_time[ARRAY_SIZE(chg_time) - 1])) {
dev_err(chip->dev, "Bad charging-timeout %d\n",
chip->safety_time);
return -EINVAL;
}
chip->bmd_algo_disabled = of_property_read_bool(node,
"qcom,bmd-algo-disabled");
chip->dc_psy_type = -EINVAL;
dc_psy_type = of_get_property(node, "qcom,dc-psy-type", NULL);
if (dc_psy_type) {
if (strcmp(dc_psy_type, "Mains") == 0)
chip->dc_psy_type = POWER_SUPPLY_TYPE_MAINS;
else if (strcmp(dc_psy_type, "Wireless") == 0)
chip->dc_psy_type = POWER_SUPPLY_TYPE_WIRELESS;
}
if (chip->dc_psy_type != -EINVAL) {
rc = of_property_read_u32(node, "qcom,dc-psy-ma",
&chip->dc_psy_ma);
if (rc < 0) {
dev_err(chip->dev,
"no mA current for dc rc = %d\n", rc);
return rc;
}
if (chip->dc_psy_ma < DC_MA_MIN
|| chip->dc_psy_ma > DC_MA_MAX) {
dev_err(chip->dev, "Bad dc mA %d\n", chip->dc_psy_ma);
return -EINVAL;
}
}
rc = of_property_read_u32(node, "qcom,recharge-thresh-mv",
&chip->resume_delta_mv);
if (rc < 0)
chip->resume_delta_mv = -EINVAL;
rc = of_property_read_u32(node, "qcom,iterm-ma", &chip->iterm_ma);
if (rc < 0)
chip->iterm_ma = -EINVAL;
chip->iterm_disabled = of_property_read_bool(node,
"qcom,iterm-disabled");
chip->chg_disabled_permanently = (of_property_read_bool(node,
"qcom,charging-disabled"));
chip->chg_enabled = !chip->chg_disabled_permanently;
chip->inhibit_disabled = of_property_read_bool(node,
"qcom,inhibit-disabled");
chip->bms_controlled_charging = of_property_read_bool(node,
"qcom,bms-controlled-charging");
rc = of_property_read_string(node, "qcom,bms-psy-name",
&chip->bms_psy_name);
if (rc)
chip->bms_psy_name = NULL;
rc = of_property_read_u32(node, "qcom,fastchg-ma", &chip->fastchg_ma);
if (rc < 0)
chip->fastchg_ma = -EINVAL;
chip->soft_vfloat_comp_disabled = of_property_read_bool(node,
"qcom,soft-vfloat-comp-disabled");
if (of_find_property(node, "therm-bias-supply", NULL)) {
/* get the thermistor bias regulator */
chip->therm_bias_vreg = devm_regulator_get(chip->dev,
"therm-bias");
if (IS_ERR(chip->therm_bias_vreg))
return PTR_ERR(chip->therm_bias_vreg);
}
if (of_find_property(node, "qcom,thermal-mitigation",
&chip->thermal_levels)) {
chip->thermal_mitigation = devm_kzalloc(chip->dev,
chip->thermal_levels,
GFP_KERNEL);
if (chip->thermal_mitigation == NULL) {
pr_err("thermal mitigation kzalloc() failed.\n");
return -ENOMEM;
}
chip->thermal_levels /= sizeof(int);
rc = of_property_read_u32_array(node,
"qcom,thermal-mitigation",
chip->thermal_mitigation, chip->thermal_levels);
if (rc) {
pr_err("Couldn't read threm limits rc = %d\n", rc);
return rc;
}
}
if (of_find_property(node, "usb-pullup-supply", NULL)) {
/* get the data line pull-up regulator */
chip->usb_pullup_vreg = devm_regulator_get(chip->dev,
"usb-pullup");
if (IS_ERR(chip->usb_pullup_vreg))
return PTR_ERR(chip->usb_pullup_vreg);
}
chip->pinctrl_state_name = of_get_property(node, "pinctrl-names", NULL);
return 0;
}
static int create_debugfs_entries(struct smb135x_chg *chip)
{
chip->debug_root = debugfs_create_dir("smb135x", NULL);
if (!chip->debug_root)
dev_err(chip->dev, "Couldn't create debug dir\n");
if (chip->debug_root) {
struct dentry *ent;
ent = debugfs_create_file("config_registers", S_IFREG | S_IRUGO,
chip->debug_root, chip,
&cnfg_debugfs_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create cnfg debug file\n");
ent = debugfs_create_file("status_registers", S_IFREG | S_IRUGO,
chip->debug_root, chip,
&status_debugfs_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create status debug file\n");
ent = debugfs_create_file("cmd_registers", S_IFREG | S_IRUGO,
chip->debug_root, chip,
&cmd_debugfs_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create cmd debug file\n");
ent = debugfs_create_x32("address", S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root,
&(chip->peek_poke_address));
if (!ent)
dev_err(chip->dev,
"Couldn't create address debug file\n");
ent = debugfs_create_file("data", S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root, chip,
&poke_poke_debug_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create data debug file\n");
ent = debugfs_create_file("force_irq",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root, chip,
&force_irq_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create force_irq debug file\n");
ent = debugfs_create_x32("skip_writes",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root,
&(chip->skip_writes));
if (!ent)
dev_err(chip->dev,
"Couldn't create skip writes debug file\n");
ent = debugfs_create_x32("skip_reads",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root,
&(chip->skip_reads));
if (!ent)
dev_err(chip->dev,
"Couldn't create skip reads debug file\n");
ent = debugfs_create_file("irq_count", S_IFREG | S_IRUGO,
chip->debug_root, chip,
&irq_count_debugfs_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create irq_count debug file\n");
ent = debugfs_create_file("force_recharge",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root, chip,
&force_rechg_ops);
if (!ent)
dev_err(chip->dev,
"Couldn't create force recharge debug file\n");
ent = debugfs_create_x32("usb_suspend_votes",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root,
&(chip->usb_suspended));
if (!ent)
dev_err(chip->dev,
"Couldn't create usb_suspend_votes file\n");
ent = debugfs_create_x32("dc_suspend_votes",
S_IFREG | S_IWUSR | S_IRUGO,
chip->debug_root,
&(chip->dc_suspended));
if (!ent)
dev_err(chip->dev,
"Couldn't create dc_suspend_votes file\n");
}
return 0;
}
static int is_parallel_charger(struct i2c_client *client)
{
struct device_node *node = client->dev.of_node;
return of_property_read_bool(node, "qcom,parallel-charger");
}
static int smb135x_main_charger_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int rc;
struct smb135x_chg *chip;
struct power_supply *usb_psy;
u8 reg = 0;
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip) {
dev_err(&client->dev, "Unable to allocate memory\n");
return -ENOMEM;
}
chip->client = client;
chip->dev = &client->dev;
rc = smb_parse_dt(chip);
if (rc < 0) {
dev_err(&client->dev, "Unable to parse DT nodes\n");
return rc;
}
usb_psy = power_supply_get_by_name("usb");
if (!usb_psy && chip->chg_enabled) {
dev_dbg(&client->dev, "USB supply not found; defer probe\n");
return -EPROBE_DEFER;
}
chip->usb_psy = usb_psy;
chip->fake_battery_soc = -EINVAL;
INIT_DELAYED_WORK(&chip->wireless_insertion_work,
wireless_insertion_work);
mutex_init(&chip->path_suspend_lock);
mutex_init(&chip->current_change_lock);
mutex_init(&chip->read_write_lock);
/* probe the device to check if its actually connected */
rc = smb135x_read(chip, CFG_4_REG, ®);
if (rc) {
pr_err("Failed to detect SMB135x, device may be absent\n");
return -ENODEV;
}
i2c_set_clientdata(client, chip);
rc = smb135x_chip_version_and_revision(chip);
if (rc) {
dev_err(&client->dev,
"Couldn't detect version/revision rc=%d\n", rc);
return rc;
}
dump_regs(chip);
rc = smb135x_regulator_init(chip);
if (rc) {
dev_err(&client->dev,
"Couldn't initialize regulator rc=%d\n", rc);
return rc;
}
rc = smb135x_hw_init(chip);
if (rc < 0) {
dev_err(&client->dev,
"Unable to intialize hardware rc = %d\n", rc);
goto free_regulator;
}
rc = determine_initial_status(chip);
if (rc < 0) {
dev_err(&client->dev,
"Unable to determine init status rc = %d\n", rc);
goto free_regulator;
}
chip->batt_psy.name = "battery";
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
chip->batt_psy.get_property = smb135x_battery_get_property;
chip->batt_psy.set_property = smb135x_battery_set_property;
chip->batt_psy.properties = smb135x_battery_properties;
chip->batt_psy.num_properties = ARRAY_SIZE(smb135x_battery_properties);
chip->batt_psy.external_power_changed = smb135x_external_power_changed;
chip->batt_psy.property_is_writeable = smb135x_battery_is_writeable;
if (chip->bms_controlled_charging) {
chip->batt_psy.supplied_to = pm_batt_supplied_to;
chip->batt_psy.num_supplicants =
ARRAY_SIZE(pm_batt_supplied_to);
}
rc = power_supply_register(chip->dev, &chip->batt_psy);
if (rc < 0) {
dev_err(&client->dev,
"Unable to register batt_psy rc = %d\n", rc);
goto free_regulator;
}
if (chip->dc_psy_type != -EINVAL) {
chip->dc_psy.name = "dc";
chip->dc_psy.type = chip->dc_psy_type;
chip->dc_psy.get_property = smb135x_dc_get_property;
chip->dc_psy.properties = smb135x_dc_properties;
chip->dc_psy.num_properties = ARRAY_SIZE(smb135x_dc_properties);
rc = power_supply_register(chip->dev, &chip->dc_psy);
if (rc < 0) {
dev_err(&client->dev,
"Unable to register dc_psy rc = %d\n", rc);
goto unregister_batt_psy;
}
}
chip->resume_completed = true;
mutex_init(&chip->irq_complete);
/* STAT irq configuration */
if (client->irq) {
rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
smb135x_chg_stat_handler,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"smb135x_chg_stat_irq", chip);
if (rc < 0) {
dev_err(&client->dev,
"request_irq for irq=%d failed rc = %d\n",
client->irq, rc);
goto unregister_dc_psy;
}
enable_irq_wake(client->irq);
}
create_debugfs_entries(chip);
dev_info(chip->dev, "SMB135X version = %s revision = %s successfully probed batt=%d dc = %d usb = %d\n",
version_str[chip->version],
revision_str[chip->revision],
smb135x_get_prop_batt_present(chip),
chip->dc_present, chip->usb_present);
return 0;
unregister_dc_psy:
if (chip->dc_psy_type != -EINVAL)
power_supply_unregister(&chip->dc_psy);
unregister_batt_psy:
power_supply_unregister(&chip->batt_psy);
free_regulator:
smb135x_regulator_deinit(chip);
return rc;
}
static int smb135x_parallel_charger_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int rc;
struct smb135x_chg *chip;
const struct of_device_id *match;
struct device_node *node = client->dev.of_node;
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip) {
dev_err(&client->dev, "Unable to allocate memory\n");
return -ENOMEM;
}
chip->client = client;
chip->dev = &client->dev;
chip->parallel_charger = true;
chip->dc_psy_type = -EINVAL;
chip->chg_enabled = !(of_property_read_bool(node,
"qcom,charging-disabled"));
rc = of_property_read_u32(node, "qcom,recharge-thresh-mv",
&chip->resume_delta_mv);
if (rc < 0)
chip->resume_delta_mv = -EINVAL;
rc = of_property_read_u32(node, "qcom,float-voltage-mv",
&chip->vfloat_mv);
if (rc < 0)
chip->vfloat_mv = -EINVAL;
mutex_init(&chip->path_suspend_lock);
mutex_init(&chip->current_change_lock);
mutex_init(&chip->read_write_lock);
match = of_match_node(smb135x_match_table, node);
if (match == NULL) {
dev_err(chip->dev, "device tree match not found\n");
return -EINVAL;
}
chip->version = *(int *)match->data;
smb135x_set_current_tables(chip);
i2c_set_clientdata(client, chip);
chip->parallel_psy.name = "usb-parallel";
chip->parallel_psy.type = POWER_SUPPLY_TYPE_USB_PARALLEL;
chip->parallel_psy.get_property = smb135x_parallel_get_property;
chip->parallel_psy.set_property = smb135x_parallel_set_property;
chip->parallel_psy.properties = smb135x_parallel_properties;
chip->parallel_psy.property_is_writeable
= smb135x_parallel_is_writeable;
chip->parallel_psy.num_properties
= ARRAY_SIZE(smb135x_parallel_properties);
rc = power_supply_register(chip->dev, &chip->parallel_psy);
if (rc < 0) {
dev_err(&client->dev,
"Unable to register parallel_psy rc = %d\n", rc);
return rc;
}
chip->resume_completed = true;
mutex_init(&chip->irq_complete);
create_debugfs_entries(chip);
dev_info(chip->dev, "SMB135X USB PARALLEL CHARGER version = %s successfully probed\n",
version_str[chip->version]);
return 0;
}
static int smb135x_charger_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
if (is_parallel_charger(client))
return smb135x_parallel_charger_probe(client, id);
else
return smb135x_main_charger_probe(client, id);
}
static int smb135x_charger_remove(struct i2c_client *client)
{
int rc;
struct smb135x_chg *chip = i2c_get_clientdata(client);
debugfs_remove_recursive(chip->debug_root);
if (chip->parallel_charger) {
power_supply_unregister(&chip->parallel_psy);
goto mutex_destroy;
}
if (chip->therm_bias_vreg) {
rc = regulator_disable(chip->therm_bias_vreg);
if (rc)
pr_err("Couldn't disable therm-bias rc = %d\n", rc);
}
if (chip->usb_pullup_vreg) {
rc = regulator_disable(chip->usb_pullup_vreg);
if (rc)
pr_err("Couldn't disable data-pullup rc = %d\n", rc);
}
if (chip->dc_psy_type != -EINVAL)
power_supply_unregister(&chip->dc_psy);
power_supply_unregister(&chip->batt_psy);
smb135x_regulator_deinit(chip);
mutex_destroy:
mutex_destroy(&chip->irq_complete);
return 0;
}
static int smb135x_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct smb135x_chg *chip = i2c_get_clientdata(client);
int i, rc;
/* no suspend resume activities for parallel charger */
if (chip->parallel_charger)
return 0;
/* Save the current IRQ config */
for (i = 0; i < 3; i++) {
rc = smb135x_read(chip, IRQ_CFG_REG + i,
&chip->irq_cfg_mask[i]);
if (rc)
dev_err(chip->dev,
"Couldn't save irq cfg regs rc=%d\n", rc);
}
/* enable only important IRQs */
rc = smb135x_write(chip, IRQ_CFG_REG, IRQ_USBIN_UV_BIT);
if (rc < 0)
dev_err(chip->dev, "Couldn't set irq_cfg rc = %d\n", rc);
rc = smb135x_write(chip, IRQ2_CFG_REG, IRQ2_BATT_MISSING_BIT
| IRQ2_VBAT_LOW_BIT
| IRQ2_POWER_OK_BIT);
if (rc < 0)
dev_err(chip->dev, "Couldn't set irq2_cfg rc = %d\n", rc);
rc = smb135x_write(chip, IRQ3_CFG_REG, IRQ3_SRC_DETECT_BIT
| IRQ3_DCIN_UV_BIT | IRQ3_RID_DETECT_BIT);
if (rc < 0)
dev_err(chip->dev, "Couldn't set irq3_cfg rc = %d\n", rc);
mutex_lock(&chip->irq_complete);
chip->resume_completed = false;
mutex_unlock(&chip->irq_complete);
return 0;
}
static int smb135x_suspend_noirq(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct smb135x_chg *chip = i2c_get_clientdata(client);
/* no suspend resume activities for parallel charger */
if (chip->parallel_charger)
return 0;
if (chip->irq_waiting) {
pr_err_ratelimited("Aborting suspend, an interrupt was detected while suspending\n");
return -EBUSY;
}
return 0;
}
static int smb135x_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct smb135x_chg *chip = i2c_get_clientdata(client);
int i, rc;
/* no suspend resume activities for parallel charger */
if (chip->parallel_charger)
return 0;
/* Restore the IRQ config */
for (i = 0; i < 3; i++) {
rc = smb135x_write(chip, IRQ_CFG_REG + i,
chip->irq_cfg_mask[i]);
if (rc)
dev_err(chip->dev,
"Couldn't restore irq cfg regs rc=%d\n", rc);
}
mutex_lock(&chip->irq_complete);
chip->resume_completed = true;
if (chip->irq_waiting) {
mutex_unlock(&chip->irq_complete);
smb135x_chg_stat_handler(client->irq, chip);
enable_irq(client->irq);
} else {
mutex_unlock(&chip->irq_complete);
}
return 0;
}
static const struct dev_pm_ops smb135x_pm_ops = {
.resume = smb135x_resume,
.suspend_noirq = smb135x_suspend_noirq,
.suspend = smb135x_suspend,
};
static const struct i2c_device_id smb135x_charger_id[] = {
{"smb135x-charger", 0},
{},
};
MODULE_DEVICE_TABLE(i2c, smb135x_charger_id);
static void smb135x_shutdown(struct i2c_client *client)
{
int rc;
struct smb135x_chg *chip = i2c_get_clientdata(client);
if (chip->usb_pullup_vreg) {
/*
* switch to 5V adapter to prevent any errorneous request of 12V
* when USB D+ line pull-up regulator turns off.
*/
rc = smb135x_masked_write(chip, CFG_E_REG, HVDCP_5_9_BIT, 0);
if (rc < 0)
dev_err(chip->dev,
"Couldn't request for 5V rc=%d\n", rc);
}
}
static struct i2c_driver smb135x_charger_driver = {
.driver = {
.name = "smb135x-charger",
.owner = THIS_MODULE,
.of_match_table = smb135x_match_table,
.pm = &smb135x_pm_ops,
},
.probe = smb135x_charger_probe,
.remove = smb135x_charger_remove,
.id_table = smb135x_charger_id,
.shutdown = smb135x_shutdown,
};
module_i2c_driver(smb135x_charger_driver);
MODULE_DESCRIPTION("SMB135x Charger");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("i2c:smb135x-charger");
| gpl-2.0 |
hroark13/WARP_KERNEL_26357 | drivers/usb/gadget/f_diag.c | 19459 | /* drivers/usb/gadget/f_diag.c
* Diag Function Device - Route ARM9 and ARM11 DIAG messages
* between HOST and DEVICE.
* Copyright (C) 2007 Google, Inc.
* Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
* Author: Brian Swetland <[email protected]>
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <mach/usbdiag.h>
#include <mach/rpc_hsusb.h>
#include <linux/usb/composite.h>
#include <linux/usb/gadget.h>
#include <linux/usb/android_composite.h>
#include <linux/workqueue.h>
static DEFINE_SPINLOCK(ch_lock);
static LIST_HEAD(usb_diag_ch_list);
static struct usb_interface_descriptor intf_desc = {
.bLength = sizeof intf_desc,
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = 0xFF,
.bInterfaceSubClass = 0xFF,
.bInterfaceProtocol = 0xFF,
};
static struct usb_endpoint_descriptor hs_bulk_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(512),
.bInterval = 0,
};
static struct usb_endpoint_descriptor fs_bulk_in_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(64),
.bInterval = 0,
};
static struct usb_endpoint_descriptor hs_bulk_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(512),
.bInterval = 0,
};
static struct usb_endpoint_descriptor fs_bulk_out_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = __constant_cpu_to_le16(64),
.bInterval = 0,
};
static struct usb_descriptor_header *fs_diag_desc[] = {
(struct usb_descriptor_header *) &intf_desc,
(struct usb_descriptor_header *) &fs_bulk_in_desc,
(struct usb_descriptor_header *) &fs_bulk_out_desc,
NULL,
};
static struct usb_descriptor_header *hs_diag_desc[] = {
(struct usb_descriptor_header *) &intf_desc,
(struct usb_descriptor_header *) &hs_bulk_in_desc,
(struct usb_descriptor_header *) &hs_bulk_out_desc,
NULL,
};
/**
* struct diag_context - USB diag function driver private structure
* @android_function: Used for registering with Android composite driver
* @function: function structure for USB interface
* @out: USB OUT endpoint struct
* @in: USB IN endpoint struct
* @in_desc: USB IN endpoint descriptor struct
* @out_desc: USB OUT endpoint descriptor struct
* @read_pool: List of requests used for Rx (OUT ep)
* @write_pool: List of requests used for Tx (IN ep)
* @config_work: Work item schedule after interface is configured to notify
* CONNECT event to diag char driver and updating product id
* and serial number to MODEM/IMEM.
* @lock: Spinlock to proctect read_pool, write_pool lists
* @cdev: USB composite device struct
* @pdata: Platform data for this driver
* @ch: USB diag channel
*
*/
struct diag_context {
#ifdef CONFIG_USB_ANDROID_DIAG
struct android_usb_function android_function;
#endif
struct usb_function function;
struct usb_ep *out;
struct usb_ep *in;
struct usb_endpoint_descriptor *in_desc;
struct usb_endpoint_descriptor *out_desc;
struct list_head read_pool;
struct list_head write_pool;
struct work_struct config_work;
spinlock_t lock;
unsigned configured;
struct usb_composite_dev *cdev;
struct usb_diag_platform_data *pdata;
struct usb_diag_ch ch;
};
static inline struct diag_context *func_to_dev(struct usb_function *f)
{
return container_of(f, struct diag_context, function);
}
static void usb_config_work_func(struct work_struct *work)
{
struct diag_context *ctxt = container_of(work,
struct diag_context, config_work);
struct usb_composite_dev *cdev = ctxt->cdev;
struct usb_gadget_strings *table;
struct usb_string *s;
if (ctxt->ch.notify)
ctxt->ch.notify(ctxt->ch.priv, USB_DIAG_CONNECT, NULL);
if (!ctxt->pdata || !ctxt->pdata->update_pid_and_serial_num)
return;
/* pass on product id and serial number to dload */
if (!cdev->desc.iSerialNumber) {
ctxt->pdata->update_pid_and_serial_num(
cdev->desc.idProduct, 0);
return;
}
/*
* Serial number is filled by the composite driver. So
* it is fair enough to assume that it will always be
* found at first table of strings.
*/
table = *(cdev->driver->strings);
for (s = table->strings; s && s->s; s++)
if (s->id == cdev->desc.iSerialNumber) {
ctxt->pdata->update_pid_and_serial_num(
cdev->desc.idProduct, s->s);
break;
}
}
static void diag_write_complete(struct usb_ep *ep,
struct usb_request *req)
{
struct diag_context *ctxt = ep->driver_data;
struct diag_request *d_req = req->context;
unsigned long flags;
if (!req->status) {
if ((req->length >= ep->maxpacket) &&
((req->length % ep->maxpacket) == 0)) {
req->length = 0;
d_req->actual = req->actual;
d_req->status = req->status;
/* Queue zero length packet */
usb_ep_queue(ctxt->in, req, GFP_ATOMIC);
return;
}
}
spin_lock_irqsave(&ctxt->lock, flags);
list_add_tail(&req->list, &ctxt->write_pool);
if (req->length != 0) {
d_req->actual = req->actual;
d_req->status = req->status;
}
spin_unlock_irqrestore(&ctxt->lock, flags);
if (ctxt->ch.notify)
ctxt->ch.notify(ctxt->ch.priv, USB_DIAG_WRITE_DONE, d_req);
}
static void diag_read_complete(struct usb_ep *ep,
struct usb_request *req)
{
struct diag_context *ctxt = ep->driver_data;
struct diag_request *d_req = req->context;
unsigned long flags;
d_req->actual = req->actual;
d_req->status = req->status;
spin_lock_irqsave(&ctxt->lock, flags);
list_add_tail(&req->list, &ctxt->read_pool);
spin_unlock_irqrestore(&ctxt->lock, flags);
if (ctxt->ch.notify)
ctxt->ch.notify(ctxt->ch.priv, USB_DIAG_READ_DONE, d_req);
}
/**
* usb_diag_open() - Open a diag channel over USB
* @name: Name of the channel
* @priv: Private structure pointer which will be passed in notify()
* @notify: Callback function to receive notifications
*
* This function iterates overs the available channels and returns
* the channel handler if the name matches. The notify callback is called
* for CONNECT, DISCONNECT, READ_DONE and WRITE_DONE events.
*
*/
struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
void (*notify)(void *, unsigned, struct diag_request *))
{
struct usb_diag_ch *ch;
unsigned long flags;
int found = 0;
spin_lock_irqsave(&ch_lock, flags);
list_for_each_entry(ch, &usb_diag_ch_list, list) {
if (!strcmp(name, ch->name)) {
found = 1;
break;
}
}
if (!found) {
ch = ERR_PTR(-ENOENT);
goto out;
}
if (ch->priv) {
ch = ERR_PTR(-EBUSY);
goto out;
}
ch->priv = priv;
ch->notify = notify;
out:
spin_unlock_irqrestore(&ch_lock, flags);
return ch;
}
EXPORT_SYMBOL(usb_diag_open);
/**
* usb_diag_close() - Close a diag channel over USB
* @ch: Channel handler
*
* This function closes the diag channel.
*
*/
void usb_diag_close(struct usb_diag_ch *ch)
{
unsigned long flags;
spin_lock_irqsave(&ch_lock, flags);
ch->priv = NULL;
ch->notify = NULL;
spin_unlock_irqrestore(&ch_lock, flags);
}
EXPORT_SYMBOL(usb_diag_close);
/**
* usb_diag_free_req() - Free USB requests
* @ch: Channel handler
*
* This function free read and write USB requests for the interface
* associated with this channel.
*
*/
void usb_diag_free_req(struct usb_diag_ch *ch)
{
struct diag_context *ctxt = ch->priv_usb;
struct usb_request *req;
struct list_head *act, *tmp;
if (!ctxt)
return;
list_for_each_safe(act, tmp, &ctxt->write_pool) {
req = list_entry(act, struct usb_request, list);
list_del(&req->list);
usb_ep_free_request(ctxt->in, req);
}
list_for_each_safe(act, tmp, &ctxt->read_pool) {
req = list_entry(act, struct usb_request, list);
list_del(&req->list);
usb_ep_free_request(ctxt->out, req);
}
}
EXPORT_SYMBOL(usb_diag_free_req);
/**
* usb_diag_alloc_req() - Allocate USB requests
* @ch: Channel handler
* @n_write: Number of requests for Tx
* @n_read: Number of requests for Rx
*
* This function allocate read and write USB requests for the interface
* associated with this channel. The actual buffer is not allocated.
* The buffer is passed by diag char driver.
*
*/
int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read)
{
struct diag_context *ctxt = ch->priv_usb;
struct usb_request *req;
int i;
if (!ctxt)
return -ENODEV;
for (i = 0; i < n_write; i++) {
req = usb_ep_alloc_request(ctxt->in, GFP_ATOMIC);
if (!req)
goto fail;
req->complete = diag_write_complete;
list_add_tail(&req->list, &ctxt->write_pool);
}
for (i = 0; i < n_read; i++) {
req = usb_ep_alloc_request(ctxt->out, GFP_ATOMIC);
if (!req)
goto fail;
req->complete = diag_read_complete;
list_add_tail(&req->list, &ctxt->read_pool);
}
return 0;
fail:
usb_diag_free_req(ch);
return -ENOMEM;
}
EXPORT_SYMBOL(usb_diag_alloc_req);
/**
* usb_diag_read() - Read data from USB diag channel
* @ch: Channel handler
* @d_req: Diag request struct
*
* Enqueue a request on OUT endpoint of the interface corresponding to this
* channel. This function returns proper error code when interface is not
* in configured state, no Rx requests available and ep queue is failed.
*
* This function operates asynchronously. READ_DONE event is notified after
* completion of OUT request.
*
*/
int usb_diag_read(struct usb_diag_ch *ch, struct diag_request *d_req)
{
struct diag_context *ctxt = ch->priv_usb;
unsigned long flags;
struct usb_request *req;
spin_lock_irqsave(&ctxt->lock, flags);
if (!ctxt->configured) {
spin_unlock_irqrestore(&ctxt->lock, flags);
return -EIO;
}
if (list_empty(&ctxt->read_pool)) {
spin_unlock_irqrestore(&ctxt->lock, flags);
ERROR(ctxt->cdev, "%s: no requests available\n", __func__);
return -EAGAIN;
}
req = list_first_entry(&ctxt->read_pool, struct usb_request, list);
list_del(&req->list);
spin_unlock_irqrestore(&ctxt->lock, flags);
req->buf = d_req->buf;
req->length = d_req->length;
req->context = d_req;
if (usb_ep_queue(ctxt->out, req, GFP_ATOMIC)) {
/* If error add the link to linked list again*/
spin_lock_irqsave(&ctxt->lock, flags);
list_add_tail(&req->list, &ctxt->read_pool);
spin_unlock_irqrestore(&ctxt->lock, flags);
ERROR(ctxt->cdev, "%s: cannot queue"
" read request\n", __func__);
return -EIO;
}
return 0;
}
EXPORT_SYMBOL(usb_diag_read);
/**
* usb_diag_write() - Write data from USB diag channel
* @ch: Channel handler
* @d_req: Diag request struct
*
* Enqueue a request on IN endpoint of the interface corresponding to this
* channel. This function returns proper error code when interface is not
* in configured state, no Tx requests available and ep queue is failed.
*
* This function operates asynchronously. WRITE_DONE event is notified after
* completion of IN request.
*
*/
int usb_diag_write(struct usb_diag_ch *ch, struct diag_request *d_req)
{
struct diag_context *ctxt = ch->priv_usb;
unsigned long flags;
struct usb_request *req = NULL;
spin_lock_irqsave(&ctxt->lock, flags);
if (!ctxt->configured) {
spin_unlock_irqrestore(&ctxt->lock, flags);
return -EIO;
}
if (list_empty(&ctxt->write_pool)) {
spin_unlock_irqrestore(&ctxt->lock, flags);
ERROR(ctxt->cdev, "%s: no requests available\n", __func__);
return -EAGAIN;
}
req = list_first_entry(&ctxt->write_pool, struct usb_request, list);
list_del(&req->list);
spin_unlock_irqrestore(&ctxt->lock, flags);
req->buf = d_req->buf;
req->length = d_req->length;
req->context = d_req;
if (usb_ep_queue(ctxt->in, req, GFP_ATOMIC)) {
/* If error add the link to linked list again*/
spin_lock_irqsave(&ctxt->lock, flags);
list_add_tail(&req->list, &ctxt->write_pool);
spin_unlock_irqrestore(&ctxt->lock, flags);
ERROR(ctxt->cdev, "%s: cannot queue"
" read request\n", __func__);
return -EIO;
}
return 0;
}
EXPORT_SYMBOL(usb_diag_write);
static void diag_function_disable(struct usb_function *f)
{
struct diag_context *dev = func_to_dev(f);
unsigned long flags;
DBG(dev->cdev, "diag_function_disable\n");
spin_lock_irqsave(&dev->lock, flags);
dev->configured = 0;
spin_unlock_irqrestore(&dev->lock, flags);
if (dev->ch.notify)
dev->ch.notify(dev->ch.priv, USB_DIAG_DISCONNECT, NULL);
usb_ep_disable(dev->in);
dev->in->driver_data = NULL;
usb_ep_disable(dev->out);
dev->out->driver_data = NULL;
}
static int diag_function_set_alt(struct usb_function *f,
unsigned intf, unsigned alt)
{
struct diag_context *dev = func_to_dev(f);
struct usb_composite_dev *cdev = f->config->cdev;
unsigned long flags;
int rc = 0;
dev->in_desc = ep_choose(cdev->gadget,
&hs_bulk_in_desc, &fs_bulk_in_desc);
dev->out_desc = ep_choose(cdev->gadget,
&hs_bulk_out_desc, &fs_bulk_in_desc);
dev->in->driver_data = dev;
rc = usb_ep_enable(dev->in, dev->in_desc);
if (rc) {
ERROR(dev->cdev, "can't enable %s, result %d\n",
dev->in->name, rc);
return rc;
}
dev->out->driver_data = dev;
rc = usb_ep_enable(dev->out, dev->out_desc);
if (rc) {
ERROR(dev->cdev, "can't enable %s, result %d\n",
dev->out->name, rc);
usb_ep_disable(dev->in);
return rc;
}
schedule_work(&dev->config_work);
spin_lock_irqsave(&dev->lock, flags);
dev->configured = 1;
spin_unlock_irqrestore(&dev->lock, flags);
return rc;
}
static void diag_function_unbind(struct usb_configuration *c,
struct usb_function *f)
{
//struct diag_context *ctxt = func_to_dev(f);
if (gadget_is_dualspeed(c->cdev->gadget))
usb_free_descriptors(f->hs_descriptors);
usb_free_descriptors(f->descriptors);
//ctxt->ch.priv_usb = NULL;
}
static int diag_function_bind(struct usb_configuration *c,
struct usb_function *f)
{
struct usb_composite_dev *cdev = c->cdev;
struct diag_context *ctxt = func_to_dev(f);
struct usb_ep *ep;
int status = -ENODEV;
intf_desc.bInterfaceNumber = usb_interface_id(c, f);
ep = usb_ep_autoconfig(cdev->gadget, &fs_bulk_in_desc);
ctxt->in = ep;
ep->driver_data = ctxt;
ep = usb_ep_autoconfig(cdev->gadget, &fs_bulk_out_desc);
ctxt->out = ep;
ep->driver_data = ctxt;
/* copy descriptors, and track endpoint copies */
f->descriptors = usb_copy_descriptors(fs_diag_desc);
if (!f->descriptors)
goto fail;
if (gadget_is_dualspeed(c->cdev->gadget)) {
hs_bulk_in_desc.bEndpointAddress =
fs_bulk_in_desc.bEndpointAddress;
hs_bulk_out_desc.bEndpointAddress =
fs_bulk_out_desc.bEndpointAddress;
/* copy descriptors, and track endpoint copies */
f->hs_descriptors = usb_copy_descriptors(hs_diag_desc);
}
return 0;
fail:
if (ctxt->out)
ctxt->out->driver_data = NULL;
if (ctxt->in)
ctxt->in->driver_data = NULL;
return status;
}
#if 0
int diag_function_add(struct usb_configuration *c)
{
struct diag_context *dev;
struct usb_diag_ch *_ch;
int found = 0, ret;
DBG(c->cdev, "diag_function_add\n");
list_for_each_entry(_ch, &usb_diag_ch_list, list) {
/* Find an unused channel */
if (!_ch->priv_usb) {
found = 1;
break;
}
}
if (!found) {
ERROR(c->cdev, "unable to get diag usb channel\n");
return -ENODEV;
}
dev = container_of(_ch, struct diag_context, ch);
/* claim the channel for this USB interface */
_ch->priv_usb = dev;
dev->cdev = c->cdev;
dev->function.name = _ch->name;
dev->function.descriptors = fs_diag_desc;
dev->function.hs_descriptors = hs_diag_desc;
dev->function.bind = diag_function_bind;
dev->function.unbind = diag_function_unbind;
dev->function.set_alt = diag_function_set_alt;
dev->function.disable = diag_function_disable;
spin_lock_init(&dev->lock);
INIT_LIST_HEAD(&dev->read_pool);
INIT_LIST_HEAD(&dev->write_pool);
INIT_WORK(&dev->config_work, usb_config_work_func);
ret = usb_add_function(c, &dev->function);
if (ret) {
INFO(c->cdev, "usb_add_function failed\n");
_ch->priv_usb = NULL;
}
return ret;
}
#else
int diag_function_add(struct usb_configuration *c, struct diag_context *dev)
{
struct usb_diag_ch *_ch = &dev->ch;
int ret;
DBG(c->cdev, "diag_function_add\n");
dev->cdev = c->cdev;
dev->function.name = _ch->name;
dev->function.descriptors = fs_diag_desc;
dev->function.hs_descriptors = hs_diag_desc;
dev->function.bind = diag_function_bind;
dev->function.unbind = diag_function_unbind;
dev->function.set_alt = diag_function_set_alt;
dev->function.disable = diag_function_disable;
spin_lock_init(&dev->lock);
INIT_LIST_HEAD(&dev->read_pool);
INIT_LIST_HEAD(&dev->write_pool);
INIT_WORK(&dev->config_work, usb_config_work_func);
ret = usb_add_function(c, &dev->function);
if (ret) {
INFO(c->cdev, "usb_add_function failed\n");
_ch->priv_usb = NULL;
}
return ret;
}
#endif
static struct
usb_diag_ch *diag_setup(struct usb_diag_platform_data *pdata)
{
struct usb_diag_ch *ch;
struct diag_context *ctxt;
unsigned long flags;
ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
if (!ctxt)
return ERR_PTR(-ENOMEM);
ctxt->pdata = pdata;
ch = &ctxt->ch;
spin_lock_irqsave(&ch_lock, flags);
ch->name = pdata->ch_name;
list_add_tail(&ch->list, &usb_diag_ch_list);
spin_unlock_irqrestore(&ch_lock, flags);
return ch;
}
static void diag_cleanup(struct usb_diag_ch *_ch)
{
struct diag_context *dev = container_of(_ch, struct diag_context, ch);
unsigned long flags;
WARN_ON(_ch->priv || _ch->priv_usb);
spin_lock_irqsave(&ch_lock, flags);
list_del(&_ch->list);
spin_unlock_irqrestore(&ch_lock, flags);
kfree(dev);
}
#ifdef CONFIG_USB_ANDROID_DIAG
#if 0
static int __init diag_probe(struct platform_device *pdev)
{
struct diag_context *dev;
struct usb_diag_ch *_ch;
struct android_usb_function *func;
struct usb_diag_platform_data *pdata = pdev->dev.platform_data;
dev_dbg(&pdev->dev, "%s\n", __func__);
_ch = diag_setup(pdata);
if (IS_ERR(_ch)) {
dev_err(&pdev->dev, "unable to create diag channel\n");
return PTR_ERR(_ch);
}
platform_set_drvdata(pdev, _ch);
dev = container_of(_ch, struct diag_context, ch);
func = &dev->android_function;
func->name = pdata->ch_name;
func->bind_config = diag_function_add;
android_register_function(func);
return 0;
}
static int diag_remove(struct platform_device *pdev)
{
struct usb_diag_ch *ch = platform_get_drvdata(pdev);
diag_cleanup(ch);
return 0;
}
static struct platform_driver usb_diag_driver = {
.remove = diag_remove,
.driver = {
.name = "usb_diag",
.owner = THIS_MODULE,
},
};
static int __init usb_diag_init(void)
{
return platform_driver_probe(&usb_diag_driver, diag_probe);
}
module_init(usb_diag_init);
#else
#endif
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("usb diag gadget driver");
MODULE_VERSION("2.00");
#endif /* CONFIG_USB_ANDROID_DIAG */
| gpl-2.0 |
Pillar1989/intel_edison_linux-3.10.17 | drivers/usb/gadget/udc-core.c | 14709 | /**
* udc.c - Core UDC Framework
*
* Copyright (C) 2010 Texas Instruments
* Author: Felipe Balbi <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 of
* the License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/err.h>
#include <linux/dma-mapping.h>
#include <linux/workqueue.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
/**
* struct usb_udc - describes one usb device controller
* @driver - the gadget driver pointer. For use by the class code
* @dev - the child device to the actual controller
* @gadget - the gadget. For use by the class code
* @list - for use by the udc class driver
*
* This represents the internal data structure which is used by the UDC-class
* to hold information about udc driver and gadget together.
*/
struct usb_udc {
struct usb_gadget_driver *driver;
struct usb_gadget *gadget;
struct device dev;
struct list_head list;
};
static struct class *udc_class;
static LIST_HEAD(udc_list);
static DEFINE_MUTEX(udc_lock);
/* ------------------------------------------------------------------------- */
int usb_gadget_map_request(struct usb_gadget *gadget,
struct usb_request *req, int is_in)
{
if (req->length == 0)
return 0;
if (req->num_sgs) {
int mapped;
mapped = dma_map_sg(&gadget->dev, req->sg, req->num_sgs,
is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (mapped == 0) {
dev_err(&gadget->dev, "failed to map SGs\n");
return -EFAULT;
}
req->num_mapped_sgs = mapped;
} else {
req->dma = dma_map_single(&gadget->dev, req->buf, req->length,
is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (dma_mapping_error(&gadget->dev, req->dma)) {
dev_err(&gadget->dev, "failed to map buffer\n");
return -EFAULT;
}
}
return 0;
}
EXPORT_SYMBOL_GPL(usb_gadget_map_request);
void usb_gadget_unmap_request(struct usb_gadget *gadget,
struct usb_request *req, int is_in)
{
if (req->length == 0)
return;
if (req->num_mapped_sgs) {
dma_unmap_sg(&gadget->dev, req->sg, req->num_mapped_sgs,
is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
req->num_mapped_sgs = 0;
} else {
dma_unmap_single(&gadget->dev, req->dma, req->length,
is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
}
}
EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
/* ------------------------------------------------------------------------- */
static void usb_gadget_state_work(struct work_struct *work)
{
struct usb_gadget *gadget = work_to_gadget(work);
sysfs_notify(&gadget->dev.kobj, NULL, "status");
}
void usb_gadget_set_state(struct usb_gadget *gadget,
enum usb_device_state state)
{
gadget->state = state;
schedule_work(&gadget->work);
}
EXPORT_SYMBOL_GPL(usb_gadget_set_state);
/* ------------------------------------------------------------------------- */
/**
* usb_gadget_udc_start - tells usb device controller to start up
* @gadget: The gadget we want to get started
* @driver: The driver we want to bind to @gadget
*
* This call is issued by the UDC Class driver when it's about
* to register a gadget driver to the device controller, before
* calling gadget driver's bind() method.
*
* It allows the controller to be powered off until strictly
* necessary to have it powered on.
*
* Returns zero on success, else negative errno.
*/
static inline int usb_gadget_udc_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
return gadget->ops->udc_start(gadget, driver);
}
/**
* usb_gadget_udc_stop - tells usb device controller we don't need it anymore
* @gadget: The device we want to stop activity
* @driver: The driver to unbind from @gadget
*
* This call is issued by the UDC Class driver after calling
* gadget driver's unbind() method.
*
* The details are implementation specific, but it can go as
* far as powering off UDC completely and disable its data
* line pullups.
*/
static inline void usb_gadget_udc_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
gadget->ops->udc_stop(gadget, driver);
}
/**
* usb_udc_release - release the usb_udc struct
* @dev: the dev member within usb_udc
*
* This is called by driver's core in order to free memory once the last
* reference is released.
*/
static void usb_udc_release(struct device *dev)
{
struct usb_udc *udc;
udc = container_of(dev, struct usb_udc, dev);
dev_dbg(dev, "releasing '%s'\n", dev_name(dev));
kfree(udc);
}
static const struct attribute_group *usb_udc_attr_groups[];
static void usb_udc_nop_release(struct device *dev)
{
dev_vdbg(dev, "%s\n", __func__);
}
/**
* usb_add_gadget_udc_release - adds a new gadget to the udc class driver list
* @parent: the parent device to this udc. Usually the controller driver's
* device.
* @gadget: the gadget to be added to the list.
* @release: a gadget release function.
*
* Returns zero on success, negative errno otherwise.
*/
int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
void (*release)(struct device *dev))
{
struct usb_udc *udc;
int ret = -ENOMEM;
udc = kzalloc(sizeof(*udc), GFP_KERNEL);
if (!udc)
goto err1;
dev_set_name(&gadget->dev, "gadget");
INIT_WORK(&gadget->work, usb_gadget_state_work);
gadget->dev.parent = parent;
dma_set_coherent_mask(&gadget->dev, parent->coherent_dma_mask);
gadget->dev.dma_parms = parent->dma_parms;
gadget->dev.dma_mask = parent->dma_mask;
if (release)
gadget->dev.release = release;
else
gadget->dev.release = usb_udc_nop_release;
ret = device_register(&gadget->dev);
if (ret)
goto err2;
device_initialize(&udc->dev);
udc->dev.release = usb_udc_release;
udc->dev.class = udc_class;
udc->dev.groups = usb_udc_attr_groups;
udc->dev.parent = parent;
ret = dev_set_name(&udc->dev, "%s", kobject_name(&parent->kobj));
if (ret)
goto err3;
udc->gadget = gadget;
mutex_lock(&udc_lock);
list_add_tail(&udc->list, &udc_list);
ret = device_add(&udc->dev);
if (ret)
goto err4;
usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED);
mutex_unlock(&udc_lock);
return 0;
err4:
list_del(&udc->list);
mutex_unlock(&udc_lock);
err3:
put_device(&udc->dev);
err2:
put_device(&gadget->dev);
kfree(udc);
err1:
return ret;
}
EXPORT_SYMBOL_GPL(usb_add_gadget_udc_release);
/**
* usb_add_gadget_udc - adds a new gadget to the udc class driver list
* @parent: the parent device to this udc. Usually the controller
* driver's device.
* @gadget: the gadget to be added to the list
*
* Returns zero on success, negative errno otherwise.
*/
int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
{
return usb_add_gadget_udc_release(parent, gadget, NULL);
}
EXPORT_SYMBOL_GPL(usb_add_gadget_udc);
static void usb_gadget_remove_driver(struct usb_udc *udc)
{
dev_dbg(&udc->dev, "unregistering UDC driver [%s]\n",
udc->gadget->name);
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
usb_gadget_disconnect(udc->gadget);
udc->driver->disconnect(udc->gadget);
udc->driver->unbind(udc->gadget);
usb_gadget_udc_stop(udc->gadget, NULL);
udc->driver = NULL;
udc->dev.driver = NULL;
udc->gadget->dev.driver = NULL;
}
/**
* usb_del_gadget_udc - deletes @udc from udc_list
* @gadget: the gadget to be removed.
*
* This, will call usb_gadget_unregister_driver() if
* the @udc is still busy.
*/
void usb_del_gadget_udc(struct usb_gadget *gadget)
{
struct usb_udc *udc = NULL;
mutex_lock(&udc_lock);
list_for_each_entry(udc, &udc_list, list)
if (udc->gadget == gadget)
goto found;
dev_err(gadget->dev.parent, "gadget not registered.\n");
mutex_unlock(&udc_lock);
return;
found:
dev_vdbg(gadget->dev.parent, "unregistering gadget\n");
list_del(&udc->list);
mutex_unlock(&udc_lock);
if (udc->driver)
usb_gadget_remove_driver(udc);
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
flush_work(&gadget->work);
device_unregister(&udc->dev);
device_unregister(&gadget->dev);
}
EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
/* ------------------------------------------------------------------------- */
static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *driver)
{
int ret;
dev_dbg(&udc->dev, "registering UDC driver [%s]\n",
driver->function);
udc->driver = driver;
udc->dev.driver = &driver->driver;
udc->gadget->dev.driver = &driver->driver;
ret = driver->bind(udc->gadget, driver);
if (ret)
goto err1;
ret = usb_gadget_udc_start(udc->gadget, driver);
if (ret) {
driver->unbind(udc->gadget);
goto err1;
}
usb_gadget_connect(udc->gadget);
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
return 0;
err1:
dev_err(&udc->dev, "failed to start %s: %d\n",
udc->driver->function, ret);
udc->driver = NULL;
udc->dev.driver = NULL;
udc->gadget->dev.driver = NULL;
return ret;
}
int udc_attach_driver(const char *name, struct usb_gadget_driver *driver)
{
struct usb_udc *udc = NULL;
int ret = -ENODEV;
mutex_lock(&udc_lock);
list_for_each_entry(udc, &udc_list, list) {
ret = strcmp(name, dev_name(&udc->dev));
if (!ret)
break;
}
if (ret) {
ret = -ENODEV;
goto out;
}
if (udc->driver) {
ret = -EBUSY;
goto out;
}
ret = udc_bind_to_driver(udc, driver);
out:
mutex_unlock(&udc_lock);
return ret;
}
EXPORT_SYMBOL_GPL(udc_attach_driver);
int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
{
struct usb_udc *udc = NULL;
int ret;
if (!driver || !driver->bind || !driver->setup)
return -EINVAL;
mutex_lock(&udc_lock);
list_for_each_entry(udc, &udc_list, list) {
/* For now we take the first one */
if (!udc->driver)
goto found;
}
pr_debug("couldn't find an available UDC\n");
mutex_unlock(&udc_lock);
return -ENODEV;
found:
ret = udc_bind_to_driver(udc, driver);
mutex_unlock(&udc_lock);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
struct usb_udc *udc = NULL;
int ret = -ENODEV;
if (!driver || !driver->unbind)
return -EINVAL;
mutex_lock(&udc_lock);
list_for_each_entry(udc, &udc_list, list)
if (udc->driver == driver) {
usb_gadget_remove_driver(udc);
ret = 0;
break;
}
mutex_unlock(&udc_lock);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver);
/* ------------------------------------------------------------------------- */
static ssize_t usb_udc_srp_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
if (sysfs_streq(buf, "1"))
usb_gadget_wakeup(udc->gadget);
return n;
}
static DEVICE_ATTR(srp, S_IWUSR, NULL, usb_udc_srp_store);
static ssize_t usb_udc_softconn_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
if (sysfs_streq(buf, "connect")) {
usb_gadget_udc_start(udc->gadget, udc->driver);
usb_gadget_connect(udc->gadget);
} else if (sysfs_streq(buf, "disconnect")) {
usb_gadget_disconnect(udc->gadget);
usb_gadget_udc_stop(udc->gadget, udc->driver);
} else {
dev_err(dev, "unsupported command '%s'\n", buf);
return -EINVAL;
}
return n;
}
static DEVICE_ATTR(soft_connect, S_IWUSR, NULL, usb_udc_softconn_store);
static ssize_t usb_gadget_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
struct usb_gadget *gadget = udc->gadget;
return sprintf(buf, "%s\n", usb_state_string(gadget->state));
}
static DEVICE_ATTR(state, S_IRUGO, usb_gadget_state_show, NULL);
#define USB_UDC_SPEED_ATTR(name, param) \
ssize_t usb_udc_##param##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \
return snprintf(buf, PAGE_SIZE, "%s\n", \
usb_speed_string(udc->gadget->param)); \
} \
static DEVICE_ATTR(name, S_IRUGO, usb_udc_##param##_show, NULL)
static USB_UDC_SPEED_ATTR(current_speed, speed);
static USB_UDC_SPEED_ATTR(maximum_speed, max_speed);
#define USB_UDC_ATTR(name) \
ssize_t usb_udc_##name##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \
struct usb_gadget *gadget = udc->gadget; \
\
return snprintf(buf, PAGE_SIZE, "%d\n", gadget->name); \
} \
static DEVICE_ATTR(name, S_IRUGO, usb_udc_##name##_show, NULL)
static USB_UDC_ATTR(is_otg);
static USB_UDC_ATTR(is_a_peripheral);
static USB_UDC_ATTR(b_hnp_enable);
static USB_UDC_ATTR(a_hnp_support);
static USB_UDC_ATTR(a_alt_hnp_support);
static struct attribute *usb_udc_attrs[] = {
&dev_attr_srp.attr,
&dev_attr_soft_connect.attr,
&dev_attr_state.attr,
&dev_attr_current_speed.attr,
&dev_attr_maximum_speed.attr,
&dev_attr_is_otg.attr,
&dev_attr_is_a_peripheral.attr,
&dev_attr_b_hnp_enable.attr,
&dev_attr_a_hnp_support.attr,
&dev_attr_a_alt_hnp_support.attr,
NULL,
};
static const struct attribute_group usb_udc_attr_group = {
.attrs = usb_udc_attrs,
};
static const struct attribute_group *usb_udc_attr_groups[] = {
&usb_udc_attr_group,
NULL,
};
static int usb_udc_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
int ret;
ret = add_uevent_var(env, "USB_UDC_NAME=%s", udc->gadget->name);
if (ret) {
dev_err(dev, "failed to add uevent USB_UDC_NAME\n");
return ret;
}
if (udc->driver) {
ret = add_uevent_var(env, "USB_UDC_DRIVER=%s",
udc->driver->function);
if (ret) {
dev_err(dev, "failed to add uevent USB_UDC_DRIVER\n");
return ret;
}
}
return 0;
}
static int __init usb_udc_init(void)
{
udc_class = class_create(THIS_MODULE, "udc");
if (IS_ERR(udc_class)) {
pr_err("failed to create udc class --> %ld\n",
PTR_ERR(udc_class));
return PTR_ERR(udc_class);
}
udc_class->dev_uevent = usb_udc_uevent;
return 0;
}
subsys_initcall(usb_udc_init);
static void __exit usb_udc_exit(void)
{
class_destroy(udc_class);
}
module_exit(usb_udc_exit);
MODULE_DESCRIPTION("UDC Framework");
MODULE_AUTHOR("Felipe Balbi <[email protected]>");
MODULE_LICENSE("GPL v2");
| gpl-2.0 |
zyweb/group5 | models/RelJob.php | 2597 | <?php
namespace app\models;
use Yii;
/**
* This is the model class for table "rel_job".
*
* @property integer $rj_id
* @property string $positiontype
* @property string $rj_name
* @property string $rj_dep
* @property string $work_type
* @property string $max_salary
* @property string $work_city
* @property string $work_year
* @property string $education
* @property string $work_tempt
* @property string $work_desc
* @property string $work_address
* @property integer $company_id
* @property integer $rj_status
* @property integer $addtime
* @property integer $m_id
* @property string $email
* @property integer $is_hot
* @property string $min_salary
* @property integer $is_ok
* @property string $lng
* @property string $lat
*/
class RelJob extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'rel_job';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['rj_name'], 'required'],
[['max_salary'], 'number'],
[['work_desc'], 'string'],
[['company_id', 'rj_status', 'addtime', 'm_id', 'is_hot', 'is_ok'], 'integer'],
[['positiontype', 'rj_dep', 'work_type'], 'string', 'max' => 30],
[['rj_name', 'lng', 'lat'], 'string', 'max' => 20],
[['work_city', 'work_year', 'education'], 'string', 'max' => 10],
[['work_tempt'], 'string', 'max' => 25],
[['work_address'], 'string', 'max' => 255],
[['email'], 'string', 'max' => 50],
[['min_salary'], 'string', 'max' => 220]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'rj_id' => 'Rj ID',
'positiontype' => 'Positiontype',
'rj_name' => 'Rj Name',
'rj_dep' => 'Rj Dep',
'work_type' => 'Work Type',
'max_salary' => 'Max Salary',
'work_city' => 'Work City',
'work_year' => 'Work Year',
'education' => 'Education',
'work_tempt' => 'Work Tempt',
'work_desc' => 'Work Desc',
'work_address' => 'Work Address',
'company_id' => 'Company ID',
'rj_status' => 'Rj Status',
'addtime' => 'Addtime',
'm_id' => 'M ID',
'email' => 'Email',
'is_hot' => 'Is Hot',
'min_salary' => 'Min Salary',
'is_ok' => 'Is Ok',
'lng' => 'Lng',
'lat' => 'Lat',
];
}
}
| gpl-2.0 |
mandeepsimak/Lyx | src/frontends/qt4/GuiTabular.h | 1507 | // -*- C++ -*-
/**
* \file GuiTabular.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Kalle Dalheimer
* \author Jürgen Spitzmüller
* \author Herbert Voß
*
* Full author contact details are available in file CREDITS.
*/
#ifndef GUITABULAR_H
#define GUITABULAR_H
#include "InsetParamsWidget.h"
#include "ui_TabularUi.h"
#include "insets/InsetTabular.h"
namespace lyx {
namespace frontend {
class GuiTabular : public InsetParamsWidget, public Ui::TabularUi
{
Q_OBJECT
public:
GuiTabular(QWidget * parent = 0);
private Q_SLOTS:
void checkEnabled();
void borderSet_clicked();
void borderUnset_clicked();
void on_topspaceCO_activated(int index);
void on_bottomspaceCO_activated(int index);
void on_interlinespaceCO_activated(int index);
private:
/// \name InsetParamsWidget inherited methods
//@{
InsetCode insetCode() const { return TABULAR_CODE; }
FuncCode creationCode() const { return LFUN_TABULAR_INSERT; }
void paramsToDialog(Inset const *);
docstring dialogToParams() const;
//@}
///
void setHAlign(std::string & param_str) const;
///
void setVAlign(std::string & param_str) const;
///
void setTableAlignment(std::string & param_str) const;
///
void setWidthAndAlignment();
///
bool funcEnabled(Tabular::Feature f) const;
///
bool firstheader_suppressable_;
///
bool lastfooter_suppressable_;
};
} // namespace frontend
} // namespace lyx
#endif // GUITABULAR_H
| gpl-2.0 |
STS-Dev-Team/kernel_omap4_xt910s | external/wlan/wl1271/Test/debug.h | 2455 | /*
* debug.h
*
* Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Texas Instruments nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file debug.h
* \brief debug module header file.
*
* \see debug.c
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include "tidef.h"
#include "commonTypes.h"
#include "DrvMainModules.h"
TI_STATUS debugFunction (TStadHandlesList *pStadHandles, TI_UINT32 functionNumber, void *hParam);
#endif /* __DEBUG_H__ */
| gpl-2.0 |
mdaniel/svn-caucho-com-resin | modules/hessian/src/com/caucho/hessian/io/AbstractStreamSerializer.java | 3888 | /*
* Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved.
*
* The Apache Software License, Version 1.1
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Caucho Technology (http://www.caucho.com/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Burlap", "Resin", and "Caucho" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* [email protected].
*
* 5. Products derived from this software may not be called "Resin"
* nor may "Resin" appear in their names without prior written
* permission of Caucho Technology.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Scott Ferguson
*/
package com.caucho.hessian.io;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
/**
* Serializing an object containing a byte stream.
*/
abstract public class AbstractStreamSerializer extends AbstractSerializer
{
/**
* Writes the object to the output stream.
*/
@Override
public void writeObject(Object obj, AbstractHessianOutput out)
throws IOException
{
if (out.addRef(obj)) {
return;
}
int ref = out.writeObjectBegin(getClassName(obj));
if (ref < -1) {
out.writeString("value");
InputStream is = null;
try {
is = getInputStream(obj);
} catch (Exception e) {
log.log(Level.WARNING, e.toString(), e);
}
if (is != null) {
try {
out.writeByteStream(is);
} finally {
is.close();
}
} else {
out.writeNull();
}
out.writeMapEnd();
}
else {
if (ref == -1) {
out.writeClassFieldLength(1);
out.writeString("value");
out.writeObjectBegin(getClassName(obj));
}
InputStream is = null;
try {
is = getInputStream(obj);
} catch (Exception e) {
log.log(Level.WARNING, e.toString(), e);
}
try {
if (is != null)
out.writeByteStream(is);
else
out.writeNull();
} finally {
if (is != null)
is.close();
}
}
}
protected String getClassName(Object obj)
{
return obj.getClass().getName();
}
abstract protected InputStream getInputStream(Object obj)
throws IOException;
}
| gpl-2.0 |
evamichalcak/doartystuff | wp-content/plugins/event-rocket/templates/cleanup-screen.php | 2765 | <?php defined( 'ABSPATH' ) or exit() ?>
<div class="wrap eventrocket cleanup">
<h2> <?php _e( 'Event Data Cleanup', 'eventrocket' ) ?> </h2>
<?php if ( ! $in_progress ): ?>
<p> <?php
_e( 'There may be occasions where you want to remove all traces of The Events Calendar and associated '
. 'plugins from the database, either because you no longer need it or because you want to start afresh. '
. 'This tool can help with that. <strong> Use with caution! </strong> ', 'eventrocket' );
?> </p>
<?php elseif ( $in_progress && 0 < max( $current_data ) ): ?>
<div class="updated">
<p> <?php _e( '<strong> Still working… </strong> please be patient while the remaining data is '
. 'removed.', 'eventrocket' ); ?>
<img src="<?php echo esc_url( admin_url( 'images/spinner.gif' ) ) ?>" />
</p>
<input type="hidden" name="keep_working" id="keep_working" value="<?php echo esc_attr( $action_url ) ?>" />
</div>
<?php elseif ( $in_progress && 0 === max( $current_data ) ): ?>
<div class="updated"> <p>
<?php _e( '<strong> Cleanup complete! </strong> Now get back to work. ', 'eventrocket' ); ?>
</p> </div>
<?php endif ?>
<?php if ( 0 === max( $current_data ) ): ?>
<p> <strong> <?php _e( 'No event related data found! You’re all set!', 'eventrocket') ?> </strong></p>
<?php else: ?>
<h4> <?php _e( 'Event data found within your database:', 'eventrocket' ) ?> </h4>
<dl>
<dt> <?php _e( 'Event objects', 'eventrocket' ) ?> </dt>
<dd> <?php echo esc_html( $current_data['events'] ) ?> </dd>
<dt> <?php _e( 'Venue objects', 'eventrocket' ) ?> </dt>
<dd> <?php echo esc_html( $current_data['venues'] ) ?> </dd>
<dt> <?php _e( 'Organizer objects', 'eventrocket' ) ?> </dt>
<dd> <?php echo esc_html( $current_data['organizers'] ) ?> </dd>
<dt> <?php _e( 'User capabilities', 'eventrocket' ) ?> </dt>
<dd> <?php echo esc_html( $current_data['capabilities'] ) ?> </dd>
<dt> <?php _e( 'Other settings', 'eventrocket' ) ?> </dt>
<dd> <?php echo esc_html( $current_data['options'] ) ?> </dd>
</dl>
<?php if ( ! $in_progress ): ?>
<h4> <?php _e( 'Run the cleanup tool', 'eventrocket' ) ?> </h4>
<div class="hide-if-no-js">
<p id="cleanup_safety">
<input type="checkbox" name="user_confirms" id="user_confirms" value="1" />
<label for="user_confirms"> <?php _e( 'I understand the risks involved and acknowledge that running '
. 'this cleanup tool without first making a backup may be deemed an act of stupidity.',
'eventrocket' ) ?> </label>
</p>
</div>
<p id="do_cleanup"> <a href="<?php echo esc_attr( $action_url ) ?>" class="button-primary"><?php _e( 'Do cleanup', 'eventrocket' ) ?></a> </p>
<?php endif ?>
<?php endif ?>
</div> | gpl-2.0 |
Fe-Pi/linux | drivers/net/ethernet/mellanox/mlx4/main.c | 124348 | /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
* Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/io-mapping.h>
#include <linux/delay.h>
#include <linux/kmod.h>
#include <linux/etherdevice.h>
#include <net/devlink.h>
#include <uapi/rdma/mlx4-abi.h>
#include <linux/mlx4/device.h>
#include <linux/mlx4/doorbell.h>
#include "mlx4.h"
#include "fw.h"
#include "icm.h"
MODULE_AUTHOR("Roland Dreier");
MODULE_DESCRIPTION("Mellanox ConnectX HCA low-level driver");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION(DRV_VERSION);
struct workqueue_struct *mlx4_wq;
#ifdef CONFIG_MLX4_DEBUG
int mlx4_debug_level = 0;
module_param_named(debug_level, mlx4_debug_level, int, 0644);
MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
#endif /* CONFIG_MLX4_DEBUG */
#ifdef CONFIG_PCI_MSI
static int msi_x = 1;
module_param(msi_x, int, 0444);
MODULE_PARM_DESC(msi_x, "0 - don't use MSI-X, 1 - use MSI-X, >1 - limit number of MSI-X irqs to msi_x");
#else /* CONFIG_PCI_MSI */
#define msi_x (0)
#endif /* CONFIG_PCI_MSI */
static uint8_t num_vfs[3] = {0, 0, 0};
static int num_vfs_argc;
module_param_array(num_vfs, byte , &num_vfs_argc, 0444);
MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0\n"
"num_vfs=port1,port2,port1+2");
static uint8_t probe_vf[3] = {0, 0, 0};
static int probe_vfs_argc;
module_param_array(probe_vf, byte, &probe_vfs_argc, 0444);
MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)\n"
"probe_vf=port1,port2,port1+2");
static int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
module_param_named(log_num_mgm_entry_size,
mlx4_log_num_mgm_entry_size, int, 0444);
MODULE_PARM_DESC(log_num_mgm_entry_size, "log mgm size, that defines the num"
" of qp per mcg, for example:"
" 10 gives 248.range: 7 <="
" log_num_mgm_entry_size <= 12."
" To activate device managed"
" flow steering when available, set to -1");
static bool enable_64b_cqe_eqe = true;
module_param(enable_64b_cqe_eqe, bool, 0444);
MODULE_PARM_DESC(enable_64b_cqe_eqe,
"Enable 64 byte CQEs/EQEs when the FW supports this (default: True)");
static bool enable_4k_uar;
module_param(enable_4k_uar, bool, 0444);
MODULE_PARM_DESC(enable_4k_uar,
"Enable using 4K UAR. Should not be enabled if have VFs which do not support 4K UARs (default: false)");
#define PF_CONTEXT_BEHAVIOUR_MASK (MLX4_FUNC_CAP_64B_EQE_CQE | \
MLX4_FUNC_CAP_EQE_CQE_STRIDE | \
MLX4_FUNC_CAP_DMFS_A0_STATIC)
#define RESET_PERSIST_MASK_FLAGS (MLX4_FLAG_SRIOV)
static char mlx4_version[] =
DRV_NAME ": Mellanox ConnectX core driver v"
DRV_VERSION "\n";
static const struct mlx4_profile default_profile = {
.num_qp = 1 << 18,
.num_srq = 1 << 16,
.rdmarc_per_qp = 1 << 4,
.num_cq = 1 << 16,
.num_mcg = 1 << 13,
.num_mpt = 1 << 19,
.num_mtt = 1 << 20, /* It is really num mtt segements */
};
static const struct mlx4_profile low_mem_profile = {
.num_qp = 1 << 17,
.num_srq = 1 << 6,
.rdmarc_per_qp = 1 << 4,
.num_cq = 1 << 8,
.num_mcg = 1 << 8,
.num_mpt = 1 << 9,
.num_mtt = 1 << 7,
};
static int log_num_mac = 7;
module_param_named(log_num_mac, log_num_mac, int, 0444);
MODULE_PARM_DESC(log_num_mac, "Log2 max number of MACs per ETH port (1-7)");
static int log_num_vlan;
module_param_named(log_num_vlan, log_num_vlan, int, 0444);
MODULE_PARM_DESC(log_num_vlan, "Log2 max number of VLANs per ETH port (0-7)");
/* Log2 max number of VLANs per ETH port (0-7) */
#define MLX4_LOG_NUM_VLANS 7
#define MLX4_MIN_LOG_NUM_VLANS 0
#define MLX4_MIN_LOG_NUM_MAC 1
static bool use_prio;
module_param_named(use_prio, use_prio, bool, 0444);
MODULE_PARM_DESC(use_prio, "Enable steering by VLAN priority on ETH ports (deprecated)");
int log_mtts_per_seg = ilog2(1);
module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment "
"(0-7) (default: 0)");
static int port_type_array[2] = {MLX4_PORT_TYPE_NONE, MLX4_PORT_TYPE_NONE};
static int arr_argc = 2;
module_param_array(port_type_array, int, &arr_argc, 0444);
MODULE_PARM_DESC(port_type_array, "Array of port types: HW_DEFAULT (0) is default "
"1 for IB, 2 for Ethernet");
struct mlx4_port_config {
struct list_head list;
enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
struct pci_dev *pdev;
};
static atomic_t pf_loading = ATOMIC_INIT(0);
static int mlx4_devlink_ierr_reset_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
ctx->val.vbool = !!mlx4_internal_err_reset;
return 0;
}
static int mlx4_devlink_ierr_reset_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
mlx4_internal_err_reset = ctx->val.vbool;
return 0;
}
static int mlx4_devlink_crdump_snapshot_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
struct mlx4_priv *priv = devlink_priv(devlink);
struct mlx4_dev *dev = &priv->dev;
ctx->val.vbool = dev->persist->crdump.snapshot_enable;
return 0;
}
static int mlx4_devlink_crdump_snapshot_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
struct mlx4_priv *priv = devlink_priv(devlink);
struct mlx4_dev *dev = &priv->dev;
dev->persist->crdump.snapshot_enable = ctx->val.vbool;
return 0;
}
static int
mlx4_devlink_max_macs_validate(struct devlink *devlink, u32 id,
union devlink_param_value val,
struct netlink_ext_ack *extack)
{
u32 value = val.vu32;
if (value < 1 || value > 128)
return -ERANGE;
if (!is_power_of_2(value)) {
NL_SET_ERR_MSG_MOD(extack, "max_macs supported must be power of 2");
return -EINVAL;
}
return 0;
}
enum mlx4_devlink_param_id {
MLX4_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
};
static const struct devlink_param mlx4_devlink_params[] = {
DEVLINK_PARAM_GENERIC(INT_ERR_RESET,
BIT(DEVLINK_PARAM_CMODE_RUNTIME) |
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
mlx4_devlink_ierr_reset_get,
mlx4_devlink_ierr_reset_set, NULL),
DEVLINK_PARAM_GENERIC(MAX_MACS,
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
NULL, NULL, mlx4_devlink_max_macs_validate),
DEVLINK_PARAM_GENERIC(REGION_SNAPSHOT,
BIT(DEVLINK_PARAM_CMODE_RUNTIME) |
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
mlx4_devlink_crdump_snapshot_get,
mlx4_devlink_crdump_snapshot_set, NULL),
DEVLINK_PARAM_DRIVER(MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
"enable_64b_cqe_eqe", DEVLINK_PARAM_TYPE_BOOL,
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
NULL, NULL, NULL),
DEVLINK_PARAM_DRIVER(MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
"enable_4k_uar", DEVLINK_PARAM_TYPE_BOOL,
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
NULL, NULL, NULL),
};
static void mlx4_devlink_set_params_init_values(struct devlink *devlink)
{
union devlink_param_value value;
value.vbool = !!mlx4_internal_err_reset;
devlink_param_driverinit_value_set(devlink,
DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
value);
value.vu32 = 1UL << log_num_mac;
devlink_param_driverinit_value_set(devlink,
DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
value);
value.vbool = enable_64b_cqe_eqe;
devlink_param_driverinit_value_set(devlink,
MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
value);
value.vbool = enable_4k_uar;
devlink_param_driverinit_value_set(devlink,
MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
value);
value.vbool = false;
devlink_param_driverinit_value_set(devlink,
DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
value);
}
static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{
/* The reserved_uars is calculated by system page size unit.
* Therefore, adjustment is added when the uar page size is less
* than the system page size
*/
dev->caps.reserved_uars =
max_t(int,
mlx4_get_num_reserved_uar(dev),
dev_cap->reserved_uars /
(1 << (PAGE_SHIFT - dev->uar_page_shift)));
}
int mlx4_check_port_params(struct mlx4_dev *dev,
enum mlx4_port_type *port_type)
{
int i;
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
for (i = 0; i < dev->caps.num_ports - 1; i++) {
if (port_type[i] != port_type[i + 1]) {
mlx4_err(dev, "Only same port types supported on this HCA, aborting\n");
return -EOPNOTSUPP;
}
}
}
for (i = 0; i < dev->caps.num_ports; i++) {
if (!(port_type[i] & dev->caps.supported_type[i+1])) {
mlx4_err(dev, "Requested port type for port %d is not supported on this HCA\n",
i + 1);
return -EOPNOTSUPP;
}
}
return 0;
}
static void mlx4_set_port_mask(struct mlx4_dev *dev)
{
int i;
for (i = 1; i <= dev->caps.num_ports; ++i)
dev->caps.port_mask[i] = dev->caps.port_type[i];
}
enum {
MLX4_QUERY_FUNC_NUM_SYS_EQS = 1 << 0,
};
static int mlx4_query_func(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
{
int err = 0;
struct mlx4_func func;
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) {
err = mlx4_QUERY_FUNC(dev, &func, 0);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
return err;
}
dev_cap->max_eqs = func.max_eq;
dev_cap->reserved_eqs = func.rsvd_eqs;
dev_cap->reserved_uars = func.rsvd_uars;
err |= MLX4_QUERY_FUNC_NUM_SYS_EQS;
}
return err;
}
static void mlx4_enable_cqe_eqe_stride(struct mlx4_dev *dev)
{
struct mlx4_caps *dev_cap = &dev->caps;
/* FW not supporting or cancelled by user */
if (!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_EQE_STRIDE) ||
!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_CQE_STRIDE))
return;
/* Must have 64B CQE_EQE enabled by FW to use bigger stride
* When FW has NCSI it may decide not to report 64B CQE/EQEs
*/
if (!(dev_cap->flags & MLX4_DEV_CAP_FLAG_64B_EQE) ||
!(dev_cap->flags & MLX4_DEV_CAP_FLAG_64B_CQE)) {
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_CQE_STRIDE;
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_EQE_STRIDE;
return;
}
if (cache_line_size() == 128 || cache_line_size() == 256) {
mlx4_dbg(dev, "Enabling CQE stride cacheLine supported\n");
/* Changing the real data inside CQE size to 32B */
dev_cap->flags &= ~MLX4_DEV_CAP_FLAG_64B_CQE;
dev_cap->flags &= ~MLX4_DEV_CAP_FLAG_64B_EQE;
if (mlx4_is_master(dev))
dev_cap->function_caps |= MLX4_FUNC_CAP_EQE_CQE_STRIDE;
} else {
if (cache_line_size() != 32 && cache_line_size() != 64)
mlx4_dbg(dev, "Disabling CQE stride, cacheLine size unsupported\n");
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_CQE_STRIDE;
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_EQE_STRIDE;
}
}
static int _mlx4_dev_port(struct mlx4_dev *dev, int port,
struct mlx4_port_cap *port_cap)
{
dev->caps.vl_cap[port] = port_cap->max_vl;
dev->caps.ib_mtu_cap[port] = port_cap->ib_mtu;
dev->phys_caps.gid_phys_table_len[port] = port_cap->max_gids;
dev->phys_caps.pkey_phys_table_len[port] = port_cap->max_pkeys;
/* set gid and pkey table operating lengths by default
* to non-sriov values
*/
dev->caps.gid_table_len[port] = port_cap->max_gids;
dev->caps.pkey_table_len[port] = port_cap->max_pkeys;
dev->caps.port_width_cap[port] = port_cap->max_port_width;
dev->caps.eth_mtu_cap[port] = port_cap->eth_mtu;
dev->caps.max_tc_eth = port_cap->max_tc_eth;
dev->caps.def_mac[port] = port_cap->def_mac;
dev->caps.supported_type[port] = port_cap->supported_port_types;
dev->caps.suggested_type[port] = port_cap->suggested_type;
dev->caps.default_sense[port] = port_cap->default_sense;
dev->caps.trans_type[port] = port_cap->trans_type;
dev->caps.vendor_oui[port] = port_cap->vendor_oui;
dev->caps.wavelength[port] = port_cap->wavelength;
dev->caps.trans_code[port] = port_cap->trans_code;
return 0;
}
static int mlx4_dev_port(struct mlx4_dev *dev, int port,
struct mlx4_port_cap *port_cap)
{
int err = 0;
err = mlx4_QUERY_PORT(dev, port, port_cap);
if (err)
mlx4_err(dev, "QUERY_PORT command failed.\n");
return err;
}
static inline void mlx4_enable_ignore_fcs(struct mlx4_dev *dev)
{
if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_IGNORE_FCS))
return;
if (mlx4_is_mfunc(dev)) {
mlx4_dbg(dev, "SRIOV mode - Disabling Ignore FCS");
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_IGNORE_FCS;
return;
}
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_FCS_KEEP)) {
mlx4_dbg(dev,
"Keep FCS is not supported - Disabling Ignore FCS");
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_IGNORE_FCS;
return;
}
}
#define MLX4_A0_STEERING_TABLE_SIZE 256
static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
{
int err;
int i;
err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting\n");
return err;
}
mlx4_dev_cap_dump(dev, dev_cap);
if (dev_cap->min_page_sz > PAGE_SIZE) {
mlx4_err(dev, "HCA minimum page size of %d bigger than kernel PAGE_SIZE of %ld, aborting\n",
dev_cap->min_page_sz, PAGE_SIZE);
return -ENODEV;
}
if (dev_cap->num_ports > MLX4_MAX_PORTS) {
mlx4_err(dev, "HCA has %d ports, but we only support %d, aborting\n",
dev_cap->num_ports, MLX4_MAX_PORTS);
return -ENODEV;
}
if (dev_cap->uar_size > pci_resource_len(dev->persist->pdev, 2)) {
mlx4_err(dev, "HCA reported UAR size of 0x%x bigger than PCI resource 2 size of 0x%llx, aborting\n",
dev_cap->uar_size,
(unsigned long long)
pci_resource_len(dev->persist->pdev, 2));
return -ENODEV;
}
dev->caps.num_ports = dev_cap->num_ports;
dev->caps.num_sys_eqs = dev_cap->num_sys_eqs;
dev->phys_caps.num_phys_eqs = dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS ?
dev->caps.num_sys_eqs :
MLX4_MAX_EQ_NUM;
for (i = 1; i <= dev->caps.num_ports; ++i) {
err = _mlx4_dev_port(dev, i, dev_cap->port_cap + i);
if (err) {
mlx4_err(dev, "QUERY_PORT command failed, aborting\n");
return err;
}
}
dev->caps.uar_page_size = PAGE_SIZE;
dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE;
dev->caps.local_ca_ack_delay = dev_cap->local_ca_ack_delay;
dev->caps.bf_reg_size = dev_cap->bf_reg_size;
dev->caps.bf_regs_per_page = dev_cap->bf_regs_per_page;
dev->caps.max_sq_sg = dev_cap->max_sq_sg;
dev->caps.max_rq_sg = dev_cap->max_rq_sg;
dev->caps.max_wqes = dev_cap->max_qp_sz;
dev->caps.max_qp_init_rdma = dev_cap->max_requester_per_qp;
dev->caps.max_srq_wqes = dev_cap->max_srq_sz;
dev->caps.max_srq_sge = dev_cap->max_rq_sg - 1;
dev->caps.reserved_srqs = dev_cap->reserved_srqs;
dev->caps.max_sq_desc_sz = dev_cap->max_sq_desc_sz;
dev->caps.max_rq_desc_sz = dev_cap->max_rq_desc_sz;
/*
* Subtract 1 from the limit because we need to allocate a
* spare CQE so the HCA HW can tell the difference between an
* empty CQ and a full CQ.
*/
dev->caps.max_cqes = dev_cap->max_cq_sz - 1;
dev->caps.reserved_cqs = dev_cap->reserved_cqs;
dev->caps.reserved_eqs = dev_cap->reserved_eqs;
dev->caps.reserved_mtts = dev_cap->reserved_mtts;
dev->caps.reserved_mrws = dev_cap->reserved_mrws;
dev->caps.reserved_pds = dev_cap->reserved_pds;
dev->caps.reserved_xrcds = (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) ?
dev_cap->reserved_xrcds : 0;
dev->caps.max_xrcds = (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) ?
dev_cap->max_xrcds : 0;
dev->caps.mtt_entry_sz = dev_cap->mtt_entry_sz;
dev->caps.max_msg_sz = dev_cap->max_msg_sz;
dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1);
dev->caps.flags = dev_cap->flags;
dev->caps.flags2 = dev_cap->flags2;
dev->caps.bmme_flags = dev_cap->bmme_flags;
dev->caps.reserved_lkey = dev_cap->reserved_lkey;
dev->caps.stat_rate_support = dev_cap->stat_rate_support;
dev->caps.max_gso_sz = dev_cap->max_gso_sz;
dev->caps.max_rss_tbl_sz = dev_cap->max_rss_tbl_sz;
dev->caps.wol_port[1] = dev_cap->wol_port[1];
dev->caps.wol_port[2] = dev_cap->wol_port[2];
dev->caps.health_buffer_addrs = dev_cap->health_buffer_addrs;
/* Save uar page shift */
if (!mlx4_is_slave(dev)) {
/* Virtual PCI function needs to determine UAR page size from
* firmware. Only master PCI function can set the uar page size
*/
if (enable_4k_uar || !dev->persist->num_vfs)
dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT;
else
dev->uar_page_shift = PAGE_SHIFT;
mlx4_set_num_reserved_uars(dev, dev_cap);
}
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_PHV_EN) {
struct mlx4_init_hca_param hca_param;
memset(&hca_param, 0, sizeof(hca_param));
err = mlx4_QUERY_HCA(dev, &hca_param);
/* Turn off PHV_EN flag in case phv_check_en is set.
* phv_check_en is a HW check that parse the packet and verify
* phv bit was reported correctly in the wqe. To allow QinQ
* PHV_EN flag should be set and phv_check_en must be cleared
* otherwise QinQ packets will be drop by the HW.
*/
if (err || hca_param.phv_check_en)
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_PHV_EN;
}
/* Sense port always allowed on supported devices for ConnectX-1 and -2 */
if (mlx4_priv(dev)->pci_dev_data & MLX4_PCI_DEV_FORCE_SENSE_PORT)
dev->caps.flags |= MLX4_DEV_CAP_FLAG_SENSE_SUPPORT;
/* Don't do sense port on multifunction devices (for now at least) */
if (mlx4_is_mfunc(dev))
dev->caps.flags &= ~MLX4_DEV_CAP_FLAG_SENSE_SUPPORT;
if (mlx4_low_memory_profile()) {
dev->caps.log_num_macs = MLX4_MIN_LOG_NUM_MAC;
dev->caps.log_num_vlans = MLX4_MIN_LOG_NUM_VLANS;
} else {
dev->caps.log_num_macs = log_num_mac;
dev->caps.log_num_vlans = MLX4_LOG_NUM_VLANS;
}
for (i = 1; i <= dev->caps.num_ports; ++i) {
dev->caps.port_type[i] = MLX4_PORT_TYPE_NONE;
if (dev->caps.supported_type[i]) {
/* if only ETH is supported - assign ETH */
if (dev->caps.supported_type[i] == MLX4_PORT_TYPE_ETH)
dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
/* if only IB is supported, assign IB */
else if (dev->caps.supported_type[i] ==
MLX4_PORT_TYPE_IB)
dev->caps.port_type[i] = MLX4_PORT_TYPE_IB;
else {
/* if IB and ETH are supported, we set the port
* type according to user selection of port type;
* if user selected none, take the FW hint */
if (port_type_array[i - 1] == MLX4_PORT_TYPE_NONE)
dev->caps.port_type[i] = dev->caps.suggested_type[i] ?
MLX4_PORT_TYPE_ETH : MLX4_PORT_TYPE_IB;
else
dev->caps.port_type[i] = port_type_array[i - 1];
}
}
/*
* Link sensing is allowed on the port if 3 conditions are true:
* 1. Both protocols are supported on the port.
* 2. Different types are supported on the port
* 3. FW declared that it supports link sensing
*/
mlx4_priv(dev)->sense.sense_allowed[i] =
((dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO) &&
(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP) &&
(dev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT));
/*
* If "default_sense" bit is set, we move the port to "AUTO" mode
* and perform sense_port FW command to try and set the correct
* port type from beginning
*/
if (mlx4_priv(dev)->sense.sense_allowed[i] && dev->caps.default_sense[i]) {
enum mlx4_port_type sensed_port = MLX4_PORT_TYPE_NONE;
dev->caps.possible_type[i] = MLX4_PORT_TYPE_AUTO;
mlx4_SENSE_PORT(dev, i, &sensed_port);
if (sensed_port != MLX4_PORT_TYPE_NONE)
dev->caps.port_type[i] = sensed_port;
} else {
dev->caps.possible_type[i] = dev->caps.port_type[i];
}
if (dev->caps.log_num_macs > dev_cap->port_cap[i].log_max_macs) {
dev->caps.log_num_macs = dev_cap->port_cap[i].log_max_macs;
mlx4_warn(dev, "Requested number of MACs is too much for port %d, reducing to %d\n",
i, 1 << dev->caps.log_num_macs);
}
if (dev->caps.log_num_vlans > dev_cap->port_cap[i].log_max_vlans) {
dev->caps.log_num_vlans = dev_cap->port_cap[i].log_max_vlans;
mlx4_warn(dev, "Requested number of VLANs is too much for port %d, reducing to %d\n",
i, 1 << dev->caps.log_num_vlans);
}
}
if (mlx4_is_master(dev) && (dev->caps.num_ports == 2) &&
(port_type_array[0] == MLX4_PORT_TYPE_IB) &&
(port_type_array[1] == MLX4_PORT_TYPE_ETH)) {
mlx4_warn(dev,
"Granular QoS per VF not supported with IB/Eth configuration\n");
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_QOS_VPP;
}
dev->caps.max_counters = dev_cap->max_counters;
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps;
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] =
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] =
(1 << dev->caps.log_num_macs) *
(1 << dev->caps.log_num_vlans) *
dev->caps.num_ports;
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH] = MLX4_NUM_FEXCH;
if (dev_cap->dmfs_high_rate_qpn_base > 0 &&
dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FS_EN)
dev->caps.dmfs_high_rate_qpn_base = dev_cap->dmfs_high_rate_qpn_base;
else
dev->caps.dmfs_high_rate_qpn_base =
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW];
if (dev_cap->dmfs_high_rate_qpn_range > 0 &&
dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FS_EN) {
dev->caps.dmfs_high_rate_qpn_range = dev_cap->dmfs_high_rate_qpn_range;
dev->caps.dmfs_high_steer_mode = MLX4_STEERING_DMFS_A0_DEFAULT;
dev->caps.flags2 |= MLX4_DEV_CAP_FLAG2_FS_A0;
} else {
dev->caps.dmfs_high_steer_mode = MLX4_STEERING_DMFS_A0_NOT_SUPPORTED;
dev->caps.dmfs_high_rate_qpn_base =
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW];
dev->caps.dmfs_high_rate_qpn_range = MLX4_A0_STEERING_TABLE_SIZE;
}
dev->caps.rl_caps = dev_cap->rl_caps;
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_RSS_RAW_ETH] =
dev->caps.dmfs_high_rate_qpn_range;
dev->caps.reserved_qps = dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] +
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] +
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] +
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH];
dev->caps.sqp_demux = (mlx4_is_master(dev)) ? MLX4_MAX_NUM_SLAVES : 0;
if (!enable_64b_cqe_eqe && !mlx4_is_slave(dev)) {
if (dev_cap->flags &
(MLX4_DEV_CAP_FLAG_64B_CQE | MLX4_DEV_CAP_FLAG_64B_EQE)) {
mlx4_warn(dev, "64B EQEs/CQEs supported by the device but not enabled\n");
dev->caps.flags &= ~MLX4_DEV_CAP_FLAG_64B_CQE;
dev->caps.flags &= ~MLX4_DEV_CAP_FLAG_64B_EQE;
}
if (dev_cap->flags2 &
(MLX4_DEV_CAP_FLAG2_CQE_STRIDE |
MLX4_DEV_CAP_FLAG2_EQE_STRIDE)) {
mlx4_warn(dev, "Disabling EQE/CQE stride per user request\n");
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_CQE_STRIDE;
dev_cap->flags2 &= ~MLX4_DEV_CAP_FLAG2_EQE_STRIDE;
}
}
if ((dev->caps.flags &
(MLX4_DEV_CAP_FLAG_64B_CQE | MLX4_DEV_CAP_FLAG_64B_EQE)) &&
mlx4_is_master(dev))
dev->caps.function_caps |= MLX4_FUNC_CAP_64B_EQE_CQE;
if (!mlx4_is_slave(dev)) {
mlx4_enable_cqe_eqe_stride(dev);
dev->caps.alloc_res_qp_mask =
(dev->caps.bf_reg_size ? MLX4_RESERVE_ETH_BF_QP : 0) |
MLX4_RESERVE_A0_QP;
if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) &&
dev->caps.flags & MLX4_DEV_CAP_FLAG_SET_ETH_SCHED) {
mlx4_warn(dev, "Old device ETS support detected\n");
mlx4_warn(dev, "Consider upgrading device FW.\n");
dev->caps.flags2 |= MLX4_DEV_CAP_FLAG2_ETS_CFG;
}
} else {
dev->caps.alloc_res_qp_mask = 0;
}
mlx4_enable_ignore_fcs(dev);
return 0;
}
/*The function checks if there are live vf, return the num of them*/
static int mlx4_how_many_lives_vf(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_slave_state *s_state;
int i;
int ret = 0;
for (i = 1/*the ppf is 0*/; i < dev->num_slaves; ++i) {
s_state = &priv->mfunc.master.slave_state[i];
if (s_state->active && s_state->last_cmd !=
MLX4_COMM_CMD_RESET) {
mlx4_warn(dev, "%s: slave: %d is still active\n",
__func__, i);
ret++;
}
}
return ret;
}
int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey)
{
u32 qk = MLX4_RESERVED_QKEY_BASE;
if (qpn >= dev->phys_caps.base_tunnel_sqpn + 8 * MLX4_MFUNC_MAX ||
qpn < dev->phys_caps.base_proxy_sqpn)
return -EINVAL;
if (qpn >= dev->phys_caps.base_tunnel_sqpn)
/* tunnel qp */
qk += qpn - dev->phys_caps.base_tunnel_sqpn;
else
qk += qpn - dev->phys_caps.base_proxy_sqpn;
*qkey = qk;
return 0;
}
EXPORT_SYMBOL(mlx4_get_parav_qkey);
void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port, int i, int val)
{
struct mlx4_priv *priv = container_of(dev, struct mlx4_priv, dev);
if (!mlx4_is_master(dev))
return;
priv->virt2phys_pkey[slave][port - 1][i] = val;
}
EXPORT_SYMBOL(mlx4_sync_pkey_table);
void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid)
{
struct mlx4_priv *priv = container_of(dev, struct mlx4_priv, dev);
if (!mlx4_is_master(dev))
return;
priv->slave_node_guids[slave] = guid;
}
EXPORT_SYMBOL(mlx4_put_slave_node_guid);
__be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave)
{
struct mlx4_priv *priv = container_of(dev, struct mlx4_priv, dev);
if (!mlx4_is_master(dev))
return 0;
return priv->slave_node_guids[slave];
}
EXPORT_SYMBOL(mlx4_get_slave_node_guid);
int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_slave_state *s_slave;
if (!mlx4_is_master(dev))
return 0;
s_slave = &priv->mfunc.master.slave_state[slave];
return !!s_slave->active;
}
EXPORT_SYMBOL(mlx4_is_slave_active);
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
struct _rule_hw *eth_header)
{
if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
struct mlx4_net_trans_rule_hw_eth *eth =
(struct mlx4_net_trans_rule_hw_eth *)eth_header;
struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
next_rule->rsvd == 0;
if (last_rule)
ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
}
}
EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
static void slave_adjust_steering_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap,
struct mlx4_init_hca_param *hca_param)
{
dev->caps.steering_mode = hca_param->steering_mode;
if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) {
dev->caps.num_qp_per_mgm = dev_cap->fs_max_num_qp_per_entry;
dev->caps.fs_log_max_ucast_qp_range_size =
dev_cap->fs_log_max_ucast_qp_range_size;
} else
dev->caps.num_qp_per_mgm =
4 * ((1 << hca_param->log_mc_entry_sz)/16 - 2);
mlx4_dbg(dev, "Steering mode is: %s\n",
mlx4_steering_mode_str(dev->caps.steering_mode));
}
static void mlx4_slave_destroy_special_qp_cap(struct mlx4_dev *dev)
{
kfree(dev->caps.spec_qps);
dev->caps.spec_qps = NULL;
}
static int mlx4_slave_special_qp_cap(struct mlx4_dev *dev)
{
struct mlx4_func_cap *func_cap = NULL;
struct mlx4_caps *caps = &dev->caps;
int i, err = 0;
func_cap = kzalloc(sizeof(*func_cap), GFP_KERNEL);
caps->spec_qps = kcalloc(caps->num_ports, sizeof(*caps->spec_qps), GFP_KERNEL);
if (!func_cap || !caps->spec_qps) {
mlx4_err(dev, "Failed to allocate memory for special qps cap\n");
err = -ENOMEM;
goto err_mem;
}
for (i = 1; i <= caps->num_ports; ++i) {
err = mlx4_QUERY_FUNC_CAP(dev, i, func_cap);
if (err) {
mlx4_err(dev, "QUERY_FUNC_CAP port command failed for port %d, aborting (%d)\n",
i, err);
goto err_mem;
}
caps->spec_qps[i - 1] = func_cap->spec_qps;
caps->port_mask[i] = caps->port_type[i];
caps->phys_port_id[i] = func_cap->phys_port_id;
err = mlx4_get_slave_pkey_gid_tbl_len(dev, i,
&caps->gid_table_len[i],
&caps->pkey_table_len[i]);
if (err) {
mlx4_err(dev, "QUERY_PORT command failed for port %d, aborting (%d)\n",
i, err);
goto err_mem;
}
}
err_mem:
if (err)
mlx4_slave_destroy_special_qp_cap(dev);
kfree(func_cap);
return err;
}
static int mlx4_slave_cap(struct mlx4_dev *dev)
{
int err;
u32 page_size;
struct mlx4_dev_cap *dev_cap = NULL;
struct mlx4_func_cap *func_cap = NULL;
struct mlx4_init_hca_param *hca_param = NULL;
hca_param = kzalloc(sizeof(*hca_param), GFP_KERNEL);
func_cap = kzalloc(sizeof(*func_cap), GFP_KERNEL);
dev_cap = kzalloc(sizeof(*dev_cap), GFP_KERNEL);
if (!hca_param || !func_cap || !dev_cap) {
mlx4_err(dev, "Failed to allocate memory for slave_cap\n");
err = -ENOMEM;
goto free_mem;
}
err = mlx4_QUERY_HCA(dev, hca_param);
if (err) {
mlx4_err(dev, "QUERY_HCA command failed, aborting\n");
goto free_mem;
}
/* fail if the hca has an unknown global capability
* at this time global_caps should be always zeroed
*/
if (hca_param->global_caps) {
mlx4_err(dev, "Unknown hca global capabilities\n");
err = -EINVAL;
goto free_mem;
}
dev->caps.hca_core_clock = hca_param->hca_core_clock;
dev->caps.max_qp_dest_rdma = 1 << hca_param->log_rd_per_qp;
err = mlx4_dev_cap(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting\n");
goto free_mem;
}
err = mlx4_QUERY_FW(dev);
if (err)
mlx4_err(dev, "QUERY_FW command failed: could not get FW version\n");
page_size = ~dev->caps.page_size_cap + 1;
mlx4_warn(dev, "HCA minimum page size:%d\n", page_size);
if (page_size > PAGE_SIZE) {
mlx4_err(dev, "HCA minimum page size of %d bigger than kernel PAGE_SIZE of %ld, aborting\n",
page_size, PAGE_SIZE);
err = -ENODEV;
goto free_mem;
}
/* Set uar_page_shift for VF */
dev->uar_page_shift = hca_param->uar_page_sz + 12;
/* Make sure the master uar page size is valid */
if (dev->uar_page_shift > PAGE_SHIFT) {
mlx4_err(dev,
"Invalid configuration: uar page size is larger than system page size\n");
err = -ENODEV;
goto free_mem;
}
/* Set reserved_uars based on the uar_page_shift */
mlx4_set_num_reserved_uars(dev, dev_cap);
/* Although uar page size in FW differs from system page size,
* upper software layers (mlx4_ib, mlx4_en and part of mlx4_core)
* still works with assumption that uar page size == system page size
*/
dev->caps.uar_page_size = PAGE_SIZE;
err = mlx4_QUERY_FUNC_CAP(dev, 0, func_cap);
if (err) {
mlx4_err(dev, "QUERY_FUNC_CAP general command failed, aborting (%d)\n",
err);
goto free_mem;
}
if ((func_cap->pf_context_behaviour | PF_CONTEXT_BEHAVIOUR_MASK) !=
PF_CONTEXT_BEHAVIOUR_MASK) {
mlx4_err(dev, "Unknown pf context behaviour %x known flags %x\n",
func_cap->pf_context_behaviour,
PF_CONTEXT_BEHAVIOUR_MASK);
err = -EINVAL;
goto free_mem;
}
dev->caps.num_ports = func_cap->num_ports;
dev->quotas.qp = func_cap->qp_quota;
dev->quotas.srq = func_cap->srq_quota;
dev->quotas.cq = func_cap->cq_quota;
dev->quotas.mpt = func_cap->mpt_quota;
dev->quotas.mtt = func_cap->mtt_quota;
dev->caps.num_qps = 1 << hca_param->log_num_qps;
dev->caps.num_srqs = 1 << hca_param->log_num_srqs;
dev->caps.num_cqs = 1 << hca_param->log_num_cqs;
dev->caps.num_mpts = 1 << hca_param->log_mpt_sz;
dev->caps.num_eqs = func_cap->max_eq;
dev->caps.reserved_eqs = func_cap->reserved_eq;
dev->caps.reserved_lkey = func_cap->reserved_lkey;
dev->caps.num_pds = MLX4_NUM_PDS;
dev->caps.num_mgms = 0;
dev->caps.num_amgms = 0;
if (dev->caps.num_ports > MLX4_MAX_PORTS) {
mlx4_err(dev, "HCA has %d ports, but we only support %d, aborting\n",
dev->caps.num_ports, MLX4_MAX_PORTS);
err = -ENODEV;
goto free_mem;
}
mlx4_replace_zero_macs(dev);
err = mlx4_slave_special_qp_cap(dev);
if (err) {
mlx4_err(dev, "Set special QP caps failed. aborting\n");
goto free_mem;
}
if (dev->caps.uar_page_size * (dev->caps.num_uars -
dev->caps.reserved_uars) >
pci_resource_len(dev->persist->pdev,
2)) {
mlx4_err(dev, "HCA reported UAR region size of 0x%x bigger than PCI resource 2 size of 0x%llx, aborting\n",
dev->caps.uar_page_size * dev->caps.num_uars,
(unsigned long long)
pci_resource_len(dev->persist->pdev, 2));
err = -ENOMEM;
goto err_mem;
}
if (hca_param->dev_cap_enabled & MLX4_DEV_CAP_64B_EQE_ENABLED) {
dev->caps.eqe_size = 64;
dev->caps.eqe_factor = 1;
} else {
dev->caps.eqe_size = 32;
dev->caps.eqe_factor = 0;
}
if (hca_param->dev_cap_enabled & MLX4_DEV_CAP_64B_CQE_ENABLED) {
dev->caps.cqe_size = 64;
dev->caps.userspace_caps |= MLX4_USER_DEV_CAP_LARGE_CQE;
} else {
dev->caps.cqe_size = 32;
}
if (hca_param->dev_cap_enabled & MLX4_DEV_CAP_EQE_STRIDE_ENABLED) {
dev->caps.eqe_size = hca_param->eqe_size;
dev->caps.eqe_factor = 0;
}
if (hca_param->dev_cap_enabled & MLX4_DEV_CAP_CQE_STRIDE_ENABLED) {
dev->caps.cqe_size = hca_param->cqe_size;
/* User still need to know when CQE > 32B */
dev->caps.userspace_caps |= MLX4_USER_DEV_CAP_LARGE_CQE;
}
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS;
mlx4_warn(dev, "Timestamping is not supported in slave mode\n");
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_USER_MAC_EN;
mlx4_dbg(dev, "User MAC FW update is not supported in slave mode\n");
slave_adjust_steering_mode(dev, dev_cap, hca_param);
mlx4_dbg(dev, "RSS support for IP fragments is %s\n",
hca_param->rss_ip_frags ? "on" : "off");
if (func_cap->extra_flags & MLX4_QUERY_FUNC_FLAGS_BF_RES_QP &&
dev->caps.bf_reg_size)
dev->caps.alloc_res_qp_mask |= MLX4_RESERVE_ETH_BF_QP;
if (func_cap->extra_flags & MLX4_QUERY_FUNC_FLAGS_A0_RES_QP)
dev->caps.alloc_res_qp_mask |= MLX4_RESERVE_A0_QP;
err_mem:
if (err)
mlx4_slave_destroy_special_qp_cap(dev);
free_mem:
kfree(hca_param);
kfree(func_cap);
kfree(dev_cap);
return err;
}
static void mlx4_request_modules(struct mlx4_dev *dev)
{
int port;
int has_ib_port = false;
int has_eth_port = false;
#define EN_DRV_NAME "mlx4_en"
#define IB_DRV_NAME "mlx4_ib"
for (port = 1; port <= dev->caps.num_ports; port++) {
if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB)
has_ib_port = true;
else if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH)
has_eth_port = true;
}
if (has_eth_port)
request_module_nowait(EN_DRV_NAME);
if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
request_module_nowait(IB_DRV_NAME);
}
/*
* Change the port configuration of the device.
* Every user of this function must hold the port mutex.
*/
int mlx4_change_port_types(struct mlx4_dev *dev,
enum mlx4_port_type *port_types)
{
int err = 0;
int change = 0;
int port;
for (port = 0; port < dev->caps.num_ports; port++) {
/* Change the port type only if the new type is different
* from the current, and not set to Auto */
if (port_types[port] != dev->caps.port_type[port + 1])
change = 1;
}
if (change) {
mlx4_unregister_device(dev);
for (port = 1; port <= dev->caps.num_ports; port++) {
mlx4_CLOSE_PORT(dev, port);
dev->caps.port_type[port] = port_types[port - 1];
err = mlx4_SET_PORT(dev, port, -1);
if (err) {
mlx4_err(dev, "Failed to set port %d, aborting\n",
port);
goto out;
}
}
mlx4_set_port_mask(dev);
err = mlx4_register_device(dev);
if (err) {
mlx4_err(dev, "Failed to register device\n");
goto out;
}
mlx4_request_modules(dev);
}
out:
return err;
}
static ssize_t show_port_type(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
port_attr);
struct mlx4_dev *mdev = info->dev;
char type[8];
sprintf(type, "%s",
(mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_IB) ?
"ib" : "eth");
if (mdev->caps.possible_type[info->port] == MLX4_PORT_TYPE_AUTO)
sprintf(buf, "auto (%s)\n", type);
else
sprintf(buf, "%s\n", type);
return strlen(buf);
}
static int __set_port_type(struct mlx4_port_info *info,
enum mlx4_port_type port_type)
{
struct mlx4_dev *mdev = info->dev;
struct mlx4_priv *priv = mlx4_priv(mdev);
enum mlx4_port_type types[MLX4_MAX_PORTS];
enum mlx4_port_type new_types[MLX4_MAX_PORTS];
int i;
int err = 0;
if ((port_type & mdev->caps.supported_type[info->port]) != port_type) {
mlx4_err(mdev,
"Requested port type for port %d is not supported on this HCA\n",
info->port);
return -EOPNOTSUPP;
}
mlx4_stop_sense(mdev);
mutex_lock(&priv->port_mutex);
info->tmp_type = port_type;
/* Possible type is always the one that was delivered */
mdev->caps.possible_type[info->port] = info->tmp_type;
for (i = 0; i < mdev->caps.num_ports; i++) {
types[i] = priv->port[i+1].tmp_type ? priv->port[i+1].tmp_type :
mdev->caps.possible_type[i+1];
if (types[i] == MLX4_PORT_TYPE_AUTO)
types[i] = mdev->caps.port_type[i+1];
}
if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP) &&
!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT)) {
for (i = 1; i <= mdev->caps.num_ports; i++) {
if (mdev->caps.possible_type[i] == MLX4_PORT_TYPE_AUTO) {
mdev->caps.possible_type[i] = mdev->caps.port_type[i];
err = -EOPNOTSUPP;
}
}
}
if (err) {
mlx4_err(mdev, "Auto sensing is not supported on this HCA. Set only 'eth' or 'ib' for both ports (should be the same)\n");
goto out;
}
mlx4_do_sense_ports(mdev, new_types, types);
err = mlx4_check_port_params(mdev, new_types);
if (err)
goto out;
/* We are about to apply the changes after the configuration
* was verified, no need to remember the temporary types
* any more */
for (i = 0; i < mdev->caps.num_ports; i++)
priv->port[i + 1].tmp_type = 0;
err = mlx4_change_port_types(mdev, new_types);
out:
mlx4_start_sense(mdev);
mutex_unlock(&priv->port_mutex);
return err;
}
static ssize_t set_port_type(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
port_attr);
struct mlx4_dev *mdev = info->dev;
enum mlx4_port_type port_type;
static DEFINE_MUTEX(set_port_type_mutex);
int err;
mutex_lock(&set_port_type_mutex);
if (!strcmp(buf, "ib\n")) {
port_type = MLX4_PORT_TYPE_IB;
} else if (!strcmp(buf, "eth\n")) {
port_type = MLX4_PORT_TYPE_ETH;
} else if (!strcmp(buf, "auto\n")) {
port_type = MLX4_PORT_TYPE_AUTO;
} else {
mlx4_err(mdev, "%s is not supported port type\n", buf);
err = -EINVAL;
goto err_out;
}
err = __set_port_type(info, port_type);
err_out:
mutex_unlock(&set_port_type_mutex);
return err ? err : count;
}
enum ibta_mtu {
IB_MTU_256 = 1,
IB_MTU_512 = 2,
IB_MTU_1024 = 3,
IB_MTU_2048 = 4,
IB_MTU_4096 = 5
};
static inline int int_to_ibta_mtu(int mtu)
{
switch (mtu) {
case 256: return IB_MTU_256;
case 512: return IB_MTU_512;
case 1024: return IB_MTU_1024;
case 2048: return IB_MTU_2048;
case 4096: return IB_MTU_4096;
default: return -1;
}
}
static inline int ibta_mtu_to_int(enum ibta_mtu mtu)
{
switch (mtu) {
case IB_MTU_256: return 256;
case IB_MTU_512: return 512;
case IB_MTU_1024: return 1024;
case IB_MTU_2048: return 2048;
case IB_MTU_4096: return 4096;
default: return -1;
}
}
static ssize_t show_port_ib_mtu(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
port_mtu_attr);
struct mlx4_dev *mdev = info->dev;
if (mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_ETH)
mlx4_warn(mdev, "port level mtu is only used for IB ports\n");
sprintf(buf, "%d\n",
ibta_mtu_to_int(mdev->caps.port_ib_mtu[info->port]));
return strlen(buf);
}
static ssize_t set_port_ib_mtu(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
port_mtu_attr);
struct mlx4_dev *mdev = info->dev;
struct mlx4_priv *priv = mlx4_priv(mdev);
int err, port, mtu, ibta_mtu = -1;
if (mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_ETH) {
mlx4_warn(mdev, "port level mtu is only used for IB ports\n");
return -EINVAL;
}
err = kstrtoint(buf, 0, &mtu);
if (!err)
ibta_mtu = int_to_ibta_mtu(mtu);
if (err || ibta_mtu < 0) {
mlx4_err(mdev, "%s is invalid IBTA mtu\n", buf);
return -EINVAL;
}
mdev->caps.port_ib_mtu[info->port] = ibta_mtu;
mlx4_stop_sense(mdev);
mutex_lock(&priv->port_mutex);
mlx4_unregister_device(mdev);
for (port = 1; port <= mdev->caps.num_ports; port++) {
mlx4_CLOSE_PORT(mdev, port);
err = mlx4_SET_PORT(mdev, port, -1);
if (err) {
mlx4_err(mdev, "Failed to set port %d, aborting\n",
port);
goto err_set_port;
}
}
err = mlx4_register_device(mdev);
err_set_port:
mutex_unlock(&priv->port_mutex);
mlx4_start_sense(mdev);
return err ? err : count;
}
/* bond for multi-function device */
#define MAX_MF_BOND_ALLOWED_SLAVES 63
static int mlx4_mf_bond(struct mlx4_dev *dev)
{
int err = 0;
int nvfs;
struct mlx4_slaves_pport slaves_port1;
struct mlx4_slaves_pport slaves_port2;
DECLARE_BITMAP(slaves_port_1_2, MLX4_MFUNC_MAX);
slaves_port1 = mlx4_phys_to_slaves_pport(dev, 1);
slaves_port2 = mlx4_phys_to_slaves_pport(dev, 2);
bitmap_and(slaves_port_1_2,
slaves_port1.slaves, slaves_port2.slaves,
dev->persist->num_vfs + 1);
/* only single port vfs are allowed */
if (bitmap_weight(slaves_port_1_2, dev->persist->num_vfs + 1) > 1) {
mlx4_warn(dev, "HA mode unsupported for dual ported VFs\n");
return -EINVAL;
}
/* number of virtual functions is number of total functions minus one
* physical function for each port.
*/
nvfs = bitmap_weight(slaves_port1.slaves, dev->persist->num_vfs + 1) +
bitmap_weight(slaves_port2.slaves, dev->persist->num_vfs + 1) - 2;
/* limit on maximum allowed VFs */
if (nvfs > MAX_MF_BOND_ALLOWED_SLAVES) {
mlx4_warn(dev, "HA mode is not supported for %d VFs (max %d are allowed)\n",
nvfs, MAX_MF_BOND_ALLOWED_SLAVES);
return -EINVAL;
}
if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) {
mlx4_warn(dev, "HA mode unsupported for NON DMFS steering\n");
return -EINVAL;
}
err = mlx4_bond_mac_table(dev);
if (err)
return err;
err = mlx4_bond_vlan_table(dev);
if (err)
goto err1;
err = mlx4_bond_fs_rules(dev);
if (err)
goto err2;
return 0;
err2:
(void)mlx4_unbond_vlan_table(dev);
err1:
(void)mlx4_unbond_mac_table(dev);
return err;
}
static int mlx4_mf_unbond(struct mlx4_dev *dev)
{
int ret, ret1;
ret = mlx4_unbond_fs_rules(dev);
if (ret)
mlx4_warn(dev, "multifunction unbond for flow rules failed (%d)\n", ret);
ret1 = mlx4_unbond_mac_table(dev);
if (ret1) {
mlx4_warn(dev, "multifunction unbond for MAC table failed (%d)\n", ret1);
ret = ret1;
}
ret1 = mlx4_unbond_vlan_table(dev);
if (ret1) {
mlx4_warn(dev, "multifunction unbond for VLAN table failed (%d)\n", ret1);
ret = ret1;
}
return ret;
}
int mlx4_bond(struct mlx4_dev *dev)
{
int ret = 0;
struct mlx4_priv *priv = mlx4_priv(dev);
mutex_lock(&priv->bond_mutex);
if (!mlx4_is_bonded(dev)) {
ret = mlx4_do_bond(dev, true);
if (ret)
mlx4_err(dev, "Failed to bond device: %d\n", ret);
if (!ret && mlx4_is_master(dev)) {
ret = mlx4_mf_bond(dev);
if (ret) {
mlx4_err(dev, "bond for multifunction failed\n");
mlx4_do_bond(dev, false);
}
}
}
mutex_unlock(&priv->bond_mutex);
if (!ret)
mlx4_dbg(dev, "Device is bonded\n");
return ret;
}
EXPORT_SYMBOL_GPL(mlx4_bond);
int mlx4_unbond(struct mlx4_dev *dev)
{
int ret = 0;
struct mlx4_priv *priv = mlx4_priv(dev);
mutex_lock(&priv->bond_mutex);
if (mlx4_is_bonded(dev)) {
int ret2 = 0;
ret = mlx4_do_bond(dev, false);
if (ret)
mlx4_err(dev, "Failed to unbond device: %d\n", ret);
if (mlx4_is_master(dev))
ret2 = mlx4_mf_unbond(dev);
if (ret2) {
mlx4_warn(dev, "Failed to unbond device for multifunction (%d)\n", ret2);
ret = ret2;
}
}
mutex_unlock(&priv->bond_mutex);
if (!ret)
mlx4_dbg(dev, "Device is unbonded\n");
return ret;
}
EXPORT_SYMBOL_GPL(mlx4_unbond);
int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p)
{
u8 port1 = v2p->port1;
u8 port2 = v2p->port2;
struct mlx4_priv *priv = mlx4_priv(dev);
int err;
if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_PORT_REMAP))
return -EOPNOTSUPP;
mutex_lock(&priv->bond_mutex);
/* zero means keep current mapping for this port */
if (port1 == 0)
port1 = priv->v2p.port1;
if (port2 == 0)
port2 = priv->v2p.port2;
if ((port1 < 1) || (port1 > MLX4_MAX_PORTS) ||
(port2 < 1) || (port2 > MLX4_MAX_PORTS) ||
(port1 == 2 && port2 == 1)) {
/* besides boundary checks cross mapping makes
* no sense and therefore not allowed */
err = -EINVAL;
} else if ((port1 == priv->v2p.port1) &&
(port2 == priv->v2p.port2)) {
err = 0;
} else {
err = mlx4_virt2phy_port_map(dev, port1, port2);
if (!err) {
mlx4_dbg(dev, "port map changed: [%d][%d]\n",
port1, port2);
priv->v2p.port1 = port1;
priv->v2p.port2 = port2;
} else {
mlx4_err(dev, "Failed to change port mape: %d\n", err);
}
}
mutex_unlock(&priv->bond_mutex);
return err;
}
EXPORT_SYMBOL_GPL(mlx4_port_map_set);
static int mlx4_load_fw(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int err;
priv->fw.fw_icm = mlx4_alloc_icm(dev, priv->fw.fw_pages,
GFP_HIGHUSER | __GFP_NOWARN, 0);
if (!priv->fw.fw_icm) {
mlx4_err(dev, "Couldn't allocate FW area, aborting\n");
return -ENOMEM;
}
err = mlx4_MAP_FA(dev, priv->fw.fw_icm);
if (err) {
mlx4_err(dev, "MAP_FA command failed, aborting\n");
goto err_free;
}
err = mlx4_RUN_FW(dev);
if (err) {
mlx4_err(dev, "RUN_FW command failed, aborting\n");
goto err_unmap_fa;
}
return 0;
err_unmap_fa:
mlx4_UNMAP_FA(dev);
err_free:
mlx4_free_icm(dev, priv->fw.fw_icm, 0);
return err;
}
static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
int cmpt_entry_sz)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int err;
int num_eqs;
err = mlx4_init_icm_table(dev, &priv->qp_table.cmpt_table,
cmpt_base +
((u64) (MLX4_CMPT_TYPE_QP *
cmpt_entry_sz) << MLX4_CMPT_SHIFT),
cmpt_entry_sz, dev->caps.num_qps,
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
0, 0);
if (err)
goto err;
err = mlx4_init_icm_table(dev, &priv->srq_table.cmpt_table,
cmpt_base +
((u64) (MLX4_CMPT_TYPE_SRQ *
cmpt_entry_sz) << MLX4_CMPT_SHIFT),
cmpt_entry_sz, dev->caps.num_srqs,
dev->caps.reserved_srqs, 0, 0);
if (err)
goto err_qp;
err = mlx4_init_icm_table(dev, &priv->cq_table.cmpt_table,
cmpt_base +
((u64) (MLX4_CMPT_TYPE_CQ *
cmpt_entry_sz) << MLX4_CMPT_SHIFT),
cmpt_entry_sz, dev->caps.num_cqs,
dev->caps.reserved_cqs, 0, 0);
if (err)
goto err_srq;
num_eqs = dev->phys_caps.num_phys_eqs;
err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
cmpt_base +
((u64) (MLX4_CMPT_TYPE_EQ *
cmpt_entry_sz) << MLX4_CMPT_SHIFT),
cmpt_entry_sz, num_eqs, num_eqs, 0, 0);
if (err)
goto err_cq;
return 0;
err_cq:
mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
err_srq:
mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
err_qp:
mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
err:
return err;
}
static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
struct mlx4_init_hca_param *init_hca, u64 icm_size)
{
struct mlx4_priv *priv = mlx4_priv(dev);
u64 aux_pages;
int num_eqs;
int err;
err = mlx4_SET_ICM_SIZE(dev, icm_size, &aux_pages);
if (err) {
mlx4_err(dev, "SET_ICM_SIZE command failed, aborting\n");
return err;
}
mlx4_dbg(dev, "%lld KB of HCA context requires %lld KB aux memory\n",
(unsigned long long) icm_size >> 10,
(unsigned long long) aux_pages << 2);
priv->fw.aux_icm = mlx4_alloc_icm(dev, aux_pages,
GFP_HIGHUSER | __GFP_NOWARN, 0);
if (!priv->fw.aux_icm) {
mlx4_err(dev, "Couldn't allocate aux memory, aborting\n");
return -ENOMEM;
}
err = mlx4_MAP_ICM_AUX(dev, priv->fw.aux_icm);
if (err) {
mlx4_err(dev, "MAP_ICM_AUX command failed, aborting\n");
goto err_free_aux;
}
err = mlx4_init_cmpt_table(dev, init_hca->cmpt_base, dev_cap->cmpt_entry_sz);
if (err) {
mlx4_err(dev, "Failed to map cMPT context memory, aborting\n");
goto err_unmap_aux;
}
num_eqs = dev->phys_caps.num_phys_eqs;
err = mlx4_init_icm_table(dev, &priv->eq_table.table,
init_hca->eqc_base, dev_cap->eqc_entry_sz,
num_eqs, num_eqs, 0, 0);
if (err) {
mlx4_err(dev, "Failed to map EQ context memory, aborting\n");
goto err_unmap_cmpt;
}
/*
* Reserved MTT entries must be aligned up to a cacheline
* boundary, since the FW will write to them, while the driver
* writes to all other MTT entries. (The variable
* dev->caps.mtt_entry_sz below is really the MTT segment
* size, not the raw entry size)
*/
dev->caps.reserved_mtts =
ALIGN(dev->caps.reserved_mtts * dev->caps.mtt_entry_sz,
dma_get_cache_alignment()) / dev->caps.mtt_entry_sz;
err = mlx4_init_icm_table(dev, &priv->mr_table.mtt_table,
init_hca->mtt_base,
dev->caps.mtt_entry_sz,
dev->caps.num_mtts,
dev->caps.reserved_mtts, 1, 0);
if (err) {
mlx4_err(dev, "Failed to map MTT context memory, aborting\n");
goto err_unmap_eq;
}
err = mlx4_init_icm_table(dev, &priv->mr_table.dmpt_table,
init_hca->dmpt_base,
dev_cap->dmpt_entry_sz,
dev->caps.num_mpts,
dev->caps.reserved_mrws, 1, 1);
if (err) {
mlx4_err(dev, "Failed to map dMPT context memory, aborting\n");
goto err_unmap_mtt;
}
err = mlx4_init_icm_table(dev, &priv->qp_table.qp_table,
init_hca->qpc_base,
dev_cap->qpc_entry_sz,
dev->caps.num_qps,
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
0, 0);
if (err) {
mlx4_err(dev, "Failed to map QP context memory, aborting\n");
goto err_unmap_dmpt;
}
err = mlx4_init_icm_table(dev, &priv->qp_table.auxc_table,
init_hca->auxc_base,
dev_cap->aux_entry_sz,
dev->caps.num_qps,
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
0, 0);
if (err) {
mlx4_err(dev, "Failed to map AUXC context memory, aborting\n");
goto err_unmap_qp;
}
err = mlx4_init_icm_table(dev, &priv->qp_table.altc_table,
init_hca->altc_base,
dev_cap->altc_entry_sz,
dev->caps.num_qps,
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
0, 0);
if (err) {
mlx4_err(dev, "Failed to map ALTC context memory, aborting\n");
goto err_unmap_auxc;
}
err = mlx4_init_icm_table(dev, &priv->qp_table.rdmarc_table,
init_hca->rdmarc_base,
dev_cap->rdmarc_entry_sz << priv->qp_table.rdmarc_shift,
dev->caps.num_qps,
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW],
0, 0);
if (err) {
mlx4_err(dev, "Failed to map RDMARC context memory, aborting\n");
goto err_unmap_altc;
}
err = mlx4_init_icm_table(dev, &priv->cq_table.table,
init_hca->cqc_base,
dev_cap->cqc_entry_sz,
dev->caps.num_cqs,
dev->caps.reserved_cqs, 0, 0);
if (err) {
mlx4_err(dev, "Failed to map CQ context memory, aborting\n");
goto err_unmap_rdmarc;
}
err = mlx4_init_icm_table(dev, &priv->srq_table.table,
init_hca->srqc_base,
dev_cap->srq_entry_sz,
dev->caps.num_srqs,
dev->caps.reserved_srqs, 0, 0);
if (err) {
mlx4_err(dev, "Failed to map SRQ context memory, aborting\n");
goto err_unmap_cq;
}
/*
* For flow steering device managed mode it is required to use
* mlx4_init_icm_table. For B0 steering mode it's not strictly
* required, but for simplicity just map the whole multicast
* group table now. The table isn't very big and it's a lot
* easier than trying to track ref counts.
*/
err = mlx4_init_icm_table(dev, &priv->mcg_table.table,
init_hca->mc_base,
mlx4_get_mgm_entry_size(dev),
dev->caps.num_mgms + dev->caps.num_amgms,
dev->caps.num_mgms + dev->caps.num_amgms,
0, 0);
if (err) {
mlx4_err(dev, "Failed to map MCG context memory, aborting\n");
goto err_unmap_srq;
}
return 0;
err_unmap_srq:
mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
err_unmap_cq:
mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
err_unmap_rdmarc:
mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
err_unmap_altc:
mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
err_unmap_auxc:
mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
err_unmap_qp:
mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
err_unmap_dmpt:
mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
err_unmap_mtt:
mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
err_unmap_eq:
mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
err_unmap_cmpt:
mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
err_unmap_aux:
mlx4_UNMAP_ICM_AUX(dev);
err_free_aux:
mlx4_free_icm(dev, priv->fw.aux_icm, 0);
return err;
}
static void mlx4_free_icms(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
mlx4_cleanup_icm_table(dev, &priv->mcg_table.table);
mlx4_cleanup_icm_table(dev, &priv->srq_table.table);
mlx4_cleanup_icm_table(dev, &priv->cq_table.table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.rdmarc_table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.altc_table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.auxc_table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.qp_table);
mlx4_cleanup_icm_table(dev, &priv->mr_table.dmpt_table);
mlx4_cleanup_icm_table(dev, &priv->mr_table.mtt_table);
mlx4_cleanup_icm_table(dev, &priv->eq_table.table);
mlx4_cleanup_icm_table(dev, &priv->eq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->cq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table);
mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table);
mlx4_UNMAP_ICM_AUX(dev);
mlx4_free_icm(dev, priv->fw.aux_icm, 0);
}
static void mlx4_slave_exit(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
mutex_lock(&priv->cmd.slave_cmd_mutex);
if (mlx4_comm_cmd(dev, MLX4_COMM_CMD_RESET, 0, MLX4_COMM_CMD_NA_OP,
MLX4_COMM_TIME))
mlx4_warn(dev, "Failed to close slave function\n");
mutex_unlock(&priv->cmd.slave_cmd_mutex);
}
static int map_bf_area(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
resource_size_t bf_start;
resource_size_t bf_len;
int err = 0;
if (!dev->caps.bf_reg_size)
return -ENXIO;
bf_start = pci_resource_start(dev->persist->pdev, 2) +
(dev->caps.num_uars << PAGE_SHIFT);
bf_len = pci_resource_len(dev->persist->pdev, 2) -
(dev->caps.num_uars << PAGE_SHIFT);
priv->bf_mapping = io_mapping_create_wc(bf_start, bf_len);
if (!priv->bf_mapping)
err = -ENOMEM;
return err;
}
static void unmap_bf_area(struct mlx4_dev *dev)
{
if (mlx4_priv(dev)->bf_mapping)
io_mapping_free(mlx4_priv(dev)->bf_mapping);
}
u64 mlx4_read_clock(struct mlx4_dev *dev)
{
u32 clockhi, clocklo, clockhi1;
u64 cycles;
int i;
struct mlx4_priv *priv = mlx4_priv(dev);
for (i = 0; i < 10; i++) {
clockhi = swab32(readl(priv->clock_mapping));
clocklo = swab32(readl(priv->clock_mapping + 4));
clockhi1 = swab32(readl(priv->clock_mapping));
if (clockhi == clockhi1)
break;
}
cycles = (u64) clockhi << 32 | (u64) clocklo;
return cycles;
}
EXPORT_SYMBOL_GPL(mlx4_read_clock);
static int map_internal_clock(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
priv->clock_mapping =
ioremap(pci_resource_start(dev->persist->pdev,
priv->fw.clock_bar) +
priv->fw.clock_offset, MLX4_CLOCK_SIZE);
if (!priv->clock_mapping)
return -ENOMEM;
return 0;
}
int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
struct mlx4_clock_params *params)
{
struct mlx4_priv *priv = mlx4_priv(dev);
if (mlx4_is_slave(dev))
return -EOPNOTSUPP;
if (!params)
return -EINVAL;
params->bar = priv->fw.clock_bar;
params->offset = priv->fw.clock_offset;
params->size = MLX4_CLOCK_SIZE;
return 0;
}
EXPORT_SYMBOL_GPL(mlx4_get_internal_clock_params);
static void unmap_internal_clock(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
if (priv->clock_mapping)
iounmap(priv->clock_mapping);
}
static void mlx4_close_hca(struct mlx4_dev *dev)
{
unmap_internal_clock(dev);
unmap_bf_area(dev);
if (mlx4_is_slave(dev))
mlx4_slave_exit(dev);
else {
mlx4_CLOSE_HCA(dev, 0);
mlx4_free_icms(dev);
}
}
static void mlx4_close_fw(struct mlx4_dev *dev)
{
if (!mlx4_is_slave(dev)) {
mlx4_UNMAP_FA(dev);
mlx4_free_icm(dev, mlx4_priv(dev)->fw.fw_icm, 0);
}
}
static int mlx4_comm_check_offline(struct mlx4_dev *dev)
{
#define COMM_CHAN_OFFLINE_OFFSET 0x09
u32 comm_flags;
u32 offline_bit;
unsigned long end;
struct mlx4_priv *priv = mlx4_priv(dev);
end = msecs_to_jiffies(MLX4_COMM_OFFLINE_TIME_OUT) + jiffies;
while (time_before(jiffies, end)) {
comm_flags = swab32(readl((__iomem char *)priv->mfunc.comm +
MLX4_COMM_CHAN_FLAGS));
offline_bit = (comm_flags &
(u32)(1 << COMM_CHAN_OFFLINE_OFFSET));
if (!offline_bit)
return 0;
/* If device removal has been requested,
* do not continue retrying.
*/
if (dev->persist->interface_state &
MLX4_INTERFACE_STATE_NOWAIT)
break;
/* There are cases as part of AER/Reset flow that PF needs
* around 100 msec to load. We therefore sleep for 100 msec
* to allow other tasks to make use of that CPU during this
* time interval.
*/
msleep(100);
}
mlx4_err(dev, "Communication channel is offline.\n");
return -EIO;
}
static void mlx4_reset_vf_support(struct mlx4_dev *dev)
{
#define COMM_CHAN_RST_OFFSET 0x1e
struct mlx4_priv *priv = mlx4_priv(dev);
u32 comm_rst;
u32 comm_caps;
comm_caps = swab32(readl((__iomem char *)priv->mfunc.comm +
MLX4_COMM_CHAN_CAPS));
comm_rst = (comm_caps & (u32)(1 << COMM_CHAN_RST_OFFSET));
if (comm_rst)
dev->caps.vf_caps |= MLX4_VF_CAP_FLAG_RESET;
}
static int mlx4_init_slave(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
u64 dma = (u64) priv->mfunc.vhcr_dma;
int ret_from_reset = 0;
u32 slave_read;
u32 cmd_channel_ver;
if (atomic_read(&pf_loading)) {
mlx4_warn(dev, "PF is not ready - Deferring probe\n");
return -EPROBE_DEFER;
}
mutex_lock(&priv->cmd.slave_cmd_mutex);
priv->cmd.max_cmds = 1;
if (mlx4_comm_check_offline(dev)) {
mlx4_err(dev, "PF is not responsive, skipping initialization\n");
goto err_offline;
}
mlx4_reset_vf_support(dev);
mlx4_warn(dev, "Sending reset\n");
ret_from_reset = mlx4_comm_cmd(dev, MLX4_COMM_CMD_RESET, 0,
MLX4_COMM_CMD_NA_OP, MLX4_COMM_TIME);
/* if we are in the middle of flr the slave will try
* NUM_OF_RESET_RETRIES times before leaving.*/
if (ret_from_reset) {
if (MLX4_DELAY_RESET_SLAVE == ret_from_reset) {
mlx4_warn(dev, "slave is currently in the middle of FLR - Deferring probe\n");
mutex_unlock(&priv->cmd.slave_cmd_mutex);
return -EPROBE_DEFER;
} else
goto err;
}
/* check the driver version - the slave I/F revision
* must match the master's */
slave_read = swab32(readl(&priv->mfunc.comm->slave_read));
cmd_channel_ver = mlx4_comm_get_version();
if (MLX4_COMM_GET_IF_REV(cmd_channel_ver) !=
MLX4_COMM_GET_IF_REV(slave_read)) {
mlx4_err(dev, "slave driver version is not supported by the master\n");
goto err;
}
mlx4_warn(dev, "Sending vhcr0\n");
if (mlx4_comm_cmd(dev, MLX4_COMM_CMD_VHCR0, dma >> 48,
MLX4_COMM_CMD_NA_OP, MLX4_COMM_TIME))
goto err;
if (mlx4_comm_cmd(dev, MLX4_COMM_CMD_VHCR1, dma >> 32,
MLX4_COMM_CMD_NA_OP, MLX4_COMM_TIME))
goto err;
if (mlx4_comm_cmd(dev, MLX4_COMM_CMD_VHCR2, dma >> 16,
MLX4_COMM_CMD_NA_OP, MLX4_COMM_TIME))
goto err;
if (mlx4_comm_cmd(dev, MLX4_COMM_CMD_VHCR_EN, dma,
MLX4_COMM_CMD_NA_OP, MLX4_COMM_TIME))
goto err;
mutex_unlock(&priv->cmd.slave_cmd_mutex);
return 0;
err:
mlx4_comm_cmd(dev, MLX4_COMM_CMD_RESET, 0, MLX4_COMM_CMD_NA_OP, 0);
err_offline:
mutex_unlock(&priv->cmd.slave_cmd_mutex);
return -EIO;
}
static void mlx4_parav_master_pf_caps(struct mlx4_dev *dev)
{
int i;
for (i = 1; i <= dev->caps.num_ports; i++) {
if (dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH)
dev->caps.gid_table_len[i] =
mlx4_get_slave_num_gids(dev, 0, i);
else
dev->caps.gid_table_len[i] = 1;
dev->caps.pkey_table_len[i] =
dev->phys_caps.pkey_phys_table_len[i] - 1;
}
}
static int choose_log_fs_mgm_entry_size(int qp_per_entry)
{
int i = MLX4_MIN_MGM_LOG_ENTRY_SIZE;
for (i = MLX4_MIN_MGM_LOG_ENTRY_SIZE; i <= MLX4_MAX_MGM_LOG_ENTRY_SIZE;
i++) {
if (qp_per_entry <= 4 * ((1 << i) / 16 - 2))
break;
}
return (i <= MLX4_MAX_MGM_LOG_ENTRY_SIZE) ? i : -1;
}
static const char *dmfs_high_rate_steering_mode_str(int dmfs_high_steer_mode)
{
switch (dmfs_high_steer_mode) {
case MLX4_STEERING_DMFS_A0_DEFAULT:
return "default performance";
case MLX4_STEERING_DMFS_A0_DYNAMIC:
return "dynamic hybrid mode";
case MLX4_STEERING_DMFS_A0_STATIC:
return "performance optimized for limited rule configuration (static)";
case MLX4_STEERING_DMFS_A0_DISABLE:
return "disabled performance optimized steering";
case MLX4_STEERING_DMFS_A0_NOT_SUPPORTED:
return "performance optimized steering not supported";
default:
return "Unrecognized mode";
}
}
#define MLX4_DMFS_A0_STEERING (1UL << 2)
static void choose_steering_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{
if (mlx4_log_num_mgm_entry_size <= 0) {
if ((-mlx4_log_num_mgm_entry_size) & MLX4_DMFS_A0_STEERING) {
if (dev->caps.dmfs_high_steer_mode ==
MLX4_STEERING_DMFS_A0_NOT_SUPPORTED)
mlx4_err(dev, "DMFS high rate mode not supported\n");
else
dev->caps.dmfs_high_steer_mode =
MLX4_STEERING_DMFS_A0_STATIC;
}
}
if (mlx4_log_num_mgm_entry_size <= 0 &&
dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_FS_EN &&
(!mlx4_is_mfunc(dev) ||
(dev_cap->fs_max_num_qp_per_entry >=
(dev->persist->num_vfs + 1))) &&
choose_log_fs_mgm_entry_size(dev_cap->fs_max_num_qp_per_entry) >=
MLX4_MIN_MGM_LOG_ENTRY_SIZE) {
dev->oper_log_mgm_entry_size =
choose_log_fs_mgm_entry_size(dev_cap->fs_max_num_qp_per_entry);
dev->caps.steering_mode = MLX4_STEERING_MODE_DEVICE_MANAGED;
dev->caps.num_qp_per_mgm = dev_cap->fs_max_num_qp_per_entry;
dev->caps.fs_log_max_ucast_qp_range_size =
dev_cap->fs_log_max_ucast_qp_range_size;
} else {
if (dev->caps.dmfs_high_steer_mode !=
MLX4_STEERING_DMFS_A0_NOT_SUPPORTED)
dev->caps.dmfs_high_steer_mode = MLX4_STEERING_DMFS_A0_DISABLE;
if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER &&
dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER)
dev->caps.steering_mode = MLX4_STEERING_MODE_B0;
else {
dev->caps.steering_mode = MLX4_STEERING_MODE_A0;
if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER ||
dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER)
mlx4_warn(dev, "Must have both UC_STEER and MC_STEER flags set to use B0 steering - falling back to A0 steering mode\n");
}
dev->oper_log_mgm_entry_size =
mlx4_log_num_mgm_entry_size > 0 ?
mlx4_log_num_mgm_entry_size :
MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE;
dev->caps.num_qp_per_mgm = mlx4_get_qp_per_mgm(dev);
}
mlx4_dbg(dev, "Steering mode is: %s, oper_log_mgm_entry_size = %d, modparam log_num_mgm_entry_size = %d\n",
mlx4_steering_mode_str(dev->caps.steering_mode),
dev->oper_log_mgm_entry_size,
mlx4_log_num_mgm_entry_size);
}
static void choose_tunnel_offload_mode(struct mlx4_dev *dev,
struct mlx4_dev_cap *dev_cap)
{
if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED &&
dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS)
dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_VXLAN;
else
dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_NONE;
mlx4_dbg(dev, "Tunneling offload mode is: %s\n", (dev->caps.tunnel_offload_mode
== MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) ? "vxlan" : "none");
}
static int mlx4_validate_optimized_steering(struct mlx4_dev *dev)
{
int i;
struct mlx4_port_cap port_cap;
if (dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_NOT_SUPPORTED)
return -EINVAL;
for (i = 1; i <= dev->caps.num_ports; i++) {
if (mlx4_dev_port(dev, i, &port_cap)) {
mlx4_err(dev,
"QUERY_DEV_CAP command failed, can't veify DMFS high rate steering.\n");
} else if ((dev->caps.dmfs_high_steer_mode !=
MLX4_STEERING_DMFS_A0_DEFAULT) &&
(port_cap.dmfs_optimized_state ==
!!(dev->caps.dmfs_high_steer_mode ==
MLX4_STEERING_DMFS_A0_DISABLE))) {
mlx4_err(dev,
"DMFS high rate steer mode differ, driver requested %s but %s in FW.\n",
dmfs_high_rate_steering_mode_str(
dev->caps.dmfs_high_steer_mode),
(port_cap.dmfs_optimized_state ?
"enabled" : "disabled"));
}
}
return 0;
}
static int mlx4_init_fw(struct mlx4_dev *dev)
{
struct mlx4_mod_stat_cfg mlx4_cfg;
int err = 0;
if (!mlx4_is_slave(dev)) {
err = mlx4_QUERY_FW(dev);
if (err) {
if (err == -EACCES)
mlx4_info(dev, "non-primary physical function, skipping\n");
else
mlx4_err(dev, "QUERY_FW command failed, aborting\n");
return err;
}
err = mlx4_load_fw(dev);
if (err) {
mlx4_err(dev, "Failed to start FW, aborting\n");
return err;
}
mlx4_cfg.log_pg_sz_m = 1;
mlx4_cfg.log_pg_sz = 0;
err = mlx4_MOD_STAT_CFG(dev, &mlx4_cfg);
if (err)
mlx4_warn(dev, "Failed to override log_pg_sz parameter\n");
}
return err;
}
static int mlx4_init_hca(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_adapter adapter;
struct mlx4_dev_cap dev_cap;
struct mlx4_profile profile;
struct mlx4_init_hca_param init_hca;
u64 icm_size;
struct mlx4_config_dev_params params;
int err;
if (!mlx4_is_slave(dev)) {
err = mlx4_dev_cap(dev, &dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting\n");
return err;
}
choose_steering_mode(dev, &dev_cap);
choose_tunnel_offload_mode(dev, &dev_cap);
if (dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC &&
mlx4_is_master(dev))
dev->caps.function_caps |= MLX4_FUNC_CAP_DMFS_A0_STATIC;
err = mlx4_get_phys_port_id(dev);
if (err)
mlx4_err(dev, "Fail to get physical port id\n");
if (mlx4_is_master(dev))
mlx4_parav_master_pf_caps(dev);
if (mlx4_low_memory_profile()) {
mlx4_info(dev, "Running from within kdump kernel. Using low memory profile\n");
profile = low_mem_profile;
} else {
profile = default_profile;
}
if (dev->caps.steering_mode ==
MLX4_STEERING_MODE_DEVICE_MANAGED)
profile.num_mcg = MLX4_FS_NUM_MCG;
icm_size = mlx4_make_profile(dev, &profile, &dev_cap,
&init_hca);
if ((long long) icm_size < 0) {
err = icm_size;
return err;
}
dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
if (enable_4k_uar || !dev->persist->num_vfs) {
init_hca.log_uar_sz = ilog2(dev->caps.num_uars) +
PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT;
init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12;
} else {
init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
init_hca.uar_page_sz = PAGE_SHIFT - 12;
}
init_hca.mw_enabled = 0;
if (dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW ||
dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN)
init_hca.mw_enabled = INIT_HCA_TPT_MW_ENABLE;
err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
if (err)
return err;
err = mlx4_INIT_HCA(dev, &init_hca);
if (err) {
mlx4_err(dev, "INIT_HCA command failed, aborting\n");
goto err_free_icm;
}
if (dev_cap.flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) {
err = mlx4_query_func(dev, &dev_cap);
if (err < 0) {
mlx4_err(dev, "QUERY_FUNC command failed, aborting.\n");
goto err_close;
} else if (err & MLX4_QUERY_FUNC_NUM_SYS_EQS) {
dev->caps.num_eqs = dev_cap.max_eqs;
dev->caps.reserved_eqs = dev_cap.reserved_eqs;
dev->caps.reserved_uars = dev_cap.reserved_uars;
}
}
/*
* If TS is supported by FW
* read HCA frequency by QUERY_HCA command
*/
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) {
memset(&init_hca, 0, sizeof(init_hca));
err = mlx4_QUERY_HCA(dev, &init_hca);
if (err) {
mlx4_err(dev, "QUERY_HCA command failed, disable timestamp\n");
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS;
} else {
dev->caps.hca_core_clock =
init_hca.hca_core_clock;
}
/* In case we got HCA frequency 0 - disable timestamping
* to avoid dividing by zero
*/
if (!dev->caps.hca_core_clock) {
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS;
mlx4_err(dev,
"HCA frequency is 0 - timestamping is not supported\n");
} else if (map_internal_clock(dev)) {
/*
* Map internal clock,
* in case of failure disable timestamping
*/
dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS;
mlx4_err(dev, "Failed to map internal clock. Timestamping is not supported\n");
}
}
if (dev->caps.dmfs_high_steer_mode !=
MLX4_STEERING_DMFS_A0_NOT_SUPPORTED) {
if (mlx4_validate_optimized_steering(dev))
mlx4_warn(dev, "Optimized steering validation failed\n");
if (dev->caps.dmfs_high_steer_mode ==
MLX4_STEERING_DMFS_A0_DISABLE) {
dev->caps.dmfs_high_rate_qpn_base =
dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW];
dev->caps.dmfs_high_rate_qpn_range =
MLX4_A0_STEERING_TABLE_SIZE;
}
mlx4_info(dev, "DMFS high rate steer mode is: %s\n",
dmfs_high_rate_steering_mode_str(
dev->caps.dmfs_high_steer_mode));
}
} else {
err = mlx4_init_slave(dev);
if (err) {
if (err != -EPROBE_DEFER)
mlx4_err(dev, "Failed to initialize slave\n");
return err;
}
err = mlx4_slave_cap(dev);
if (err) {
mlx4_err(dev, "Failed to obtain slave caps\n");
goto err_close;
}
}
if (map_bf_area(dev))
mlx4_dbg(dev, "Failed to map blue flame area\n");
/*Only the master set the ports, all the rest got it from it.*/
if (!mlx4_is_slave(dev))
mlx4_set_port_mask(dev);
err = mlx4_QUERY_ADAPTER(dev, &adapter);
if (err) {
mlx4_err(dev, "QUERY_ADAPTER command failed, aborting\n");
goto unmap_bf;
}
/* Query CONFIG_DEV parameters */
err = mlx4_config_dev_retrieval(dev, ¶ms);
if (err && err != -EOPNOTSUPP) {
mlx4_err(dev, "Failed to query CONFIG_DEV parameters\n");
} else if (!err) {
dev->caps.rx_checksum_flags_port[1] = params.rx_csum_flags_port_1;
dev->caps.rx_checksum_flags_port[2] = params.rx_csum_flags_port_2;
}
priv->eq_table.inta_pin = adapter.inta_pin;
memcpy(dev->board_id, adapter.board_id, sizeof(dev->board_id));
return 0;
unmap_bf:
unmap_internal_clock(dev);
unmap_bf_area(dev);
if (mlx4_is_slave(dev))
mlx4_slave_destroy_special_qp_cap(dev);
err_close:
if (mlx4_is_slave(dev))
mlx4_slave_exit(dev);
else
mlx4_CLOSE_HCA(dev, 0);
err_free_icm:
if (!mlx4_is_slave(dev))
mlx4_free_icms(dev);
return err;
}
static int mlx4_init_counters_table(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int nent_pow2;
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return -ENOENT;
if (!dev->caps.max_counters)
return -ENOSPC;
nent_pow2 = roundup_pow_of_two(dev->caps.max_counters);
/* reserve last counter index for sink counter */
return mlx4_bitmap_init(&priv->counters_bitmap, nent_pow2,
nent_pow2 - 1, 0,
nent_pow2 - dev->caps.max_counters + 1);
}
static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
{
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return;
if (!dev->caps.max_counters)
return;
mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap);
}
static void mlx4_cleanup_default_counters(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int port;
for (port = 0; port < dev->caps.num_ports; port++)
if (priv->def_counter[port] != -1)
mlx4_counter_free(dev, priv->def_counter[port]);
}
static int mlx4_allocate_default_counters(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int port, err = 0;
u32 idx;
for (port = 0; port < dev->caps.num_ports; port++)
priv->def_counter[port] = -1;
for (port = 0; port < dev->caps.num_ports; port++) {
err = mlx4_counter_alloc(dev, &idx, MLX4_RES_USAGE_DRIVER);
if (!err || err == -ENOSPC) {
priv->def_counter[port] = idx;
} else if (err == -ENOENT) {
err = 0;
continue;
} else if (mlx4_is_slave(dev) && err == -EINVAL) {
priv->def_counter[port] = MLX4_SINK_COUNTER_INDEX(dev);
mlx4_warn(dev, "can't allocate counter from old PF driver, using index %d\n",
MLX4_SINK_COUNTER_INDEX(dev));
err = 0;
} else {
mlx4_err(dev, "%s: failed to allocate default counter port %d err %d\n",
__func__, port + 1, err);
mlx4_cleanup_default_counters(dev);
return err;
}
mlx4_dbg(dev, "%s: default counter index %d for port %d\n",
__func__, priv->def_counter[port], port + 1);
}
return err;
}
int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
{
struct mlx4_priv *priv = mlx4_priv(dev);
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return -ENOENT;
*idx = mlx4_bitmap_alloc(&priv->counters_bitmap);
if (*idx == -1) {
*idx = MLX4_SINK_COUNTER_INDEX(dev);
return -ENOSPC;
}
return 0;
}
int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx, u8 usage)
{
u32 in_modifier = RES_COUNTER | (((u32)usage & 3) << 30);
u64 out_param;
int err;
if (mlx4_is_mfunc(dev)) {
err = mlx4_cmd_imm(dev, 0, &out_param, in_modifier,
RES_OP_RESERVE, MLX4_CMD_ALLOC_RES,
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
if (!err)
*idx = get_param_l(&out_param);
return err;
}
return __mlx4_counter_alloc(dev, idx);
}
EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
static int __mlx4_clear_if_stat(struct mlx4_dev *dev,
u8 counter_index)
{
struct mlx4_cmd_mailbox *if_stat_mailbox;
int err;
u32 if_stat_in_mod = (counter_index & 0xff) | MLX4_QUERY_IF_STAT_RESET;
if_stat_mailbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(if_stat_mailbox))
return PTR_ERR(if_stat_mailbox);
err = mlx4_cmd_box(dev, 0, if_stat_mailbox->dma, if_stat_in_mod, 0,
MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C,
MLX4_CMD_NATIVE);
mlx4_free_cmd_mailbox(dev, if_stat_mailbox);
return err;
}
void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
{
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return;
if (idx == MLX4_SINK_COUNTER_INDEX(dev))
return;
__mlx4_clear_if_stat(dev, idx);
mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx, MLX4_USE_RR);
return;
}
void mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
{
u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, idx);
mlx4_cmd(dev, in_param, RES_COUNTER, RES_OP_RESERVE,
MLX4_CMD_FREE_RES, MLX4_CMD_TIME_CLASS_A,
MLX4_CMD_WRAPPED);
return;
}
__mlx4_counter_free(dev, idx);
}
EXPORT_SYMBOL_GPL(mlx4_counter_free);
int mlx4_get_default_counter_index(struct mlx4_dev *dev, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
return priv->def_counter[port - 1];
}
EXPORT_SYMBOL_GPL(mlx4_get_default_counter_index);
void mlx4_set_admin_guid(struct mlx4_dev *dev, __be64 guid, int entry, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
priv->mfunc.master.vf_admin[entry].vport[port].guid = guid;
}
EXPORT_SYMBOL_GPL(mlx4_set_admin_guid);
__be64 mlx4_get_admin_guid(struct mlx4_dev *dev, int entry, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
return priv->mfunc.master.vf_admin[entry].vport[port].guid;
}
EXPORT_SYMBOL_GPL(mlx4_get_admin_guid);
void mlx4_set_random_admin_guid(struct mlx4_dev *dev, int entry, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
__be64 guid;
/* hw GUID */
if (entry == 0)
return;
get_random_bytes((char *)&guid, sizeof(guid));
guid &= ~(cpu_to_be64(1ULL << 56));
guid |= cpu_to_be64(1ULL << 57);
priv->mfunc.master.vf_admin[entry].vport[port].guid = guid;
}
static int mlx4_setup_hca(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int err;
int port;
__be32 ib_port_default_caps;
err = mlx4_init_uar_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize user access region table, aborting\n");
return err;
}
err = mlx4_uar_alloc(dev, &priv->driver_uar);
if (err) {
mlx4_err(dev, "Failed to allocate driver access region, aborting\n");
goto err_uar_table_free;
}
priv->kar = ioremap((phys_addr_t) priv->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
if (!priv->kar) {
mlx4_err(dev, "Couldn't map kernel access region, aborting\n");
err = -ENOMEM;
goto err_uar_free;
}
err = mlx4_init_pd_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize protection domain table, aborting\n");
goto err_kar_unmap;
}
err = mlx4_init_xrcd_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize reliable connection domain table, aborting\n");
goto err_pd_table_free;
}
err = mlx4_init_mr_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize memory region table, aborting\n");
goto err_xrcd_table_free;
}
if (!mlx4_is_slave(dev)) {
err = mlx4_init_mcg_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize multicast group table, aborting\n");
goto err_mr_table_free;
}
err = mlx4_config_mad_demux(dev);
if (err) {
mlx4_err(dev, "Failed in config_mad_demux, aborting\n");
goto err_mcg_table_free;
}
}
err = mlx4_init_eq_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize event queue table, aborting\n");
goto err_mcg_table_free;
}
err = mlx4_cmd_use_events(dev);
if (err) {
mlx4_err(dev, "Failed to switch to event-driven firmware commands, aborting\n");
goto err_eq_table_free;
}
err = mlx4_NOP(dev);
if (err) {
if (dev->flags & MLX4_FLAG_MSI_X) {
mlx4_warn(dev, "NOP command failed to generate MSI-X interrupt IRQ %d)\n",
priv->eq_table.eq[MLX4_EQ_ASYNC].irq);
mlx4_warn(dev, "Trying again without MSI-X\n");
} else {
mlx4_err(dev, "NOP command failed to generate interrupt (IRQ %d), aborting\n",
priv->eq_table.eq[MLX4_EQ_ASYNC].irq);
mlx4_err(dev, "BIOS or ACPI interrupt routing problem?\n");
}
goto err_cmd_poll;
}
mlx4_dbg(dev, "NOP command IRQ test passed\n");
err = mlx4_init_cq_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize completion queue table, aborting\n");
goto err_cmd_poll;
}
err = mlx4_init_srq_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize shared receive queue table, aborting\n");
goto err_cq_table_free;
}
err = mlx4_init_qp_table(dev);
if (err) {
mlx4_err(dev, "Failed to initialize queue pair table, aborting\n");
goto err_srq_table_free;
}
if (!mlx4_is_slave(dev)) {
err = mlx4_init_counters_table(dev);
if (err && err != -ENOENT) {
mlx4_err(dev, "Failed to initialize counters table, aborting\n");
goto err_qp_table_free;
}
}
err = mlx4_allocate_default_counters(dev);
if (err) {
mlx4_err(dev, "Failed to allocate default counters, aborting\n");
goto err_counters_table_free;
}
if (!mlx4_is_slave(dev)) {
for (port = 1; port <= dev->caps.num_ports; port++) {
ib_port_default_caps = 0;
err = mlx4_get_port_ib_caps(dev, port,
&ib_port_default_caps);
if (err)
mlx4_warn(dev, "failed to get port %d default ib capabilities (%d). Continuing with caps = 0\n",
port, err);
dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
/* initialize per-slave default ib port capabilities */
if (mlx4_is_master(dev)) {
int i;
for (i = 0; i < dev->num_slaves; i++) {
if (i == mlx4_master_func_num(dev))
continue;
priv->mfunc.master.slave_state[i].ib_cap_mask[port] =
ib_port_default_caps;
}
}
if (mlx4_is_mfunc(dev))
dev->caps.port_ib_mtu[port] = IB_MTU_2048;
else
dev->caps.port_ib_mtu[port] = IB_MTU_4096;
err = mlx4_SET_PORT(dev, port, mlx4_is_master(dev) ?
dev->caps.pkey_table_len[port] : -1);
if (err) {
mlx4_err(dev, "Failed to set port %d, aborting\n",
port);
goto err_default_countes_free;
}
}
}
return 0;
err_default_countes_free:
mlx4_cleanup_default_counters(dev);
err_counters_table_free:
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev);
err_qp_table_free:
mlx4_cleanup_qp_table(dev);
err_srq_table_free:
mlx4_cleanup_srq_table(dev);
err_cq_table_free:
mlx4_cleanup_cq_table(dev);
err_cmd_poll:
mlx4_cmd_use_polling(dev);
err_eq_table_free:
mlx4_cleanup_eq_table(dev);
err_mcg_table_free:
if (!mlx4_is_slave(dev))
mlx4_cleanup_mcg_table(dev);
err_mr_table_free:
mlx4_cleanup_mr_table(dev);
err_xrcd_table_free:
mlx4_cleanup_xrcd_table(dev);
err_pd_table_free:
mlx4_cleanup_pd_table(dev);
err_kar_unmap:
iounmap(priv->kar);
err_uar_free:
mlx4_uar_free(dev, &priv->driver_uar);
err_uar_table_free:
mlx4_cleanup_uar_table(dev);
return err;
}
static int mlx4_init_affinity_hint(struct mlx4_dev *dev, int port, int eqn)
{
int requested_cpu = 0;
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_eq *eq;
int off = 0;
int i;
if (eqn > dev->caps.num_comp_vectors)
return -EINVAL;
for (i = 1; i < port; i++)
off += mlx4_get_eqs_per_port(dev, i);
requested_cpu = eqn - off - !!(eqn > MLX4_EQ_ASYNC);
/* Meaning EQs are shared, and this call comes from the second port */
if (requested_cpu < 0)
return 0;
eq = &priv->eq_table.eq[eqn];
if (!zalloc_cpumask_var(&eq->affinity_mask, GFP_KERNEL))
return -ENOMEM;
cpumask_set_cpu(requested_cpu, eq->affinity_mask);
return 0;
}
static void mlx4_enable_msi_x(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct msix_entry *entries;
int i;
int port = 0;
if (msi_x) {
int nreq = min3(dev->caps.num_ports *
(int)num_online_cpus() + 1,
dev->caps.num_eqs - dev->caps.reserved_eqs,
MAX_MSIX);
if (msi_x > 1)
nreq = min_t(int, nreq, msi_x);
entries = kcalloc(nreq, sizeof(*entries), GFP_KERNEL);
if (!entries)
goto no_msi;
for (i = 0; i < nreq; ++i)
entries[i].entry = i;
nreq = pci_enable_msix_range(dev->persist->pdev, entries, 2,
nreq);
if (nreq < 0 || nreq < MLX4_EQ_ASYNC) {
kfree(entries);
goto no_msi;
}
/* 1 is reserved for events (asyncrounous EQ) */
dev->caps.num_comp_vectors = nreq - 1;
priv->eq_table.eq[MLX4_EQ_ASYNC].irq = entries[0].vector;
bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports,
dev->caps.num_ports);
for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) {
if (i == MLX4_EQ_ASYNC)
continue;
priv->eq_table.eq[i].irq =
entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector;
if (MLX4_IS_LEGACY_EQ_MODE(dev->caps)) {
bitmap_fill(priv->eq_table.eq[i].actv_ports.ports,
dev->caps.num_ports);
/* We don't set affinity hint when there
* aren't enough EQs
*/
} else {
set_bit(port,
priv->eq_table.eq[i].actv_ports.ports);
if (mlx4_init_affinity_hint(dev, port + 1, i))
mlx4_warn(dev, "Couldn't init hint cpumask for EQ %d\n",
i);
}
/* We divide the Eqs evenly between the two ports.
* (dev->caps.num_comp_vectors / dev->caps.num_ports)
* refers to the number of Eqs per port
* (i.e eqs_per_port). Theoretically, we would like to
* write something like (i + 1) % eqs_per_port == 0.
* However, since there's an asynchronous Eq, we have
* to skip over it by comparing this condition to
* !!((i + 1) > MLX4_EQ_ASYNC).
*/
if ((dev->caps.num_comp_vectors > dev->caps.num_ports) &&
((i + 1) %
(dev->caps.num_comp_vectors / dev->caps.num_ports)) ==
!!((i + 1) > MLX4_EQ_ASYNC))
/* If dev->caps.num_comp_vectors < dev->caps.num_ports,
* everything is shared anyway.
*/
port++;
}
dev->flags |= MLX4_FLAG_MSI_X;
kfree(entries);
return;
}
no_msi:
dev->caps.num_comp_vectors = 1;
BUG_ON(MLX4_EQ_ASYNC >= 2);
for (i = 0; i < 2; ++i) {
priv->eq_table.eq[i].irq = dev->persist->pdev->irq;
if (i != MLX4_EQ_ASYNC) {
bitmap_fill(priv->eq_table.eq[i].actv_ports.ports,
dev->caps.num_ports);
}
}
}
static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
{
struct devlink *devlink = priv_to_devlink(mlx4_priv(dev));
struct mlx4_port_info *info = &mlx4_priv(dev)->port[port];
int err;
err = devlink_port_register(devlink, &info->devlink_port, port);
if (err)
return err;
info->dev = dev;
info->port = port;
if (!mlx4_is_slave(dev)) {
mlx4_init_mac_table(dev, &info->mac_table);
mlx4_init_vlan_table(dev, &info->vlan_table);
mlx4_init_roce_gid_table(dev, &info->gid_table);
info->base_qpn = mlx4_get_base_qpn(dev, port);
}
sprintf(info->dev_name, "mlx4_port%d", port);
info->port_attr.attr.name = info->dev_name;
if (mlx4_is_mfunc(dev)) {
info->port_attr.attr.mode = 0444;
} else {
info->port_attr.attr.mode = 0644;
info->port_attr.store = set_port_type;
}
info->port_attr.show = show_port_type;
sysfs_attr_init(&info->port_attr.attr);
err = device_create_file(&dev->persist->pdev->dev, &info->port_attr);
if (err) {
mlx4_err(dev, "Failed to create file for port %d\n", port);
devlink_port_unregister(&info->devlink_port);
info->port = -1;
return err;
}
sprintf(info->dev_mtu_name, "mlx4_port%d_mtu", port);
info->port_mtu_attr.attr.name = info->dev_mtu_name;
if (mlx4_is_mfunc(dev)) {
info->port_mtu_attr.attr.mode = 0444;
} else {
info->port_mtu_attr.attr.mode = 0644;
info->port_mtu_attr.store = set_port_ib_mtu;
}
info->port_mtu_attr.show = show_port_ib_mtu;
sysfs_attr_init(&info->port_mtu_attr.attr);
err = device_create_file(&dev->persist->pdev->dev,
&info->port_mtu_attr);
if (err) {
mlx4_err(dev, "Failed to create mtu file for port %d\n", port);
device_remove_file(&info->dev->persist->pdev->dev,
&info->port_attr);
devlink_port_unregister(&info->devlink_port);
info->port = -1;
return err;
}
return 0;
}
static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
{
if (info->port < 0)
return;
device_remove_file(&info->dev->persist->pdev->dev, &info->port_attr);
device_remove_file(&info->dev->persist->pdev->dev,
&info->port_mtu_attr);
devlink_port_unregister(&info->devlink_port);
#ifdef CONFIG_RFS_ACCEL
free_irq_cpu_rmap(info->rmap);
info->rmap = NULL;
#endif
}
static int mlx4_init_steering(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int num_entries = dev->caps.num_ports;
int i, j;
priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer),
GFP_KERNEL);
if (!priv->steer)
return -ENOMEM;
for (i = 0; i < num_entries; i++)
for (j = 0; j < MLX4_NUM_STEERS; j++) {
INIT_LIST_HEAD(&priv->steer[i].promisc_qps[j]);
INIT_LIST_HEAD(&priv->steer[i].steer_entries[j]);
}
return 0;
}
static void mlx4_clear_steering(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_steer_index *entry, *tmp_entry;
struct mlx4_promisc_qp *pqp, *tmp_pqp;
int num_entries = dev->caps.num_ports;
int i, j;
for (i = 0; i < num_entries; i++) {
for (j = 0; j < MLX4_NUM_STEERS; j++) {
list_for_each_entry_safe(pqp, tmp_pqp,
&priv->steer[i].promisc_qps[j],
list) {
list_del(&pqp->list);
kfree(pqp);
}
list_for_each_entry_safe(entry, tmp_entry,
&priv->steer[i].steer_entries[j],
list) {
list_del(&entry->list);
list_for_each_entry_safe(pqp, tmp_pqp,
&entry->duplicates,
list) {
list_del(&pqp->list);
kfree(pqp);
}
kfree(entry);
}
}
}
kfree(priv->steer);
}
static int extended_func_num(struct pci_dev *pdev)
{
return PCI_SLOT(pdev->devfn) * 8 + PCI_FUNC(pdev->devfn);
}
#define MLX4_OWNER_BASE 0x8069c
#define MLX4_OWNER_SIZE 4
static int mlx4_get_ownership(struct mlx4_dev *dev)
{
void __iomem *owner;
u32 ret;
if (pci_channel_offline(dev->persist->pdev))
return -EIO;
owner = ioremap(pci_resource_start(dev->persist->pdev, 0) +
MLX4_OWNER_BASE,
MLX4_OWNER_SIZE);
if (!owner) {
mlx4_err(dev, "Failed to obtain ownership bit\n");
return -ENOMEM;
}
ret = readl(owner);
iounmap(owner);
return (int) !!ret;
}
static void mlx4_free_ownership(struct mlx4_dev *dev)
{
void __iomem *owner;
if (pci_channel_offline(dev->persist->pdev))
return;
owner = ioremap(pci_resource_start(dev->persist->pdev, 0) +
MLX4_OWNER_BASE,
MLX4_OWNER_SIZE);
if (!owner) {
mlx4_err(dev, "Failed to obtain ownership bit\n");
return;
}
writel(0, owner);
msleep(1000);
iounmap(owner);
}
#define SRIOV_VALID_STATE(flags) (!!((flags) & MLX4_FLAG_SRIOV) ==\
!!((flags) & MLX4_FLAG_MASTER))
static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev,
u8 total_vfs, int existing_vfs, int reset_flow)
{
u64 dev_flags = dev->flags;
int err = 0;
int fw_enabled_sriov_vfs = min(pci_sriov_get_totalvfs(pdev),
MLX4_MAX_NUM_VF);
if (reset_flow) {
dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs),
GFP_KERNEL);
if (!dev->dev_vfs)
goto free_mem;
return dev_flags;
}
atomic_inc(&pf_loading);
if (dev->flags & MLX4_FLAG_SRIOV) {
if (existing_vfs != total_vfs) {
mlx4_err(dev, "SR-IOV was already enabled, but with num_vfs (%d) different than requested (%d)\n",
existing_vfs, total_vfs);
total_vfs = existing_vfs;
}
}
dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL);
if (NULL == dev->dev_vfs) {
mlx4_err(dev, "Failed to allocate memory for VFs\n");
goto disable_sriov;
}
if (!(dev->flags & MLX4_FLAG_SRIOV)) {
if (total_vfs > fw_enabled_sriov_vfs) {
mlx4_err(dev, "requested vfs (%d) > available vfs (%d). Continuing without SR_IOV\n",
total_vfs, fw_enabled_sriov_vfs);
err = -ENOMEM;
goto disable_sriov;
}
mlx4_warn(dev, "Enabling SR-IOV with %d VFs\n", total_vfs);
err = pci_enable_sriov(pdev, total_vfs);
}
if (err) {
mlx4_err(dev, "Failed to enable SR-IOV, continuing without SR-IOV (err = %d)\n",
err);
goto disable_sriov;
} else {
mlx4_warn(dev, "Running in master mode\n");
dev_flags |= MLX4_FLAG_SRIOV |
MLX4_FLAG_MASTER;
dev_flags &= ~MLX4_FLAG_SLAVE;
dev->persist->num_vfs = total_vfs;
}
return dev_flags;
disable_sriov:
atomic_dec(&pf_loading);
free_mem:
dev->persist->num_vfs = 0;
kfree(dev->dev_vfs);
dev->dev_vfs = NULL;
return dev_flags & ~MLX4_FLAG_MASTER;
}
enum {
MLX4_DEV_CAP_CHECK_NUM_VFS_ABOVE_64 = -1,
};
static int mlx4_check_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
int *nvfs)
{
int requested_vfs = nvfs[0] + nvfs[1] + nvfs[2];
/* Checking for 64 VFs as a limitation of CX2 */
if (!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_80_VFS) &&
requested_vfs >= 64) {
mlx4_err(dev, "Requested %d VFs, but FW does not support more than 64\n",
requested_vfs);
return MLX4_DEV_CAP_CHECK_NUM_VFS_ABOVE_64;
}
return 0;
}
static int mlx4_pci_enable_device(struct mlx4_dev *dev)
{
struct pci_dev *pdev = dev->persist->pdev;
int err = 0;
mutex_lock(&dev->persist->pci_status_mutex);
if (dev->persist->pci_status == MLX4_PCI_STATUS_DISABLED) {
err = pci_enable_device(pdev);
if (!err)
dev->persist->pci_status = MLX4_PCI_STATUS_ENABLED;
}
mutex_unlock(&dev->persist->pci_status_mutex);
return err;
}
static void mlx4_pci_disable_device(struct mlx4_dev *dev)
{
struct pci_dev *pdev = dev->persist->pdev;
mutex_lock(&dev->persist->pci_status_mutex);
if (dev->persist->pci_status == MLX4_PCI_STATUS_ENABLED) {
pci_disable_device(pdev);
dev->persist->pci_status = MLX4_PCI_STATUS_DISABLED;
}
mutex_unlock(&dev->persist->pci_status_mutex);
}
static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
int total_vfs, int *nvfs, struct mlx4_priv *priv,
int reset_flow)
{
struct mlx4_dev *dev;
unsigned sum = 0;
int err;
int port;
int i;
struct mlx4_dev_cap *dev_cap = NULL;
int existing_vfs = 0;
dev = &priv->dev;
INIT_LIST_HEAD(&priv->ctx_list);
spin_lock_init(&priv->ctx_lock);
mutex_init(&priv->port_mutex);
mutex_init(&priv->bond_mutex);
INIT_LIST_HEAD(&priv->pgdir_list);
mutex_init(&priv->pgdir_mutex);
spin_lock_init(&priv->cmd.context_lock);
INIT_LIST_HEAD(&priv->bf_list);
mutex_init(&priv->bf_mutex);
dev->rev_id = pdev->revision;
dev->numa_node = dev_to_node(&pdev->dev);
/* Detect if this device is a virtual function */
if (pci_dev_data & MLX4_PCI_DEV_IS_VF) {
mlx4_warn(dev, "Detected virtual function - running in slave mode\n");
dev->flags |= MLX4_FLAG_SLAVE;
} else {
/* We reset the device and enable SRIOV only for physical
* devices. Try to claim ownership on the device;
* if already taken, skip -- do not allow multiple PFs */
err = mlx4_get_ownership(dev);
if (err) {
if (err < 0)
return err;
else {
mlx4_warn(dev, "Multiple PFs not yet supported - Skipping PF\n");
return -EINVAL;
}
}
atomic_set(&priv->opreq_count, 0);
INIT_WORK(&priv->opreq_task, mlx4_opreq_action);
/*
* Now reset the HCA before we touch the PCI capabilities or
* attempt a firmware command, since a boot ROM may have left
* the HCA in an undefined state.
*/
err = mlx4_reset(dev);
if (err) {
mlx4_err(dev, "Failed to reset HCA, aborting\n");
goto err_sriov;
}
if (total_vfs) {
dev->flags = MLX4_FLAG_MASTER;
existing_vfs = pci_num_vf(pdev);
if (existing_vfs)
dev->flags |= MLX4_FLAG_SRIOV;
dev->persist->num_vfs = total_vfs;
}
}
/* on load remove any previous indication of internal error,
* device is up.
*/
dev->persist->state = MLX4_DEVICE_STATE_UP;
slave_start:
err = mlx4_cmd_init(dev);
if (err) {
mlx4_err(dev, "Failed to init command interface, aborting\n");
goto err_sriov;
}
/* In slave functions, the communication channel must be initialized
* before posting commands. Also, init num_slaves before calling
* mlx4_init_hca */
if (mlx4_is_mfunc(dev)) {
if (mlx4_is_master(dev)) {
dev->num_slaves = MLX4_MAX_NUM_SLAVES;
} else {
dev->num_slaves = 0;
err = mlx4_multi_func_init(dev);
if (err) {
mlx4_err(dev, "Failed to init slave mfunc interface, aborting\n");
goto err_cmd;
}
}
}
err = mlx4_init_fw(dev);
if (err) {
mlx4_err(dev, "Failed to init fw, aborting.\n");
goto err_mfunc;
}
if (mlx4_is_master(dev)) {
/* when we hit the goto slave_start below, dev_cap already initialized */
if (!dev_cap) {
dev_cap = kzalloc(sizeof(*dev_cap), GFP_KERNEL);
if (!dev_cap) {
err = -ENOMEM;
goto err_fw;
}
err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
goto err_fw;
}
if (mlx4_check_dev_cap(dev, dev_cap, nvfs))
goto err_fw;
if (!(dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS)) {
u64 dev_flags = mlx4_enable_sriov(dev, pdev,
total_vfs,
existing_vfs,
reset_flow);
mlx4_close_fw(dev);
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
dev->flags = dev_flags;
if (!SRIOV_VALID_STATE(dev->flags)) {
mlx4_err(dev, "Invalid SRIOV state\n");
goto err_sriov;
}
err = mlx4_reset(dev);
if (err) {
mlx4_err(dev, "Failed to reset HCA, aborting.\n");
goto err_sriov;
}
goto slave_start;
}
} else {
/* Legacy mode FW requires SRIOV to be enabled before
* doing QUERY_DEV_CAP, since max_eq's value is different if
* SRIOV is enabled.
*/
memset(dev_cap, 0, sizeof(*dev_cap));
err = mlx4_QUERY_DEV_CAP(dev, dev_cap);
if (err) {
mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
goto err_fw;
}
if (mlx4_check_dev_cap(dev, dev_cap, nvfs))
goto err_fw;
}
}
err = mlx4_init_hca(dev);
if (err) {
if (err == -EACCES) {
/* Not primary Physical function
* Running in slave mode */
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
/* We're not a PF */
if (dev->flags & MLX4_FLAG_SRIOV) {
if (!existing_vfs)
pci_disable_sriov(pdev);
if (mlx4_is_master(dev) && !reset_flow)
atomic_dec(&pf_loading);
dev->flags &= ~MLX4_FLAG_SRIOV;
}
if (!mlx4_is_slave(dev))
mlx4_free_ownership(dev);
dev->flags |= MLX4_FLAG_SLAVE;
dev->flags &= ~MLX4_FLAG_MASTER;
goto slave_start;
} else
goto err_fw;
}
if (mlx4_is_master(dev) && (dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS)) {
u64 dev_flags = mlx4_enable_sriov(dev, pdev, total_vfs,
existing_vfs, reset_flow);
if ((dev->flags ^ dev_flags) & (MLX4_FLAG_MASTER | MLX4_FLAG_SLAVE)) {
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_VHCR);
dev->flags = dev_flags;
err = mlx4_cmd_init(dev);
if (err) {
/* Only VHCR is cleaned up, so could still
* send FW commands
*/
mlx4_err(dev, "Failed to init VHCR command interface, aborting\n");
goto err_close;
}
} else {
dev->flags = dev_flags;
}
if (!SRIOV_VALID_STATE(dev->flags)) {
mlx4_err(dev, "Invalid SRIOV state\n");
goto err_close;
}
}
/* check if the device is functioning at its maximum possible speed.
* No return code for this call, just warn the user in case of PCI
* express device capabilities are under-satisfied by the bus.
*/
if (!mlx4_is_slave(dev))
pcie_print_link_status(dev->persist->pdev);
/* In master functions, the communication channel must be initialized
* after obtaining its address from fw */
if (mlx4_is_master(dev)) {
if (dev->caps.num_ports < 2 &&
num_vfs_argc > 1) {
err = -EINVAL;
mlx4_err(dev,
"Error: Trying to configure VFs on port 2, but HCA has only %d physical ports\n",
dev->caps.num_ports);
goto err_close;
}
memcpy(dev->persist->nvfs, nvfs, sizeof(dev->persist->nvfs));
for (i = 0;
i < sizeof(dev->persist->nvfs)/
sizeof(dev->persist->nvfs[0]); i++) {
unsigned j;
for (j = 0; j < dev->persist->nvfs[i]; ++sum, ++j) {
dev->dev_vfs[sum].min_port = i < 2 ? i + 1 : 1;
dev->dev_vfs[sum].n_ports = i < 2 ? 1 :
dev->caps.num_ports;
}
}
/* In master functions, the communication channel
* must be initialized after obtaining its address from fw
*/
err = mlx4_multi_func_init(dev);
if (err) {
mlx4_err(dev, "Failed to init master mfunc interface, aborting.\n");
goto err_close;
}
}
err = mlx4_alloc_eq_table(dev);
if (err)
goto err_master_mfunc;
bitmap_zero(priv->msix_ctl.pool_bm, MAX_MSIX);
mutex_init(&priv->msix_ctl.pool_lock);
mlx4_enable_msi_x(dev);
if ((mlx4_is_mfunc(dev)) &&
!(dev->flags & MLX4_FLAG_MSI_X)) {
err = -EOPNOTSUPP;
mlx4_err(dev, "INTx is not supported in multi-function mode, aborting\n");
goto err_free_eq;
}
if (!mlx4_is_slave(dev)) {
err = mlx4_init_steering(dev);
if (err)
goto err_disable_msix;
}
mlx4_init_quotas(dev);
err = mlx4_setup_hca(dev);
if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X) &&
!mlx4_is_mfunc(dev)) {
dev->flags &= ~MLX4_FLAG_MSI_X;
dev->caps.num_comp_vectors = 1;
pci_disable_msix(pdev);
err = mlx4_setup_hca(dev);
}
if (err)
goto err_steer;
/* When PF resources are ready arm its comm channel to enable
* getting commands
*/
if (mlx4_is_master(dev)) {
err = mlx4_ARM_COMM_CHANNEL(dev);
if (err) {
mlx4_err(dev, " Failed to arm comm channel eq: %x\n",
err);
goto err_steer;
}
}
for (port = 1; port <= dev->caps.num_ports; port++) {
err = mlx4_init_port_info(dev, port);
if (err)
goto err_port;
}
priv->v2p.port1 = 1;
priv->v2p.port2 = 2;
err = mlx4_register_device(dev);
if (err)
goto err_port;
mlx4_request_modules(dev);
mlx4_sense_init(dev);
mlx4_start_sense(dev);
priv->removed = 0;
if (mlx4_is_master(dev) && dev->persist->num_vfs && !reset_flow)
atomic_dec(&pf_loading);
kfree(dev_cap);
return 0;
err_port:
for (--port; port >= 1; --port)
mlx4_cleanup_port_info(&priv->port[port]);
mlx4_cleanup_default_counters(dev);
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev);
mlx4_cleanup_cq_table(dev);
mlx4_cmd_use_polling(dev);
mlx4_cleanup_eq_table(dev);
mlx4_cleanup_mcg_table(dev);
mlx4_cleanup_mr_table(dev);
mlx4_cleanup_xrcd_table(dev);
mlx4_cleanup_pd_table(dev);
mlx4_cleanup_uar_table(dev);
err_steer:
if (!mlx4_is_slave(dev))
mlx4_clear_steering(dev);
err_disable_msix:
if (dev->flags & MLX4_FLAG_MSI_X)
pci_disable_msix(pdev);
err_free_eq:
mlx4_free_eq_table(dev);
err_master_mfunc:
if (mlx4_is_master(dev)) {
mlx4_free_resource_tracker(dev, RES_TR_FREE_STRUCTS_ONLY);
mlx4_multi_func_cleanup(dev);
}
if (mlx4_is_slave(dev))
mlx4_slave_destroy_special_qp_cap(dev);
err_close:
mlx4_close_hca(dev);
err_fw:
mlx4_close_fw(dev);
err_mfunc:
if (mlx4_is_slave(dev))
mlx4_multi_func_cleanup(dev);
err_cmd:
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
err_sriov:
if (dev->flags & MLX4_FLAG_SRIOV && !existing_vfs) {
pci_disable_sriov(pdev);
dev->flags &= ~MLX4_FLAG_SRIOV;
}
if (mlx4_is_master(dev) && dev->persist->num_vfs && !reset_flow)
atomic_dec(&pf_loading);
kfree(priv->dev.dev_vfs);
if (!mlx4_is_slave(dev))
mlx4_free_ownership(dev);
kfree(dev_cap);
return err;
}
static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data,
struct mlx4_priv *priv)
{
int err;
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int prb_vf[MLX4_MAX_PORTS + 1] = {0, 0, 0};
const int param_map[MLX4_MAX_PORTS + 1][MLX4_MAX_PORTS + 1] = {
{2, 0, 0}, {0, 1, 2}, {0, 1, 2} };
unsigned total_vfs = 0;
unsigned int i;
pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev));
err = mlx4_pci_enable_device(&priv->dev);
if (err) {
dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n");
return err;
}
/* Due to requirement that all VFs and the PF are *guaranteed* 2 MACS
* per port, we must limit the number of VFs to 63 (since their are
* 128 MACs)
*/
for (i = 0; i < ARRAY_SIZE(nvfs) && i < num_vfs_argc;
total_vfs += nvfs[param_map[num_vfs_argc - 1][i]], i++) {
nvfs[param_map[num_vfs_argc - 1][i]] = num_vfs[i];
if (nvfs[i] < 0) {
dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n");
err = -EINVAL;
goto err_disable_pdev;
}
}
for (i = 0; i < ARRAY_SIZE(prb_vf) && i < probe_vfs_argc;
i++) {
prb_vf[param_map[probe_vfs_argc - 1][i]] = probe_vf[i];
if (prb_vf[i] < 0 || prb_vf[i] > nvfs[i]) {
dev_err(&pdev->dev, "probe_vf module parameter cannot be negative or greater than num_vfs\n");
err = -EINVAL;
goto err_disable_pdev;
}
}
if (total_vfs > MLX4_MAX_NUM_VF) {
dev_err(&pdev->dev,
"Requested more VF's (%d) than allowed by hw (%d)\n",
total_vfs, MLX4_MAX_NUM_VF);
err = -EINVAL;
goto err_disable_pdev;
}
for (i = 0; i < MLX4_MAX_PORTS; i++) {
if (nvfs[i] + nvfs[2] > MLX4_MAX_NUM_VF_P_PORT) {
dev_err(&pdev->dev,
"Requested more VF's (%d) for port (%d) than allowed by driver (%d)\n",
nvfs[i] + nvfs[2], i + 1,
MLX4_MAX_NUM_VF_P_PORT);
err = -EINVAL;
goto err_disable_pdev;
}
}
/* Check for BARs. */
if (!(pci_dev_data & MLX4_PCI_DEV_IS_VF) &&
!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "Missing DCS, aborting (driver_data: 0x%x, pci_resource_flags(pdev, 0):0x%lx)\n",
pci_dev_data, pci_resource_flags(pdev, 0));
err = -ENODEV;
goto err_disable_pdev;
}
if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "Missing UAR, aborting\n");
err = -ENODEV;
goto err_disable_pdev;
}
err = pci_request_regions(pdev, DRV_NAME);
if (err) {
dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
goto err_disable_pdev;
}
pci_set_master(pdev);
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
if (err) {
dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask\n");
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting\n");
goto err_release_regions;
}
}
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
if (err) {
dev_warn(&pdev->dev, "Warning: couldn't set 64-bit consistent PCI DMA mask\n");
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, aborting\n");
goto err_release_regions;
}
}
/* Allow large DMA segments, up to the firmware limit of 1 GB */
dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
/* Detect if this device is a virtual function */
if (pci_dev_data & MLX4_PCI_DEV_IS_VF) {
/* When acting as pf, we normally skip vfs unless explicitly
* requested to probe them.
*/
if (total_vfs) {
unsigned vfs_offset = 0;
for (i = 0; i < ARRAY_SIZE(nvfs) &&
vfs_offset + nvfs[i] < extended_func_num(pdev);
vfs_offset += nvfs[i], i++)
;
if (i == ARRAY_SIZE(nvfs)) {
err = -ENODEV;
goto err_release_regions;
}
if ((extended_func_num(pdev) - vfs_offset)
> prb_vf[i]) {
dev_warn(&pdev->dev, "Skipping virtual function:%d\n",
extended_func_num(pdev));
err = -ENODEV;
goto err_release_regions;
}
}
}
err = mlx4_crdump_init(&priv->dev);
if (err)
goto err_release_regions;
err = mlx4_catas_init(&priv->dev);
if (err)
goto err_crdump;
err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 0);
if (err)
goto err_catas;
return 0;
err_catas:
mlx4_catas_end(&priv->dev);
err_crdump:
mlx4_crdump_end(&priv->dev);
err_release_regions:
pci_release_regions(pdev);
err_disable_pdev:
mlx4_pci_disable_device(&priv->dev);
return err;
}
static int mlx4_devlink_port_type_set(struct devlink_port *devlink_port,
enum devlink_port_type port_type)
{
struct mlx4_port_info *info = container_of(devlink_port,
struct mlx4_port_info,
devlink_port);
enum mlx4_port_type mlx4_port_type;
switch (port_type) {
case DEVLINK_PORT_TYPE_AUTO:
mlx4_port_type = MLX4_PORT_TYPE_AUTO;
break;
case DEVLINK_PORT_TYPE_ETH:
mlx4_port_type = MLX4_PORT_TYPE_ETH;
break;
case DEVLINK_PORT_TYPE_IB:
mlx4_port_type = MLX4_PORT_TYPE_IB;
break;
default:
return -EOPNOTSUPP;
}
return __set_port_type(info, mlx4_port_type);
}
static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
{
struct mlx4_priv *priv = devlink_priv(devlink);
struct mlx4_dev *dev = &priv->dev;
struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
union devlink_param_value saved_value;
int err;
err = devlink_param_driverinit_value_get(devlink,
DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
&saved_value);
if (!err && mlx4_internal_err_reset != saved_value.vbool) {
mlx4_internal_err_reset = saved_value.vbool;
/* Notify on value changed on runtime configuration mode */
devlink_param_value_changed(devlink,
DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET);
}
err = devlink_param_driverinit_value_get(devlink,
DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
&saved_value);
if (!err)
log_num_mac = order_base_2(saved_value.vu32);
err = devlink_param_driverinit_value_get(devlink,
MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
&saved_value);
if (!err)
enable_64b_cqe_eqe = saved_value.vbool;
err = devlink_param_driverinit_value_get(devlink,
MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
&saved_value);
if (!err)
enable_4k_uar = saved_value.vbool;
err = devlink_param_driverinit_value_get(devlink,
DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
&saved_value);
if (!err && crdump->snapshot_enable != saved_value.vbool) {
crdump->snapshot_enable = saved_value.vbool;
devlink_param_value_changed(devlink,
DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT);
}
}
static int mlx4_devlink_reload(struct devlink *devlink,
struct netlink_ext_ack *extack)
{
struct mlx4_priv *priv = devlink_priv(devlink);
struct mlx4_dev *dev = &priv->dev;
struct mlx4_dev_persistent *persist = dev->persist;
int err;
if (persist->num_vfs)
mlx4_warn(persist->dev, "Reload performed on PF, will cause reset on operating Virtual Functions\n");
err = mlx4_restart_one(persist->pdev, true, devlink);
if (err)
mlx4_err(persist->dev, "mlx4_restart_one failed, ret=%d\n", err);
return err;
}
static const struct devlink_ops mlx4_devlink_ops = {
.port_type_set = mlx4_devlink_port_type_set,
.reload = mlx4_devlink_reload,
};
static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct devlink *devlink;
struct mlx4_priv *priv;
struct mlx4_dev *dev;
int ret;
printk_once(KERN_INFO "%s", mlx4_version);
devlink = devlink_alloc(&mlx4_devlink_ops, sizeof(*priv));
if (!devlink)
return -ENOMEM;
priv = devlink_priv(devlink);
dev = &priv->dev;
dev->persist = kzalloc(sizeof(*dev->persist), GFP_KERNEL);
if (!dev->persist) {
ret = -ENOMEM;
goto err_devlink_free;
}
dev->persist->pdev = pdev;
dev->persist->dev = dev;
pci_set_drvdata(pdev, dev->persist);
priv->pci_dev_data = id->driver_data;
mutex_init(&dev->persist->device_state_mutex);
mutex_init(&dev->persist->interface_state_mutex);
mutex_init(&dev->persist->pci_status_mutex);
ret = devlink_register(devlink, &pdev->dev);
if (ret)
goto err_persist_free;
ret = devlink_params_register(devlink, mlx4_devlink_params,
ARRAY_SIZE(mlx4_devlink_params));
if (ret)
goto err_devlink_unregister;
mlx4_devlink_set_params_init_values(devlink);
ret = __mlx4_init_one(pdev, id->driver_data, priv);
if (ret)
goto err_params_unregister;
pci_save_state(pdev);
return 0;
err_params_unregister:
devlink_params_unregister(devlink, mlx4_devlink_params,
ARRAY_SIZE(mlx4_devlink_params));
err_devlink_unregister:
devlink_unregister(devlink);
err_persist_free:
kfree(dev->persist);
err_devlink_free:
devlink_free(devlink);
return ret;
}
static void mlx4_clean_dev(struct mlx4_dev *dev)
{
struct mlx4_dev_persistent *persist = dev->persist;
struct mlx4_priv *priv = mlx4_priv(dev);
unsigned long flags = (dev->flags & RESET_PERSIST_MASK_FLAGS);
memset(priv, 0, sizeof(*priv));
priv->dev.persist = persist;
priv->dev.flags = flags;
}
static void mlx4_unload_one(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
int pci_dev_data;
int p, i;
if (priv->removed)
return;
/* saving current ports type for further use */
for (i = 0; i < dev->caps.num_ports; i++) {
dev->persist->curr_port_type[i] = dev->caps.port_type[i + 1];
dev->persist->curr_port_poss_type[i] = dev->caps.
possible_type[i + 1];
}
pci_dev_data = priv->pci_dev_data;
mlx4_stop_sense(dev);
mlx4_unregister_device(dev);
for (p = 1; p <= dev->caps.num_ports; p++) {
mlx4_cleanup_port_info(&priv->port[p]);
mlx4_CLOSE_PORT(dev, p);
}
if (mlx4_is_master(dev))
mlx4_free_resource_tracker(dev,
RES_TR_FREE_SLAVES_ONLY);
mlx4_cleanup_default_counters(dev);
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev);
mlx4_cleanup_cq_table(dev);
mlx4_cmd_use_polling(dev);
mlx4_cleanup_eq_table(dev);
mlx4_cleanup_mcg_table(dev);
mlx4_cleanup_mr_table(dev);
mlx4_cleanup_xrcd_table(dev);
mlx4_cleanup_pd_table(dev);
if (mlx4_is_master(dev))
mlx4_free_resource_tracker(dev,
RES_TR_FREE_STRUCTS_ONLY);
iounmap(priv->kar);
mlx4_uar_free(dev, &priv->driver_uar);
mlx4_cleanup_uar_table(dev);
if (!mlx4_is_slave(dev))
mlx4_clear_steering(dev);
mlx4_free_eq_table(dev);
if (mlx4_is_master(dev))
mlx4_multi_func_cleanup(dev);
mlx4_close_hca(dev);
mlx4_close_fw(dev);
if (mlx4_is_slave(dev))
mlx4_multi_func_cleanup(dev);
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
if (dev->flags & MLX4_FLAG_MSI_X)
pci_disable_msix(pdev);
if (!mlx4_is_slave(dev))
mlx4_free_ownership(dev);
mlx4_slave_destroy_special_qp_cap(dev);
kfree(dev->dev_vfs);
mlx4_clean_dev(dev);
priv->pci_dev_data = pci_dev_data;
priv->removed = 1;
}
static void mlx4_remove_one(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
struct devlink *devlink = priv_to_devlink(priv);
int active_vfs = 0;
if (mlx4_is_slave(dev))
persist->interface_state |= MLX4_INTERFACE_STATE_NOWAIT;
mutex_lock(&persist->interface_state_mutex);
persist->interface_state |= MLX4_INTERFACE_STATE_DELETION;
mutex_unlock(&persist->interface_state_mutex);
/* Disabling SR-IOV is not allowed while there are active vf's */
if (mlx4_is_master(dev) && dev->flags & MLX4_FLAG_SRIOV) {
active_vfs = mlx4_how_many_lives_vf(dev);
if (active_vfs) {
pr_warn("Removing PF when there are active VF's !!\n");
pr_warn("Will not disable SR-IOV.\n");
}
}
/* device marked to be under deletion running now without the lock
* letting other tasks to be terminated
*/
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
else
mlx4_info(dev, "%s: interface is down\n", __func__);
mlx4_catas_end(dev);
mlx4_crdump_end(dev);
if (dev->flags & MLX4_FLAG_SRIOV && !active_vfs) {
mlx4_warn(dev, "Disabling SR-IOV\n");
pci_disable_sriov(pdev);
}
pci_release_regions(pdev);
mlx4_pci_disable_device(dev);
devlink_params_unregister(devlink, mlx4_devlink_params,
ARRAY_SIZE(mlx4_devlink_params));
devlink_unregister(devlink);
kfree(dev->persist);
devlink_free(devlink);
}
static int restore_current_port_types(struct mlx4_dev *dev,
enum mlx4_port_type *types,
enum mlx4_port_type *poss_types)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int err, i;
mlx4_stop_sense(dev);
mutex_lock(&priv->port_mutex);
for (i = 0; i < dev->caps.num_ports; i++)
dev->caps.possible_type[i + 1] = poss_types[i];
err = mlx4_change_port_types(dev, types);
mlx4_start_sense(dev);
mutex_unlock(&priv->port_mutex);
return err;
}
int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int pci_dev_data, err, total_vfs;
pci_dev_data = priv->pci_dev_data;
total_vfs = dev->persist->num_vfs;
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
mlx4_unload_one(pdev);
if (reload)
mlx4_devlink_param_load_driverinit_values(devlink);
err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 1);
if (err) {
mlx4_err(dev, "%s: ERROR: mlx4_load_one failed, pci_name=%s, err=%d\n",
__func__, pci_name(pdev), err);
return err;
}
err = restore_current_port_types(dev, dev->persist->curr_port_type,
dev->persist->curr_port_poss_type);
if (err)
mlx4_err(dev, "could not restore original port types (%d)\n",
err);
return err;
}
#define MLX_SP(id) { PCI_VDEVICE(MELLANOX, id), MLX4_PCI_DEV_FORCE_SENSE_PORT }
#define MLX_VF(id) { PCI_VDEVICE(MELLANOX, id), MLX4_PCI_DEV_IS_VF }
#define MLX_GN(id) { PCI_VDEVICE(MELLANOX, id), 0 }
static const struct pci_device_id mlx4_pci_table[] = {
#ifdef CONFIG_MLX4_CORE_GEN2
/* MT25408 "Hermon" */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_SDR), /* SDR */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_DDR), /* DDR */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_QDR), /* QDR */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_DDR_GEN2), /* DDR Gen2 */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_QDR_GEN2), /* QDR Gen2 */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_EN), /* EN 10GigE */
MLX_SP(PCI_DEVICE_ID_MELLANOX_HERMON_EN_GEN2), /* EN 10GigE Gen2 */
/* MT25458 ConnectX EN 10GBASE-T */
MLX_SP(PCI_DEVICE_ID_MELLANOX_CONNECTX_EN),
MLX_SP(PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_T_GEN2), /* Gen2 */
/* MT26468 ConnectX EN 10GigE PCIe Gen2*/
MLX_SP(PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_GEN2),
/* MT26438 ConnectX EN 40GigE PCIe Gen2 5GT/s */
MLX_SP(PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_5_GEN2),
/* MT26478 ConnectX2 40GigE PCIe Gen2 */
MLX_SP(PCI_DEVICE_ID_MELLANOX_CONNECTX2),
/* MT25400 Family [ConnectX-2] */
MLX_VF(0x1002), /* Virtual Function */
#endif /* CONFIG_MLX4_CORE_GEN2 */
/* MT27500 Family [ConnectX-3] */
MLX_GN(PCI_DEVICE_ID_MELLANOX_CONNECTX3),
MLX_VF(0x1004), /* Virtual Function */
MLX_GN(0x1005), /* MT27510 Family */
MLX_GN(0x1006), /* MT27511 Family */
MLX_GN(PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO), /* MT27520 Family */
MLX_GN(0x1008), /* MT27521 Family */
MLX_GN(0x1009), /* MT27530 Family */
MLX_GN(0x100a), /* MT27531 Family */
MLX_GN(0x100b), /* MT27540 Family */
MLX_GN(0x100c), /* MT27541 Family */
MLX_GN(0x100d), /* MT27550 Family */
MLX_GN(0x100e), /* MT27551 Family */
MLX_GN(0x100f), /* MT27560 Family */
MLX_GN(0x1010), /* MT27561 Family */
/*
* See the mellanox_check_broken_intx_masking() quirk when
* adding devices
*/
{ 0, }
};
MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
pci_channel_state_t state)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
mlx4_err(persist->dev, "mlx4_pci_err_detected was called\n");
mlx4_enter_error_state(persist);
mutex_lock(&persist->interface_state_mutex);
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
mutex_unlock(&persist->interface_state_mutex);
if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
mlx4_pci_disable_device(persist->dev);
return PCI_ERS_RESULT_NEED_RESET;
}
static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
int err;
mlx4_err(dev, "mlx4_pci_slot_reset was called\n");
err = mlx4_pci_enable_device(dev);
if (err) {
mlx4_err(dev, "Can not re-enable device, err=%d\n", err);
return PCI_ERS_RESULT_DISCONNECT;
}
pci_set_master(pdev);
pci_restore_state(pdev);
pci_save_state(pdev);
return PCI_ERS_RESULT_RECOVERED;
}
static void mlx4_pci_resume(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int total_vfs;
int err;
mlx4_err(dev, "%s was called\n", __func__);
total_vfs = dev->persist->num_vfs;
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
mutex_lock(&persist->interface_state_mutex);
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
err = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs,
priv, 1);
if (err) {
mlx4_err(dev, "%s: mlx4_load_one failed, err=%d\n",
__func__, err);
goto end;
}
err = restore_current_port_types(dev, dev->persist->
curr_port_type, dev->persist->
curr_port_poss_type);
if (err)
mlx4_err(dev, "could not restore original port types (%d)\n", err);
}
end:
mutex_unlock(&persist->interface_state_mutex);
}
static void mlx4_shutdown(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
mlx4_info(persist->dev, "mlx4_shutdown was called\n");
mutex_lock(&persist->interface_state_mutex);
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
mutex_unlock(&persist->interface_state_mutex);
}
static const struct pci_error_handlers mlx4_err_handler = {
.error_detected = mlx4_pci_err_detected,
.slot_reset = mlx4_pci_slot_reset,
.resume = mlx4_pci_resume,
};
static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
mlx4_err(dev, "suspend was called\n");
mutex_lock(&persist->interface_state_mutex);
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
mutex_unlock(&persist->interface_state_mutex);
return 0;
}
static int mlx4_resume(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int total_vfs;
int ret = 0;
mlx4_err(dev, "resume was called\n");
total_vfs = dev->persist->num_vfs;
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
mutex_lock(&persist->interface_state_mutex);
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs,
nvfs, priv, 1);
if (!ret) {
ret = restore_current_port_types(dev,
dev->persist->curr_port_type,
dev->persist->curr_port_poss_type);
if (ret)
mlx4_err(dev, "resume: could not restore original port types (%d)\n", ret);
}
}
mutex_unlock(&persist->interface_state_mutex);
return ret;
}
static struct pci_driver mlx4_driver = {
.name = DRV_NAME,
.id_table = mlx4_pci_table,
.probe = mlx4_init_one,
.shutdown = mlx4_shutdown,
.remove = mlx4_remove_one,
.suspend = mlx4_suspend,
.resume = mlx4_resume,
.err_handler = &mlx4_err_handler,
};
static int __init mlx4_verify_params(void)
{
if (msi_x < 0) {
pr_warn("mlx4_core: bad msi_x: %d\n", msi_x);
return -1;
}
if ((log_num_mac < 0) || (log_num_mac > 7)) {
pr_warn("mlx4_core: bad num_mac: %d\n", log_num_mac);
return -1;
}
if (log_num_vlan != 0)
pr_warn("mlx4_core: log_num_vlan - obsolete module param, using %d\n",
MLX4_LOG_NUM_VLANS);
if (use_prio != 0)
pr_warn("mlx4_core: use_prio - obsolete module param, ignored\n");
if ((log_mtts_per_seg < 0) || (log_mtts_per_seg > 7)) {
pr_warn("mlx4_core: bad log_mtts_per_seg: %d\n",
log_mtts_per_seg);
return -1;
}
/* Check if module param for ports type has legal combination */
if (port_type_array[0] == false && port_type_array[1] == true) {
pr_warn("Module parameter configuration ETH/IB is not supported. Switching to default configuration IB/IB\n");
port_type_array[0] = true;
}
if (mlx4_log_num_mgm_entry_size < -7 ||
(mlx4_log_num_mgm_entry_size > 0 &&
(mlx4_log_num_mgm_entry_size < MLX4_MIN_MGM_LOG_ENTRY_SIZE ||
mlx4_log_num_mgm_entry_size > MLX4_MAX_MGM_LOG_ENTRY_SIZE))) {
pr_warn("mlx4_core: mlx4_log_num_mgm_entry_size (%d) not in legal range (-7..0 or %d..%d)\n",
mlx4_log_num_mgm_entry_size,
MLX4_MIN_MGM_LOG_ENTRY_SIZE,
MLX4_MAX_MGM_LOG_ENTRY_SIZE);
return -1;
}
return 0;
}
static int __init mlx4_init(void)
{
int ret;
if (mlx4_verify_params())
return -EINVAL;
mlx4_wq = create_singlethread_workqueue("mlx4");
if (!mlx4_wq)
return -ENOMEM;
ret = pci_register_driver(&mlx4_driver);
if (ret < 0)
destroy_workqueue(mlx4_wq);
return ret < 0 ? ret : 0;
}
static void __exit mlx4_cleanup(void)
{
pci_unregister_driver(&mlx4_driver);
destroy_workqueue(mlx4_wq);
}
module_init(mlx4_init);
module_exit(mlx4_cleanup);
| gpl-2.0 |
SeeyaSia/www | web/libraries/ckeditor/tests/tickets/8103/_assets/tc1_word2010_gecko.html | 18626 | <!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:TargetScreenSize>800x600</o:TargetScreenSize>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<ol style="margin-top:0cm" start="1" type="1"><li class="MsoNormal" style="mso-list:l0 level1 lfo1">Item1</li><ol style="margin-top:0cm" start="1" type="a"><li class="MsoNormal" style="mso-list:l0 level2 lfo1">Item1.1</li><li class="MsoNormal" style="mso-list:l0 level2 lfo1">Item1.2</li></ol><li class="MsoNormal" style="mso-list:l0 level1 lfo1">Item2</li><ol style="margin-top:0cm" start="1" type="a"><li class="MsoNormal" style="mso-list:l0 level2 lfo1">Item2.1</li><li class="MsoNormal" style="mso-list:l0 level2 lfo1">Item2.2</li></ol><li class="MsoNormal" style="mso-list:l0 level1 lfo1">Item3</li></ol>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>PL</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="0" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:Standardowy;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
</style>
<![endif]-->
=>
<ol>
<li>Item1
<ol>
<li>Item1.1</li>
<li>Item1.2</li>
</ol>
</li>
<li>Item2
<ol>
<li>Item2.1</li>
<li>Item2.2</li>
</ol>
</li>
<li>Item3</li>
</ol> | gpl-2.0 |
h0tw1r3/mame | src/mame/drivers/comx35.cpp | 23542 | // license:BSD-3-Clause
// copyright-holders:Curt Coder
/*
TODO:
- tape input/output
- PL-80 plotter
- serial printer
- thermal printer
*/
#include "includes/comx35.h"
#include "formats/imageutl.h"
#include "softlist.h"
/***************************************************************************
PARAMETERS
***************************************************************************/
#define LOG 0
enum
{
COMX_TYPE_BINARY = 1,
COMX_TYPE_BASIC,
COMX_TYPE_BASIC_FM,
COMX_TYPE_RESERVED,
COMX_TYPE_DATA
};
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
image_fread_memory - read image to memory
-------------------------------------------------*/
void comx35_state::image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
UINT8 *ram = m_ram->pointer() + (addr - 0x4000);
image.fread(ram, count);
}
/*-------------------------------------------------
QUICKLOAD_LOAD_MEMBER( comx35_state, comx35_comx )
-------------------------------------------------*/
QUICKLOAD_LOAD_MEMBER( comx35_state, comx35_comx )
{
address_space &program = m_maincpu->space(AS_PROGRAM);
UINT8 header[16] = {0};
int size = image.length();
if (size > m_ram->size())
{
return IMAGE_INIT_FAIL;
}
image.fread( header, 5);
if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' )
{
return IMAGE_INIT_FAIL;
}
switch (header[0])
{
case COMX_TYPE_BINARY:
/*
Type 1: pure machine code (i.e. no basic)
Byte 0 to 4: 1 - 'COMX'
Byte 5 and 6: Start address (1802 way; see above)
Byte 6 and 7: End address
Byte 9 and 10: Execution address
Byte 11 to Eof, should be stored in ram from start to end; execution address
'xxxx' for the CALL (@xxxx) basic statement to actually run the code.
*/
{
UINT16 start_address, end_address, run_address;
image.fread(header, 6);
start_address = pick_integer_be(header, 0, 2);
end_address = pick_integer_be(header, 2, 2);
run_address = pick_integer_be(header, 4, 2);
image_fread_memory(image, start_address, end_address - start_address);
popmessage("Type CALL (@%04x) to start program", run_address);
}
break;
case COMX_TYPE_BASIC:
/*
Type 2: Regular basic code or machine code followed by basic
Byte 0 to 4: 2 - 'COMX'
Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282
Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284
Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293
Byte 11 and 12: start array to be stored on 0x4294 and 0x4295
Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A
Byte 15 to Eof to be stored on 0x4400 and onwards
Byte 0x4281-0x429A (or at least the ones above) should be set otherwise
BASIC won't 'see' the code.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x4400, size);
break;
case COMX_TYPE_BASIC_FM:
/*
Type 3: F&M basic load
Not the most important! But we designed our own basic extension, you can
find it in the F&M basic folder as F&M Basic.comx. When you run this all
basic code should start at address 0x6700 instead of 0x4400 as from
0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type
2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of
this format can also be found in the same folder as the F&M basic.comx file.
*/
image_fread_memory(image, 0x4281, 4);
image_fread_memory(image, 0x4292, 4);
image_fread_memory(image, 0x4299, 2);
image_fread_memory(image, 0x6700, size);
break;
case COMX_TYPE_RESERVED:
/*
Type 4: Incorrect DATA format, I suggest to forget this one as it won't work
in most cases. Instead I left this one reserved and designed Type 5 instead.
*/
break;
case COMX_TYPE_DATA:
/*
Type 5: Data load
Byte 0 to 4: 5 - 'COMX'
Byte 5 and 6: Array length
Byte 7 to Eof: Basic 'data'
To load this first get the 'start array' from the running COMX, i.e. address
0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e.
file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the
'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the
'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the
'start array' value fetched from 0x4295/0x4296.
*/
{
UINT16 start_array, end_array, start_string, array_length;
image.fread(header, 2);
array_length = pick_integer_be(header, 0, 2);
start_array = (program.read_byte(0x4295) << 8) | program.read_byte(0x4296);
end_array = start_array + (size - 7);
program.write_byte(0x4299, end_array >> 8);
program.write_byte(0x429a, end_array & 0xff);
start_string = start_array + array_length;
program.write_byte(0x4292, start_string >> 8);
program.write_byte(0x4293, start_string & 0xff);
image_fread_memory(image, start_array, size);
}
break;
}
return IMAGE_INIT_PASS;
}
//**************************************************************************
// MEMORY ACCESS
//**************************************************************************
//-------------------------------------------------
// mem_r - memory read
//-------------------------------------------------
READ8_MEMBER( comx35_state::mem_r )
{
int extrom = 1;
UINT8 data = m_exp->mrd_r(space, offset, &extrom);
if (offset < 0x4000)
{
if (extrom) data = m_rom->base()[offset & 0x3fff];
}
else if (offset >= 0x4000 && offset < 0xc000)
{
data = m_ram->pointer()[offset - 0x4000];
}
else if (offset >= 0xf400 && offset < 0xf800)
{
data = m_vis->char_ram_r(space, offset & 0x3ff);
}
return data;
}
//-------------------------------------------------
// mem_w - memory write
//-------------------------------------------------
WRITE8_MEMBER( comx35_state::mem_w )
{
m_exp->mwr_w(space, offset, data);
if (offset >= 0x4000 && offset < 0xc000)
{
m_ram->pointer()[offset - 0x4000] = data;
}
else if (offset >= 0xf400 && offset < 0xf800)
{
m_vis->char_ram_w(space, offset & 0x3ff, data);
}
else if (offset >= 0xf800)
{
m_vis->page_ram_w(space, offset & 0x3ff, data);
}
}
//-------------------------------------------------
// io_r - I/O read
//-------------------------------------------------
READ8_MEMBER( comx35_state::io_r )
{
UINT8 data = m_exp->io_r(space, offset);
if (offset == 3)
{
data = m_kbe->read(space, 0);
}
return data;
}
//-------------------------------------------------
// io_w - I/O write
//-------------------------------------------------
WRITE8_MEMBER( comx35_state::io_w )
{
m_exp->io_w(space, offset, data);
if (offset >= 3)
{
cdp1869_w(space, offset, data);
}
}
//**************************************************************************
// ADDRESS MAPS
//**************************************************************************
//-------------------------------------------------
// ADDRESS_MAP( comx35_mem )
//-------------------------------------------------
static ADDRESS_MAP_START( comx35_mem, AS_PROGRAM, 8, comx35_state )
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x0000, 0xffff) AM_READWRITE(mem_r, mem_w)
ADDRESS_MAP_END
//-------------------------------------------------
// ADDRESS_MAP( comx35_io )
//-------------------------------------------------
static ADDRESS_MAP_START( comx35_io, AS_IO, 8, comx35_state )
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x00, 0x07) AM_READWRITE(io_r, io_w)
ADDRESS_MAP_END
//**************************************************************************
// INPUT PORTS
//**************************************************************************
//-------------------------------------------------
// INPUT_CHANGED_MEMBER( comx35_reset )
//-------------------------------------------------
INPUT_CHANGED_MEMBER( comx35_state::trigger_reset )
{
if (newval && BIT(m_d6->read(), 7))
{
machine_reset();
}
}
//-------------------------------------------------
// INPUT_PORTS( comx35 )
//-------------------------------------------------
static INPUT_PORTS_START( comx35 )
PORT_START("D1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0 \xE2\x96\xA0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('@')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('?')
PORT_START("D2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('[')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(']')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR(':')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR(';')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('<') PORT_CHAR('(')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('=') PORT_CHAR('^')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('>') PORT_CHAR(')')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('\\') PORT_CHAR('_')
PORT_START("D3")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('?')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
PORT_START("D4")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
PORT_START("D5")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
PORT_START("D6")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR('+') PORT_CHAR('{')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('-') PORT_CHAR('|')
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('*') PORT_CHAR('}')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('~')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') PORT_CHAR(8)
PORT_START("D7")
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("D8")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CR") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(UTF8_UP) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(UTF8_RIGHT) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(UTF8_LEFT) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(UTF8_DOWN) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("DEL") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("D9")
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("D10")
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("D11")
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("MODIFIERS")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_WRITE_LINE_DEVICE_MEMBER(CDP1871_TAG, cdp1871_device, shift_w)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CNTL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL)) PORT_WRITE_LINE_DEVICE_MEMBER(CDP1871_TAG, cdp1871_device, control_w)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("RESET")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RT") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) PORT_CHANGED_MEMBER(DEVICE_SELF, comx35_state, trigger_reset, 0)
INPUT_PORTS_END
//**************************************************************************
// DEVICE CONFIGURATION
//**************************************************************************
//-------------------------------------------------
// COSMAC_INTERFACE( cosmac_intf )
//-------------------------------------------------
void comx35_state::check_interrupt()
{
m_maincpu->set_input_line(COSMAC_INPUT_LINE_INT, m_cr1 || m_int);
}
READ_LINE_MEMBER( comx35_state::clear_r )
{
return m_clear;
}
READ_LINE_MEMBER( comx35_state::ef2_r )
{
if (m_iden)
{
// interrupts disabled: PAL/NTSC
return m_vis->pal_ntsc_r();
}
else
{
// interrupts enabled: keyboard repeat
return m_kbe->rpt_r();
}
}
READ_LINE_MEMBER( comx35_state::ef4_r )
{
return m_exp->ef4_r(); // | (m_cassette->input() > 0.0f);
}
WRITE_LINE_MEMBER( comx35_state::q_w )
{
m_q = state;
if (m_iden && state)
{
// enable interrupts
m_iden = 0;
}
// cassette output
m_cassette->output(state ? +1.0 : -1.0);
// expansion bus
m_exp->q_w(state);
}
WRITE8_MEMBER( comx35_state::sc_w )
{
switch (data)
{
case COSMAC_STATE_CODE_S0_FETCH:
// not connected
break;
case COSMAC_STATE_CODE_S1_EXECUTE:
// every other S1 triggers a DMAOUT request
if (m_dma)
{
m_dma = 0;
if (!m_iden)
{
m_maincpu->set_input_line(COSMAC_INPUT_LINE_DMAOUT, ASSERT_LINE);
}
}
else
{
m_dma = 1;
}
break;
case COSMAC_STATE_CODE_S2_DMA:
// DMA acknowledge clears the DMAOUT request
m_maincpu->set_input_line(COSMAC_INPUT_LINE_DMAOUT, CLEAR_LINE);
break;
case COSMAC_STATE_CODE_S3_INTERRUPT:
// interrupt acknowledge clears the INT request
m_maincpu->set_input_line(COSMAC_INPUT_LINE_INT, CLEAR_LINE);
break;
}
}
//-------------------------------------------------
// COMX_EXPANSION_INTERFACE( expansion_intf )
//-------------------------------------------------
WRITE_LINE_MEMBER( comx35_state::irq_w )
{
m_int = state;
check_interrupt();
}
//**************************************************************************
// MACHINE INITIALIZATION
//**************************************************************************
//-------------------------------------------------
// device_timer - handler timer events
//-------------------------------------------------
void comx35_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
switch (id)
{
case TIMER_ID_RESET:
m_clear = 1;
break;
}
}
//-------------------------------------------------
// MACHINE_START( comx35 )
//-------------------------------------------------
void comx35_state::machine_start()
{
// clear the RAM since DOS card will go crazy if RAM is not all zeroes
UINT8 *ram = m_ram->pointer();
memset(ram, 0, m_ram->size());
// register for state saving
save_item(NAME(m_clear));
save_item(NAME(m_q));
save_item(NAME(m_iden));
save_item(NAME(m_dma));
save_item(NAME(m_int));
save_item(NAME(m_prd));
save_item(NAME(m_cr1));
}
void comx35_state::machine_reset()
{
m_exp->reset();
int t = RES_K(27) * CAP_U(1) * 1000; // t = R1 * C1
m_clear = 0;
m_iden = 1;
m_cr1 = 1;
m_int = CLEAR_LINE;
m_prd = CLEAR_LINE;
timer_set(attotime::from_msec(t), TIMER_ID_RESET);
}
//**************************************************************************
// MACHINE DRIVERS
//**************************************************************************
//-------------------------------------------------
// MACHINE_CONFIG( pal )
//-------------------------------------------------
static MACHINE_CONFIG_START( pal, comx35_state )
// basic system hardware
MCFG_CPU_ADD(CDP1802_TAG, CDP1802, CDP1869_CPU_CLK_PAL)
MCFG_CPU_PROGRAM_MAP(comx35_mem)
MCFG_CPU_IO_MAP(comx35_io)
MCFG_COSMAC_WAIT_CALLBACK(VCC)
MCFG_COSMAC_CLEAR_CALLBACK(READLINE(comx35_state, clear_r))
MCFG_COSMAC_EF2_CALLBACK(READLINE(comx35_state, ef2_r))
MCFG_COSMAC_EF4_CALLBACK(READLINE(comx35_state, ef4_r))
MCFG_COSMAC_Q_CALLBACK(WRITELINE(comx35_state, q_w))
MCFG_COSMAC_SC_CALLBACK(WRITE8(comx35_state, sc_w))
// sound and video hardware
MCFG_FRAGMENT_ADD(comx35_pal_video)
// peripheral hardware
MCFG_DEVICE_ADD(CDP1871_TAG, CDP1871, CDP1869_CPU_CLK_PAL/8)
MCFG_CDP1871_D1_CALLBACK(IOPORT("D1"))
MCFG_CDP1871_D2_CALLBACK(IOPORT("D2"))
MCFG_CDP1871_D3_CALLBACK(IOPORT("D3"))
MCFG_CDP1871_D4_CALLBACK(IOPORT("D4"))
MCFG_CDP1871_D5_CALLBACK(IOPORT("D5"))
MCFG_CDP1871_D6_CALLBACK(IOPORT("D6"))
MCFG_CDP1871_D7_CALLBACK(IOPORT("D7"))
MCFG_CDP1871_D8_CALLBACK(IOPORT("D8"))
MCFG_CDP1871_D9_CALLBACK(IOPORT("D9"))
MCFG_CDP1871_D10_CALLBACK(IOPORT("D10"))
MCFG_CDP1871_D11_CALLBACK(IOPORT("D11"))
MCFG_CDP1871_DA_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF3))
MCFG_QUICKLOAD_ADD("quickload", comx35_state, comx35_comx, "comx", 0)
MCFG_CASSETTE_ADD("cassette")
MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)
// expansion bus
MCFG_COMX_EXPANSION_SLOT_ADD(EXPANSION_TAG, comx_expansion_cards, "eb")
MCFG_COMX_EXPANSION_SLOT_IRQ_CALLBACK(WRITELINE(comx35_state, irq_w))
// internal ram
MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("32K")
// software lists
MCFG_SOFTWARE_LIST_ADD("flop_list", "comx35_flop")
MACHINE_CONFIG_END
//-------------------------------------------------
// MACHINE_CONFIG( ntsc )
//-------------------------------------------------
static MACHINE_CONFIG_START( ntsc, comx35_state )
// basic system hardware
MCFG_CPU_ADD(CDP1802_TAG, CDP1802, CDP1869_CPU_CLK_NTSC)
MCFG_CPU_PROGRAM_MAP(comx35_mem)
MCFG_CPU_IO_MAP(comx35_io)
MCFG_COSMAC_WAIT_CALLBACK(VCC)
MCFG_COSMAC_CLEAR_CALLBACK(READLINE(comx35_state, clear_r))
MCFG_COSMAC_EF2_CALLBACK(READLINE(comx35_state, ef2_r))
MCFG_COSMAC_EF4_CALLBACK(READLINE(comx35_state, ef4_r))
MCFG_COSMAC_Q_CALLBACK(WRITELINE(comx35_state, q_w))
MCFG_COSMAC_SC_CALLBACK(WRITE8(comx35_state, sc_w))
// sound and video hardware
MCFG_FRAGMENT_ADD(comx35_ntsc_video)
// peripheral hardware
MCFG_DEVICE_ADD(CDP1871_TAG, CDP1871, CDP1869_CPU_CLK_PAL/8)
MCFG_CDP1871_D1_CALLBACK(IOPORT("D1"))
MCFG_CDP1871_D2_CALLBACK(IOPORT("D2"))
MCFG_CDP1871_D3_CALLBACK(IOPORT("D3"))
MCFG_CDP1871_D4_CALLBACK(IOPORT("D4"))
MCFG_CDP1871_D5_CALLBACK(IOPORT("D5"))
MCFG_CDP1871_D6_CALLBACK(IOPORT("D6"))
MCFG_CDP1871_D7_CALLBACK(IOPORT("D7"))
MCFG_CDP1871_D8_CALLBACK(IOPORT("D8"))
MCFG_CDP1871_D9_CALLBACK(IOPORT("D9"))
MCFG_CDP1871_D10_CALLBACK(IOPORT("D10"))
MCFG_CDP1871_D11_CALLBACK(IOPORT("D11"))
MCFG_CDP1871_DA_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF3))
MCFG_QUICKLOAD_ADD("quickload", comx35_state, comx35_comx, "comx", 0)
MCFG_CASSETTE_ADD("cassette")
MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)
// expansion bus
MCFG_COMX_EXPANSION_SLOT_ADD(EXPANSION_TAG, comx_expansion_cards, "eb")
MCFG_COMX_EXPANSION_SLOT_IRQ_CALLBACK(WRITELINE(comx35_state, irq_w))
// internal ram
MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("32K")
// software lists
MCFG_SOFTWARE_LIST_ADD("flop_list", "comx35_flop")
MACHINE_CONFIG_END
//**************************************************************************
// ROMS
//**************************************************************************
//-------------------------------------------------
// ROM( comx35p )
//-------------------------------------------------
ROM_START( comx35p )
ROM_REGION( 0x4000, CDP1802_TAG, 0 )
ROM_DEFAULT_BIOS( "basic100" )
ROM_SYSTEM_BIOS( 0, "basic100", "COMX BASIC V1.00" )
ROMX_LOAD( "comx_10.u21", 0x0000, 0x4000, CRC(68d0db2d) SHA1(062328361629019ceed9375afac18e2b7849ce47), ROM_BIOS(1) )
ROM_SYSTEM_BIOS( 1, "basic101", "COMX BASIC V1.01" )
ROMX_LOAD( "comx_11.u21", 0x0000, 0x4000, CRC(609d89cd) SHA1(799646810510d8236fbfafaff7a73d5170990f16), ROM_BIOS(2) )
ROM_END
//-------------------------------------------------
// ROM( comx35n )
//-------------------------------------------------
#define rom_comx35n rom_comx35p
//**************************************************************************
// SYSTEM DRIVERS
//**************************************************************************
// YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS
COMP( 1983, comx35p, 0, 0, pal, comx35, driver_device, 0, "Comx World Operations Ltd", "COMX 35 (PAL)", MACHINE_IMPERFECT_SOUND )
COMP( 1983, comx35n, comx35p,0, ntsc, comx35, driver_device, 0, "Comx World Operations Ltd", "COMX 35 (NTSC)", MACHINE_IMPERFECT_SOUND )
| gpl-2.0 |
Endika/rpcs3 | rpcs3/Emu/SysCalls/Modules/cellSpurs.h | 33185 | #pragma once
#include "cellSync.h"
namespace vm { using namespace ps3; }
struct CellSpurs;
struct CellSpursTaskset;
// Core return codes.
enum
{
CELL_SPURS_CORE_ERROR_AGAIN = 0x80410701,
CELL_SPURS_CORE_ERROR_INVAL = 0x80410702,
CELL_SPURS_CORE_ERROR_NOMEM = 0x80410704,
CELL_SPURS_CORE_ERROR_SRCH = 0x80410705,
CELL_SPURS_CORE_ERROR_PERM = 0x80410709,
CELL_SPURS_CORE_ERROR_BUSY = 0x8041070A,
CELL_SPURS_CORE_ERROR_STAT = 0x8041070F,
CELL_SPURS_CORE_ERROR_ALIGN = 0x80410710,
CELL_SPURS_CORE_ERROR_NULL_POINTER = 0x80410711,
};
//
enum
{
CELL_SPURS_POLICY_MODULE_ERROR_AGAIN = 0x80410801,
CELL_SPURS_POLICY_MODULE_ERROR_INVAL = 0x80410802,
CELL_SPURS_POLICY_MODULE_ERROR_NOSYS = 0x80410803,
CELL_SPURS_POLICY_MODULE_ERROR_NOMEM = 0x80410804,
CELL_SPURS_POLICY_MODULE_ERROR_SRCH = 0x80410805,
CELL_SPURS_POLICY_MODULE_ERROR_NOENT = 0x80410806,
CELL_SPURS_POLICY_MODULE_ERROR_NOEXEC = 0x80410807,
CELL_SPURS_POLICY_MODULE_ERROR_DEADLK = 0x80410808,
CELL_SPURS_POLICY_MODULE_ERROR_PERM = 0x80410809,
CELL_SPURS_POLICY_MODULE_ERROR_BUSY = 0x8041080A,
CELL_SPURS_POLICY_MODULE_ERROR_ABORT = 0x8041080C,
CELL_SPURS_POLICY_MODULE_ERROR_FAULT = 0x8041080D,
CELL_SPURS_POLICY_MODULE_ERROR_CHILD = 0x8041080E,
CELL_SPURS_POLICY_MODULE_ERROR_STAT = 0x8041080F,
CELL_SPURS_POLICY_MODULE_ERROR_ALIGN = 0x80410810,
CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER = 0x80410811,
};
// Task return codes.
enum
{
CELL_SPURS_TASK_ERROR_AGAIN = 0x80410901,
CELL_SPURS_TASK_ERROR_INVAL = 0x80410902,
CELL_SPURS_TASK_ERROR_NOSYS = 0x80410903,
CELL_SPURS_TASK_ERROR_NOMEM = 0x80410904,
CELL_SPURS_TASK_ERROR_SRCH = 0x80410905,
CELL_SPURS_TASK_ERROR_NOEXEC = 0x80410907,
CELL_SPURS_TASK_ERROR_PERM = 0x80410909,
CELL_SPURS_TASK_ERROR_BUSY = 0x8041090A,
CELL_SPURS_TASK_ERROR_FAULT = 0x8041090D,
CELL_SPURS_TASK_ERROR_ALIGN = 0x80410910,
CELL_SPURS_TASK_ERROR_STAT = 0x8041090F,
CELL_SPURS_TASK_ERROR_NULL_POINTER = 0x80410911,
CELL_SPURS_TASK_ERROR_FATAL = 0x80410914,
CELL_SPURS_TASK_ERROR_SHUTDOWN = 0x80410920,
};
enum
{
CELL_SPURS_JOB_ERROR_AGAIN = 0x80410A01,
CELL_SPURS_JOB_ERROR_INVAL = 0x80410A02,
CELL_SPURS_JOB_ERROR_NOSYS = 0x80410A03,
CELL_SPURS_JOB_ERROR_NOMEM = 0x80410A04,
CELL_SPURS_JOB_ERROR_SRCH = 0x80410A05,
CELL_SPURS_JOB_ERROR_NOENT = 0x80410A06,
CELL_SPURS_JOB_ERROR_NOEXEC = 0x80410A07,
CELL_SPURS_JOB_ERROR_DEADLK = 0x80410A08,
CELL_SPURS_JOB_ERROR_PERM = 0x80410A09,
CELL_SPURS_JOB_ERROR_BUSY = 0x80410A0A,
CELL_SPURS_JOB_ERROR_JOB_DESCRIPTOR = 0x80410A0B,
CELL_SPURS_JOB_ERROR_JOB_DESCRIPTOR_SIZE = 0x80410A0C,
CELL_SPURS_JOB_ERROR_FAULT = 0x80410A0D,
CELL_SPURS_JOB_ERROR_CHILD = 0x80410A0E,
CELL_SPURS_JOB_ERROR_STAT = 0x80410A0F,
CELL_SPURS_JOB_ERROR_ALIGN = 0x80410A10,
CELL_SPURS_JOB_ERROR_NULL_POINTER = 0x80410A11,
CELL_SPURS_JOB_ERROR_MEMORY_CORRUPTED = 0x80410A12,
CELL_SPURS_JOB_ERROR_MEMORY_SIZE = 0x80410A17,
CELL_SPURS_JOB_ERROR_UNKNOWN_COMMAND = 0x80410A18,
CELL_SPURS_JOB_ERROR_JOBLIST_ALIGNMENT = 0x80410A19,
CELL_SPURS_JOB_ERROR_JOB_ALIGNMENT = 0x80410A1a,
CELL_SPURS_JOB_ERROR_CALL_OVERFLOW = 0x80410A1b,
CELL_SPURS_JOB_ERROR_ABORT = 0x80410A1c,
CELL_SPURS_JOB_ERROR_DMALIST_ELEMENT = 0x80410A1d,
CELL_SPURS_JOB_ERROR_NUM_CACHE = 0x80410A1e,
CELL_SPURS_JOB_ERROR_INVALID_BINARY = 0x80410A1f,
};
// SPURS defines.
enum SPURSKernelInterfaces : u32
{
CELL_SPURS_MAX_SPU = 8,
CELL_SPURS_MAX_WORKLOAD = 16,
CELL_SPURS_MAX_WORKLOAD2 = 32,
CELL_SPURS_SYS_SERVICE_WORKLOAD_ID = 32,
CELL_SPURS_MAX_PRIORITY = 16,
CELL_SPURS_NAME_MAX_LENGTH = 15,
CELL_SPURS_SIZE = 4096,
CELL_SPURS_SIZE2 = 8192,
CELL_SPURS_INTERRUPT_VECTOR = 0x0,
CELL_SPURS_LOCK_LINE = 0x80,
CELL_SPURS_KERNEL_DMA_TAG_ID = 31,
CELL_SPURS_KERNEL1_ENTRY_ADDR = 0x818,
CELL_SPURS_KERNEL2_ENTRY_ADDR = 0x848,
CELL_SPURS_KERNEL1_EXIT_ADDR = 0x808,
CELL_SPURS_KERNEL2_EXIT_ADDR = 0x838,
CELL_SPURS_KERNEL1_SELECT_WORKLOAD_ADDR = 0x290,
CELL_SPURS_KERNEL2_SELECT_WORKLOAD_ADDR = 0x290,
};
enum RangeofEventQueuePortNumbers
{
CELL_SPURS_STATIC_PORT_RANGE_BOTTOM = 15,
CELL_SPURS_DYNAMIC_PORT_RANGE_TOP = 16,
CELL_SPURS_DYNAMIC_PORT_RANGE_BOTTOM = 63,
};
enum SpursAttrFlags : u32
{
SAF_NONE = 0x00000000,
SAF_EXIT_IF_NO_WORK = 0x00000001,
SAF_UNKNOWN_FLAG_30 = 0x00000002,
SAF_SECOND_VERSION = 0x00000004,
SAF_UNKNOWN_FLAG_9 = 0x00400000,
SAF_UNKNOWN_FLAG_8 = 0x00800000,
SAF_UNKNOWN_FLAG_7 = 0x01000000,
SAF_SYSTEM_WORKLOAD_ENABLED = 0x02000000,
SAF_SPU_PRINTF_ENABLED = 0x10000000,
SAF_SPU_TGT_EXCLUSIVE_NON_CONTEXT = 0x20000000,
SAF_SPU_MEMORY_CONTAINER_SET = 0x40000000,
SAF_UNKNOWN_FLAG_0 = 0x80000000,
};
enum SpursFlags1 : u8
{
SF1_NONE = 0x00,
SF1_32_WORKLOADS = 0x40,
SF1_EXIT_IF_NO_WORK = 0x80,
};
enum SpursWorkloadConstants : u32
{
// Workload states
SPURS_WKL_STATE_NON_EXISTENT = 0,
SPURS_WKL_STATE_PREPARING = 1,
SPURS_WKL_STATE_RUNNABLE = 2,
SPURS_WKL_STATE_SHUTTING_DOWN = 3,
SPURS_WKL_STATE_REMOVABLE = 4,
SPURS_WKL_STATE_INVALID = 5,
// Image addresses
SPURS_IMG_ADDR_SYS_SRV_WORKLOAD = 0x100,
SPURS_IMG_ADDR_TASKSET_PM = 0x200,
};
enum SpursWorkloadGUIDs : u64
{
// GUID
SPURS_GUID_SYS_WKL = 0x1BB841BF38F89D33ull,
SPURS_GUID_TASKSET_PM = 0x836E915B2E654143ull,
};
enum CellSpursModulePollStatus
{
CELL_SPURS_MODULE_POLL_STATUS_READYCOUNT = 1,
CELL_SPURS_MODULE_POLL_STATUS_SIGNAL = 2,
CELL_SPURS_MODULE_POLL_STATUS_FLAG = 4
};
enum SpursTraceConstants
{
// Trace tag types
CELL_SPURS_TRACE_TAG_KERNEL = 0x20,
CELL_SPURS_TRACE_TAG_SERVICE = 0x21,
CELL_SPURS_TRACE_TAG_TASK = 0x22,
CELL_SPURS_TRACE_TAG_JOB = 0x23,
CELL_SPURS_TRACE_TAG_OVIS = 0x24,
CELL_SPURS_TRACE_TAG_LOAD = 0x2a,
CELL_SPURS_TRACE_TAG_MAP = 0x2b,
CELL_SPURS_TRACE_TAG_START = 0x2c,
CELL_SPURS_TRACE_TAG_STOP = 0x2d,
CELL_SPURS_TRACE_TAG_USER = 0x2e,
CELL_SPURS_TRACE_TAG_GUID = 0x2f,
// Service incident
CELL_SPURS_TRACE_SERVICE_INIT = 0x01,
CELL_SPURS_TRACE_SERVICE_WAIT = 0x02,
CELL_SPURS_TRACE_SERVICE_EXIT = 0x03,
// Task incident
CELL_SPURS_TRACE_TASK_DISPATCH = 0x01,
CELL_SPURS_TRACE_TASK_YIELD = 0x03,
CELL_SPURS_TRACE_TASK_WAIT = 0x04,
CELL_SPURS_TRACE_TASK_EXIT = 0x05,
// Trace mode flags
CELL_SPURS_TRACE_MODE_FLAG_WRAP_BUFFER = 0x1,
CELL_SPURS_TRACE_MODE_FLAG_SYNCHRONOUS_START_STOP = 0x2,
CELL_SPURS_TRACE_MODE_FLAG_MASK = 0x3,
};
// SPURS task constants
enum SpursTaskConstants
{
CELL_SPURS_MAX_TASK = 128,
CELL_SPURS_TASK_TOP = 0x3000,
CELL_SPURS_TASK_BOTTOM = 0x40000,
CELL_SPURS_MAX_TASK_NAME_LENGTH = 32,
CELL_SPURS_TASK_ATTRIBUTE_REVISION = 1,
CELL_SPURS_TASKSET_ATTRIBUTE_REVISION = 1,
CELL_SPURS_TASK_EXECUTION_CONTEXT_SIZE = 1024,
CELL_SPURS_TASKSET_PM_ENTRY_ADDR = 0xA00,
CELL_SPURS_TASKSET_PM_SYSCALL_ADDR = 0xA70,
// Task syscall numbers
CELL_SPURS_TASK_SYSCALL_EXIT = 0,
CELL_SPURS_TASK_SYSCALL_YIELD = 1,
CELL_SPURS_TASK_SYSCALL_WAIT_SIGNAL = 2,
CELL_SPURS_TASK_SYSCALL_POLL = 3,
CELL_SPURS_TASK_SYSCALL_RECV_WKL_FLAG = 4,
// Task poll status
CELL_SPURS_TASK_POLL_FOUND_TASK = 1,
CELL_SPURS_TASK_POLL_FOUND_WORKLOAD = 2,
};
enum CellSpursEventFlagWaitMode
{
CELL_SPURS_EVENT_FLAG_OR = 0,
CELL_SPURS_EVENT_FLAG_AND = 1,
CELL_SPURS_EVENT_FLAG_WAIT_MODE_LAST = CELL_SPURS_EVENT_FLAG_AND,
};
enum CellSpursEventFlagClearMode
{
CELL_SPURS_EVENT_FLAG_CLEAR_AUTO = 0,
CELL_SPURS_EVENT_FLAG_CLEAR_MANUAL = 1,
CELL_SPURS_EVENT_FLAG_CLEAR_LAST = CELL_SPURS_EVENT_FLAG_CLEAR_MANUAL,
};
enum CellSpursEventFlagDirection
{
CELL_SPURS_EVENT_FLAG_SPU2SPU,
CELL_SPURS_EVENT_FLAG_SPU2PPU,
CELL_SPURS_EVENT_FLAG_PPU2SPU,
CELL_SPURS_EVENT_FLAG_ANY2ANY,
CELL_SPURS_EVENT_FLAG_LAST = CELL_SPURS_EVENT_FLAG_ANY2ANY,
};
// Event flag constants
enum SpursEventFlagConstants
{
CELL_SPURS_EVENT_FLAG_MAX_WAIT_SLOTS = 16,
CELL_SPURS_EVENT_FLAG_INVALID_SPU_PORT = 0xFF,
};
struct alignas(16) CellSpursWorkloadFlag
{
be_t<u64> unused0;
be_t<u32> unused1;
atomic_be_t<u32> flag;
};
CHECK_SIZE_ALIGN(CellSpursWorkloadFlag, 16, 16);
struct CellSpursInfo
{
be_t<s32> nSpus;
be_t<s32> spuThreadGroupPriority;
be_t<s32> ppuThreadPriority;
bool exitIfNoWork;
bool spurs2;
u8 padding24[2];
vm::bptr<void> traceBuffer;
be_t<u32> padding32;
be_t<u64> traceBufferSize;
be_t<u32> traceMode;
be_t<u32> spuThreadGroup;
be_t<u32> spuThreads[8];
be_t<u64> spursHandlerThread0;
be_t<u64> spursHandlerThread1;
char namePrefix[16];
be_t<u32> namePrefixLength;
be_t<u32> deadlineMissCounter;
be_t<u32> deadlineMeetCounter;
u8 padding[164];
};
CHECK_SIZE(CellSpursInfo, 280);
struct alignas(8) CellSpursAttribute
{
be_t<u32> revision; // 0x0
be_t<u32> sdkVersion; // 0x4
be_t<u32> nSpus; // 0x8
be_t<s32> spuPriority; // 0xC
be_t<s32> ppuPriority; // 0x10
bool exitIfNoWork; // 0x14
char prefix[15]; // 0x15 (not a NTS)
be_t<u32> prefixSize; // 0x24
be_t<u32> flags; // 0x28 (SpursAttrFlags)
be_t<u32> container; // 0x2C
be_t<u32> unk0; // 0x30
be_t<u32> unk1; // 0x34
u8 swlPriority[8]; // 0x38
be_t<u32> swlMaxSpu; // 0x40
be_t<u32> swlIsPreem; // 0x44
u8 padding[440];
};
CHECK_SIZE_ALIGN(CellSpursAttribute, 512, 8);
using CellSpursShutdownCompletionEventHook = void(vm::ptr<CellSpurs> spurs, u32 wid, vm::ptr<void> arg);
struct alignas(16) CellSpursTraceInfo
{
be_t<u32> spuThread[8]; // 0x00
be_t<u32> count[8]; // 0x20
be_t<u32> spuThreadGroup; // 0x40
be_t<u32> numSpus; // 0x44
u8 padding[56];
};
CHECK_SIZE_ALIGN(CellSpursTraceInfo, 128, 16);
struct CellSpursTraceHeader
{
u8 tag;
u8 length;
u8 spu;
u8 workload;
be_t<u32> time;
};
struct CellSpursTraceControlData
{
be_t<u32> incident;
be_t<u32> reserved;
};
struct CellSpursTraceServiceData
{
be_t<u32> incident;
be_t<u32> reserved;
};
struct CellSpursTraceTaskData
{
be_t<u32> incident;
be_t<u32> taskId;
};
struct CellSpursTraceJobData
{
u8 reserved[3];
u8 binLSAhigh8;
be_t<u32> jobDescriptor;
};
struct CellSpursTraceLoadData
{
be_t<u32> ea;
be_t<u16> ls;
be_t<u16> size;
};
struct CellSpursTraceMapData
{
be_t<u32> offset;
be_t<u16> ls;
be_t<u16> size;
};
struct CellSpursTraceStartData
{
char module[4];
be_t<u16> level;
be_t<u16> ls;
};
struct alignas(16) CellSpursTracePacket
{
CellSpursTraceHeader header;
union
{
CellSpursTraceControlData control;
CellSpursTraceServiceData service;
CellSpursTraceTaskData task;
CellSpursTraceJobData job;
CellSpursTraceLoadData load;
CellSpursTraceMapData map;
CellSpursTraceStartData start;
be_t<u64> stop;
be_t<u64> user;
be_t<u64> guid;
be_t<u64> raw;
}
data;
};
CHECK_SIZE_ALIGN(CellSpursTracePacket, 16, 16);
// Core CellSpurs structures
struct alignas(128) CellSpurs
{
struct _sub_str1
{
u8 unk0[0x20]; // 0x00 - SPU exception handler 0x08 - SPU exception handler args
be_t<u64> sem; // 0x20
be_t<u32> x28; // 0x28
be_t<u32> x2C; // 0x2C
vm::bptr<CellSpursShutdownCompletionEventHook, u64> hook; // 0x30
vm::bptr<void, u64> hookArg; // 0x38
u8 unk2[0x40];
};
CHECK_SIZE(_sub_str1, 128);
struct EventPortMux;
using EventHandlerCallback = void(vm::ptr<EventPortMux>, u64 data);
struct EventHandlerListNode
{
vm::bptr<EventHandlerListNode, u64> next;
be_t<u64> data;
vm::bptr<EventHandlerCallback, u64> handler;
};
struct EventPortMux
{
atomic_be_t<u32> reqPending; // 0x00
be_t<u32> spuPort; // 0x04
be_t<u32> x08; // 0x08
be_t<u32> x0C; // 0x0C
be_t<u64> eventPort; // 0x10
atomic_t<vm::bptr<EventHandlerListNode, u64>> handlerList; // 0x18
u8 x20[0x80 - 0x20]; // 0x20
};
CHECK_SIZE(EventPortMux, 128);
struct WorkloadInfo
{
vm::bcptr<void, u64> addr; // 0x00 Address of the executable
be_t<u64> arg; // 0x08 Argument
be_t<u32> size; // 0x10 Size of the executable
atomic_t<u8> uniqueId; // 0x14 Unique id of the workload. It is the same for all workloads with the same addr.
u8 pad[3];
u8 priority[8]; // 0x18 Priority of the workload on each SPU
};
CHECK_SIZE(WorkloadInfo, 32);
struct _sub_str4
{
vm::bcptr<char, u64> nameClass;
vm::bcptr<char, u64> nameInstance;
};
atomic_t<u8> wklReadyCount1[0x10]; // 0x00 Number of SPUs requested by each workload (0..15 wids).
atomic_t<u8> wklIdleSpuCountOrReadyCount2[0x10]; // 0x10 SPURS1: Number of idle SPUs requested by each workload (0..15 wids). SPURS2: Number of SPUs requested by each workload (16..31 wids).
u8 wklCurrentContention[0x10]; // 0x20 Number of SPUs used by each workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
u8 wklPendingContention[0x10]; // 0x30 Number of SPUs that are pending to context switch to the workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
u8 wklMinContention[0x10]; // 0x40 Min SPUs required for each workload. SPURS1: index = wid. SPURS2: Unused.
atomic_t<u8> wklMaxContention[0x10]; // 0x50 Max SPUs that may be allocated to each workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
CellSpursWorkloadFlag wklFlag; // 0x60
atomic_be_t<u16> wklSignal1; // 0x70 Bitset for 0..15 wids
atomic_t<u8> sysSrvMessage; // 0x72
u8 spuIdling; // 0x73
u8 flags1; // 0x74 Type is SpursFlags1
u8 sysSrvTraceControl; // 0x75
u8 nSpus; // 0x76
atomic_t<u8> wklFlagReceiver; // 0x77
atomic_be_t<u16> wklSignal2; // 0x78 Bitset for 16..32 wids
u8 x7A[6]; // 0x7A
atomic_t<u8> wklState1[0x10]; // 0x80 SPURS_WKL_STATE_*
u8 wklStatus1[0x10]; // 0x90
atomic_t<u8> wklEvent1[0x10]; // 0xA0
atomic_be_t<u32> wklEnabled; // 0xB0
atomic_be_t<u32> wklMskB; // 0xB4 - System service - Available module id
u32 xB8; // 0xB8
u8 sysSrvExitBarrier; // 0xBC
atomic_t<u8> sysSrvMsgUpdateWorkload; // 0xBD
u8 xBE; // 0xBE
u8 sysSrvMsgTerminate; // 0xBF
u8 sysSrvPreemptWklId[8]; // 0xC0 Id of the workload that was preempted by the system workload on each SPU
u8 sysSrvOnSpu; // 0xC8
u8 spuPort; // 0xC9
u8 xCA; // 0xCA
u8 xCB; // 0xCB
struct SrvTraceSyncVar
{
u8 sysSrvTraceInitialised; // 0xCC
u8 sysSrvNotifyUpdateTraceComplete; // 0xCD
u8 sysSrvMsgUpdateTrace; // 0xCE
u8 xCF;
};
atomic_t<SrvTraceSyncVar> sysSrvTrace; // 0xCC
atomic_t<u8> wklState2[0x10]; // 0xD0 SPURS_WKL_STATE_*
u8 wklStatus2[0x10]; // 0xE0
atomic_t<u8> wklEvent2[0x10]; // 0xF0
_sub_str1 wklF1[0x10]; // 0x100
vm::bptr<CellSpursTraceInfo, u64> traceBuffer; // 0x900
be_t<u32> traceStartIndex[6]; // 0x908
u8 unknown7[0x948 - 0x920]; // 0x920
be_t<u64> traceDataSize; // 0x948
be_t<u32> traceMode; // 0x950
u8 unknown8[0x980 - 0x954]; // 0x954
be_t<u64> semPrv; // 0x980
be_t<u32> unk11; // 0x988
be_t<u32> unk12; // 0x98C
be_t<u64> unk13; // 0x990
u8 unknown4[0xB00 - 0x998];
WorkloadInfo wklInfo1[0x10]; // 0xB00
WorkloadInfo wklInfoSysSrv; // 0xD00
be_t<u64> ppu0; // 0xD20 Handler thread
be_t<u64> ppu1; // 0xD28
be_t<u32> spuTG; // 0xD30 SPU thread group
be_t<u32> spus[8]; // 0xD34
u8 unknown3[0xD5C - 0xD54];
be_t<u32> eventQueue; // 0xD5C
be_t<u32> eventPort; // 0xD60
atomic_t<u8> handlerDirty; // 0xD64
atomic_t<u8> handlerWaiting; // 0xD65
atomic_t<u8> handlerExiting; // 0xD66
atomic_be_t<u32> enableEH; // 0xD68
be_t<u32> exception; // 0xD6C
sys_spu_image spuImg; // 0xD70
be_t<u32> flags; // 0xD80
be_t<s32> spuPriority; // 0xD84
be_t<u32> ppuPriority; // 0xD88
char prefix[0x0f]; // 0xD8C
u8 prefixSize; // 0xD9B
be_t<u32> unk5; // 0xD9C
be_t<u32> revision; // 0xDA0
be_t<u32> sdkVersion; // 0xDA4
atomic_be_t<u64> spuPortBits; // 0xDA8
sys_lwmutex_t mutex; // 0xDB0
sys_lwcond_t cond; // 0xDC8
u8 unknown9[0xE00 - 0xDD0];
_sub_str4 wklH1[0x10]; // 0xE00
EventPortMux eventPortMux; // 0xF00
atomic_be_t<u64> globalSpuExceptionHandler; // 0xF80
be_t<u64> globalSpuExceptionHandlerArgs; // 0xF88
u8 unknown6[0x1000 - 0xF90];
WorkloadInfo wklInfo2[0x10]; // 0x1000
_sub_str1 wklF2[0x10]; // 0x1200
_sub_str4 wklH2[0x10]; // 0x1A00
u8 unknown_[0x2000 - 0x1B00];
force_inline atomic_t<u8>& wklState(const u32 wid)
{
if (wid & 0x10)
{
return wklState2[wid & 0xf];
}
else
{
return wklState1[wid & 0xf];
}
}
};
CHECK_SIZE_ALIGN(CellSpurs, 0x2000, 128);
using CellSpurs2 = CellSpurs;
struct CellSpursExceptionInfo
{
be_t<u32> spu_thread;
be_t<u32> spu_npc;
be_t<u32> cause;
be_t<u64> option;
};
// Exception handler
using CellSpursGlobalExceptionEventHandler = void(vm::ptr<CellSpurs> spurs, vm::cptr<CellSpursExceptionInfo> info, u32 id, vm::ptr<void> arg);
struct CellSpursWorkloadAttribute
{
be_t<u32> revision;
be_t<u32> sdkVersion;
vm::bcptr<void> pm;
be_t<u32> size;
be_t<u64> data;
u8 priority[8];
be_t<u32> minContention;
be_t<u32> maxContention;
vm::bcptr<char> nameClass;
vm::bcptr<char> nameInstance;
vm::bptr<CellSpursShutdownCompletionEventHook> hook;
vm::bptr<void> hookArg;
u8 padding[456];
};
CHECK_SIZE_ALIGN(CellSpursWorkloadAttribute, 512, 8);
struct alignas(128) CellSpursEventFlag
{
struct ControlSyncVar
{
be_t<u16> events; // 0x00 Event bits
be_t<u16> spuTaskPendingRecv; // 0x02 A bit is set to 1 when the condition of the SPU task using the slot are met and back to 0 when the SPU task unblocks
be_t<u16> ppuWaitMask; // 0x04 Wait mask for blocked PPU thread
u8 ppuWaitSlotAndMode; // 0x06 Top 4 bits: Wait slot number of the blocked PPU threa, Bottom 4 bits: Wait mode of the blocked PPU thread
u8 ppuPendingRecv; // 0x07 Set to 1 when the blocked PPU thread's conditions are met and back to 0 when the PPU thread is unblocked
};
union
{
atomic_t<ControlSyncVar> ctrl; // 0x00
atomic_be_t<u16> events; // 0x00
};
be_t<u16> spuTaskUsedWaitSlots; // 0x08 A bit is set to 1 if the wait slot corresponding to the bit is used by an SPU task and 0 otherwise
be_t<u16> spuTaskWaitMode; // 0x0A A bit is set to 1 if the wait mode for the SPU task corresponding to the bit is AND and 0 otherwise
u8 spuPort; // 0x0C
u8 isIwl; // 0x0D
u8 direction; // 0x0E
u8 clearMode; // 0x0F
be_t<u16> spuTaskWaitMask[16]; // 0x10 Wait mask for blocked SPU tasks
be_t<u16> pendingRecvTaskEvents[16]; // 0x30 The value of event flag when the wait condition for the thread/task was met
u8 waitingTaskId[16]; // 0x50 Task id of waiting SPU threads
u8 waitingTaskWklId[16]; // 0x60 Workload id of waiting SPU threads
be_t<u64> addr; // 0x70
be_t<u32> eventPortId; // 0x78
be_t<u32> eventQueueId; // 0x7C
};
CHECK_SIZE_ALIGN(CellSpursEventFlag, 128, 128);
using CellSpursLFQueue = CellSyncLFQueue;
union CellSpursTaskArgument
{
be_t<u32> _u32[4];
be_t<u64> _u64[2];
};
union CellSpursTaskLsPattern
{
be_t<u32> _u32[4];
be_t<u64> _u64[2];
};
struct alignas(16) CellSpursTaskAttribute
{
u8 reserved[256];
};
CHECK_SIZE_ALIGN(CellSpursTaskAttribute, 256, 16);
struct alignas(16) CellSpursTaskAttribute2
{
be_t<u32> revision;
be_t<u32> sizeContext;
be_t<u64> eaContext;
CellSpursTaskLsPattern lsPattern;
vm::bcptr<char> name;
u8 reserved[220];
};
CHECK_SIZE_ALIGN(CellSpursTaskAttribute2, 256, 16);
// Exception handler
using CellSpursTasksetExceptionEventHandler = void(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset> taskset, u32 idTask, vm::cptr<CellSpursExceptionInfo> info, vm::ptr<void> arg);
struct alignas(128) CellSpursTaskExitCode
{
u8 skip[128];
};
CHECK_SIZE_ALIGN(CellSpursTaskExitCode, 128, 128);
struct CellSpursTaskInfo
{
CellSpursTaskLsPattern lsPattern;
CellSpursTaskArgument argument;
vm::bptr<void> eaElf;
vm::bptr<void> eaContext;
be_t<u32> sizeContext;
u8 state;
u8 hasSignal;
u8 padding[2];
vm::bcptr<CellSpursTaskExitCode> eaTaskExitCode;
u8 guid[8];
u8 reserved[12];
};
CHECK_SIZE(CellSpursTaskInfo, 72);
struct CellSpursTasksetInfo
{
CellSpursTaskInfo taskInfo[CELL_SPURS_MAX_TASK];
be_t<u64> argument;
be_t<u32> idWorkload;
be_t<u32> idLastScheduledTask;
vm::bcptr<char> name;
vm::bptr<CellSpursTasksetExceptionEventHandler> exceptionEventHandler;
vm::bptr<void> exceptionEventHandlerArgument;
be_t<u32> sizeTaskset;
u8 reserved[112];
};
CHECK_SIZE(CellSpursTasksetInfo, 9360);
struct alignas(8) CellSpursTasksetAttribute
{
be_t<u32> revision; // 0x00
be_t<u32> sdk_version; // 0x04
be_t<u64> args; // 0x08
u8 priority[8]; // 0x10
be_t<u32> max_contention; // 0x18
vm::bcptr<char> name; // 0x1C
be_t<u32> taskset_size; // 0x20
be_t<s32> enable_clear_ls; // 0x24
u8 reserved[472];
};
CHECK_SIZE_ALIGN(CellSpursTasksetAttribute, 512, 8);
struct alignas(128) CellSpursTaskset
{
struct TaskInfo
{
CellSpursTaskArgument args; // 0x00
vm::bcptr<void, u64> elf; // 0x10
be_t<u64> context_save_storage_and_alloc_ls_blocks; // 0x18 This is (context_save_storage_addr | allocated_ls_blocks)
CellSpursTaskLsPattern ls_pattern; // 0x20
};
CHECK_SIZE(TaskInfo, 48);
be_t<v128> running; // 0x00
be_t<v128> ready; // 0x10
be_t<v128> pending_ready; // 0x20
be_t<v128> enabled; // 0x30
be_t<v128> signalled; // 0x40
be_t<v128> waiting; // 0x50
vm::bptr<CellSpurs, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
u8 wkl_flag_wait_task; // 0x72
u8 last_scheduled_task; // 0x73
be_t<u32> wid; // 0x74
be_t<u64> x78; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<CellSpursTasksetExceptionEventHandler, u64> exception_handler; // 0x1880
vm::bptr<u64, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
u32 event_flag_id2; // 0x189C
u8 unk3[0x60]; // 0x18A0
};
CHECK_SIZE_ALIGN(CellSpursTaskset, 128 * 50, 128);
struct alignas(128) CellSpursTaskset2
{
struct TaskInfo
{
CellSpursTaskArgument args;
vm::bptr<u64, u64> elf_addr;
vm::bptr<u64, u64> context_save_storage; // This is (context_save_storage_addr | allocated_ls_blocks)
CellSpursTaskLsPattern ls_pattern;
};
CHECK_SIZE(TaskInfo, 48);
be_t<u32> running_set[4]; // 0x00
be_t<u32> ready_set[4]; // 0x10
be_t<u32> ready2_set[4]; // 0x20 - TODO: Find out what this is
be_t<u32> enabled_set[4]; // 0x30
be_t<u32> signal_received_set[4]; // 0x40
be_t<u32> waiting_set[4]; // 0x50
vm::bptr<CellSpurs, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
u8 x72; // 0x72
u8 last_scheduled_task; // 0x73
be_t<u32> wid; // 0x74
be_t<u64> x78; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<u64, u64> exception_handler; // 0x1880
vm::bptr<u64, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
u32 event_flag_id2; // 0x189C
u8 unk3[0x1980 - 0x18A0]; // 0x18A0
be_t<v128> task_exit_code[128]; // 0x1980
u8 unk4[0x2900 - 0x2180]; // 0x2180
};
CHECK_SIZE_ALIGN(CellSpursTaskset2, 128 * 82, 128);
struct alignas(16) CellSpursTaskNameBuffer
{
char taskName[CELL_SPURS_MAX_TASK][CELL_SPURS_MAX_TASK_NAME_LENGTH];
};
struct alignas(8) CellSpursTasksetAttribute2
{
be_t<u32> revision; // 0x00
vm::bcptr<char> name; // 0x04
be_t<u64> args; // 0x08
u8 priority[8]; // 0x10
be_t<u32> max_contention; // 0x18
be_t<s32> enable_clear_ls; // 0x1C
vm::bptr<CellSpursTaskNameBuffer> task_name_buffer; // 0x20
u8 reserved[472];
};
CHECK_SIZE_ALIGN(CellSpursTasksetAttribute2, 512, 8);
struct alignas(16) CellSpursTaskBinInfo
{
be_t<u64> eaElf;
be_t<u32> sizeContext;
be_t<u32> reserved;
CellSpursTaskLsPattern lsPattern;
};
// The SPURS kernel context. This resides at 0x100 of the LS.
struct SpursKernelContext
{
u8 tempArea[0x80]; // 0x100
u8 wklLocContention[0x10]; // 0x180
u8 wklLocPendingContention[0x10]; // 0x190
u8 priority[0x10]; // 0x1A0
u8 x1B0[0x10]; // 0x1B0
vm::bptr<CellSpurs, u64> spurs; // 0x1C0
be_t<u32> spuNum; // 0x1C8
be_t<u32> dmaTagId; // 0x1CC
vm::bcptr<void, u64> wklCurrentAddr; // 0x1D0
be_t<u32> wklCurrentUniqueId; // 0x1D8
be_t<u32> wklCurrentId; // 0x1DC
be_t<u32> exitToKernelAddr; // 0x1E0
be_t<u32> selectWorkloadAddr; // 0x1E4
u8 moduleId[2]; // 0x1E8
u8 sysSrvInitialised; // 0x1EA
u8 spuIdling; // 0x1EB
be_t<u16> wklRunnable1; // 0x1EC
be_t<u16> wklRunnable2; // 0x1EE
be_t<u32> x1F0; // 0x1F0
be_t<u32> x1F4; // 0x1F4
be_t<u32> x1F8; // 0x1F8
be_t<u32> x1FC; // 0x1FC
be_t<u32> x200; // 0x200
be_t<u32> x204; // 0x204
be_t<u32> x208; // 0x208
be_t<u32> x20C; // 0x20C
be_t<u64> traceBuffer; // 0x210
be_t<u32> traceMsgCount; // 0x218
be_t<u32> traceMaxCount; // 0x21C
u8 wklUniqueId[0x10]; // 0x220
u8 x230[0x280 - 0x230]; // 0x230
be_t<u32> guid[4]; // 0x280
};
CHECK_SIZE(SpursKernelContext, 0x190);
// The SPURS taskset policy module context. This resides at 0x2700 of the LS.
struct SpursTasksetContext
{
u8 tempAreaTaskset[0x80]; // 0x2700
u8 tempAreaTaskInfo[0x30]; // 0x2780
be_t<u64> x27B0; // 0x27B0
vm::bptr<CellSpursTaskset, u64> taskset; // 0x27B8
be_t<u32> kernelMgmtAddr; // 0x27C0
be_t<u32> syscallAddr; // 0x27C4
be_t<u32> x27C8; // 0x27C8
be_t<u32> spuNum; // 0x27CC
be_t<u32> dmaTagId; // 0x27D0
be_t<u32> taskId; // 0x27D4
u8 x27D8[0x2840 - 0x27D8]; // 0x27D8
u8 moduleId[16]; // 0x2840
u8 stackArea[0x2C80 - 0x2850]; // 0x2850
be_t<v128> savedContextLr; // 0x2C80
be_t<v128> savedContextSp; // 0x2C90
be_t<v128> savedContextR80ToR127[48]; // 0x2CA0
be_t<v128> savedContextFpscr; // 0x2FA0
be_t<u32> savedWriteTagGroupQueryMask; // 0x2FB0
be_t<u32> savedSpuWriteEventMask; // 0x2FB4
be_t<u32> tasksetMgmtAddr; // 0x2FB8
be_t<u32> guidAddr; // 0x2FBC
be_t<u64> x2FC0; // 0x2FC0
be_t<u64> x2FC8; // 0x2FC8
be_t<u32> taskExitCode; // 0x2FD0
be_t<u32> x2FD4; // 0x2FD4
u8 x2FD8[0x3000 - 0x2FD8]; // 0x2FD8
};
CHECK_SIZE(SpursTasksetContext, 0x900);
class SpursModuleExit
{
};
inline static s32 SyncErrorToSpursError(s32 res)
{
return res < 0 ? 0x80410900 | (res & 0xff) : res;
}
| gpl-2.0 |
Gelvazio/ORGANIZACOES | microsoft.github.io/microsoft.github.io-master/js/main.js | 3518 | var app = angular.module('site', ['ui.bootstrap', 'ngAria']);
app.factory('Backend', ['$http',
function($http) {
var get = function(url) {
return function() {
return $http.get(url).then(function(resp) {
return resp.data;
});
}
};
return {
featured: get('data/featured.json'),
orgs: get('data/organization.json')
}
}
])
.controller('MainCtrl', ['Backend', '$scope', 'filterFilter',
function(Backend, $scope, filterFilter) {
var self = this;
Backend.orgs().then(function(data) {
self.orgs = data;
});
Backend.featured().then(function(data) {
self.featured = data;
$.ajax({
url: 'https://popularrepostg.blob.core.windows.net/popularrepos/projects.json',
dataType: 'jsonp',
jsonpCallback: 'JSON_CALLBACK',
success: function(data) {
var projects = data[0].AllProjects;
$scope.currentPage = 1; //current page
$scope.maxSize = 5; //pagination max size
$scope.entryLimit = 36; //max rows for data table
/* init pagination with $scope.list */
$scope.noOfRepos = projects.length;
$scope.noOfPages = Math.ceil($scope.noOfRepos / $scope.entryLimit);
$scope.resultsSectionTitle = 'All Repos';
$scope.$watch('searchText', function(term) {
// Create $scope.filtered and then calculate $scope.noOfPages, no racing!
$scope.filtered = filterFilter(projects, term);
$scope.noOfRepos = $scope.filtered.length;
$scope.noOfPages = Math.ceil($scope.noOfRepos / $scope.entryLimit);
$scope.resultsSectionTitle = (!term) ? 'All Repos' : (($scope.noOfRepos == 0) ? 'Search results' : ($scope.noOfRepos + ' repositories found'));
});
var featuredProjects = new Array();
self.featured.forEach(function (name) {
for (var i = 0; i < projects.length; i++) {
var project = projects[i];
if (project.Name == name) {
featuredProjects.push(project);
return;
}
}
});
self.projects = projects;
self.featuredProjects = featuredProjects;
$scope.$apply();
}
});
$.ajax({
url: 'https://popularrepostg.blob.core.windows.net/popularrepos/projectssummary.json',
dataType: 'jsonp',
jsonpCallback: 'JSON_CALLBACK',
success: function (stats) {
if (stats != null) {
$scope.overAllStats = stats[0];
}
}
})
});
}
])
.filter('startFrom', function() {
return function(input, start) {
if (input) {
start = +start; //parse to int
return input.slice(start);
}
return [];
}
});
| gpl-2.0 |
gittup/gcc | gcc/config/ia64/sync.md | 5765 | ;; GCC machine description for IA-64 synchronization instructions.
;; Copyright (C) 2005, 2007, 2008, 2009
;; Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3. If not see
;; <http://www.gnu.org/licenses/>.
(define_mode_iterator IMODE [QI HI SI DI])
(define_mode_iterator I124MODE [QI HI SI])
(define_mode_iterator I48MODE [SI DI])
(define_mode_attr modesuffix [(QI "1") (HI "2") (SI "4") (DI "8")])
(define_code_iterator FETCHOP [plus minus ior xor and])
(define_code_attr fetchop_name
[(plus "add") (minus "sub") (ior "ior") (xor "xor") (and "and")])
(define_expand "memory_barrier"
[(set (match_dup 0)
(unspec:BLK [(match_dup 0)] UNSPEC_MF))]
""
{
operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
MEM_VOLATILE_P (operands[0]) = 1;
})
(define_insn "*memory_barrier"
[(set (match_operand:BLK 0 "" "")
(unspec:BLK [(match_dup 0)] UNSPEC_MF))]
""
"mf"
[(set_attr "itanium_class" "syst_m")])
(define_insn "fetchadd_acq_<mode>"
[(set (match_operand:I48MODE 0 "gr_register_operand" "=r")
(match_operand:I48MODE 1 "not_postinc_memory_operand" "+S"))
(set (match_dup 1)
(unspec:I48MODE [(match_dup 1)
(match_operand:I48MODE 2 "fetchadd_operand" "n")]
UNSPEC_FETCHADD_ACQ))]
""
"fetchadd<modesuffix>.acq %0 = %1, %2"
[(set_attr "itanium_class" "sem")])
(define_expand "sync_<fetchop_name><mode>"
[(set (match_operand:IMODE 0 "memory_operand" "")
(FETCHOP:IMODE (match_dup 0)
(match_operand:IMODE 1 "general_operand" "")))]
""
{
ia64_expand_atomic_op (<CODE>, operands[0], operands[1], NULL, NULL);
DONE;
})
(define_expand "sync_nand<mode>"
[(set (match_operand:IMODE 0 "memory_operand" "")
(not:IMODE
(and:IMODE (match_dup 0)
(match_operand:IMODE 1 "general_operand" ""))))]
""
{
ia64_expand_atomic_op (NOT, operands[0], operands[1], NULL, NULL);
DONE;
})
(define_expand "sync_old_<fetchop_name><mode>"
[(set (match_operand:IMODE 0 "gr_register_operand" "")
(FETCHOP:IMODE
(match_operand:IMODE 1 "memory_operand" "")
(match_operand:IMODE 2 "general_operand" "")))]
""
{
ia64_expand_atomic_op (<CODE>, operands[1], operands[2], operands[0], NULL);
DONE;
})
(define_expand "sync_old_nand<mode>"
[(set (match_operand:IMODE 0 "gr_register_operand" "")
(not:IMODE
(and:IMODE (match_operand:IMODE 1 "memory_operand" "")
(match_operand:IMODE 2 "general_operand" ""))))]
""
{
ia64_expand_atomic_op (NOT, operands[1], operands[2], operands[0], NULL);
DONE;
})
(define_expand "sync_new_<fetchop_name><mode>"
[(set (match_operand:IMODE 0 "gr_register_operand" "")
(FETCHOP:IMODE
(match_operand:IMODE 1 "memory_operand" "")
(match_operand:IMODE 2 "general_operand" "")))]
""
{
ia64_expand_atomic_op (<CODE>, operands[1], operands[2], NULL, operands[0]);
DONE;
})
(define_expand "sync_new_nand<mode>"
[(set (match_operand:IMODE 0 "gr_register_operand" "")
(not:IMODE
(and:IMODE (match_operand:IMODE 1 "memory_operand" "")
(match_operand:IMODE 2 "general_operand" ""))))]
""
{
ia64_expand_atomic_op (NOT, operands[1], operands[2], NULL, operands[0]);
DONE;
})
(define_expand "sync_compare_and_swap<mode>"
[(match_operand:IMODE 0 "gr_register_operand" "")
(match_operand:IMODE 1 "memory_operand" "")
(match_operand:IMODE 2 "gr_register_operand" "")
(match_operand:IMODE 3 "gr_register_operand" "")]
""
{
rtx ccv = gen_rtx_REG (DImode, AR_CCV_REGNUM);
rtx dst;
convert_move (ccv, operands[2], 1);
dst = operands[0];
if (GET_MODE (dst) != DImode)
dst = gen_reg_rtx (DImode);
emit_insn (gen_memory_barrier ());
emit_insn (gen_cmpxchg_rel_<mode> (dst, operands[1], ccv, operands[3]));
if (dst != operands[0])
emit_move_insn (operands[0], gen_lowpart (<MODE>mode, dst));
DONE;
})
(define_insn "cmpxchg_rel_<mode>"
[(set (match_operand:DI 0 "gr_register_operand" "=r")
(zero_extend:DI
(match_operand:I124MODE 1 "not_postinc_memory_operand" "+S")))
(set (match_dup 1)
(unspec:I124MODE
[(match_dup 1)
(match_operand:DI 2 "ar_ccv_reg_operand" "")
(match_operand:I124MODE 3 "gr_register_operand" "r")]
UNSPEC_CMPXCHG_ACQ))]
""
"cmpxchg<modesuffix>.rel %0 = %1, %3, %2"
[(set_attr "itanium_class" "sem")])
(define_insn "cmpxchg_rel_di"
[(set (match_operand:DI 0 "gr_register_operand" "=r")
(match_operand:DI 1 "not_postinc_memory_operand" "+S"))
(set (match_dup 1)
(unspec:DI [(match_dup 1)
(match_operand:DI 2 "ar_ccv_reg_operand" "")
(match_operand:DI 3 "gr_register_operand" "r")]
UNSPEC_CMPXCHG_ACQ))]
""
"cmpxchg8.rel %0 = %1, %3, %2"
[(set_attr "itanium_class" "sem")])
(define_insn "sync_lock_test_and_set<mode>"
[(set (match_operand:IMODE 0 "gr_register_operand" "=r")
(match_operand:IMODE 1 "not_postinc_memory_operand" "+S"))
(set (match_dup 1)
(match_operand:IMODE 2 "gr_register_operand" "r"))]
""
"xchg<modesuffix> %0 = %1, %2"
[(set_attr "itanium_class" "sem")])
(define_expand "sync_lock_release<mode>"
[(set (match_operand:IMODE 0 "memory_operand" "")
(match_operand:IMODE 1 "gr_reg_or_0_operand" ""))]
""
{
gcc_assert (MEM_VOLATILE_P (operands[0]));
})
| gpl-2.0 |
sunnyden/reactos | dll/win32/winsta/misc.c | 1258 | /*
* PROJECT: ReactOS winsta.dll
* FILE: lib/winsta/misc.c
* PURPOSE: WinStation
* PROGRAMMER: Samuel Serapi?n
* NOTES: Misc functions.
*
*/
#include "winsta.h"
VOID
WINSTAAPI LogonIdFromWinStationNameA(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI LogonIdFromWinStationNameW(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI RemoteAssistancePrepareSystemRestore(PVOID A)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI _NWLogonQueryAdmin(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI _NWLogonSetAdmin(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI WinStationNameFromLogonIdA(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
VOID
WINSTAAPI WinStationNameFromLogonIdW(PVOID A,
PVOID B,
PVOID C)
{
UNIMPLEMENTED;
}
/* EOF */
| gpl-2.0 |
twitter/mysql | storage/myisam/mi_write.c | 33677 | /*
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/* Write a row to a MyISAM table */
#include "fulltext.h"
#include "rt_index.h"
#define MAX_POINTER_LENGTH 8
/* Functions declared in this file */
static int w_search(MI_INFO *info,MI_KEYDEF *keyinfo,
uint comp_flag, uchar *key,
uint key_length, my_off_t pos, uchar *father_buff,
uchar *father_keypos, my_off_t father_page,
my_bool insert_last);
static int _mi_balance_page(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,
uchar *curr_buff,uchar *father_buff,
uchar *father_keypos,my_off_t father_page);
static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uint *return_key_length,
uchar **after_key);
int _mi_ck_write_tree(register MI_INFO *info, uint keynr,uchar *key,
uint key_length);
int _mi_ck_write_btree(register MI_INFO *info, uint keynr,uchar *key,
uint key_length);
/* Write new record to database */
int mi_write(MI_INFO *info, uchar *record)
{
MYISAM_SHARE *share=info->s;
uint i;
int save_errno;
my_off_t filepos;
uchar *buff;
my_bool lock_tree= share->concurrent_insert;
DBUG_ENTER("mi_write");
DBUG_PRINT("enter",("isam: %d data: %d",info->s->kfile,info->dfile));
DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage",
mi_print_error(info->s, HA_ERR_CRASHED);
DBUG_RETURN(my_errno= HA_ERR_CRASHED););
if (share->options & HA_OPTION_READ_ONLY_DATA)
{
DBUG_RETURN(my_errno=EACCES);
}
if (_mi_readinfo(info,F_WRLCK,1))
DBUG_RETURN(my_errno);
filepos= ((share->state.dellink != HA_OFFSET_ERROR &&
!info->append_insert_at_end) ?
share->state.dellink :
info->state->data_file_length);
if (share->base.reloc == (ha_rows) 1 &&
share->base.records == (ha_rows) 1 &&
info->state->records == (ha_rows) 1)
{ /* System file */
my_errno=HA_ERR_RECORD_FILE_FULL;
goto err2;
}
if (info->state->key_file_length >= share->base.margin_key_file_length)
{
my_errno=HA_ERR_INDEX_FILE_FULL;
goto err2;
}
if (_mi_mark_file_changed(info))
goto err2;
/* Calculate and check all unique constraints */
if (mi_is_any_key_active(share->state.key_map))
{
for (i= 0 ; i < share->state.header.uniques ; i++)
{
if (mi_check_unique(info, share->uniqueinfo + i, record,
mi_unique_hash(share->uniqueinfo + i, record),
HA_OFFSET_ERROR))
goto err2;
}
}
/* Write all keys to indextree */
buff=info->lastkey2;
for (i=0 ; i < share->base.keys ; i++)
{
if (mi_is_key_active(share->state.key_map, i))
{
my_bool local_lock_tree= (lock_tree &&
!(info->bulk_insert &&
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
{
mysql_rwlock_wrlock(&share->key_root_lock[i]);
share->keyinfo[i].version++;
}
if (share->keyinfo[i].flag & HA_FULLTEXT )
{
if (_mi_ft_add(info,i, buff, record, filepos))
{
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
}
else
{
if (share->keyinfo[i].ck_insert(info,i,buff,
_mi_make_key(info,i,buff,record,filepos)))
{
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
}
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
}
}
if (share->calc_checksum)
info->checksum=(*share->calc_checksum)(info,record);
if (!(info->opt_flag & OPT_NO_ROWS))
{
if ((*share->write_record)(info,record))
goto err;
info->state->checksum+=info->checksum;
}
if (share->base.auto_key)
set_if_bigger(info->s->state.auto_increment,
retrieve_auto_increment(info, record));
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
HA_STATE_ROW_CHANGED);
info->state->records++;
info->lastpos=filepos;
myisam_log_record(MI_LOG_WRITE,info,record,filepos,0);
(void) _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE);
if (info->invalidator != 0)
{
DBUG_PRINT("info", ("invalidator... '%s' (update)", info->filename));
(*info->invalidator)(info->filename);
info->invalidator=0;
}
/*
Update status of the table. We need to do so after each row write
for the log tables, as we want the new row to become visible to
other threads as soon as possible. We don't lock mutex here
(as it is required by pthread memory visibility rules) as (1) it's
not critical to use outdated share->is_log_table value (2) locking
mutex here for every write is too expensive.
*/
if (share->is_log_table)
mi_update_status((void*) info);
DBUG_RETURN(0);
err:
save_errno=my_errno;
if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL ||
my_errno == HA_ERR_NULL_IN_SPATIAL || my_errno == HA_ERR_OUT_OF_MEM)
{
if (info->bulk_insert)
{
uint j;
for (j=0 ; j < share->base.keys ; j++)
mi_flush_bulk_insert(info, j);
}
info->errkey= (int) i;
while ( i-- > 0)
{
if (mi_is_key_active(share->state.key_map, i))
{
my_bool local_lock_tree= (lock_tree &&
!(info->bulk_insert &&
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
mysql_rwlock_wrlock(&share->key_root_lock[i]);
if (share->keyinfo[i].flag & HA_FULLTEXT)
{
if (_mi_ft_del(info,i, buff,record,filepos))
{
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
break;
}
}
else
{
uint key_length=_mi_make_key(info,i,buff,record,filepos);
if (share->keyinfo[i].ck_delete(info, i, buff, key_length))
{
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
break;
}
}
if (local_lock_tree)
mysql_rwlock_unlock(&share->key_root_lock[i]);
}
}
}
else
{
mi_print_error(info->s, HA_ERR_CRASHED);
mi_mark_crashed(info);
}
info->update= (HA_STATE_CHANGED | HA_STATE_WRITTEN | HA_STATE_ROW_CHANGED);
my_errno=save_errno;
err2:
save_errno=my_errno;
myisam_log_record(MI_LOG_WRITE,info,record,filepos,my_errno);
(void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
DBUG_RETURN(my_errno=save_errno);
} /* mi_write */
/* Write one key to btree */
int _mi_ck_write(MI_INFO *info, uint keynr, uchar *key, uint key_length)
{
DBUG_ENTER("_mi_ck_write");
if (info->bulk_insert && is_tree_inited(&info->bulk_insert[keynr]))
{
DBUG_RETURN(_mi_ck_write_tree(info, keynr, key, key_length));
}
else
{
DBUG_RETURN(_mi_ck_write_btree(info, keynr, key, key_length));
}
} /* _mi_ck_write */
/**********************************************************************
* Normal insert code *
**********************************************************************/
int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key,
uint key_length)
{
int error;
uint comp_flag;
MI_KEYDEF *keyinfo=info->s->keyinfo+keynr;
my_off_t *root=&info->s->state.key_root[keynr];
DBUG_ENTER("_mi_ck_write_btree");
if (keyinfo->flag & HA_SORT_ALLOWS_SAME)
comp_flag=SEARCH_BIGGER; /* Put after same key */
else if (keyinfo->flag & (HA_NOSAME|HA_FULLTEXT))
{
comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No duplicates */
if (keyinfo->flag & HA_NULL_ARE_EQUAL)
comp_flag|= SEARCH_NULL_ARE_EQUAL;
}
else
comp_flag=SEARCH_SAME; /* Keys in rec-pos order */
error=_mi_ck_real_write_btree(info, keyinfo, key, key_length,
root, comp_flag);
if (info->ft1_to_ft2)
{
if (!error)
error= _mi_ft_convert_to_ft2(info, keynr, key);
delete_dynamic(info->ft1_to_ft2);
my_free(info->ft1_to_ft2);
info->ft1_to_ft2=0;
}
DBUG_RETURN(error);
} /* _mi_ck_write_btree */
int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo,
uchar *key, uint key_length, my_off_t *root, uint comp_flag)
{
int error;
DBUG_ENTER("_mi_ck_real_write_btree");
/* key_length parameter is used only if comp_flag is SEARCH_FIND */
if (*root == HA_OFFSET_ERROR ||
(error=w_search(info, keyinfo, comp_flag, key, key_length,
*root, (uchar *) 0, (uchar*) 0,
(my_off_t) 0, 1)) > 0)
error=_mi_enlarge_root(info,keyinfo,key,root);
DBUG_RETURN(error);
} /* _mi_ck_real_write_btree */
/* Make a new root with key as only pointer */
int _mi_enlarge_root(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
my_off_t *root)
{
uint t_length,nod_flag;
MI_KEY_PARAM s_temp;
MYISAM_SHARE *share=info->s;
DBUG_ENTER("_mi_enlarge_root");
nod_flag= (*root != HA_OFFSET_ERROR) ? share->base.key_reflength : 0;
_mi_kpointer(info,info->buff+2,*root); /* if nod */
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,(uchar*) 0,
(uchar*) 0, (uchar*) 0, key,&s_temp);
mi_putint(info->buff,t_length+2+nod_flag,nod_flag);
(*keyinfo->store_key)(keyinfo,info->buff+2+nod_flag,&s_temp);
info->buff_used=info->page_changed=1; /* info->buff is used */
if ((*root= _mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR ||
_mi_write_keypage(info,keyinfo,*root,DFLT_INIT_HITS,info->buff))
DBUG_RETURN(-1);
DBUG_RETURN(0);
} /* _mi_enlarge_root */
/*
Search after a position for a key and store it there
Returns -1 = error
0 = ok
1 = key should be stored in higher tree
*/
static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
uint comp_flag, uchar *key, uint key_length, my_off_t page,
uchar *father_buff, uchar *father_keypos,
my_off_t father_page, my_bool insert_last)
{
int error,flag;
uint nod_flag, search_key_length;
uchar *temp_buff,*keypos;
uchar keybuff[MI_MAX_KEY_BUFF];
my_bool was_last_key;
my_off_t next_page, dupp_key_pos;
DBUG_ENTER("w_search");
DBUG_PRINT("enter",("page: %ld", (long) page));
search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY;
if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
MI_MAX_KEY_BUFF*2)))
DBUG_RETURN(-1);
if (!_mi_fetch_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff,0))
goto err;
flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,search_key_length,
comp_flag, &keypos, keybuff, &was_last_key);
nod_flag=mi_test_if_nod(temp_buff);
if (flag == 0)
{
uint tmp_key_length;
/* get position to record with duplicated key */
tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,keybuff);
if (tmp_key_length)
dupp_key_pos=_mi_dpos(info,0,keybuff+tmp_key_length);
else
dupp_key_pos= HA_OFFSET_ERROR;
if (keyinfo->flag & HA_FULLTEXT)
{
uint off;
int subkeys;
get_key_full_length_rdonly(off, keybuff);
subkeys=ft_sintXkorr(keybuff+off);
comp_flag=SEARCH_SAME;
if (subkeys >= 0)
{
/* normal word, one-level tree structure */
flag=(*keyinfo->bin_search)(info, keyinfo, temp_buff, key,
USE_WHOLE_KEY, comp_flag,
&keypos, keybuff, &was_last_key);
}
else
{
/* popular word. two-level tree. going down */
my_off_t root=dupp_key_pos;
keyinfo=&info->s->ft2_keyinfo;
get_key_full_length_rdonly(off, key);
key+=off;
keypos-=keyinfo->keylength+nod_flag; /* we'll modify key entry 'in vivo' */
error=_mi_ck_real_write_btree(info, keyinfo, key, 0,
&root, comp_flag);
_mi_dpointer(info, keypos+HA_FT_WLEN, root);
subkeys--; /* should there be underflow protection ? */
DBUG_ASSERT(subkeys < 0);
ft_intXstore(keypos, subkeys);
if (!error)
error=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff);
my_afree((uchar*) temp_buff);
DBUG_RETURN(error);
}
}
else /* not HA_FULLTEXT, normal HA_NOSAME key */
{
info->dupp_key_pos= dupp_key_pos;
my_afree((uchar*) temp_buff);
my_errno=HA_ERR_FOUND_DUPP_KEY;
DBUG_RETURN(-1);
}
}
if (flag == MI_FOUND_WRONG_KEY)
DBUG_RETURN(-1);
if (!was_last_key)
insert_last=0;
next_page=_mi_kpos(nod_flag,keypos);
if (next_page == HA_OFFSET_ERROR ||
(error=w_search(info, keyinfo, comp_flag, key, key_length, next_page,
temp_buff, keypos, page, insert_last)) >0)
{
error=_mi_insert(info,keyinfo,key,temp_buff,keypos,keybuff,father_buff,
father_keypos,father_page, insert_last);
if (_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff))
goto err;
}
my_afree((uchar*) temp_buff);
DBUG_RETURN(error);
err:
my_afree((uchar*) temp_buff);
DBUG_PRINT("exit",("Error: %d",my_errno));
DBUG_RETURN (-1);
} /* w_search */
/*
Insert new key.
SYNOPSIS
_mi_insert()
info Open table information.
keyinfo Key definition information.
key New key.
anc_buff Key page (beginning).
key_pos Position in key page where to insert.
key_buff Copy of previous key.
father_buff parent key page for balancing.
father_key_pos position in parent key page for balancing.
father_page position of parent key page in file.
insert_last If to append at end of page.
DESCRIPTION
Insert new key at right of key_pos.
RETURN
2 if key contains key to upper level.
0 OK.
< 0 Error.
*/
int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
uchar *key, uchar *anc_buff, uchar *key_pos, uchar *key_buff,
uchar *father_buff, uchar *father_key_pos, my_off_t father_page,
my_bool insert_last)
{
uint a_length,nod_flag;
int t_length;
uchar *endpos, *prev_key;
MI_KEY_PARAM s_temp;
DBUG_ENTER("_mi_insert");
DBUG_PRINT("enter",("key_pos: 0x%lx", (long) key_pos));
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,key,USE_WHOLE_KEY););
nod_flag=mi_test_if_nod(anc_buff);
a_length=mi_getint(anc_buff);
endpos= anc_buff+ a_length;
prev_key=(key_pos == anc_buff+2+nod_flag ? (uchar*) 0 : key_buff);
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,
(key_pos == endpos ? (uchar*) 0 : key_pos),
prev_key, prev_key,
key,&s_temp);
#ifndef DBUG_OFF
if (key_pos != anc_buff+2+nod_flag && (keyinfo->flag &
(HA_BINARY_PACK_KEY | HA_PACK_KEY)))
{
DBUG_DUMP("prev_key",(uchar*) key_buff,_mi_keylength(keyinfo,key_buff));
}
if (keyinfo->flag & HA_PACK_KEY)
{
DBUG_PRINT("test",("t_length: %d ref_len: %d",
t_length,s_temp.ref_length));
DBUG_PRINT("test",("n_ref_len: %d n_length: %d key_pos: 0x%lx",
s_temp.n_ref_length,s_temp.n_length, (long) s_temp.key));
}
#endif
if (t_length > 0)
{
if (t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH)
{
mi_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(-1);
}
bmove_upp((uchar*) endpos+t_length,(uchar*) endpos,(uint) (endpos-key_pos));
}
else
{
if (-t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH)
{
mi_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(-1);
}
bmove(key_pos,key_pos-t_length,(uint) (endpos-key_pos)+t_length);
}
(*keyinfo->store_key)(keyinfo,key_pos,&s_temp);
a_length+=t_length;
mi_putint(anc_buff,a_length,nod_flag);
if (a_length <= keyinfo->block_length)
{
if (keyinfo->block_length - a_length < 32 &&
keyinfo->flag & HA_FULLTEXT && key_pos == endpos &&
info->s->base.key_reflength <= info->s->rec_reflength &&
info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))
{
/*
Normal word. One-level tree. Page is almost full.
Let's consider converting.
We'll compare 'key' and the first key at anc_buff
*/
uchar *a=key, *b=anc_buff+2+nod_flag;
uint alen, blen, ft2len=info->s->ft2_keyinfo.keylength;
/* the very first key on the page is always unpacked */
DBUG_ASSERT((*b & 128) == 0);
#if HA_FT_MAXLEN >= 127
blen= mi_uint2korr(b); b+=2;
#else
blen= *b++;
#endif
get_key_length(alen,a);
DBUG_ASSERT(info->ft1_to_ft2==0);
if (alen == blen &&
ha_compare_text(keyinfo->seg->charset, a, alen, b, blen, 0, 0)==0)
{
/* yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)
my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50);
/*
now, adding all keys from the page to dynarray
if the page is a leaf (if not keys will be deleted later)
*/
if (!nod_flag)
{
/* let's leave the first key on the page, though, because
we cannot easily dispatch an empty page here */
b+=blen+ft2len+2;
for (a=anc_buff+a_length ; b < a ; b+=ft2len+2)
{
if (insert_dynamic(info->ft1_to_ft2, b))
{
mi_print_error(info->s, HA_ERR_OUT_OF_MEM);
my_errno= HA_ERR_OUT_OF_MEM;
DBUG_RETURN(-1);
}
}
/* fixing the page's length - it contains only one key now */
mi_putint(anc_buff,2+blen+ft2len+2,0);
}
/* the rest will be done when we're back from recursion */
}
}
DBUG_RETURN(0); /* There is room on page */
}
/* Page is full */
if (nod_flag)
insert_last=0;
if (!(keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)) &&
father_buff && !insert_last)
DBUG_RETURN(_mi_balance_page(info,keyinfo,key,anc_buff,father_buff,
father_key_pos,father_page));
DBUG_RETURN(_mi_split_page(info,keyinfo,key,anc_buff,key_buff, insert_last));
} /* _mi_insert */
/* split a full page in two and assign emerging item to key */
int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo,
uchar *key, uchar *buff, uchar *key_buff,
my_bool insert_last_key)
{
uint length,a_length,key_ref_length,t_length,nod_flag,key_length;
uchar *key_pos,*pos, *UNINIT_VAR(after_key);
my_off_t new_pos;
MI_KEY_PARAM s_temp;
DBUG_ENTER("mi_split_page");
DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff));
if (info->s->keyinfo+info->lastinx == keyinfo)
info->page_changed=1; /* Info->buff is used */
info->buff_used=1;
nod_flag=mi_test_if_nod(buff);
key_ref_length=2+nod_flag;
if (insert_last_key)
key_pos=_mi_find_last_pos(keyinfo,buff,key_buff, &key_length, &after_key);
else
key_pos=_mi_find_half_pos(nod_flag,keyinfo,buff,key_buff, &key_length,
&after_key);
if (!key_pos)
DBUG_RETURN(-1);
length=(uint) (key_pos-buff);
a_length=mi_getint(buff);
mi_putint(buff,length,nod_flag);
key_pos=after_key;
if (nod_flag)
{
DBUG_PRINT("test",("Splitting nod"));
pos=key_pos-nod_flag;
memcpy((uchar*) info->buff+2,(uchar*) pos,(size_t) nod_flag);
}
/* Move middle item to key and pointer to new page */
if ((new_pos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR)
DBUG_RETURN(-1);
_mi_kpointer(info,_mi_move_key(keyinfo,key,key_buff),new_pos);
/* Store new page */
if (!(*keyinfo->get_key)(keyinfo,nod_flag,&key_pos,key_buff))
DBUG_RETURN(-1);
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,(uchar *) 0,
(uchar*) 0, (uchar*) 0,
key_buff, &s_temp);
length=(uint) ((buff+a_length)-key_pos);
memcpy((uchar*) info->buff+key_ref_length+t_length,(uchar*) key_pos,
(size_t) length);
(*keyinfo->store_key)(keyinfo,info->buff+key_ref_length,&s_temp);
mi_putint(info->buff,length+t_length+key_ref_length,nod_flag);
if (_mi_write_keypage(info,keyinfo,new_pos,DFLT_INIT_HITS,info->buff))
DBUG_RETURN(-1);
DBUG_DUMP("key",(uchar*) key,_mi_keylength(keyinfo,key));
DBUG_RETURN(2); /* Middle key up */
} /* _mi_split_page */
/*
Calculate how to much to move to split a page in two
Returns pointer to start of key.
key will contain the key.
return_key_length will contain the length of key
after_key will contain the position to where the next key starts
*/
uchar *_mi_find_half_pos(uint nod_flag, MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uint *return_key_length,
uchar **after_key)
{
uint keys,length,key_ref_length;
uchar *end,*lastpos;
DBUG_ENTER("_mi_find_half_pos");
key_ref_length=2+nod_flag;
length=mi_getint(page)-key_ref_length;
page+=key_ref_length;
if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
HA_BINARY_PACK_KEY)))
{
key_ref_length=keyinfo->keylength+nod_flag;
keys=length/(key_ref_length*2);
*return_key_length=keyinfo->keylength;
end=page+keys*key_ref_length;
*after_key=end+key_ref_length;
memcpy(key,end,key_ref_length);
DBUG_RETURN(end);
}
end=page+length/2-key_ref_length; /* This is aprox. half */
*key='\0';
do
{
lastpos=page;
if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,key)))
DBUG_RETURN(0);
} while (page < end);
*return_key_length=length;
*after_key=page;
DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx half: 0x%lx",
(long) lastpos, (long) page, (long) end));
DBUG_RETURN(lastpos);
} /* _mi_find_half_pos */
/*
Split buffer at last key
Returns pointer to the start of the key before the last key
key will contain the last key
*/
static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uint *return_key_length,
uchar **after_key)
{
uint keys,length,UNINIT_VAR(last_length),key_ref_length;
uchar *end,*lastpos,*UNINIT_VAR(prevpos);
uchar key_buff[MI_MAX_KEY_BUFF];
DBUG_ENTER("_mi_find_last_pos");
key_ref_length=2;
length=mi_getint(page)-key_ref_length;
page+=key_ref_length;
if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
HA_BINARY_PACK_KEY)))
{
keys=length/keyinfo->keylength-2;
*return_key_length=length=keyinfo->keylength;
end=page+keys*length;
*after_key=end+length;
memcpy(key,end,length);
DBUG_RETURN(end);
}
end=page+length-key_ref_length;
*key='\0';
length=0;
lastpos=page;
while (page < end)
{
prevpos=lastpos; lastpos=page;
last_length=length;
memcpy(key, key_buff, length); /* previous key */
if (!(length=(*keyinfo->get_key)(keyinfo,0,&page,key_buff)))
{
mi_print_error(keyinfo->share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(0);
}
}
*return_key_length=last_length;
*after_key=lastpos;
DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx end: 0x%lx",
(long) prevpos,(long) page,(long) end));
DBUG_RETURN(prevpos);
} /* _mi_find_last_pos */
/* Balance page with not packed keys with page on right/left */
/* returns 0 if balance was done */
static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo,
uchar *key, uchar *curr_buff, uchar *father_buff,
uchar *father_key_pos, my_off_t father_page)
{
my_bool right;
uint k_length,father_length,father_keylength,nod_flag,curr_keylength,
right_length,left_length,new_right_length,new_left_length,extra_length,
length,keys;
uchar *pos,*buff,*extra_buff;
my_off_t next_page,new_pos;
uchar tmp_part_key[MI_MAX_KEY_BUFF];
DBUG_ENTER("_mi_balance_page");
k_length=keyinfo->keylength;
father_length=mi_getint(father_buff);
father_keylength=k_length+info->s->base.key_reflength;
nod_flag=mi_test_if_nod(curr_buff);
curr_keylength=k_length+nod_flag;
info->page_changed=1;
if ((father_key_pos != father_buff+father_length &&
(info->state->records & 1)) ||
father_key_pos == father_buff+2+info->s->base.key_reflength)
{
right=1;
next_page= _mi_kpos(info->s->base.key_reflength,
father_key_pos+father_keylength);
buff=info->buff;
DBUG_PRINT("test",("use right page: %lu", (ulong) next_page));
}
else
{
right=0;
father_key_pos-=father_keylength;
next_page= _mi_kpos(info->s->base.key_reflength,father_key_pos);
/* Fix that curr_buff is to left */
buff=curr_buff; curr_buff=info->buff;
DBUG_PRINT("test",("use left page: %lu", (ulong) next_page));
} /* father_key_pos ptr to parting key */
if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0))
goto err;
DBUG_DUMP("next",(uchar*) info->buff,mi_getint(info->buff));
/* Test if there is room to share keys */
left_length=mi_getint(curr_buff);
right_length=mi_getint(buff);
keys=(left_length+right_length-4-nod_flag*2)/curr_keylength;
if ((right ? right_length : left_length) + curr_keylength <=
keyinfo->block_length)
{ /* Merge buffs */
new_left_length=2+nod_flag+(keys/2)*curr_keylength;
new_right_length=2+nod_flag+((keys+1)/2)*curr_keylength;
mi_putint(curr_buff,new_left_length,nod_flag);
mi_putint(buff,new_right_length,nod_flag);
if (left_length < new_left_length)
{ /* Move keys buff -> leaf */
pos=curr_buff+left_length;
memcpy((uchar*) pos,(uchar*) father_key_pos, (size_t) k_length);
memcpy((uchar*) pos+k_length, (uchar*) buff+2,
(size_t) (length=new_left_length - left_length - k_length));
pos=buff+2+length;
memcpy((uchar*) father_key_pos,(uchar*) pos,(size_t) k_length);
bmove((uchar*) buff + 2, (uchar*) pos + k_length, new_right_length - 2);
}
else
{ /* Move keys -> buff */
bmove_upp((uchar*) buff+new_right_length,(uchar*) buff+right_length,
right_length-2);
length=new_right_length-right_length-k_length;
memcpy((uchar*) buff+2+length,father_key_pos,(size_t) k_length);
pos=curr_buff+new_left_length;
memcpy((uchar*) father_key_pos,(uchar*) pos,(size_t) k_length);
memcpy((uchar*) buff+2,(uchar*) pos+k_length,(size_t) length);
}
if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff) ||
_mi_write_keypage(info,keyinfo,father_page,DFLT_INIT_HITS,father_buff))
goto err;
DBUG_RETURN(0);
}
/* curr_buff[] and buff[] are full, lets split and make new nod */
extra_buff=info->buff+info->s->base.max_key_block_length;
new_left_length=new_right_length=2+nod_flag+(keys+1)/3*curr_keylength;
if (keys == 5) /* Too few keys to balance */
new_left_length-=curr_keylength;
extra_length=nod_flag+left_length+right_length-
new_left_length-new_right_length-curr_keylength;
DBUG_PRINT("info",("left_length: %d right_length: %d new_left_length: %d new_right_length: %d extra_length: %d",
left_length, right_length,
new_left_length, new_right_length,
extra_length));
mi_putint(curr_buff,new_left_length,nod_flag);
mi_putint(buff,new_right_length,nod_flag);
mi_putint(extra_buff,extra_length+2,nod_flag);
/* move first largest keys to new page */
pos=buff+right_length-extra_length;
memcpy((uchar*) extra_buff+2,pos,(size_t) extra_length);
/* Save new parting key */
memcpy(tmp_part_key, pos-k_length,k_length);
/* Make place for new keys */
bmove_upp((uchar*) buff+new_right_length,(uchar*) pos-k_length,
right_length-extra_length-k_length-2);
/* Copy keys from left page */
pos= curr_buff+new_left_length;
memcpy((uchar*) buff+2,(uchar*) pos+k_length,
(size_t) (length=left_length-new_left_length-k_length));
/* Copy old parting key */
memcpy((uchar*) buff+2+length,father_key_pos,(size_t) k_length);
/* Move new parting keys up to caller */
memcpy((uchar*) (right ? key : father_key_pos),pos,(size_t) k_length);
memcpy((uchar*) (right ? father_key_pos : key),tmp_part_key, k_length);
if ((new_pos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR)
goto err;
_mi_kpointer(info,key+k_length,new_pos);
if (_mi_write_keypage(info,keyinfo,(right ? new_pos : next_page),
DFLT_INIT_HITS,info->buff) ||
_mi_write_keypage(info,keyinfo,(right ? next_page : new_pos),
DFLT_INIT_HITS,extra_buff))
goto err;
DBUG_RETURN(1); /* Middle key up */
err:
DBUG_RETURN(-1);
} /* _mi_balance_page */
/**********************************************************************
* Bulk insert code *
**********************************************************************/
typedef struct {
MI_INFO *info;
uint keynr;
} bulk_insert_param;
int _mi_ck_write_tree(register MI_INFO *info, uint keynr, uchar *key,
uint key_length)
{
int error;
DBUG_ENTER("_mi_ck_write_tree");
error= tree_insert(&info->bulk_insert[keynr], key,
key_length + info->s->rec_reflength,
info->bulk_insert[keynr].custom_arg) ? 0 : HA_ERR_OUT_OF_MEM ;
DBUG_RETURN(error);
} /* _mi_ck_write_tree */
/* typeof(_mi_keys_compare)=qsort_cmp2 */
static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
{
uint not_used[2];
return ha_key_cmp(param->info->s->keyinfo[param->keynr].seg,
key1, key2, USE_WHOLE_KEY, SEARCH_SAME,
not_used);
}
static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
{
/*
Probably I can use info->lastkey here, but I'm not sure,
and to be safe I'd better use local lastkey.
*/
uchar lastkey[MI_MAX_KEY_BUFF];
uint keylen;
MI_KEYDEF *keyinfo;
switch (mode) {
case free_init:
if (param->info->s->concurrent_insert)
{
mysql_rwlock_wrlock(¶m->info->s->key_root_lock[param->keynr]);
param->info->s->keyinfo[param->keynr].version++;
}
return 0;
case free_free:
keyinfo=param->info->s->keyinfo+param->keynr;
keylen=_mi_keylength(keyinfo, key);
memcpy(lastkey, key, keylen);
return _mi_ck_write_btree(param->info,param->keynr,lastkey,
keylen - param->info->s->rec_reflength);
case free_end:
if (param->info->s->concurrent_insert)
mysql_rwlock_unlock(¶m->info->s->key_root_lock[param->keynr]);
return 0;
}
return -1;
}
int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows)
{
MYISAM_SHARE *share=info->s;
MI_KEYDEF *key=share->keyinfo;
bulk_insert_param *params;
uint i, num_keys, total_keylength;
ulonglong key_map;
DBUG_ENTER("_mi_init_bulk_insert");
DBUG_PRINT("enter",("cache_size: %lu", cache_size));
DBUG_ASSERT(!info->bulk_insert &&
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT));
mi_clear_all_keys_active(key_map);
for (i=total_keylength=num_keys=0 ; i < share->base.keys ; i++)
{
if (! (key[i].flag & HA_NOSAME) && (share->base.auto_key != i + 1) &&
mi_is_key_active(share->state.key_map, i))
{
num_keys++;
mi_set_key_active(key_map, i);
total_keylength+=key[i].maxlength+TREE_ELEMENT_EXTRA_SIZE;
}
}
if (num_keys==0 ||
num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > cache_size)
DBUG_RETURN(0);
if (rows && rows*total_keylength < cache_size)
cache_size= (ulong)rows;
else
cache_size/=total_keylength*16;
info->bulk_insert=(TREE *)
my_malloc((sizeof(TREE)*share->base.keys+
sizeof(bulk_insert_param)*num_keys),MYF(0));
if (!info->bulk_insert)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
params=(bulk_insert_param *)(info->bulk_insert+share->base.keys);
for (i=0 ; i < share->base.keys ; i++)
{
if (mi_is_key_active(key_map, i))
{
params->info=info;
params->keynr=i;
/* Only allocate a 16'th of the buffer at a time */
init_tree(&info->bulk_insert[i],
cache_size * key[i].maxlength,
cache_size * key[i].maxlength, 0,
(qsort_cmp2)keys_compare, 0,
(tree_element_free) keys_free, (void *)params++);
}
else
info->bulk_insert[i].root=0;
}
DBUG_RETURN(0);
}
void mi_flush_bulk_insert(MI_INFO *info, uint inx)
{
if (info->bulk_insert)
{
if (is_tree_inited(&info->bulk_insert[inx]))
reset_tree(&info->bulk_insert[inx]);
}
}
void mi_end_bulk_insert(MI_INFO *info)
{
if (info->bulk_insert)
{
uint i;
for (i=0 ; i < info->s->base.keys ; i++)
{
if (is_tree_inited(& info->bulk_insert[i]))
{
delete_tree(& info->bulk_insert[i]);
}
}
my_free(info->bulk_insert);
info->bulk_insert=0;
}
}
| gpl-2.0 |
lizhuobin1981/rtems_test | c/src/ada-tests/tmtests/tm29/config.h | 958 | /* config.h
*
* This include file defines the Configuration Table for this test.
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
/* configuration information */
#define CONFIGURE_TMTEST
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 111
#define CONFIGURE_MAXIMUM_PERIODS 111
#define CONFIGURE_TICKS_PER_TIMESLICE 0
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 20
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
#include <rtems/confdefs.h>
/* end of include file */
| gpl-2.0 |
aldencolerain/mc2kernel | drivers/net/ethernet/mvebu_net/switch/qd-dsdt-3.3/src/msapi/gtPhyInt_mad.c | 7842 | #include <Copyright.h>
/********************************************************************************
* gtPhyInt.h
*
* DESCRIPTION:
* API definitions for PHY interrupt handling
*
* DEPENDENCIES:
* None.
*
* FILE REVISION NUMBER:
* $Revision: 10 $
*******************************************************************************/
#include <msApi.h>
#include <gtHwCntl.h>
#include <gtDrvSwRegs.h>
#include <gtDrvConfig.h>
#include "madApi.h"
/*******************************************************************************
* gprtPhyIntEnable_mad
*
* DESCRIPTION:
* Enable/Disable one PHY Interrupt
* This register determines whether the INT# pin is asserted when an interrupt
* event occurs. When an interrupt occurs, the corresponding bit is set and
* remains set until register 19 is read via the SMI. When interrupt enable
* bits are not set in register 18, interrupt status bits in register 19 are
* still set when the corresponding interrupt events occur. However, the INT#
* is not asserted.
*
* INPUTS:
* port - The logical port number, unless SERDES device is accessed
* The physical address, if SERDES device is accessed
* intType - the type of interrupt to enable/disable. any combination of
* GT_SPEED_CHANGED,
* GT_DUPLEX_CHANGED,
* GT_PAGE_RECEIVED,
* GT_AUTO_NEG_COMPLETED,
* GT_LINK_STATUS_CHANGED,
* GT_SYMBOL_ERROR,
* GT_FALSE_CARRIER,
* GT_FIFO_FLOW,
* GT_CROSSOVER_CHANGED, ( Copper only )
* GT_DOWNSHIFT_DETECT, ( for 1000M Copper only )
* GT_ENERGY_DETECT, ( for 1000M Copper only )
* GT_POLARITY_CHANGED, and ( Copper only )
* GT_JABBER (Copper only )
*
*
* OUTPUTS:
* None.
*
* RETURNS:
* GT_OK - on success
* GT_FAIL - on error
*
* COMMENTS:
* For 88E6131, 88E6122, and 88E6108 devices, Serdes port can be accessed using
* logical port number.
* For 88E6161 88E6165 and 88E6352 devices, Serdes port 5 (address 0xD/0xF) can be accessed
* using logical port number, but not port 4 (since port 4 could be an internal
* PHY.)
*******************************************************************************/
GT_STATUS gprtPhyIntEnable_mad
(
IN GT_QD_DEV *dev,
IN GT_LPORT port,
IN GT_U16 intType
)
{
GT_U8 hwPort; /* the physical port number */
MAD_INT_TYPE mintType;
DBG_INFO(("gprtPhyIntEnable_mad Called.\n"));
/* translate LPORT to hardware port */
hwPort = GT_LPORT_2_PHY(port);
if((IS_IN_DEV_GROUP(dev,DEV_SERDES_CORE)) && (hwPort > 3))
{
if(!(dev->validSerdesVec & (1 << hwPort)))
{
if(!((IS_IN_DEV_GROUP(dev,DEV_SERDES_ACCESS_CONFIG)) && (hwPort == 4)))
GT_GET_SERDES_PORT(dev,&hwPort);
}
if(hwPort >= dev->maxPhyNum)
{
return GT_NOT_SUPPORTED;
}
}
/* check if the port is configurable */
if(!IS_CONFIGURABLE_PHY(dev,hwPort))
{
return GT_NOT_SUPPORTED;
}
mintType.intGroup0 = 0;
mintType.intGroup1 = 0;
mintType.intGroup0 = intType;
if(mdIntSetEnable(&(dev->mad_dev),hwPort,&mintType) != MAD_OK)
{
DBG_INFO(("Call mdIntSetEnable failed.\n"));
return GT_FAIL;
}
return GT_OK;
}
/*******************************************************************************
* gprtGetPhyIntStatus_mad
*
* DESCRIPTION:
* Check to see if a specific type of interrupt occured
*
* INPUTS:
* port - The logical port number, unless SERDES device is accessed
* The physical address, if SERDES device is accessed
* intType - the type of interrupt which causes an interrupt.
* any combination of
* GT_SPEED_CHANGED,
* GT_DUPLEX_CHANGED,
* GT_PAGE_RECEIVED,
* GT_AUTO_NEG_COMPLETED,
* GT_LINK_STATUS_CHANGED,
* GT_SYMBOL_ERROR,
* GT_FALSE_CARRIER,
* GT_FIFO_FLOW,
* GT_CROSSOVER_CHANGED, ( Copper only )
* GT_DOWNSHIFT_DETECT, ( for 1000M Copper only )
* GT_ENERGY_DETECT, ( for 1000M Copper only )
* GT_POLARITY_CHANGED, and ( Copper only )
* GT_JABBER (Copper only )
*
* OUTPUTS:
* None.
*
* RETURNS:
* GT_OK - on success
* GT_FAIL - on error
*
* COMMENTS:
* For 88E6131, 88E6122, and 88E6108 devices, Serdes port can be accessed using
* logical port number.
* For 88E6161 88E6165 and 88E6352 devices, Serdes port 5 (address 0xD/0xF) can be accessed
* using logical port number, but not port 4 (since port 4 could be an internal
* PHY.)
*
*******************************************************************************/
GT_STATUS gprtGetPhyIntStatus_mad
(
IN GT_QD_DEV *dev,
IN GT_LPORT port,
OUT GT_U16* intType
)
{
GT_U8 hwPort; /* the physical port number */
MAD_INT_TYPE mintType;
DBG_INFO(("gprtGetPhyIntStatus_mad Called.\n"));
/* translate LPORT to hardware port */
hwPort = GT_LPORT_2_PHY(port);
if((IS_IN_DEV_GROUP(dev,DEV_SERDES_CORE)) && (hwPort > 3))
{
if(!(dev->validSerdesVec & (1 << hwPort)))
{
if(!((IS_IN_DEV_GROUP(dev,DEV_SERDES_ACCESS_CONFIG)) && (hwPort == 4)))
GT_GET_SERDES_PORT(dev,&hwPort);
}
if(hwPort >= dev->maxPhyNum)
{
return GT_NOT_SUPPORTED;
}
}
/* check if the port is configurable */
if(!IS_CONFIGURABLE_PHY(dev,hwPort))
{
return GT_NOT_SUPPORTED;
}
if(mdIntGetStatus(&(dev->mad_dev),hwPort,&mintType) != MAD_OK)
{
DBG_INFO(("Call mdIntGetStatus failed.\n"));
return GT_FAIL;
}
*intType = mintType.intGroup0;
return GT_OK;
}
/*******************************************************************************
* gprtGetPhyIntPortSummary_mad
*
* DESCRIPTION:
* Lists the ports that have active interrupts. It provides a quick way to
* isolate the interrupt so that the MAC or switch does not have to poll the
* interrupt status register (19) for all ports. Reading this register does not
* de-assert the INT# pin
*
* INPUTS:
* none
*
* OUTPUTS:
* GT_U8 *intPortMask - bit Mask with the bits set for the corresponding
* phys with active interrupt. E.g., the bit number 0 and 2 are set when
* port number 0 and 2 have active interrupt
*
* RETURNS:
* GT_OK - on success
* GT_FAIL - on error
*
* COMMENTS:
* 88E3081 data sheet register 20
* For 88E6165, 88E6375 devices, geventGetDevIntStatus should be used instead.
*
*******************************************************************************/
GT_STATUS gprtGetPhyIntPortSummary_mad
(
IN GT_QD_DEV *dev,
OUT GT_U16 *intPortMask
)
{
GT_STATUS retVal;
GT_U8 hwPort; /* the physical port number */
GT_U16 portVec;
MAD_U32 mportVec;
DBG_INFO(("gprtGetPhyIntPortSummary_mad Called.\n"));
/* translate LPORT 0 to hardware port */
hwPort = GT_LPORT_2_PORT(0);
*intPortMask=0;
if (IS_IN_DEV_GROUP(dev,DEV_DEV_PHY_INTERRUPT))
{
return GT_NOT_SUPPORTED;
}
if (IS_IN_DEV_GROUP(dev,DEV_INTERNAL_GPHY))
{
/* get the interrupt port summary from global register */
retVal = hwGetGlobal2RegField(dev,QD_REG_PHYINT_SOURCE,0,dev->maxPorts,&portVec);
GT_GIG_PHY_INT_MASK(dev,portVec);
*intPortMask = (GT_U16)GT_PORTVEC_2_LPORTVEC(portVec);
}
else
{
/* get the interrupt port summary from phy */
if(mdIntGetPortSummary(&(dev->mad_dev), &mportVec) != MAD_OK)
{
DBG_INFO(("Call mdIntGetPortSummary failed.\n"));
return GT_FAIL;
}
portVec = mportVec;
*intPortMask = (GT_U16)GT_PORTVEC_2_LPORTVEC(portVec);
}
return GT_OK;
}
| gpl-2.0 |
ogajduse/spacewalk | backend/cdn_tools/manifest.py | 13620 | # Copyright (c) 2016--2017 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
import sys
import cStringIO
import json
import zipfile
import os
from M2Crypto import X509
from spacewalk.satellite_tools.syncLib import log2
from spacewalk.server.rhnServer.satellite_cert import SatelliteCert
import constants
class Manifest(object):
"""Class containing relevant data from RHSM manifest."""
SIGNATURE_NAME = "signature"
INNER_ZIP_NAME = "consumer_export.zip"
ENTITLEMENTS_PATH = "export/entitlements"
CERTIFICATE_PATH = "export/extensions"
PRODUCTS_PATH = "export/products"
CONSUMER_INFO = "export/consumer.json"
META_INFO = "export/meta.json"
UPSTREAM_CONSUMER_PATH = "export/upstream_consumer"
def __init__(self, zip_path):
self.all_entitlements = []
self.manifest_repos = {}
self.sat5_certificate = None
self.satellite_version = None
self.consumer_credentials = None
self.uuid = None
self.name = None
self.ownerid = None
self.api_url = None
self.web_url = None
self.created = None
# Signature and signed data
self.signature = None
self.data = None
# Open manifest from path
top_zip = None
inner_zip = None
inner_file = None
# normalize path
zip_path = os.path.abspath(os.path.expanduser(zip_path))
try:
top_zip = zipfile.ZipFile(zip_path, 'r')
# Fetch inner zip file into memory
try:
# inner_file = top_zip.open(zip_path.split('.zip')[0] + '/' + self.INNER_ZIP_NAME)
inner_file = top_zip.open(self.INNER_ZIP_NAME)
self.data = inner_file.read()
inner_file_data = cStringIO.StringIO(self.data)
signature_file = top_zip.open(self.SIGNATURE_NAME)
self.signature = signature_file.read()
# Open the inner zip file
try:
inner_zip = zipfile.ZipFile(inner_file_data)
self._extract_consumer_info(inner_zip)
self._load_entitlements(inner_zip)
self._extract_certificate(inner_zip)
self._extract_meta_info(inner_zip)
self._extract_consumer_credentials(inner_zip)
finally:
if inner_zip is not None:
inner_zip.close()
finally:
if inner_file is not None:
inner_file.close()
finally:
if top_zip is not None:
top_zip.close()
def _extract_certificate(self, zip_file):
files = zip_file.namelist()
certificates_names = []
for f in files:
if f.startswith(self.CERTIFICATE_PATH) and f.endswith(".xml"):
certificates_names.append(f)
if len(certificates_names) >= 1:
# take only first file
cert_file = zip_file.open(certificates_names[0]) # take only first file
self.sat5_certificate = cert_file.read().strip()
cert_file.close()
# Save version too
sat5_cert = SatelliteCert()
sat5_cert.load(self.sat5_certificate)
self.satellite_version = getattr(sat5_cert, 'satellite-version')
else:
raise MissingSatelliteCertificateError("Satellite Certificate was not found in manifest.")
def _fill_product_repositories(self, zip_file, product):
product_file = zip_file.open(self.PRODUCTS_PATH + '/' + str(product.get_id()) + '.json')
product_data = json.load(product_file)
product_file.close()
try:
for content in product_data['productContent']:
content = content['content']
product.add_repository(content['label'], content['contentUrl'])
except KeyError:
log2(0, 0, "ERROR: Cannot access required field in product '%s'" % product.get_id(), stream=sys.stderr)
raise
def _load_entitlements(self, zip_file):
files = zip_file.namelist()
entitlements_files = []
for f in files:
if f.startswith(self.ENTITLEMENTS_PATH) and f.endswith(".json"):
entitlements_files.append(f)
if len(entitlements_files) >= 1:
self.all_entitlements = []
for entitlement_file in entitlements_files:
entitlements = zip_file.open(entitlement_file)
# try block in try block - this is hack for python 2.4 compatibility
# to support finally
try:
try:
data = json.load(entitlements)
# Extract credentials
certs = data['certificates']
if len(certs) != 1:
raise IncorrectEntitlementsFileFormatError(
"Single certificate in entitlements file '%s' is expected, found: %d"
% (entitlement_file, len(certs)))
cert = certs[0]
credentials = Credentials(data['id'], cert['cert'], cert['key'])
# Extract product IDs
products = []
provided_products = data['pool']['providedProducts'] or []
derived_provided_products = data['pool']['derivedProvidedProducts'] or []
product_ids = [provided_product['productId'] for provided_product
in provided_products + derived_provided_products]
for product_id in set(product_ids):
product = Product(product_id)
self._fill_product_repositories(zip_file, product)
products.append(product)
# Skip entitlements not providing any products
if products:
entitlement = Entitlement(products, credentials)
self.all_entitlements.append(entitlement)
except KeyError:
log2(0, 0, "ERROR: Cannot access required field in file '%s'" % entitlement_file,
stream=sys.stderr)
raise
finally:
entitlements.close()
else:
refer_url = "%s%s" % (self.web_url, self.uuid)
if not refer_url.startswith("http"):
refer_url = "https://" + refer_url
raise IncorrectEntitlementsFileFormatError(
"No subscriptions were found in manifest.\n\nPlease refer to %s for setting up subscriptions."
% refer_url)
def _extract_consumer_info(self, zip_file):
files = zip_file.namelist()
found = False
for f in files:
if f == self.CONSUMER_INFO:
found = True
break
if found:
consumer_info = zip_file.open(self.CONSUMER_INFO)
try:
try:
data = json.load(consumer_info)
self.uuid = data['uuid']
self.name = data['name']
self.ownerid = data['owner']['key']
self.api_url = data['urlApi']
self.web_url = data['urlWeb']
except KeyError:
log2(0, 0, "ERROR: Cannot access required field in file '%s'" % self.CONSUMER_INFO,
stream=sys.stderr)
raise
finally:
consumer_info.close()
else:
raise MissingConsumerInfoError()
def _extract_meta_info(self, zip_file):
files = zip_file.namelist()
found = False
for f in files:
if f == self.META_INFO:
found = True
break
if found:
meta_info = zip_file.open(self.META_INFO)
try:
try:
data = json.load(meta_info)
self.created = data['created']
except KeyError:
log2(0, 0, "ERROR: Cannot access required field in file '%s'" % self.META_INFO, stream=sys.stderr)
raise
finally:
meta_info.close()
else:
raise MissingMetaInfoError()
def _extract_consumer_credentials(self, zip_file):
files = zip_file.namelist()
consumer_credentials = []
for f in files:
if f.startswith(self.UPSTREAM_CONSUMER_PATH) and f.endswith(".json"):
consumer_credentials.append(f)
if len(consumer_credentials) == 1:
upstream_consumer = zip_file.open(consumer_credentials[0])
try:
try:
data = json.load(upstream_consumer)
self.consumer_credentials = Credentials(data['id'], data['cert'], data['key'])
except KeyError:
log2(0, 0, "ERROR: Cannot access required field in file '%s'" % consumer_credentials[0],
stream=sys.stderr)
raise
finally:
upstream_consumer.close()
else:
raise IncorrectCredentialsError(
"ERROR: Single upstream consumer certificate expected, found %d." % len(consumer_credentials))
def get_all_entitlements(self):
return self.all_entitlements
def get_satellite_certificate(self):
return self.sat5_certificate
def get_satellite_version(self):
return self.satellite_version
def get_consumer_credentials(self):
return self.consumer_credentials
def get_name(self):
return self.name
def get_uuid(self):
return self.uuid
def get_ownerid(self):
return self.ownerid
def get_api_url(self):
return self.api_url
def get_created(self):
return self.created
def check_signature(self):
if self.signature and self.data:
certs = os.listdir(constants.CANDLEPIN_CA_CERT_DIR)
# At least one certificate has to match
for cert_name in certs:
cert_file = None
try:
try:
cert_file = open(constants.CANDLEPIN_CA_CERT_DIR + '/' + cert_name, 'r')
cert = X509.load_cert_string(cert_file.read())
except (IOError, X509.X509Error):
continue
finally:
if cert_file is not None:
cert_file.close()
pubkey = cert.get_pubkey()
pubkey.reset_context(md='sha256')
pubkey.verify_init()
pubkey.verify_update(self.data)
if pubkey.verify_final(self.signature):
return True
return False
class Entitlement(object):
def __init__(self, products, credentials):
if products and credentials:
self.products = products
self.credentials = credentials
else:
raise IncorrectEntitlementError()
def get_products(self):
return self.products
def get_credentials(self):
return self.credentials
class Credentials(object):
def __init__(self, identifier, cert, key):
if identifier:
self.id = identifier
else:
raise IncorrectCredentialsError(
"ERROR: ID of credentials has to be defined"
)
if cert and key:
self.cert = cert
self.key = key
else:
raise IncorrectCredentialsError(
"ERROR: Trying to create object with cert = %s and key = %s"
% (cert, key)
)
def get_id(self):
return self.id
def get_cert(self):
return self.cert
def get_key(self):
return self.key
class Product(object):
def __init__(self, identifier):
try:
self.id = int(identifier)
except ValueError:
raise IncorrectProductError(
"ERROR: Invalid product id: %s" % identifier
)
self.repositories = {}
def get_id(self):
return self.id
def get_repositories(self):
return self.repositories
def add_repository(self, label, url):
self.repositories[label] = url
class IncorrectProductError(Exception):
pass
class IncorrectEntitlementError(Exception):
pass
class IncorrectCredentialsError(Exception):
pass
class IncorrectEntitlementsFileFormatError(Exception):
pass
class MissingSatelliteCertificateError(Exception):
pass
class ManifestValidationError(Exception):
pass
class MissingConsumerInfoError(Exception):
pass
class MissingMetaInfoError(Exception):
pass
| gpl-2.0 |
Gurgel100/gcc | gcc/testsuite/gcc.target/powerpc/vsx_mask-move-runnable.c | 5978 | /* { dg-do run { target { power10_hw } } } */
/* { dg-do link { target { ! power10_hw } } } */
/* { dg-options "-mdejagnu-cpu=power10 -O2 -save-temps" } */
/* { dg-require-effective-target power10_ok } */
/* { dg-require-effective-target int128 } */
/* Check that the expected 128-bit instructions are generated if the processor
supports the 128-bit integer instructions. */
/* { dg-final { scan-assembler-times {\mmtvsrbm\M} 1 } } */
/* { dg-final { scan-assembler-times {\mmtvsrhm\M} 1 } } */
/* { dg-final { scan-assembler-times {\mmtvsrwm\M} 1 } } */
/* { dg-final { scan-assembler-times {\mmtvsrdm\M} 1 } } */
/* { dg-final { scan-assembler-times {\mmtvsrqm\M} 1 } } */
/* { dg-final { scan-assembler-times {\mmtvsrbmi\M} 2 } } */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
#include <altivec.h>
void abort (void);
int main ()
{
int i, num_elements;
unsigned long long arg1;
vector unsigned char vbc_result_bi, vbc_expected_result_bi;
vector unsigned short vbc_result_hi, vbc_expected_result_hi;
vector unsigned int vbc_result_wi, vbc_expected_result_wi;
vector unsigned long long vbc_result_di, vbc_expected_result_di;
vector __uint128_t vbc_result_qi, vbc_expected_result_qi;
unsigned int result_wi, expected_result_wi;
unsigned long long result, expected_result;
const unsigned char mp=1;
vector unsigned char vbc_bi_src;
vector unsigned short vbc_hi_src;
vector unsigned int vbc_wi_src;
vector unsigned long long vbc_di_src;
vector __uint128_t vbc_qi_src;
/* mtvsrbmi */
num_elements = 16;
for (i = 0; i<num_elements; i++)
vbc_expected_result_bi[i] = 0x0;
vbc_expected_result_bi[0] = 0xFF;
vbc_expected_result_bi[2] = 0xFF;
vbc_result_bi = vec_genbm(5);
for (i = 0; i<num_elements; i++) {
if (vbc_result_bi[i] != vbc_expected_result_bi[i]) {
#if DEBUG
printf("ERROR: vec_genbm(const 5) ");
printf("element %d equals 0x%x does not match expected_result = 0x%x",
i, vbc_result_bi[i], vbc_expected_result_bi[i]);
printf("\n\n");
#else
abort();
#endif
}
}
/* mtvsrbm */
num_elements = 16;
/* -O2 should generate mtvsrbmi as argument will fit in 6-bit field. */
arg1 = 3;
for (i = 0; i<num_elements; i++)
vbc_expected_result_bi[i] = 0x0;
vbc_expected_result_bi[1] = 0xFF;
vbc_expected_result_bi[0] = 0xFF;
vbc_result_bi = vec_genbm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_bi[i] != vbc_expected_result_bi[i]) {
#if DEBUG
printf("ERROR: vec_genbm(%d) ", arg1);
printf("element %d equals 0x%x does not match expected_result = 0x%x",
i, vbc_result_bi[i], vbc_expected_result_bi[i]);
printf("\n\n");
#else
abort();
#endif
}
}
num_elements = 16;
/* Should generate mtvsrbm as argument will not fit in 6-bit field. */
arg1 = 0xEA; // 234 decimal
for (i = 0; i<num_elements; i++)
vbc_expected_result_bi[i] = 0x0;
vbc_expected_result_bi[7] = 0xFF;
vbc_expected_result_bi[6] = 0xFF;
vbc_expected_result_bi[5] = 0xFF;
vbc_expected_result_bi[3] = 0xFF;
vbc_expected_result_bi[1] = 0xFF;
vbc_result_bi = vec_genbm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_bi[i] != vbc_expected_result_bi[i]) {
#if DEBUG
printf("ERROR: vec_genbm(%d) ", arg1);
printf("element %d equals 0x%x does not match expected_result = 0x%x",
i, vbc_result_bi[i], vbc_expected_result_bi[i]);
printf("\n\n");
#else
abort();
#endif
}
}
/* mtvsrhm */
num_elements = 8;
arg1 = 5;
for (i = 0; i<num_elements; i++)
vbc_expected_result_hi[i] = 0x0;
vbc_expected_result_hi[2] = 0xFFFF;
vbc_expected_result_hi[0] = 0xFFFF;
vbc_result_hi = vec_genhm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_hi[i] != vbc_expected_result_hi[i]) {
#if DEBUG
printf("ERROR: vec_genhm(%d) ", arg1);
printf("element %d equals 0x%x does not match expected_result = 0x%x",
i, vbc_result_hi[i], vbc_expected_result_hi[i]);
printf("\n\n");
#else
abort();
#endif
}
}
/* mtvsrwm */
num_elements = 4;
arg1 = 7;
for (i = 0; i<num_elements; i++)
vbc_expected_result_wi[i] = 0x0;
vbc_expected_result_wi[2] = 0xFFFFFFFF;
vbc_expected_result_wi[1] = 0xFFFFFFFF;
vbc_expected_result_wi[0] = 0xFFFFFFFF;
vbc_result_wi = vec_genwm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_wi[i] != vbc_expected_result_wi[i]) {
#if DEBUG
printf("ERROR: vec_genwm(%d) ", arg1);
printf("element %d equals 0x%x does not match expected_result = 0x%x",
i, vbc_result_wi[i], vbc_expected_result_wi[i]);
printf("\n\n");
#else
abort();
#endif
}
}
/* mtvsrdm */
num_elements = 2;
arg1 = 1;
for (i = 0; i<num_elements; i++)
vbc_expected_result_di[i] = 0x0;
vbc_expected_result_di[1] = 0x0;
vbc_expected_result_di[0] = 0xFFFFFFFFFFFFFFFF;
vbc_result_di = vec_gendm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_di[i] != vbc_expected_result_di[i]) {
#if DEBUG
printf("ERROR: vec_gendm(%d) ", arg1);
printf("element %d equals 0x%llx does not match expected_result = ",
i, vbc_result_di[i]);
printf("0x%llx\n\n", vbc_expected_result_di[i]);
#else
abort();
#endif
}
}
/* mtvsrqm */
num_elements = 1;
arg1 = 1;
for (i = 0; i<num_elements; i++)
vbc_expected_result_qi[i] = 0x0;
vbc_expected_result_qi[0] = 0xFFFFFFFFFFFFFFFFULL;
vbc_expected_result_qi[0] = (vbc_expected_result_qi[0] << 64)
| 0xFFFFFFFFFFFFFFFFULL;
vbc_result_qi = vec_genqm(arg1);
for (i = 0; i<num_elements; i++) {
if (vbc_result_qi[i] != vbc_expected_result_qi[i]) {
#if DEBUG
printf("ERROR: vec_genqm(%d) ", arg1);
printf("element %d equals 0x%llx does not match expected_result = ",
i, vbc_result_qi[i]);
printf("0x%llx\n\n", vbc_expected_result_qi[i]);
#else
abort();
#endif
}
}
return 0;
}
| gpl-2.0 |
GuillaumeSeren/linux | include/net/udp.h | 15581 | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the UDP module.
*
* Version: @(#)udp.h 1.0.2 05/07/93
*
* Authors: Ross Biro
* Fred N. van Kempen, <[email protected]>
*
* Fixes:
* Alan Cox : Turned on udp checksums. I don't want to
* chase 'memory corruption' bugs that aren't!
*/
#ifndef _UDP_H
#define _UDP_H
#include <linux/list.h>
#include <linux/bug.h>
#include <net/inet_sock.h>
#include <net/sock.h>
#include <net/snmp.h>
#include <net/ip.h>
#include <linux/ipv6.h>
#include <linux/seq_file.h>
#include <linux/poll.h>
#include <linux/indirect_call_wrapper.h>
/**
* struct udp_skb_cb - UDP(-Lite) private variables
*
* @header: private variables used by IPv4/IPv6
* @cscov: checksum coverage length (UDP-Lite only)
* @partial_cov: if set indicates partial csum coverage
*/
struct udp_skb_cb {
union {
struct inet_skb_parm h4;
#if IS_ENABLED(CONFIG_IPV6)
struct inet6_skb_parm h6;
#endif
} header;
__u16 cscov;
__u8 partial_cov;
};
#define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
/**
* struct udp_hslot - UDP hash slot
*
* @head: head of list of sockets
* @count: number of sockets in 'head' list
* @lock: spinlock protecting changes to head/count
*/
struct udp_hslot {
struct hlist_head head;
int count;
spinlock_t lock;
} __attribute__((aligned(2 * sizeof(long))));
/**
* struct udp_table - UDP table
*
* @hash: hash table, sockets are hashed on (local port)
* @hash2: hash table, sockets are hashed on (local port, local address)
* @mask: number of slots in hash tables, minus 1
* @log: log2(number of slots in hash table)
*/
struct udp_table {
struct udp_hslot *hash;
struct udp_hslot *hash2;
unsigned int mask;
unsigned int log;
};
extern struct udp_table udp_table;
void udp_table_init(struct udp_table *, const char *);
static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
struct net *net, unsigned int num)
{
return &table->hash[udp_hashfn(net, num, table->mask)];
}
/*
* For secondary hash, net_hash_mix() is performed before calling
* udp_hashslot2(), this explains difference with udp_hashslot()
*/
static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
unsigned int hash)
{
return &table->hash2[hash & table->mask];
}
extern struct proto udp_prot;
extern atomic_long_t udp_memory_allocated;
/* sysctl variables for udp */
extern long sysctl_udp_mem[3];
extern int sysctl_udp_rmem_min;
extern int sysctl_udp_wmem_min;
struct sk_buff;
/*
* Generic checksumming routines for UDP(-Lite) v4 and v6
*/
static inline __sum16 __udp_lib_checksum_complete(struct sk_buff *skb)
{
return (UDP_SKB_CB(skb)->cscov == skb->len ?
__skb_checksum_complete(skb) :
__skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov));
}
static inline int udp_lib_checksum_complete(struct sk_buff *skb)
{
return !skb_csum_unnecessary(skb) &&
__udp_lib_checksum_complete(skb);
}
/**
* udp_csum_outgoing - compute UDPv4/v6 checksum over fragments
* @sk: socket we are writing to
* @skb: sk_buff containing the filled-in UDP header
* (checksum field must be zeroed out)
*/
static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb)
{
__wsum csum = csum_partial(skb_transport_header(skb),
sizeof(struct udphdr), 0);
skb_queue_walk(&sk->sk_write_queue, skb) {
csum = csum_add(csum, skb->csum);
}
return csum;
}
static inline __wsum udp_csum(struct sk_buff *skb)
{
__wsum csum = csum_partial(skb_transport_header(skb),
sizeof(struct udphdr), skb->csum);
for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) {
csum = csum_add(csum, skb->csum);
}
return csum;
}
static inline __sum16 udp_v4_check(int len, __be32 saddr,
__be32 daddr, __wsum base)
{
return csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base);
}
void udp_set_csum(bool nocheck, struct sk_buff *skb,
__be32 saddr, __be32 daddr, int len);
static inline void udp_csum_pull_header(struct sk_buff *skb)
{
if (!skb->csum_valid && skb->ip_summed == CHECKSUM_NONE)
skb->csum = csum_partial(skb->data, sizeof(struct udphdr),
skb->csum);
skb_pull_rcsum(skb, sizeof(struct udphdr));
UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr);
}
typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport,
__be16 dport);
INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp4_gro_receive(struct list_head *,
struct sk_buff *));
INDIRECT_CALLABLE_DECLARE(int udp4_gro_complete(struct sk_buff *, int));
INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp6_gro_receive(struct list_head *,
struct sk_buff *));
INDIRECT_CALLABLE_DECLARE(int udp6_gro_complete(struct sk_buff *, int));
struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
struct udphdr *uh, struct sock *sk);
int udp_gro_complete(struct sk_buff *skb, int nhoff, udp_lookup_t lookup);
struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
netdev_features_t features, bool is_ipv6);
static inline struct udphdr *udp_gro_udphdr(struct sk_buff *skb)
{
struct udphdr *uh;
unsigned int hlen, off;
off = skb_gro_offset(skb);
hlen = off + sizeof(*uh);
uh = skb_gro_header_fast(skb, off);
if (skb_gro_header_hard(skb, hlen))
uh = skb_gro_header_slow(skb, hlen, off);
return uh;
}
/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
static inline int udp_lib_hash(struct sock *sk)
{
BUG();
return 0;
}
void udp_lib_unhash(struct sock *sk);
void udp_lib_rehash(struct sock *sk, u16 new_hash);
static inline void udp_lib_close(struct sock *sk, long timeout)
{
sk_common_release(sk);
}
int udp_lib_get_port(struct sock *sk, unsigned short snum,
unsigned int hash2_nulladdr);
u32 udp_flow_hashrnd(void);
static inline __be16 udp_flow_src_port(struct net *net, struct sk_buff *skb,
int min, int max, bool use_eth)
{
u32 hash;
if (min >= max) {
/* Use default range */
inet_get_local_port_range(net, &min, &max);
}
hash = skb_get_hash(skb);
if (unlikely(!hash)) {
if (use_eth) {
/* Can't find a normal hash, caller has indicated an
* Ethernet packet so use that to compute a hash.
*/
hash = jhash(skb->data, 2 * ETH_ALEN,
(__force u32) skb->protocol);
} else {
/* Can't derive any sort of hash for the packet, set
* to some consistent random value.
*/
hash = udp_flow_hashrnd();
}
}
/* Since this is being sent on the wire obfuscate hash a bit
* to minimize possbility that any useful information to an
* attacker is leaked. Only upper 16 bits are relevant in the
* computation for 16 bit port value.
*/
hash ^= hash << 16;
return htons((((u64) hash * (max - min)) >> 32) + min);
}
static inline int udp_rqueue_get(struct sock *sk)
{
return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit);
}
static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if,
int dif, int sdif)
{
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
return inet_bound_dev_eq(!!net->ipv4.sysctl_udp_l3mdev_accept,
bound_dev_if, dif, sdif);
#else
return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
#endif
}
/* net/ipv4/udp.c */
void udp_destruct_sock(struct sock *sk);
void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len);
int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb);
void udp_skb_destructor(struct sock *sk, struct sk_buff *skb);
struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,
int noblock, int *off, int *err);
static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
int noblock, int *err)
{
int off = 0;
return __skb_recv_udp(sk, flags, noblock, &off, err);
}
int udp_v4_early_demux(struct sk_buff *skb);
bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
int udp_get_port(struct sock *sk, unsigned short snum,
int (*saddr_cmp)(const struct sock *,
const struct sock *));
int udp_err(struct sk_buff *, u32);
int udp_abort(struct sock *sk, int err);
int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
int udp_push_pending_frames(struct sock *sk);
void udp_flush_pending_frames(struct sock *sk);
int udp_cmsg_send(struct sock *sk, struct msghdr *msg, u16 *gso_size);
void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst);
int udp_rcv(struct sk_buff *skb);
int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
int udp_init_sock(struct sock *sk);
int udp_pre_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
int __udp_disconnect(struct sock *sk, int flags);
int udp_disconnect(struct sock *sk, int flags);
__poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait);
struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
netdev_features_t features,
bool is_ipv6);
int udp_lib_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen);
int udp_lib_setsockopt(struct sock *sk, int level, int optname,
sockptr_t optval, unsigned int optlen,
int (*push_pending_frames)(struct sock *));
struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
__be32 daddr, __be16 dport, int dif);
struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
__be32 daddr, __be16 dport, int dif, int sdif,
struct udp_table *tbl, struct sk_buff *skb);
struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
__be16 sport, __be16 dport);
struct sock *udp6_lib_lookup(struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr, __be16 dport,
int dif);
struct sock *__udp6_lib_lookup(struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr, __be16 dport,
int dif, int sdif, struct udp_table *tbl,
struct sk_buff *skb);
struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb,
__be16 sport, __be16 dport);
/* UDP uses skb->dev_scratch to cache as much information as possible and avoid
* possibly multiple cache miss on dequeue()
*/
struct udp_dev_scratch {
/* skb->truesize and the stateless bit are embedded in a single field;
* do not use a bitfield since the compiler emits better/smaller code
* this way
*/
u32 _tsize_state;
#if BITS_PER_LONG == 64
/* len and the bit needed to compute skb_csum_unnecessary
* will be on cold cache lines at recvmsg time.
* skb->len can be stored on 16 bits since the udp header has been
* already validated and pulled.
*/
u16 len;
bool is_linear;
bool csum_unnecessary;
#endif
};
static inline struct udp_dev_scratch *udp_skb_scratch(struct sk_buff *skb)
{
return (struct udp_dev_scratch *)&skb->dev_scratch;
}
#if BITS_PER_LONG == 64
static inline unsigned int udp_skb_len(struct sk_buff *skb)
{
return udp_skb_scratch(skb)->len;
}
static inline bool udp_skb_csum_unnecessary(struct sk_buff *skb)
{
return udp_skb_scratch(skb)->csum_unnecessary;
}
static inline bool udp_skb_is_linear(struct sk_buff *skb)
{
return udp_skb_scratch(skb)->is_linear;
}
#else
static inline unsigned int udp_skb_len(struct sk_buff *skb)
{
return skb->len;
}
static inline bool udp_skb_csum_unnecessary(struct sk_buff *skb)
{
return skb_csum_unnecessary(skb);
}
static inline bool udp_skb_is_linear(struct sk_buff *skb)
{
return !skb_is_nonlinear(skb);
}
#endif
static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
struct iov_iter *to)
{
int n;
n = copy_to_iter(skb->data + off, len, to);
if (n == len)
return 0;
iov_iter_revert(to, n);
return -EFAULT;
}
/*
* SNMP statistics for UDP and UDP-Lite
*/
#define UDP_INC_STATS(net, field, is_udplite) do { \
if (is_udplite) SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
else SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
#define __UDP_INC_STATS(net, field, is_udplite) do { \
if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
else __SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
#define __UDP6_INC_STATS(net, field, is_udplite) do { \
if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_stats_in6, field);\
else __SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
} while(0)
#define UDP6_INC_STATS(net, field, __lite) do { \
if (__lite) SNMP_INC_STATS((net)->mib.udplite_stats_in6, field); \
else SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
} while(0)
#if IS_ENABLED(CONFIG_IPV6)
#define __UDPX_MIB(sk, ipv4) \
({ \
ipv4 ? (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
sock_net(sk)->mib.udp_statistics) : \
(IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_stats_in6 : \
sock_net(sk)->mib.udp_stats_in6); \
})
#else
#define __UDPX_MIB(sk, ipv4) \
({ \
IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
sock_net(sk)->mib.udp_statistics; \
})
#endif
#define __UDPX_INC_STATS(sk, field) \
__SNMP_INC_STATS(__UDPX_MIB(sk, (sk)->sk_family == AF_INET), field)
#ifdef CONFIG_PROC_FS
struct udp_seq_afinfo {
sa_family_t family;
struct udp_table *udp_table;
};
struct udp_iter_state {
struct seq_net_private p;
int bucket;
struct udp_seq_afinfo *bpf_seq_afinfo;
};
void *udp_seq_start(struct seq_file *seq, loff_t *pos);
void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos);
void udp_seq_stop(struct seq_file *seq, void *v);
extern const struct seq_operations udp_seq_ops;
extern const struct seq_operations udp6_seq_ops;
int udp4_proc_init(void);
void udp4_proc_exit(void);
#endif /* CONFIG_PROC_FS */
int udpv4_offload_init(void);
void udp_init(void);
DECLARE_STATIC_KEY_FALSE(udp_encap_needed_key);
void udp_encap_enable(void);
#if IS_ENABLED(CONFIG_IPV6)
DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
void udpv6_encap_enable(void);
#endif
static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
struct sk_buff *skb, bool ipv4)
{
netdev_features_t features = NETIF_F_SG;
struct sk_buff *segs;
/* Avoid csum recalculation by skb_segment unless userspace explicitly
* asks for the final checksum values
*/
if (!inet_get_convert_csum(sk))
features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
/* UDP segmentation expects packets of type CHECKSUM_PARTIAL or
* CHECKSUM_NONE in __udp_gso_segment. UDP GRO indeed builds partial
* packets in udp_gro_complete_segment. As does UDP GSO, verified by
* udp_send_skb. But when those packets are looped in dev_loopback_xmit
* their ip_summed is set to CHECKSUM_UNNECESSARY. Reset in this
* specific case, where PARTIAL is both correct and required.
*/
if (skb->pkt_type == PACKET_LOOPBACK)
skb->ip_summed = CHECKSUM_PARTIAL;
/* the GSO CB lays after the UDP one, no need to save and restore any
* CB fragment
*/
segs = __skb_gso_segment(skb, features, false);
if (IS_ERR_OR_NULL(segs)) {
int segs_nr = skb_shinfo(skb)->gso_segs;
atomic_add(segs_nr, &sk->sk_drops);
SNMP_ADD_STATS(__UDPX_MIB(sk, ipv4), UDP_MIB_INERRORS, segs_nr);
kfree_skb(skb);
return NULL;
}
consume_skb(skb);
return segs;
}
#ifdef CONFIG_BPF_STREAM_PARSER
struct sk_psock;
struct proto *udp_bpf_get_proto(struct sock *sk, struct sk_psock *psock);
#endif /* BPF_STREAM_PARSER */
#endif /* _UDP_H */
| gpl-2.0 |
FPLD/project0 | vendor/magento/magento2-base/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php | 1240 | <?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sales\Service\V1;
use Magento\TestFramework\TestCase\WebapiAbstract;
class OrderHoldTest extends WebapiAbstract
{
const SERVICE_VERSION = 'V1';
const SERVICE_NAME = 'salesOrderManagementV1';
/**
* @magentoApiDataFixture Magento/Sales/_files/order.php
*/
public function testOrderHold()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001');
$serviceInfo = [
'rest' => [
'resourcePath' => '/V1/orders/' . $order->getId() . '/hold',
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'hold',
],
];
$requestData = ['id' => $order->getId()];
$result = $this->_webApiCall($serviceInfo, $requestData);
$this->assertTrue($result);
}
}
| gpl-2.0 |
hoist/consul-alerts | leader-election.go | 1548 | package main
import (
log "github.com/AcalephStorage/consul-alerts/Godeps/_workspace/src/github.com/Sirupsen/logrus"
consulapi "github.com/AcalephStorage/consul-alerts/Godeps/_workspace/src/github.com/hashicorp/consul/api"
)
const LockKey = "consul-alerts/leader"
type LeaderElection struct {
lock *consulapi.Lock
cleanupChannel chan struct{}
stopChannel chan struct{}
leader bool
}
func (l *LeaderElection) start() {
clean := false
for !clean {
select {
case <-l.cleanupChannel:
clean = true
default:
log.Infoln("Running for leader election...")
intChan, _ := l.lock.Lock(l.stopChannel)
if intChan != nil {
log.Infoln("Now acting as leader.")
l.leader = true
<-intChan
l.leader = false
log.Infoln("Lost leadership.")
l.lock.Unlock()
l.lock.Destroy()
}
}
}
}
func (l *LeaderElection) stop() {
log.Infoln("cleaning up")
l.cleanupChannel <- struct{}{}
l.stopChannel <- struct{}{}
l.lock.Unlock()
l.lock.Destroy()
l.leader = false
log.Infoln("cleanup done")
}
func startLeaderElection(addr, dc, acl string) *LeaderElection {
config := consulapi.DefaultConfig()
config.Address = addr
config.Datacenter = dc
config.Token = acl
client, _ := consulapi.NewClient(config)
lock, _ := client.LockKey(LockKey)
leader := &LeaderElection{
lock: lock,
cleanupChannel: make(chan struct{}, 1),
stopChannel: make(chan struct{}, 1),
}
go leader.start()
return leader
}
func hasLeader() bool {
return consulClient.CheckKeyExists(LockKey)
}
| gpl-2.0 |
DarkDefender/coreboot | src/northbridge/intel/sandybridge/report_platform.c | 2847 | /*
* This file is part of the coreboot project.
*
* Copyright (C) 2012 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <console/console.h>
#include <arch/cpu.h>
#include <string.h>
#include "southbridge/intel/bd82x6x/pch.h"
#include <arch/io.h>
#include "sandybridge.h"
static void report_cpu_info(void)
{
struct cpuid_result cpuidr;
u32 i, index;
char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
int vt, txt, aes;
const char *mode[] = {"NOT ", ""};
index = 0x80000000;
cpuidr = cpuid(index);
if (cpuidr.eax < 0x80000004) {
strcpy(cpu_string, "Platform info not available");
} else {
u32 *p = (u32*) cpu_string;
for (i = 2; i <= 4 ; i++) {
cpuidr = cpuid(index + i);
*p++ = cpuidr.eax;
*p++ = cpuidr.ebx;
*p++ = cpuidr.ecx;
*p++ = cpuidr.edx;
}
}
/* Skip leading spaces in CPU name string */
while (cpu_name[0] == ' ')
cpu_name++;
cpuidr = cpuid(1);
printk(BIOS_DEBUG, "CPU id(%x): %s\n", cpuidr.eax, cpu_name);
aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
printk(BIOS_DEBUG, "AES %ssupported, TXT %ssupported, VT %ssupported\n",
mode[aes], mode[txt], mode[vt]);
}
/* The PCI id name match comes from Intel document 472178 */
static struct {
u16 dev_id;
const char *dev_name;
} pch_table [] = {
{0x1E41, "Desktop Sample"},
{0x1E42, "Mobile Sample"},
{0x1E43, "SFF Sample"},
{0x1E44, "Z77"},
{0x1E45, "H71"},
{0x1E46, "Z75"},
{0x1E47, "Q77"},
{0x1E48, "Q75"},
{0x1E49, "B75"},
{0x1E4A, "H77"},
{0x1E53, "C216"},
{0x1E55, "QM77"},
{0x1E56, "QS77"},
{0x1E58, "UM77"},
{0x1E57, "HM77"},
{0x1E59, "HM76"},
{0x1E5D, "HM75"},
{0x1E5E, "HM70"},
{0x1E5F, "NM70"},
};
static void report_pch_info(void)
{
int i;
u16 dev_id = pci_read_config16(PCH_LPC_DEV, 2);
const char *pch_type = "Unknown";
for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
if (pch_table[i].dev_id == dev_id) {
pch_type = pch_table[i].dev_name;
break;
}
}
printk (BIOS_DEBUG, "PCH type: %s, device id: %x, rev id %x\n",
pch_type, dev_id, pci_read_config8(PCH_LPC_DEV, 8));
}
void report_platform_info(void)
{
report_cpu_info();
report_pch_info();
}
| gpl-2.0 |
md-5/jdk10 | src/java.desktop/share/classes/javax/swing/plaf/basic/package-info.java | 2590 | /*
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Provides user interface objects built according to the Basic look and feel.
* The Basic look and feel provides default behavior used by many look and feel
* packages. It contains components, layout managers, events, event listeners,
* and adapters. You can subclass the classes in this package to create your own
* customized look and feel.
* <p>
* These classes are designed to be used while the corresponding
* {@code LookAndFeel} class has been installed
* (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
* Using them while a different {@code LookAndFeel} is installed may produce
* unexpected results, including exceptions. Additionally, changing the
* {@code LookAndFeel} maintained by the {@code UIManager} without updating the
* corresponding {@code ComponentUI} of any {@code JComponent}s may also produce
* unexpected results, such as the wrong colors showing up, and is generally not
* encouraged.
* <p>
* <strong>Note:</strong>
* Most of the Swing API is <em>not</em> thread safe. For details, see
* <a
* href="https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
* target="_top">Concurrency in Swing</a>,
* a section in
* <em><a href="https://docs.oracle.com/javase/tutorial/"
* target="_top">The Java Tutorial</a></em>.
*
* @since 1.2
* @serial exclude
*/
package javax.swing.plaf.basic;
| gpl-2.0 |
WensiWu/openfoam-extend-foam-extend-3.1 | src/foam/matrices/Matrix/MatrixI.H | 3618 | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Type>
inline Foam::Matrix<Form, Type>::Matrix()
:
v_(NULL),
n_(0),
m_(0)
{}
template<class Form, class Type>
inline Foam::autoPtr<Foam::Matrix<Form, Type> >
Foam::Matrix<Form, Type>::clone() const
{
return autoPtr<Matrix<Form, Type> >(new Matrix<Form, Type>(*this));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Form, class Type>
inline const Foam::Matrix<Form, Type>& Foam::Matrix<Form, Type>::null()
{
return zero;
}
//- Return the number of rows
template<class Form, class Type>
inline Foam::label Foam::Matrix<Form, Type>::n() const
{
return n_;
}
template<class Form, class Type>
inline Foam::label Foam::Matrix<Form, Type>::m() const
{
return m_;
}
template<class Form, class Type>
inline Foam::label Foam::Matrix<Form, Type>::size() const
{
return n_*m_;
}
template<class Form, class Type>
inline void Foam::Matrix<Form, Type>::checki(const label i) const
{
if (!n_)
{
FatalErrorIn("Matrix<Form, Type>::checki(const label)")
<< "attempt to access element from zero sized row"
<< abort(FatalError);
}
else if (i<0 || i>=n_)
{
FatalErrorIn("Matrix<Form, Type>::checki(const label)")
<< "index " << i << " out of range 0 ... " << n_-1
<< abort(FatalError);
}
}
template<class Form, class Type>
inline void Foam::Matrix<Form, Type>::checkj(const label j) const
{
if (!m_)
{
FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
<< "attempt to access element from zero sized column"
<< abort(FatalError);
}
else if (j<0 || j>=m_)
{
FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
<< "index " << j << " out of range 0 ... " << m_-1
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Form, class Type>
inline Type* Foam::Matrix<Form, Type>::operator[](const label i)
{
# ifdef FULLDEBUG
checki(i);
# endif
return v_[i];
}
template<class Form, class Type>
inline const Type* Foam::Matrix<Form, Type>::operator[](const label i) const
{
# ifdef FULLDEBUG
checki(i);
# endif
return v_[i];
}
// ************************************************************************* //
| gpl-3.0 |
artandrtom/MyRepository | RacingCars/RacingCars/Assets/NGUI/Scripts/Internal/UIBasicSprite.cs | 25566 | using UnityEngine;
/// <summary>
/// Functionality common to both NGUI and 2D sprites brought out into a single common parent.
/// Mostly contains everything related to drawing the sprite.
/// </summary>
public abstract class UIBasicSprite : UIWidget
{
public enum Type
{
Simple,
Sliced,
Tiled,
Filled,
Advanced,
}
public enum FillDirection
{
Horizontal,
Vertical,
Radial90,
Radial180,
Radial360,
}
public enum AdvancedType
{
Invisible,
Sliced,
Tiled,
}
public enum Flip
{
Nothing,
Horizontally,
Vertically,
Both,
}
[HideInInspector][SerializeField] protected Type mType = Type.Simple;
[HideInInspector][SerializeField] protected FillDirection mFillDirection = FillDirection.Radial360;
[Range(0f, 1f)]
[HideInInspector][SerializeField] protected float mFillAmount = 1.0f;
[HideInInspector][SerializeField] protected bool mInvert = false;
[HideInInspector][SerializeField] protected Flip mFlip = Flip.Nothing;
// Cached to avoid allocations
[System.NonSerialized] Rect mInnerUV = new Rect();
[System.NonSerialized] Rect mOuterUV = new Rect();
/// <summary>
/// When the sprite type is advanced, this determines whether the center is tiled or sliced.
/// </summary>
public AdvancedType centerType = AdvancedType.Sliced;
/// <summary>
/// When the sprite type is advanced, this determines whether the left edge is tiled or sliced.
/// </summary>
public AdvancedType leftType = AdvancedType.Sliced;
/// <summary>
/// When the sprite type is advanced, this determines whether the right edge is tiled or sliced.
/// </summary>
public AdvancedType rightType = AdvancedType.Sliced;
/// <summary>
/// When the sprite type is advanced, this determines whether the bottom edge is tiled or sliced.
/// </summary>
public AdvancedType bottomType = AdvancedType.Sliced;
/// <summary>
/// When the sprite type is advanced, this determines whether the top edge is tiled or sliced.
/// </summary>
public AdvancedType topType = AdvancedType.Sliced;
/// <summary>
/// How the sprite is drawn. It's virtual for legacy reasons (UISlicedSprite, UITiledSprite, UIFilledSprite).
/// </summary>
public virtual Type type
{
get
{
return mType;
}
set
{
if (mType != value)
{
mType = value;
MarkAsChanged();
}
}
}
/// <summary>
/// Sprite flip setting.
/// </summary>
public Flip flip
{
get
{
return mFlip;
}
set
{
if (mFlip != value)
{
mFlip = value;
MarkAsChanged();
}
}
}
/// <summary>
/// Direction of the cut procedure.
/// </summary>
public FillDirection fillDirection
{
get
{
return mFillDirection;
}
set
{
if (mFillDirection != value)
{
mFillDirection = value;
mChanged = true;
}
}
}
/// <summary>
/// Amount of the sprite shown. 0-1 range with 0 being nothing shown, and 1 being the full sprite.
/// </summary>
public float fillAmount
{
get
{
return mFillAmount;
}
set
{
float val = Mathf.Clamp01(value);
if (mFillAmount != val)
{
mFillAmount = val;
mChanged = true;
}
}
}
/// <summary>
/// Minimum allowed width for this widget.
/// </summary>
override public int minWidth
{
get
{
if (type == Type.Sliced || type == Type.Advanced)
{
Vector4 b = border * pixelSize;
int min = Mathf.RoundToInt(b.x + b.z);
return Mathf.Max(base.minWidth, ((min & 1) == 1) ? min + 1 : min);
}
return base.minWidth;
}
}
/// <summary>
/// Minimum allowed height for this widget.
/// </summary>
override public int minHeight
{
get
{
if (type == Type.Sliced || type == Type.Advanced)
{
Vector4 b = border * pixelSize;
int min = Mathf.RoundToInt(b.y + b.w);
return Mathf.Max(base.minHeight, ((min & 1) == 1) ? min + 1 : min);
}
return base.minHeight;
}
}
/// <summary>
/// Whether the sprite should be filled in the opposite direction.
/// </summary>
public bool invert
{
get
{
return mInvert;
}
set
{
if (mInvert != value)
{
mInvert = value;
mChanged = true;
}
}
}
/// <summary>
/// Whether the widget has a border for 9-slicing.
/// </summary>
public bool hasBorder
{
get
{
Vector4 br = border;
return (br.x != 0f || br.y != 0f || br.z != 0f || br.w != 0f);
}
}
/// <summary>
/// Whether the sprite's material is using a pre-multiplied alpha shader.
/// </summary>
public virtual bool premultipliedAlpha { get { return false; } }
/// <summary>
/// Size of the pixel. Overwritten in the NGUI sprite to pull a value from the atlas.
/// </summary>
public virtual float pixelSize { get { return 1f; } }
#if UNITY_EDITOR
/// <summary>
/// Keep sane values.
/// </summary>
protected override void OnValidate ()
{
base.OnValidate();
mFillAmount = Mathf.Clamp01(mFillAmount);
}
#endif
#region Fill Functions
// Static variables to reduce garbage collection
static protected Vector2[] mTempPos = new Vector2[4];
static protected Vector2[] mTempUVs = new Vector2[4];
/// <summary>
/// Convenience function that returns the drawn UVs after flipping gets considered.
/// X = left, Y = bottom, Z = right, W = top.
/// </summary>
Vector4 drawingUVs
{
get
{
switch (mFlip)
{
case Flip.Horizontally: return new Vector4(mOuterUV.xMax, mOuterUV.yMin, mOuterUV.xMin, mOuterUV.yMax);
case Flip.Vertically: return new Vector4(mOuterUV.xMin, mOuterUV.yMax, mOuterUV.xMax, mOuterUV.yMin);
case Flip.Both: return new Vector4(mOuterUV.xMax, mOuterUV.yMax, mOuterUV.xMin, mOuterUV.yMin);
default: return new Vector4(mOuterUV.xMin, mOuterUV.yMin, mOuterUV.xMax, mOuterUV.yMax);
}
}
}
/// <summary>
/// Final widget's color passed to the draw buffer.
/// </summary>
Color32 drawingColor
{
get
{
Color colF = color;
colF.a = finalAlpha;
if (premultipliedAlpha) colF = NGUITools.ApplyPMA(colF);
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
{
colF.r = Mathf.GammaToLinearSpace(colF.r);
colF.g = Mathf.GammaToLinearSpace(colF.g);
colF.b = Mathf.GammaToLinearSpace(colF.b);
colF.a = Mathf.GammaToLinearSpace(colF.a);
}
return colF;
}
}
/// <summary>
/// Fill the draw buffers.
/// </summary>
protected void Fill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols, Rect outer, Rect inner)
{
mOuterUV = outer;
mInnerUV = inner;
switch (type)
{
case Type.Simple:
SimpleFill(verts, uvs, cols);
break;
case Type.Sliced:
SlicedFill(verts, uvs, cols);
break;
case Type.Filled:
FilledFill(verts, uvs, cols);
break;
case Type.Tiled:
TiledFill(verts, uvs, cols);
break;
case Type.Advanced:
AdvancedFill(verts, uvs, cols);
break;
}
}
/// <summary>
/// Regular sprite fill function is quite simple.
/// </summary>
void SimpleFill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
Vector4 v = drawingDimensions;
Vector4 u = drawingUVs;
Color32 c = drawingColor;
verts.Add(new Vector3(v.x, v.y));
verts.Add(new Vector3(v.x, v.w));
verts.Add(new Vector3(v.z, v.w));
verts.Add(new Vector3(v.z, v.y));
uvs.Add(new Vector2(u.x, u.y));
uvs.Add(new Vector2(u.x, u.w));
uvs.Add(new Vector2(u.z, u.w));
uvs.Add(new Vector2(u.z, u.y));
cols.Add(c);
cols.Add(c);
cols.Add(c);
cols.Add(c);
}
/// <summary>
/// Sliced sprite fill function is more complicated as it generates 9 quads instead of 1.
/// </summary>
void SlicedFill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
Vector4 br = border * pixelSize;
if (br.x == 0f && br.y == 0f && br.z == 0f && br.w == 0f)
{
SimpleFill(verts, uvs, cols);
return;
}
Color32 c = drawingColor;
Vector4 v = drawingDimensions;
mTempPos[0].x = v.x;
mTempPos[0].y = v.y;
mTempPos[3].x = v.z;
mTempPos[3].y = v.w;
if (mFlip == Flip.Horizontally || mFlip == Flip.Both)
{
mTempPos[1].x = mTempPos[0].x + br.z;
mTempPos[2].x = mTempPos[3].x - br.x;
mTempUVs[3].x = mOuterUV.xMin;
mTempUVs[2].x = mInnerUV.xMin;
mTempUVs[1].x = mInnerUV.xMax;
mTempUVs[0].x = mOuterUV.xMax;
}
else
{
mTempPos[1].x = mTempPos[0].x + br.x;
mTempPos[2].x = mTempPos[3].x - br.z;
mTempUVs[0].x = mOuterUV.xMin;
mTempUVs[1].x = mInnerUV.xMin;
mTempUVs[2].x = mInnerUV.xMax;
mTempUVs[3].x = mOuterUV.xMax;
}
if (mFlip == Flip.Vertically || mFlip == Flip.Both)
{
mTempPos[1].y = mTempPos[0].y + br.w;
mTempPos[2].y = mTempPos[3].y - br.y;
mTempUVs[3].y = mOuterUV.yMin;
mTempUVs[2].y = mInnerUV.yMin;
mTempUVs[1].y = mInnerUV.yMax;
mTempUVs[0].y = mOuterUV.yMax;
}
else
{
mTempPos[1].y = mTempPos[0].y + br.y;
mTempPos[2].y = mTempPos[3].y - br.w;
mTempUVs[0].y = mOuterUV.yMin;
mTempUVs[1].y = mInnerUV.yMin;
mTempUVs[2].y = mInnerUV.yMax;
mTempUVs[3].y = mOuterUV.yMax;
}
for (int x = 0; x < 3; ++x)
{
int x2 = x + 1;
for (int y = 0; y < 3; ++y)
{
if (centerType == AdvancedType.Invisible && x == 1 && y == 1) continue;
int y2 = y + 1;
verts.Add(new Vector3(mTempPos[x].x, mTempPos[y].y));
verts.Add(new Vector3(mTempPos[x].x, mTempPos[y2].y));
verts.Add(new Vector3(mTempPos[x2].x, mTempPos[y2].y));
verts.Add(new Vector3(mTempPos[x2].x, mTempPos[y].y));
uvs.Add(new Vector2(mTempUVs[x].x, mTempUVs[y].y));
uvs.Add(new Vector2(mTempUVs[x].x, mTempUVs[y2].y));
uvs.Add(new Vector2(mTempUVs[x2].x, mTempUVs[y2].y));
uvs.Add(new Vector2(mTempUVs[x2].x, mTempUVs[y].y));
cols.Add(c);
cols.Add(c);
cols.Add(c);
cols.Add(c);
}
}
}
/// <summary>
/// Tiled sprite fill function.
/// </summary>
void TiledFill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
Texture tex = mainTexture;
if (tex == null) return;
Vector2 size = new Vector2(mInnerUV.width * tex.width, mInnerUV.height * tex.height);
size *= pixelSize;
if (tex == null || size.x < 2f || size.y < 2f) return;
Color32 c = drawingColor;
Vector4 v = drawingDimensions;
Vector4 u;
if (mFlip == Flip.Horizontally || mFlip == Flip.Both)
{
u.x = mInnerUV.xMax;
u.z = mInnerUV.xMin;
}
else
{
u.x = mInnerUV.xMin;
u.z = mInnerUV.xMax;
}
if (mFlip == Flip.Vertically || mFlip == Flip.Both)
{
u.y = mInnerUV.yMax;
u.w = mInnerUV.yMin;
}
else
{
u.y = mInnerUV.yMin;
u.w = mInnerUV.yMax;
}
float x0 = v.x;
float y0 = v.y;
float u0 = u.x;
float v0 = u.y;
while (y0 < v.w)
{
x0 = v.x;
float y1 = y0 + size.y;
float v1 = u.w;
if (y1 > v.w)
{
v1 = Mathf.Lerp(u.y, u.w, (v.w - y0) / size.y);
y1 = v.w;
}
while (x0 < v.z)
{
float x1 = x0 + size.x;
float u1 = u.z;
if (x1 > v.z)
{
u1 = Mathf.Lerp(u.x, u.z, (v.z - x0) / size.x);
x1 = v.z;
}
verts.Add(new Vector3(x0, y0));
verts.Add(new Vector3(x0, y1));
verts.Add(new Vector3(x1, y1));
verts.Add(new Vector3(x1, y0));
uvs.Add(new Vector2(u0, v0));
uvs.Add(new Vector2(u0, v1));
uvs.Add(new Vector2(u1, v1));
uvs.Add(new Vector2(u1, v0));
cols.Add(c);
cols.Add(c);
cols.Add(c);
cols.Add(c);
x0 += size.x;
}
y0 += size.y;
}
}
/// <summary>
/// Filled sprite fill function.
/// </summary>
void FilledFill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
if (mFillAmount < 0.001f) return;
Vector4 v = drawingDimensions;
Vector4 u = drawingUVs;
Color32 c = drawingColor;
// Horizontal and vertical filled sprites are simple -- just end the sprite prematurely
if (mFillDirection == FillDirection.Horizontal || mFillDirection == FillDirection.Vertical)
{
if (mFillDirection == FillDirection.Horizontal)
{
float fill = (u.z - u.x) * mFillAmount;
if (mInvert)
{
v.x = v.z - (v.z - v.x) * mFillAmount;
u.x = u.z - fill;
}
else
{
v.z = v.x + (v.z - v.x) * mFillAmount;
u.z = u.x + fill;
}
}
else if (mFillDirection == FillDirection.Vertical)
{
float fill = (u.w - u.y) * mFillAmount;
if (mInvert)
{
v.y = v.w - (v.w - v.y) * mFillAmount;
u.y = u.w - fill;
}
else
{
v.w = v.y + (v.w - v.y) * mFillAmount;
u.w = u.y + fill;
}
}
}
mTempPos[0] = new Vector2(v.x, v.y);
mTempPos[1] = new Vector2(v.x, v.w);
mTempPos[2] = new Vector2(v.z, v.w);
mTempPos[3] = new Vector2(v.z, v.y);
mTempUVs[0] = new Vector2(u.x, u.y);
mTempUVs[1] = new Vector2(u.x, u.w);
mTempUVs[2] = new Vector2(u.z, u.w);
mTempUVs[3] = new Vector2(u.z, u.y);
if (mFillAmount < 1f)
{
if (mFillDirection == FillDirection.Radial90)
{
if (RadialCut(mTempPos, mTempUVs, mFillAmount, mInvert, 0))
{
for (int i = 0; i < 4; ++i)
{
verts.Add(mTempPos[i]);
uvs.Add(mTempUVs[i]);
cols.Add(c);
}
}
return;
}
if (mFillDirection == FillDirection.Radial180)
{
for (int side = 0; side < 2; ++side)
{
float fx0, fx1, fy0, fy1;
fy0 = 0f;
fy1 = 1f;
if (side == 0) { fx0 = 0f; fx1 = 0.5f; }
else { fx0 = 0.5f; fx1 = 1f; }
mTempPos[0].x = Mathf.Lerp(v.x, v.z, fx0);
mTempPos[1].x = mTempPos[0].x;
mTempPos[2].x = Mathf.Lerp(v.x, v.z, fx1);
mTempPos[3].x = mTempPos[2].x;
mTempPos[0].y = Mathf.Lerp(v.y, v.w, fy0);
mTempPos[1].y = Mathf.Lerp(v.y, v.w, fy1);
mTempPos[2].y = mTempPos[1].y;
mTempPos[3].y = mTempPos[0].y;
mTempUVs[0].x = Mathf.Lerp(u.x, u.z, fx0);
mTempUVs[1].x = mTempUVs[0].x;
mTempUVs[2].x = Mathf.Lerp(u.x, u.z, fx1);
mTempUVs[3].x = mTempUVs[2].x;
mTempUVs[0].y = Mathf.Lerp(u.y, u.w, fy0);
mTempUVs[1].y = Mathf.Lerp(u.y, u.w, fy1);
mTempUVs[2].y = mTempUVs[1].y;
mTempUVs[3].y = mTempUVs[0].y;
float val = !mInvert ? fillAmount * 2f - side : mFillAmount * 2f - (1 - side);
if (RadialCut(mTempPos, mTempUVs, Mathf.Clamp01(val), !mInvert, NGUIMath.RepeatIndex(side + 3, 4)))
{
for (int i = 0; i < 4; ++i)
{
verts.Add(mTempPos[i]);
uvs.Add(mTempUVs[i]);
cols.Add(c);
}
}
}
return;
}
if (mFillDirection == FillDirection.Radial360)
{
for (int corner = 0; corner < 4; ++corner)
{
float fx0, fx1, fy0, fy1;
if (corner < 2) { fx0 = 0f; fx1 = 0.5f; }
else { fx0 = 0.5f; fx1 = 1f; }
if (corner == 0 || corner == 3) { fy0 = 0f; fy1 = 0.5f; }
else { fy0 = 0.5f; fy1 = 1f; }
mTempPos[0].x = Mathf.Lerp(v.x, v.z, fx0);
mTempPos[1].x = mTempPos[0].x;
mTempPos[2].x = Mathf.Lerp(v.x, v.z, fx1);
mTempPos[3].x = mTempPos[2].x;
mTempPos[0].y = Mathf.Lerp(v.y, v.w, fy0);
mTempPos[1].y = Mathf.Lerp(v.y, v.w, fy1);
mTempPos[2].y = mTempPos[1].y;
mTempPos[3].y = mTempPos[0].y;
mTempUVs[0].x = Mathf.Lerp(u.x, u.z, fx0);
mTempUVs[1].x = mTempUVs[0].x;
mTempUVs[2].x = Mathf.Lerp(u.x, u.z, fx1);
mTempUVs[3].x = mTempUVs[2].x;
mTempUVs[0].y = Mathf.Lerp(u.y, u.w, fy0);
mTempUVs[1].y = Mathf.Lerp(u.y, u.w, fy1);
mTempUVs[2].y = mTempUVs[1].y;
mTempUVs[3].y = mTempUVs[0].y;
float val = mInvert ?
mFillAmount * 4f - NGUIMath.RepeatIndex(corner + 2, 4) :
mFillAmount * 4f - (3 - NGUIMath.RepeatIndex(corner + 2, 4));
if (RadialCut(mTempPos, mTempUVs, Mathf.Clamp01(val), mInvert, NGUIMath.RepeatIndex(corner + 2, 4)))
{
for (int i = 0; i < 4; ++i)
{
verts.Add(mTempPos[i]);
uvs.Add(mTempUVs[i]);
cols.Add(c);
}
}
}
return;
}
}
// Fill the buffer with the quad for the sprite
for (int i = 0; i < 4; ++i)
{
verts.Add(mTempPos[i]);
uvs.Add(mTempUVs[i]);
cols.Add(c);
}
}
/// <summary>
/// Advanced sprite fill function. Contributed by Nicki Hansen.
/// </summary>
void AdvancedFill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
{
Texture tex = mainTexture;
if (tex == null) return;
Vector4 br = border * pixelSize;
if (br.x == 0f && br.y == 0f && br.z == 0f && br.w == 0f)
{
SimpleFill(verts, uvs, cols);
return;
}
Color32 c = drawingColor;
Vector4 v = drawingDimensions;
Vector2 tileSize = new Vector2(mInnerUV.width * tex.width, mInnerUV.height * tex.height);
tileSize *= pixelSize;
if (tileSize.x < 1f) tileSize.x = 1f;
if (tileSize.y < 1f) tileSize.y = 1f;
mTempPos[0].x = v.x;
mTempPos[0].y = v.y;
mTempPos[3].x = v.z;
mTempPos[3].y = v.w;
if (mFlip == Flip.Horizontally || mFlip == Flip.Both)
{
mTempPos[1].x = mTempPos[0].x + br.z;
mTempPos[2].x = mTempPos[3].x - br.x;
mTempUVs[3].x = mOuterUV.xMin;
mTempUVs[2].x = mInnerUV.xMin;
mTempUVs[1].x = mInnerUV.xMax;
mTempUVs[0].x = mOuterUV.xMax;
}
else
{
mTempPos[1].x = mTempPos[0].x + br.x;
mTempPos[2].x = mTempPos[3].x - br.z;
mTempUVs[0].x = mOuterUV.xMin;
mTempUVs[1].x = mInnerUV.xMin;
mTempUVs[2].x = mInnerUV.xMax;
mTempUVs[3].x = mOuterUV.xMax;
}
if (mFlip == Flip.Vertically || mFlip == Flip.Both)
{
mTempPos[1].y = mTempPos[0].y + br.w;
mTempPos[2].y = mTempPos[3].y - br.y;
mTempUVs[3].y = mOuterUV.yMin;
mTempUVs[2].y = mInnerUV.yMin;
mTempUVs[1].y = mInnerUV.yMax;
mTempUVs[0].y = mOuterUV.yMax;
}
else
{
mTempPos[1].y = mTempPos[0].y + br.y;
mTempPos[2].y = mTempPos[3].y - br.w;
mTempUVs[0].y = mOuterUV.yMin;
mTempUVs[1].y = mInnerUV.yMin;
mTempUVs[2].y = mInnerUV.yMax;
mTempUVs[3].y = mOuterUV.yMax;
}
for (int x = 0; x < 3; ++x)
{
int x2 = x + 1;
for (int y = 0; y < 3; ++y)
{
if (centerType == AdvancedType.Invisible && x == 1 && y == 1) continue;
int y2 = y + 1;
if (x == 1 && y == 1) // Center
{
if (centerType == AdvancedType.Tiled)
{
float startPositionX = mTempPos[x].x;
float endPositionX = mTempPos[x2].x;
float startPositionY = mTempPos[y].y;
float endPositionY = mTempPos[y2].y;
float textureStartX = mTempUVs[x].x;
float textureStartY = mTempUVs[y].y;
float tileStartY = startPositionY;
while (tileStartY < endPositionY)
{
float tileStartX = startPositionX;
float textureEndY = mTempUVs[y2].y;
float tileEndY = tileStartY + tileSize.y;
if (tileEndY > endPositionY)
{
textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y);
tileEndY = endPositionY;
}
while (tileStartX < endPositionX)
{
float tileEndX = tileStartX + tileSize.x;
float textureEndX = mTempUVs[x2].x;
if (tileEndX > endPositionX)
{
textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x);
tileEndX = endPositionX;
}
Fill(verts, uvs, cols,
tileStartX, tileEndX,
tileStartY, tileEndY,
textureStartX, textureEndX,
textureStartY, textureEndY, c);
tileStartX += tileSize.x;
}
tileStartY += tileSize.y;
}
}
else if (centerType == AdvancedType.Sliced)
{
Fill(verts, uvs, cols,
mTempPos[x].x, mTempPos[x2].x,
mTempPos[y].y, mTempPos[y2].y,
mTempUVs[x].x, mTempUVs[x2].x,
mTempUVs[y].y, mTempUVs[y2].y, c);
}
}
else if (x == 1) // Top or bottom
{
if ((y == 0 && bottomType == AdvancedType.Tiled) || (y == 2 && topType == AdvancedType.Tiled))
{
float startPositionX = mTempPos[x].x;
float endPositionX = mTempPos[x2].x;
float startPositionY = mTempPos[y].y;
float endPositionY = mTempPos[y2].y;
float textureStartX = mTempUVs[x].x;
float textureStartY = mTempUVs[y].y;
float textureEndY = mTempUVs[y2].y;
float tileStartX = startPositionX;
while (tileStartX < endPositionX)
{
float tileEndX = tileStartX + tileSize.x;
float textureEndX = mTempUVs[x2].x;
if (tileEndX > endPositionX)
{
textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x);
tileEndX = endPositionX;
}
Fill(verts, uvs, cols,
tileStartX, tileEndX,
startPositionY, endPositionY,
textureStartX, textureEndX,
textureStartY, textureEndY, c);
tileStartX += tileSize.x;
}
}
else if ((y == 0 && bottomType != AdvancedType.Invisible) || (y == 2 && topType != AdvancedType.Invisible))
{
Fill(verts, uvs, cols,
mTempPos[x].x, mTempPos[x2].x,
mTempPos[y].y, mTempPos[y2].y,
mTempUVs[x].x, mTempUVs[x2].x,
mTempUVs[y].y, mTempUVs[y2].y, c);
}
}
else if (y == 1) // Left or right
{
if ((x == 0 && leftType == AdvancedType.Tiled) || (x == 2 && rightType == AdvancedType.Tiled))
{
float startPositionX = mTempPos[x].x;
float endPositionX = mTempPos[x2].x;
float startPositionY = mTempPos[y].y;
float endPositionY = mTempPos[y2].y;
float textureStartX = mTempUVs[x].x;
float textureEndX = mTempUVs[x2].x;
float textureStartY = mTempUVs[y].y;
float tileStartY = startPositionY;
while (tileStartY < endPositionY)
{
float textureEndY = mTempUVs[y2].y;
float tileEndY = tileStartY + tileSize.y;
if (tileEndY > endPositionY)
{
textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y);
tileEndY = endPositionY;
}
Fill(verts, uvs, cols,
startPositionX, endPositionX,
tileStartY, tileEndY,
textureStartX, textureEndX,
textureStartY, textureEndY, c);
tileStartY += tileSize.y;
}
}
else if ((x == 0 && leftType != AdvancedType.Invisible) || (x == 2 && rightType != AdvancedType.Invisible))
{
Fill(verts, uvs, cols,
mTempPos[x].x, mTempPos[x2].x,
mTempPos[y].y, mTempPos[y2].y,
mTempUVs[x].x, mTempUVs[x2].x,
mTempUVs[y].y, mTempUVs[y2].y, c);
}
}
else // Corner
{
if ((y == 0 && bottomType != AdvancedType.Invisible) || (y == 2 && topType != AdvancedType.Invisible) ||
(x == 0 && leftType != AdvancedType.Invisible) || (x == 2 && rightType != AdvancedType.Invisible))
{
Fill(verts, uvs, cols,
mTempPos[x].x, mTempPos[x2].x,
mTempPos[y].y, mTempPos[y2].y,
mTempUVs[x].x, mTempUVs[x2].x,
mTempUVs[y].y, mTempUVs[y2].y, c);
}
}
}
}
}
/// <summary>
/// Adjust the specified quad, making it be radially filled instead.
/// </summary>
static bool RadialCut (Vector2[] xy, Vector2[] uv, float fill, bool invert, int corner)
{
// Nothing to fill
if (fill < 0.001f) return false;
// Even corners invert the fill direction
if ((corner & 1) == 1) invert = !invert;
// Nothing to adjust
if (!invert && fill > 0.999f) return true;
// Convert 0-1 value into 0 to 90 degrees angle in radians
float angle = Mathf.Clamp01(fill);
if (invert) angle = 1f - angle;
angle *= 90f * Mathf.Deg2Rad;
// Calculate the effective X and Y factors
float cos = Mathf.Cos(angle);
float sin = Mathf.Sin(angle);
RadialCut(xy, cos, sin, invert, corner);
RadialCut(uv, cos, sin, invert, corner);
return true;
}
/// <summary>
/// Adjust the specified quad, making it be radially filled instead.
/// </summary>
static void RadialCut (Vector2[] xy, float cos, float sin, bool invert, int corner)
{
int i0 = corner;
int i1 = NGUIMath.RepeatIndex(corner + 1, 4);
int i2 = NGUIMath.RepeatIndex(corner + 2, 4);
int i3 = NGUIMath.RepeatIndex(corner + 3, 4);
if ((corner & 1) == 1)
{
if (sin > cos)
{
cos /= sin;
sin = 1f;
if (invert)
{
xy[i1].x = Mathf.Lerp(xy[i0].x, xy[i2].x, cos);
xy[i2].x = xy[i1].x;
}
}
else if (cos > sin)
{
sin /= cos;
cos = 1f;
if (!invert)
{
xy[i2].y = Mathf.Lerp(xy[i0].y, xy[i2].y, sin);
xy[i3].y = xy[i2].y;
}
}
else
{
cos = 1f;
sin = 1f;
}
if (!invert) xy[i3].x = Mathf.Lerp(xy[i0].x, xy[i2].x, cos);
else xy[i1].y = Mathf.Lerp(xy[i0].y, xy[i2].y, sin);
}
else
{
if (cos > sin)
{
sin /= cos;
cos = 1f;
if (!invert)
{
xy[i1].y = Mathf.Lerp(xy[i0].y, xy[i2].y, sin);
xy[i2].y = xy[i1].y;
}
}
else if (sin > cos)
{
cos /= sin;
sin = 1f;
if (invert)
{
xy[i2].x = Mathf.Lerp(xy[i0].x, xy[i2].x, cos);
xy[i3].x = xy[i2].x;
}
}
else
{
cos = 1f;
sin = 1f;
}
if (invert) xy[i3].y = Mathf.Lerp(xy[i0].y, xy[i2].y, sin);
else xy[i1].x = Mathf.Lerp(xy[i0].x, xy[i2].x, cos);
}
}
/// <summary>
/// Helper function that adds the specified values to the buffers.
/// </summary>
static void Fill (BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols,
float v0x, float v1x, float v0y, float v1y, float u0x, float u1x, float u0y, float u1y, Color col)
{
verts.Add(new Vector3(v0x, v0y));
verts.Add(new Vector3(v0x, v1y));
verts.Add(new Vector3(v1x, v1y));
verts.Add(new Vector3(v1x, v0y));
uvs.Add(new Vector2(u0x, u0y));
uvs.Add(new Vector2(u0x, u1y));
uvs.Add(new Vector2(u1x, u1y));
uvs.Add(new Vector2(u1x, u0y));
cols.Add(col);
cols.Add(col);
cols.Add(col);
cols.Add(col);
}
#endregion // Fill functions
}
| gpl-3.0 |
Unofficial-Extend-Project-Mirror/openfoam-extend-foam-extend-3.0 | src/meshTools/PointEdgeWave/PointEdgeWave.C | 34391 | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PointEdgeWave.H"
#include "polyMesh.H"
#include "processorPolyPatch.H"
#include "cyclicPolyPatch.H"
#include "ggiPolyPatch.H"
#include "OPstream.H"
#include "IPstream.H"
#include "PstreamCombineReduceOps.H"
#include "debug.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template <class Type>
Foam::scalar Foam::PointEdgeWave<Type>::propagationTol_ = 0.01;
// Offset labelList. Used for transferring from one cyclic half to the other.
template <class Type>
void Foam::PointEdgeWave<Type>::offset(const label val, labelList& elems)
{
forAll(elems, i)
{
elems[i] += val;
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Gets point-point correspondence. Is
// - list of halfA points (in cyclic patch points)
// - list of halfB points (can overlap with A!)
// - for every patchPoint its corresponding point
template <class Type>
void Foam::PointEdgeWave<Type>::calcCyclicAddressing()
{
label cycHalf = 0;
forAll(mesh_.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<cyclicPolyPatch>(patch))
{
label halfSize = patch.size()/2;
SubList<face> halfAFaces
(
mesh_.faces(),
halfSize,
patch.start()
);
cycHalves_.set
(
cycHalf++,
new primitivePatch(halfAFaces, mesh_.points())
);
SubList<face> halfBFaces
(
mesh_.faces(),
halfSize,
patch.start() + halfSize
);
cycHalves_.set
(
cycHalf++,
new primitivePatch(halfBFaces, mesh_.points())
);
}
}
}
// Handle leaving domain. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::leaveDomain
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& patchPointLabels,
List<Type>& pointInfo
) const
{
const labelList& meshPoints = patch.meshPoints();
forAll(patchPointLabels, i)
{
label patchPointI = patchPointLabels[i];
const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].leaveDomain(meshPatch, patchPointI, pt);
}
}
// Handle entering domain. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::enterDomain
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& patchPointLabels,
List<Type>& pointInfo
) const
{
const labelList& meshPoints = patch.meshPoints();
forAll(patchPointLabels, i)
{
label patchPointI = patchPointLabels[i];
const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].enterDomain(meshPatch, patchPointI, pt);
}
}
// Transform. Implementation referred to Type
template <class Type>
void Foam::PointEdgeWave<Type>::transform
(
const tensorField& rotTensor,
List<Type>& pointInfo
) const
{
if (rotTensor.size() == 1)
{
const tensor& T = rotTensor[0];
forAll(pointInfo, i)
{
pointInfo[i].transform(T);
}
}
else
{
FatalErrorIn
(
"PointEdgeWave<Type>::transform(const tensorField&, List<Type>&)"
) << "Parallel cyclics not supported"
<< abort(FatalError);
forAll(pointInfo, i)
{
pointInfo[i].transform(rotTensor[i]);
}
}
}
// Update info for pointI, at position pt, with information from
// neighbouring edge.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template <class Type>
bool Foam::PointEdgeWave<Type>::updatePoint
(
const label pointI,
const label neighbourEdgeI,
const Type& neighbourInfo,
const scalar tol,
Type& pointInfo
)
{
nEvals_++;
bool wasValid = pointInfo.valid();
bool propagate =
pointInfo.updatePoint
(
mesh_,
pointI,
neighbourEdgeI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
if (!wasValid && pointInfo.valid())
{
--nUnvisitedPoints_;
}
return propagate;
}
// Update info for pointI, at position pt, with information from
// same point.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template <class Type>
bool Foam::PointEdgeWave<Type>::updatePoint
(
const label pointI,
const Type& neighbourInfo,
const scalar tol,
Type& pointInfo
)
{
nEvals_++;
bool wasValid = pointInfo.valid();
bool propagate =
pointInfo.updatePoint
(
mesh_,
pointI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
if (!wasValid && pointInfo.valid())
{
--nUnvisitedPoints_;
}
return propagate;
}
// Update info for edgeI, at position pt, with information from
// neighbouring point.
// Updates:
// - changedEdge_, changedEdges_, nChangedEdges_,
// - statistics: nEvals_, nUnvisitedEdge_
template <class Type>
bool Foam::PointEdgeWave<Type>::updateEdge
(
const label edgeI,
const label neighbourPointI,
const Type& neighbourInfo,
const scalar tol,
Type& edgeInfo
)
{
nEvals_++;
bool wasValid = edgeInfo.valid();
bool propagate =
edgeInfo.updateEdge
(
mesh_,
edgeI,
neighbourPointI,
neighbourInfo,
tol
);
if (propagate)
{
if (!changedEdge_[edgeI])
{
changedEdge_[edgeI] = true;
changedEdges_[nChangedEdges_++] = edgeI;
}
}
if (!wasValid && edgeInfo.valid())
{
--nUnvisitedEdges_;
}
return propagate;
}
// Check if patches of given type name are present
template <class Type>
template <class PatchType>
Foam::label Foam::PointEdgeWave<Type>::countPatchType() const
{
label nPatches = 0;
forAll(mesh_.boundaryMesh(), patchI)
{
if (isA<PatchType>(mesh_.boundaryMesh()[patchI]))
{
nPatches++;
}
}
return nPatches;
}
// Collect changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::getChangedPatchPoints
(
const primitivePatch& patch,
DynamicList<Type>& patchInfo,
DynamicList<label>& patchPoints,
DynamicList<label>& owner,
DynamicList<label>& ownerIndex
) const
{
const labelList& meshPoints = patch.meshPoints();
const faceList& localFaces = patch.localFaces();
const labelListList& pointFaces = patch.pointFaces();
forAll(meshPoints, patchPointI)
{
label meshPointI = meshPoints[patchPointI];
if (changedPoint_[meshPointI])
{
patchInfo.append(allPointInfo_[meshPointI]);
//Pout << "Sending " << meshPointI << " " << mesh_.points()[meshPointI] << " o = " << patchInfo[patchInfo.size()-1].origin() << " " << allPointInfo_[meshPointI] << endl;
patchPoints.append(patchPointI);
label patchFaceI = pointFaces[patchPointI][0];
const face& f = localFaces[patchFaceI];
label index = findIndex(f, patchPointI);
owner.append(patchFaceI);
ownerIndex.append(index);
}
}
patchInfo.shrink();
patchPoints.shrink();
owner.shrink();
ownerIndex.shrink();
}
// Update overall for changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::updateFromPatchInfo
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& owner,
const labelList& ownerIndex,
List<Type>& patchInfo
)
{
const faceList& localFaces = patch.localFaces();
const labelList& meshPoints = patch.meshPoints();
// Get patch and mesh points.
labelList changedPatchPoints(patchInfo.size());
labelList changedMeshPoints(patchInfo.size());
forAll(owner, i)
{
label faceI = owner[i];
const face& f = localFaces[faceI];
label index = (f.size() - ownerIndex[i]) % f.size();
changedPatchPoints[i] = f[index];
changedMeshPoints[i] = meshPoints[f[index]];
}
// Adapt for entering domain
enterDomain(meshPatch, patch, changedPatchPoints, patchInfo);
// Merge received info
forAll(patchInfo, i)
{
updatePoint
(
changedMeshPoints[i],
patchInfo[i],
propagationTol_,
allPointInfo_[changedMeshPoints[i]]
);
}
}
// Transfer all the information to/from neighbouring processors
template <class Type>
void Foam::PointEdgeWave<Type>::handleProcPatches()
{
// 1. Send all point info on processor patches. Send as
// face label + offset in face.
forAll(mesh_.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<processorPolyPatch>(patch))
{
// Get all changed points in relative addressing
DynamicList<Type> patchInfo(patch.nPoints());
DynamicList<label> patchPoints(patch.nPoints());
DynamicList<label> owner(patch.nPoints());
DynamicList<label> ownerIndex(patch.nPoints());
getChangedPatchPoints
(
patch,
patchInfo,
patchPoints,
owner,
ownerIndex
);
// Adapt for leaving domain
leaveDomain(patch, patch, patchPoints, patchInfo);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << patch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Sending:" << patchInfo.size() << endl;
}
{
OPstream toNeighbour
(
Pstream::blocking,
procPatch.neighbProcNo()
);
toNeighbour << owner << ownerIndex << patchInfo;
}
}
}
//
// 2. Receive all point info on processor patches.
//
forAll(mesh_.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<processorPolyPatch>(patch))
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
List<Type> patchInfo;
labelList owner;
labelList ownerIndex;
{
IPstream fromNeighbour
(
Pstream::blocking,
procPatch.neighbProcNo()
);
fromNeighbour >> owner >> ownerIndex >> patchInfo;
}
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << patch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Received:" << patchInfo.size() << endl;
}
// Apply transform to received data for non-parallel planes
if (!procPatch.parallel())
{
transform(procPatch.forwardT(), patchInfo);
}
updateFromPatchInfo
(
patch,
patch,
owner,
ownerIndex,
patchInfo
);
}
}
//
// 3. Handle all shared points
// (Note:irrespective if changed or not for now)
//
const globalMeshData& pd = mesh_.globalData();
List<Type> sharedData(pd.nGlobalPoints());
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Fill my entries in the shared points
sharedData[pd.sharedPointAddr()[i]] = allPointInfo_[meshPointI];
}
// Combine on master. Reduce operator has to handle a list and call
// Type.updatePoint for all elements
combineReduce(sharedData, listUpdateOp<Type>());
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Retrieve my entries from the shared points
updatePoint
(
meshPointI,
sharedData[pd.sharedPointAddr()[i]],
propagationTol_,
allPointInfo_[meshPointI]
);
}
}
template <class Type>
void Foam::PointEdgeWave<Type>::handleCyclicPatches()
{
// 1. Send all point info on cyclic patches. Send as
// face label + offset in face.
label cycHalf = 0;
forAll(mesh_.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<cyclicPolyPatch>(patch))
{
const primitivePatch& halfA = cycHalves_[cycHalf++];
const primitivePatch& halfB = cycHalves_[cycHalf++];
// HalfA : get all changed points in relative addressing
DynamicList<Type> halfAInfo(halfA.nPoints());
DynamicList<label> halfAPoints(halfA.nPoints());
DynamicList<label> halfAOwner(halfA.nPoints());
DynamicList<label> halfAIndex(halfA.nPoints());
getChangedPatchPoints
(
halfA,
halfAInfo,
halfAPoints,
halfAOwner,
halfAIndex
);
// HalfB : get all changed points in relative addressing
DynamicList<Type> halfBInfo(halfB.nPoints());
DynamicList<label> halfBPoints(halfB.nPoints());
DynamicList<label> halfBOwner(halfB.nPoints());
DynamicList<label> halfBIndex(halfB.nPoints());
getChangedPatchPoints
(
halfB,
halfBInfo,
halfBPoints,
halfBOwner,
halfBIndex
);
// HalfA : adapt for leaving domain
leaveDomain(patch, halfA, halfAPoints, halfAInfo);
// HalfB : adapt for leaving domain
leaveDomain(patch, halfB, halfBPoints, halfBInfo);
// Apply rotation for non-parallel planes
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patch);
if (!cycPatch.parallel())
{
// received data from half1
transform(cycPatch.forwardT(), halfAInfo);
// received data from half2
transform(cycPatch.forwardT(), halfBInfo);
}
if (debug)
{
Pout<< "Cyclic patch " << patchI << ' ' << patch.name()
<< " Changed on first half : " << halfAInfo.size()
<< " Changed on second half : " << halfBInfo.size()
<< endl;
}
// Half1: update with data from halfB
updateFromPatchInfo
(
patch,
halfA,
halfBOwner,
halfBIndex,
halfBInfo
);
// Half2: update with data from halfA
updateFromPatchInfo
(
patch,
halfB,
halfAOwner,
halfAIndex,
halfAInfo
);
if (debug)
{
//checkCyclic(patch);
}
}
}
}
// Update overall for changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::updateFromPatchInfo
(
const ggiPolyPatch& to,
const labelListList& shadowAddr,
const labelList& owner,
const labelList& ownerIndex,
List<Type>& patchInfo
)
{
//const labelList& meshPoints = to.meshPoints();
const pointField& points = to.points();
const List<face>& allFaces = mesh_.allFaces();
forAll(patchInfo, i)
{
label fID = to.shadow().zone()[owner[i]];
label pID = allFaces[fID][ownerIndex[i]];
point p = points[pID];
// Update in sending zone without propagation
if(fID >= mesh_.nFaces())
{
allPointInfo_[pID].updatePoint
(
mesh_,
pID,
patchInfo[i],
propagationTol_
);
}
const labelList& addr = shadowAddr[owner[i]];
if(addr.size() > 0)
{
label nearestPoint = -1;
label nearestFace = -1;
scalar dist = GREAT;
forAll(addr, saI)
{
label fID2 = to.zone()[addr[saI]];
const face& f = allFaces[fID2];
forAll(f, pI)
{
label pID2 = f[pI];
scalar d = magSqr(points[pID2] - p);
if(d < dist)
{
nearestFace = fID2;
nearestPoint = pID2;
dist = d;
}
else if(nearestPoint == pID2 && fID2 < mesh_.nFaces())
{
// Choose face in patch over face in zone
nearestFace = fID2;
}
}
}
patchInfo[i].enterDomain(to, nearestPoint, points[nearestPoint]);
if(nearestFace < mesh_.nFaces())
{
// Update in receiving patch with propagation
updatePoint
(
nearestPoint,
patchInfo[i],
propagationTol_,
allPointInfo_[nearestPoint]
);
}
else
{
// Update in receiving zone without propagation
allPointInfo_[nearestPoint].updatePoint
(
mesh_,
nearestPoint,
patchInfo[i],
propagationTol_
);
}
}
}
}
// Transfer all the information to/from neighbouring processors
template <class Type>
void Foam::PointEdgeWave<Type>::handleGgiPatches()
{
forAll(mesh_.boundaryMesh(), patchI)
{
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<ggiPolyPatch>(patch))
{
const ggiPolyPatch& master = refCast<const ggiPolyPatch>(patch);
const ggiPolyPatch& slave = master.shadow();
if(master.master() && (master.localParallel() || master.size()))
{
// 1. Collect all point info on master side
DynamicList<Type> masterInfo(master.nPoints());
DynamicList<label> masterOwner(master.nPoints());
DynamicList<label> masterOwnerIndex(master.nPoints());
{
DynamicList<label> patchPoints(master.nPoints());
// Get all changed points in relative addressing
getChangedPatchPoints
(
master,
masterInfo,
patchPoints,
masterOwner,
masterOwnerIndex
);
forAll(masterOwner, i)
{
masterOwner[i] =
master.zoneAddressing()[masterOwner[i]];
}
// Adapt for leaving domain
leaveDomain(master, master, patchPoints, masterInfo);
if (debug)
{
Pout<< "Ggi patch " << master.index() << ' ' << master.name()
<< " Sending:" << masterInfo.size() << endl;
}
}
// 2. Collect all point info on slave side
DynamicList<Type> slaveInfo(slave.nPoints());
DynamicList<label> slaveOwner(slave.nPoints());
DynamicList<label> slaveOwnerIndex(slave.nPoints());
{
DynamicList<label> patchPoints(slave.nPoints());
// Get all changed points in relative addressing
getChangedPatchPoints
(
slave,
slaveInfo,
patchPoints,
slaveOwner,
slaveOwnerIndex
);
forAll(slaveOwner, i)
{
slaveOwner[i] =
slave.zoneAddressing()[slaveOwner[i]];
}
// Adapt for leaving domain
leaveDomain(slave, slave, patchPoints, slaveInfo);
if (debug)
{
Pout<< "Ggi patch " << slave.index() << ' ' << slave.name()
<< " Sending:" << slaveInfo.size() << endl;
}
}
if(!master.localParallel())
{
combineReduce(masterInfo, listAppendOp<Type>());
combineReduce(slaveInfo, listAppendOp<Type>());
combineReduce(masterOwner, listAppendOp<label>());
combineReduce(slaveOwner, listAppendOp<label>());
combineReduce(masterOwnerIndex, listAppendOp<label>());
combineReduce(slaveOwnerIndex, listAppendOp<label>());
}
// 3. Apply point info on master & slave side
if (debug)
{
Pout<< "Ggi patch " << slave.index() << ' ' << slave.name()
<< " Received:" << masterInfo.size() << endl;
Pout<< "Ggi patch " << master.index() << ' ' << master.name()
<< " Received:" << slaveInfo.size() << endl;
}
// Apply transform to received data for non-parallel planes
if (!master.parallel())
{
transform(master.forwardT(), masterInfo);
transform(slave.forwardT(), slaveInfo);
}
updateFromPatchInfo
(
slave,
master.patchToPatch().masterAddr(),
masterOwner,
masterOwnerIndex,
masterInfo
);
updateFromPatchInfo
(
master,
master.patchToPatch().slaveAddr(),
slaveOwner,
slaveOwnerIndex,
slaveInfo
);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Iterate, propagating changedPointsInfo across mesh, until no change (or
// maxIter reached). Initial point values specified.
template <class Type>
Foam::PointEdgeWave<Type>::PointEdgeWave
(
const polyMesh& mesh,
const labelList& changedPoints,
const List<Type>& changedPointsInfo,
List<Type>& allPointInfo,
List<Type>& allEdgeInfo,
const label maxIter
)
:
mesh_(mesh),
allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo),
changedPoint_(mesh_.nPoints(), false),
changedPoints_(mesh_.nPoints()),
nChangedPoints_(0),
changedEdge_(mesh_.nEdges(), false),
changedEdges_(mesh_.nEdges()),
nChangedEdges_(0),
nCyclicPatches_(countPatchType<cyclicPolyPatch>()),
nGgiPatches_(countPatchType<ggiPolyPatch>()),
cycHalves_(2*nCyclicPatches_),
nEvals_(0),
nUnvisitedPoints_(mesh_.nPoints()),
nUnvisitedEdges_(mesh_.nEdges())
{
if
(
allPointInfo_.size() != mesh_.nPoints()
&& allPointInfo_.size() != mesh_.allPoints().size()
)
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of pointInfo work array is not equal to the number"
<< " of points in the mesh" << endl
<< " pointInfo :" << allPointInfo_.size() << endl
<< " mesh.nPoints:" << mesh_.nPoints()
<< exit(FatalError);
}
if (allEdgeInfo_.size() != mesh_.nEdges())
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of edgeInfo work array is not equal to the number"
<< " of edges in the mesh" << endl
<< " edgeInfo :" << allEdgeInfo_.size() << endl
<< " mesh.nEdges:" << mesh_.nEdges()
<< exit(FatalError);
}
// Calculate cyclic halves addressing.
if (nCyclicPatches_ > 0)
{
calcCyclicAddressing();
}
// Set from initial changed points data
setPointInfo(changedPoints, changedPointsInfo);
if (debug)
{
Pout<< "Seed points : " << nChangedPoints_ << endl;
}
// Iterate until nothing changes
label iter = iterate(maxIter);
if ((maxIter > 0) && (iter >= maxIter))
{
FatalErrorIn
(
"PointEdgeWave<Type>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << endl
<< " nChangedPoints:" << nChangedPoints_ << endl
<< " nChangedEdges:" << nChangedEdges_ << endl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template <class Type>
Foam::PointEdgeWave<Type>::~PointEdgeWave()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::getUnsetPoints() const
{
return nUnvisitedPoints_;
}
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::getUnsetEdges() const
{
return nUnvisitedEdges_;
}
// Copy point information into member data
template <class Type>
void Foam::PointEdgeWave<Type>::setPointInfo
(
const labelList& changedPoints,
const List<Type>& changedPointsInfo
)
{
forAll(changedPoints, changedPointI)
{
label pointI = changedPoints[changedPointI];
bool wasValid = allPointInfo_[pointI].valid();
// Copy info for pointI
allPointInfo_[pointI] = changedPointsInfo[changedPointI];
// Maintain count of unset points
if (!wasValid && allPointInfo_[pointI].valid())
{
--nUnvisitedPoints_;
}
// Mark pointI as changed, both on list and on point itself.
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
}
// Propagate information from edge to point. Return number of points changed.
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::edgeToPoint()
{
for
(
label changedEdgeI = 0;
changedEdgeI < nChangedEdges_;
changedEdgeI++
)
{
label edgeI = changedEdges_[changedEdgeI];
if (!changedEdge_[edgeI])
{
FatalErrorIn("PointEdgeWave<Type>::edgeToPoint()")
<< "edge " << edgeI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed point." << abort(FatalError);
}
const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
// Evaluate all connected points (= edge endpoints)
const edge& e = mesh_.edges()[edgeI];
forAll(e, eI)
{
Type& currentWallInfo = allPointInfo_[e[eI]];
if (currentWallInfo != neighbourWallInfo)
{
updatePoint
(
e[eI],
edgeI,
neighbourWallInfo,
propagationTol_,
currentWallInfo
);
}
}
// Reset status of edge
changedEdge_[edgeI] = false;
}
// Handled all changed edges by now
nChangedEdges_ = 0;
if (nCyclicPatches_ > 0)
{
// Transfer changed points across cyclic halves
handleCyclicPatches();
}
if (nGgiPatches_ > 0)
{
// Transfer changed points across cyclic halves
handleGgiPatches();
}
if (Pstream::parRun())
{
// Transfer changed points from neighbouring processors.
handleProcPatches();
}
if (debug)
{
Pout<< "Changed points : " << nChangedPoints_ << endl;
}
// Sum nChangedPoints over all procs
label totNChanged = nChangedPoints_;
reduce(totNChanged, sumOp<label>());
return totNChanged;
}
// Propagate information from point to edge. Return number of edges changed.
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::pointToEdge()
{
const labelListList& pointEdges = mesh_.pointEdges();
for
(
label changedPointI = 0;
changedPointI < nChangedPoints_;
changedPointI++
)
{
label pointI = changedPoints_[changedPointI];
if (!changedPoint_[pointI])
{
FatalErrorIn("PointEdgeWave<Type>::pointToEdge()")
<< "Point " << pointI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed point." << abort(FatalError);
}
const Type& neighbourWallInfo = allPointInfo_[pointI];
// Evaluate all connected edges
const labelList& edgeLabels = pointEdges[pointI];
forAll(edgeLabels, edgeLabelI)
{
label edgeI = edgeLabels[edgeLabelI];
Type& currentWallInfo = allEdgeInfo_[edgeI];
if (currentWallInfo != neighbourWallInfo)
{
updateEdge
(
edgeI,
pointI,
neighbourWallInfo,
propagationTol_,
currentWallInfo
);
}
}
// Reset status of point
changedPoint_[pointI] = false;
}
// Handled all changed points by now
nChangedPoints_ = 0;
if (debug)
{
Pout<< "Changed edges : " << nChangedEdges_ << endl;
}
// Sum nChangedPoints over all procs
label totNChanged = nChangedEdges_;
reduce(totNChanged, sumOp<label>());
return totNChanged;
}
// Iterate
template <class Type>
Foam::label Foam::PointEdgeWave<Type>::iterate(const label maxIter)
{
if (nCyclicPatches_ > 0)
{
// Transfer changed points across cyclic halves
handleCyclicPatches();
}
if (nGgiPatches_ > 0)
{
// Transfer changed points across ggi patches
handleGgiPatches();
}
if (Pstream::parRun())
{
// Transfer changed points from neighbouring processors.
handleProcPatches();
}
nEvals_ = 0;
label iter = 0;
while(iter < maxIter)
{
if (debug)
{
Pout<< "Iteration " << iter << endl;
}
label nEdges = pointToEdge();
if (debug)
{
Pout<< "Total changed edges : " << nEdges << endl;
}
if (nEdges == 0)
{
break;
}
label nPoints = edgeToPoint();
if (debug)
{
Pout<< "Total changed points : " << nPoints << endl;
Pout<< "Total evaluations : " << nEvals_ << endl;
Pout<< "Remaining unvisited points: " << nUnvisitedPoints_ << endl;
Pout<< "Remaining unvisited edges : " << nUnvisitedEdges_ << endl;
Pout<< endl;
}
if (nPoints == 0)
{
break;
}
iter++;
}
return iter;
}
// ************************************************************************* //
| gpl-3.0 |
raisercostin/mucommander-2 | src/main/com/mucommander/ui/dialog/server/package.html | 103 | <body>
Components used to let users enter remote file systems information before connecting.
</body>
| gpl-3.0 |
UnknownX7/darkstar | scripts/zones/Inner_Horutoto_Ruins/TextIDs.lua | 1317 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6548; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6554; -- Obtained: <item>.
GIL_OBTAINED = 6555; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6557; -- Obtained key item: <keyitem>.
NOT_BROKEN_ORB = 7231; -- The Mana Orb in this receptacle is not broken.
EXAMINED_RECEPTACLE = 7232; -- You have already examined this receptacle.
DOOR_FIRMLY_CLOSED = 7259; -- The door is firmly closed.
-- Treasure Coffer/Chest Dialog
CHEST_UNLOCKED = 7334; -- You unlock the chest!
CHEST_FAIL = 7335; -- Fails to open the chest.
CHEST_TRAP = 7336; -- The chest was trapped!
CHEST_WEAK = 7337; -- You cannot open the chest when you are in a weakened state.
CHEST_MIMIC = 7338; -- The chest was a mimic!
CHEST_MOOGLE = 7339; -- You cannot open the chest while participating in the moogle event.
CHEST_ILLUSION = 7340; -- The chest was but an illusion...
CHEST_LOCKED = 7341; -- The chest appears to be locked.
-- Other texts
PORTAL_SEALED_BY_3_MAGIC = 8; -- The Sealed Portal is sealed by three kinds of magic.
PORTAL_NOT_OPEN_THAT_SIDE = 9; -- The Sealed Portal cannot be opened from this side.
-- conquest Base
CONQUEST_BASE = 10;
| gpl-3.0 |
ptwales/Rubberduck | RetailCoder.VBE/UI/Refactorings/RenameDialog.cs | 2733 | using System;
using System.Linq;
using System.Windows.Forms;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Refactorings.Rename;
namespace Rubberduck.UI.Refactorings
{
public partial class RenameDialog : Form, IRenameView
{
public RenameDialog()
{
InitializeComponent();
InitializeCaptions();
Shown += RenameDialog_Shown;
NewNameBox.TextChanged += NewNameBox_TextChanged;
}
private void InitializeCaptions()
{
Text = RubberduckUI.RenameDialog_Caption;
OkButton.Text = RubberduckUI.OK;
CancelDialogButton.Text = RubberduckUI.CancelButtonText;
TitleLabel.Text = RubberduckUI.RenameDialog_TitleText;
InstructionsLabel.Text = RubberduckUI.RenameDialog_InstructionsLabelText;
NameLabel.Text = RubberduckUI.NameLabelText;
}
private void NewNameBox_TextChanged(object sender, EventArgs e)
{
NewName = NewNameBox.Text;
}
private void RenameDialog_Shown(object sender, EventArgs e)
{
NewNameBox.SelectAll();
NewNameBox.Focus();
}
private Declaration _target;
public Declaration Target
{
get { return _target; }
set
{
_target = value;
if (_target == null)
{
return;
}
NewName = _target.IdentifierName;
var declarationType =
RubberduckUI.ResourceManager.GetString("DeclarationType_" + _target.DeclarationType, RubberduckUI.Culture);
InstructionsLabel.Text = string.Format(RubberduckUI.RenameDialog_InstructionsLabelText, declarationType,
_target.IdentifierName);
}
}
public string NewName
{
get { return NewNameBox.Text; }
set
{
NewNameBox.Text = value;
ValidateNewName();
}
}
private void ValidateNewName()
{
var tokenValues = typeof(Tokens).GetFields().Select(item => item.GetValueDirect(new TypedReference())).Cast<string>().Select(item => item.ToLower());
OkButton.Enabled = NewName != Target.IdentifierName
&& char.IsLetter(NewName.FirstOrDefault())
&& !tokenValues.Contains(NewName.ToLower())
&& !NewName.Any(c => !char.IsLetterOrDigit(c) && c != '_');
InvalidNameValidationIcon.Visible = !OkButton.Enabled;
}
}
} | gpl-3.0 |
tectronics/photivo | Sources/ptImage8.cpp | 3515 | /*******************************************************************************
**
** Photivo
**
** Copyright (C) 2008 Jos De Laender <[email protected]>
** Copyright (C) 2012-2013 Michael Munzert <[email protected]>
**
** This file is part of Photivo.
**
** Photivo is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License version 3
** as published by the Free Software Foundation.
**
** Photivo is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Photivo. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/
#include "ptError.h"
#include "ptCalloc.h"
#include "ptImage8.h"
#include "ptImage.h"
#include "ptResizeFilters.h"
#include <cstdio>
#include <cstdlib>
#include <cassert>
//==============================================================================
ptImage8::ptImage8():
m_Width(0),
m_Height(0),
m_Colors(0),
m_ColorSpace(ptSpace_sRGB_D65),
m_SizeBytes(0)
{}
//==============================================================================
ptImage8::ptImage8(uint16_t AWidth,
uint16_t AHeight,
short ANrColors)
{
m_Image.clear();
m_ColorSpace = ptSpace_sRGB_D65;
setSize(AWidth, AHeight, ANrColors);
}
//==============================================================================
void ptImage8::setSize(uint16_t AWidth, uint16_t AHeight, int AColorCount) {
m_Width = AWidth;
m_Height = AHeight;
m_Colors = AColorCount;
m_SizeBytes = m_Width * m_Height * m_Colors;
m_Image.resize(m_Width * m_Height);
}
//==============================================================================
void ptImage8::fillColor(uint8_t ARed, uint8_t AGreen, uint8_t ABlue, uint8_t AAlpha) {
std::array<uint8_t, 4> hTemp = {{ARed, AGreen, ABlue, AAlpha}};
std::fill(std::begin(m_Image), std::end(m_Image), hTemp);
}
//==============================================================================
ptImage8::~ptImage8() {
// nothing to do
}
//==============================================================================
ptImage8* ptImage8::Set(const ptImage *Origin) {
assert(NULL != Origin);
assert(ptSpace_Lab != Origin->m_ColorSpace);
setSize(Origin->m_Width, Origin->m_Height, Origin->m_Colors);
m_ColorSpace = Origin->m_ColorSpace;
for (uint32_t i = 0; i < static_cast<uint32_t>(m_Width)*m_Height; i++) {
for (short c = 0; c < 3; c++) {
// Mind the R<->B swap !
m_Image[i][2-c] = Origin->m_Image[i][c]>>8;
}
m_Image[i][3] = 0xff;
}
return this;
}
//==============================================================================
ptImage8 *ptImage8::Set(const ptImage8 *Origin)
{
assert(NULL != Origin);
setSize(Origin->m_Width,
Origin->m_Height,
Origin->m_Colors);
m_ColorSpace = Origin->m_ColorSpace;
m_Image = Origin->m_Image;
return this;
}
//==============================================================================
void ptImage8::FromQImage(const QImage AImage)
{
setSize(AImage.width(), AImage.height(), 4);
m_ColorSpace = ptSpace_sRGB_D65;
memcpy((uint8_t (*)[4]) m_Image.data(), AImage.bits(), m_SizeBytes);
}
| gpl-3.0 |
Whitechaser/darkstar | scripts/zones/West_Ronfaure/mobs/Jaggedy-Eared_Jack.lua | 211 | -----------------------------------
-- Area: West Ronfaure (100)
-- NM: Jaggedy-Eared_Jack
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
function onMobDespawn(mob)
end;
| gpl-3.0 |
Edwardro22/cgrates | data/storage/postgres/pg_cdr_migration.sql | 2315 | /*
This script will migrate CDRs from the old CGRateS tables to the new cdrs table
but it only migrate CDRs where the duration is > 0.
If you need CDRs also with duration is = 0 you can make the appropriate change in the line beginning WHERE cdrs_primary.usage
Also the script will process 10,000 CDRs before committing to save system resources
especially in systems where they are millions of CDRs to be migrated
You can increase or lower the value of step in the line after BEGIN below.
*/
DO $$
DECLARE
max_cdrs bigint;
start_id bigint;
end_id bigint;
step bigint;
BEGIN
/* You must change the step var to commit every step rows inserted */
step := 10000;
start_id := 0;
end_id := start_id + step;
select max(id) INTO max_cdrs from rated_cdrs;
WHILE start_id <= max_cdrs
LOOP
--RAISE NOTICE '%', (to_char(start_id, '99999999') || '-' || to_char(end_id, '99999999'));
INSERT INTO
cdrs(cgrid,run_id,origin_host,source,origin_id,tor,request_type,direction,tenant,category,account,subject,destination,setup_time,pdd,answer_time,usage,supplier,disconnect_cause,extra_fields,cost_source,cost,cost_details,extra_info, created_at, updated_at, deleted_at)
SELECT cdrs_primary.cgrid,rated_cdrs.runid as run_id,cdrs_primary.cdrhost as origin_host,cdrs_primary.cdrsource as source,cdrs_primary.accid as origin_id, cdrs_primary.tor,rated_cdrs.reqtype as request_type,rated_cdrs.direction, rated_cdrs.tenant,rated_cdrs.category, rated_cdrs.account, rated_cdrs.subject, rated_cdrs.destination,rated_cdrs.setup_time,rated_cdrs.pdd,rated_cdrs.answer_time,rated_cdrs.usage,rated_cdrs.supplier,rated_cdrs.disconnect_cause,cdrs_extra.extra_fields,cost_details.cost_source,rated_cdrs.cost,cost_details.timespans as cost_details,rated_cdrs.extra_info,rated_cdrs.created_at,rated_cdrs.updated_at, rated_cdrs.deleted_at
FROM rated_cdrs
INNER JOIN cdrs_primary ON rated_cdrs.cgrid = cdrs_primary.cgrid
INNER JOIN cdrs_extra ON rated_cdrs.cgrid = cdrs_extra.cgrid
INNER JOIN cost_details ON rated_cdrs.cgrid = cost_details.cgrid
WHERE cdrs_primary.usage > '0'
AND not exists (select 1 from cdrs c where c.cgrid = cdrs_primary.cgrid)
AND rated_cdrs.id >= start_id
AND rated_cdrs.id < end_id
;
start_id = start_id + step;
end_id = end_id + step;
END LOOP;
END
$$;
| gpl-3.0 |
zhuyue1314/phishing-frenzy | config/routes.rb | 2411 | PhishingFramework::Application.routes.draw do
devise_for :admins
# image tracking routes.
get '/reports/image/:uid.png' => 'reports#image'
# only allow emails to be send from POST request
post '/email/preview_email/:id' => 'email#preview', as: 'preview_email'
post '/email/test_email/:id' => 'email#test', as: 'test_email'
post '/email/launch_email/:id' => 'email#launch', as: 'launch'
# only allow deletion from POST requests
get '/campaigns/delete_smtp_entry/:id' => 'campaigns#list'
get "reports/list"
get "reports/show"
get "reports/delete"
get "tools/emails" => "tools#emails"
get "tools/show_emails/:id" => "tools#show_emails", as: 'show_emails'
post "tools/enumerate_emails" => "tools#enumerate_emails"
delete "tools/emails/:id" => "tools#destroy_email", as: 'destroy_email'
get "tools/download_emails/:id" => "tools#download_emails", as: "download_emails"
get "tools/import_emails" => "tools#import_emails"
resources :campaigns do
collection do
get 'options'
get 'home'
get 'list'
get 'aboutus'
get 'victims'
get 'activity'
delete 'destroy'
end
member do
post 'clear_victims'
end
end
resources :blasts, only: [:show], shallow: true
resources :templates do
collection do
get 'list'
get 'restore'
get 'edit_email'
get 'update_attachment'
delete 'destroy'
end
end
resources :reports do
collection do
get 'list'
get 'stats'
get 'results'
get 'download_logs'
get 'download_stats'
get 'apache_logs'
get 'smtp'
get 'passwords'
post 'results'
delete 'clear'
end
member do
get 'download_excel'
end
end
resources :admin do
collection do
get 'list'
get 'global_settings'
put 'update_global_settings'
end
member do
get 'logins'
post 'approve'
post 'revoke'
delete 'destroy'
end
end
resources :clones do
member do
get 'download'
get 'preview'
end
end
resources :tools
root :to => 'campaigns#home'
match 'access', :to => 'access#menu', as: 'access', via: :get
require 'sidekiq/web'
authenticate :admin do
mount Sidekiq::Web => '/sidekiq'
end
require 'sidekiq/api'
match "queue-status" => proc { [200, {"Content-Type" => "text/plain"}, [Sidekiq::Queue.new.size < 100 ? "OK" : "UHOH" ]] }, via: :get
mount LetterOpenerWeb::Engine, at: 'letter_opener'
match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
end
| gpl-3.0 |
libis/ca_babtekst | app/controllers/find/BrowseObjectsController.php | 4873 | <?php
/* ----------------------------------------------------------------------
* app/controllers/find/BrowseObjectsController.php
* ----------------------------------------------------------------------
* CollectiveAccess
* Open-source collections management software
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2009-2013 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
* This program is free software; you may redistribute it and/or modify it under
* the terms of the provided license as published by Whirl-i-Gig
*
* CollectiveAccess is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This source code is free and modifiable under the terms of
* GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
* the "license.txt" file for details, or visit the CollectiveAccess web site at
* http://www.CollectiveAccess.org
*
* ----------------------------------------------------------------------
*/
require_once(__CA_LIB_DIR__."/ca/BaseBrowseController.php");
require_once(__CA_LIB_DIR__."/ca/Browse/ObjectBrowse.php");
require_once(__CA_LIB_DIR__."/core/GeographicMap.php");
class BrowseObjectsController extends BaseBrowseController {
# -------------------------------------------------------
/**
* Name of table for which this browse returns items
*/
protected $ops_tablename = 'ca_objects';
/**
* Number of items per results page
*/
protected $opa_items_per_page = array(8, 16, 24, 32);
/**
* List of result views supported for this browse
* Is associative array: keys are view labels, values are view specifier to be incorporated into view name
*/
protected $opa_views;
/**
* List of available result sorting fields
* Is associative array: values are display names for fields, keys are full fields names (table.field) to be used as sort
*/
protected $opa_sorts;
/**
* Name of "find" used to defined result context for ResultContext object
* Must be unique for the table and have a corresponding entry in find_navigation.conf
*/
protected $ops_find_type = 'basic_browse';
# -------------------------------------------------------
public function __construct(&$po_request, &$po_response, $pa_view_paths=null) {
parent::__construct($po_request, $po_response, $pa_view_paths);
$this->opo_browse = new ObjectBrowse($this->opo_result_context->getSearchExpression(), 'providence');
$this->opa_views = array(
'thumbnail' => _t('thumbnails'),
'full' => _t('full'),
'list' => _t('list'),
'editable' => _t('editable')
);
$this->opa_sorts = array_merge(array(
'ca_object_labels.name' => _t('title'),
'ca_objects.type_id' => _t('type'),
'ca_objects.idno_sort' => _t('idno')
), $this->opa_sorts);
}
# -------------------------------------------------------
public function Index($pa_options=null) {
JavascriptLoadManager::register('imageScroller');
JavascriptLoadManager::register('tabUI');
JavascriptLoadManager::register('panel');
parent::Index($pa_options);
}
# -------------------------------------------------------
/**
* Ajax action that returns info on a mapped location based upon the 'id' request parameter.
* 'id' is a list of object_ids to display information before. Each integer id is separated by a semicolon (";")
* The "ca_objects_results_map_balloon_html" view in Results/ is used to render the content.
*/
public function getMapItemInfo() {
$pa_object_ids = explode(';', $this->request->getParameter('id', pString));
$va_access_values = caGetUserAccessValues($this->request);
$this->view->setVar('ids', $pa_object_ids);
$this->view->setVar('access_values', $va_access_values);
$this->render("Results/ca_objects_results_map_balloon_html.php");
}
# -------------------------------------------------------
/**
* Returns string representing the name of the item the browse will return
*
* If $ps_mode is 'singular' [default] then the singular version of the name is returned, otherwise the plural is returned
*/
public function browseName($ps_mode='singular') {
return ($ps_mode === 'singular') ? _t('object') : _t('objects');
}
# -------------------------------------------------------
/**
* Returns string representing the name of this controller (minus the "Controller" part)
*/
public function controllerName() {
return 'BrowseObjects';
}
# -------------------------------------------------------
}
?> | gpl-3.0 |
jtracey/Signal-Android | src/org/thoughtcrime/securesms/crypto/DatabaseSecret.java | 627 | package org.thoughtcrime.securesms.crypto;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.util.Hex;
import java.io.IOException;
public class DatabaseSecret {
private final byte[] key;
private final String encoded;
public DatabaseSecret(@NonNull byte[] key) {
this.key = key;
this.encoded = Hex.toStringCondensed(key);
}
public DatabaseSecret(@NonNull String encoded) throws IOException {
this.key = Hex.fromStringCondensed(encoded);
this.encoded = encoded;
}
public String asString() {
return encoded;
}
public byte[] asBytes() {
return key;
}
}
| gpl-3.0 |
Unofficial-Extend-Project-Mirror/openfoam-extend-foam-extend-3.1 | src/finiteVolume/interpolation/surfaceInterpolation/schemes/UpwindFitScheme/UpwindFitData.C | 5777 | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "UpwindFitData.H"
#include "surfaceFields.H"
#include "volFields.H"
#include "SVD.H"
#include "syncTools.H"
#include "extendedUpwindCellToFaceStencil.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Polynomial>
Foam::UpwindFitData<Polynomial>::UpwindFitData
(
const fvMesh& mesh,
const extendedUpwindCellToFaceStencil& stencil,
const bool linearCorrection,
const scalar linearLimitFactor,
const scalar centralWeight
)
:
FitData
<
UpwindFitData<Polynomial>,
extendedUpwindCellToFaceStencil,
Polynomial
>
(
mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
),
owncoeffs_(mesh.nFaces()),
neicoeffs_(mesh.nFaces())
{
if (debug)
{
Info<< "Contructing UpwindFitData<Polynomial>" << endl;
}
calcFit();
if (debug)
{
Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
<< "Finished constructing polynomialFit data"
<< endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Polynomial>
void Foam::UpwindFitData<Polynomial>::calcFit()
{
const fvMesh& mesh = this->mesh();
const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
// Owner stencil weights
// ~~~~~~~~~~~~~~~~~~~~~
// Get the cell/face centres in stencil order.
List<List<point> > stencilPoints(mesh.nFaces());
this->stencil().collectData
(
this->stencil().ownMap(),
this->stencil().ownStencil(),
mesh.C(),
stencilPoints
);
// find the fit coefficients for every owner
//Pout<< "-- Owner --" << endl;
for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
FitData
<
UpwindFitData<Polynomial>,
extendedUpwindCellToFaceStencil,
Polynomial
>::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
//Pout<< " facei:" << facei
// << " at:" << mesh.faceCentres()[facei] << endl;
//forAll(owncoeffs_[facei], i)
//{
// Pout<< " point:" << stencilPoints[facei][i]
// << "\tweight:" << owncoeffs_[facei][i]
// << endl;
//}
}
forAll(bw, patchi)
{
const fvsPatchScalarField& pw = bw[patchi];
if (pw.coupled())
{
label facei = pw.patch().patch().start();
forAll(pw, i)
{
FitData
<
UpwindFitData<Polynomial>,
extendedUpwindCellToFaceStencil,
Polynomial
>::calcFit
(
owncoeffs_[facei], stencilPoints[facei], pw[i], facei
);
facei++;
}
}
}
// Neighbour stencil weights
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// Note:reuse stencilPoints since is major storage
this->stencil().collectData
(
this->stencil().neiMap(),
this->stencil().neiStencil(),
mesh.C(),
stencilPoints
);
// find the fit coefficients for every neighbour
//Pout<< "-- Neighbour --" << endl;
for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
FitData
<
UpwindFitData<Polynomial>,
extendedUpwindCellToFaceStencil,
Polynomial
>::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
//Pout<< " facei:" << facei
// << " at:" << mesh.faceCentres()[facei] << endl;
//forAll(neicoeffs_[facei], i)
//{
// Pout<< " point:" << stencilPoints[facei][i]
// << "\tweight:" << neicoeffs_[facei][i]
// << endl;
//}
}
forAll(bw, patchi)
{
const fvsPatchScalarField& pw = bw[patchi];
if (pw.coupled())
{
label facei = pw.patch().patch().start();
forAll(pw, i)
{
FitData
<
UpwindFitData<Polynomial>,
extendedUpwindCellToFaceStencil,
Polynomial
>::calcFit
(
neicoeffs_[facei], stencilPoints[facei], pw[i], facei
);
facei++;
}
}
}
}
// ************************************************************************* //
| gpl-3.0 |
Microvellum/Fluid-Designer | win64-vc/2.78/scripts/freestyle/styles/long_anisotropically_dense.py | 3125 | # ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# Filename : long_anisotropically_dense.py
# Author : Stephane Grabli
# Date : 04/08/2005
# Purpose : Selects the lines that are long and have a high anisotropic
# a priori density and uses causal density
# to draw without cluttering. Ideally, half of the
# selected lines are culled using the causal density.
#
# ********************* WARNING *************************************
# ******** The Directional a priori density maps must ******
# ******** have been computed prior to using this style module ******
from freestyle.chainingiterators import ChainSilhouetteIterator
from freestyle.functions import DensityF1D
from freestyle.predicates import (
NotUP1D,
QuantitativeInvisibilityUP1D,
UnaryPredicate1D,
pyHighDensityAnisotropyUP1D,
pyHigherLengthUP1D,
pyLengthBP1D,
)
from freestyle.shaders import (
ConstantColorShader,
ConstantThicknessShader,
SamplingShader,
)
from freestyle.types import IntegrationType, Operators
## custom density predicate
class pyDensityUP1D(UnaryPredicate1D):
def __init__(self, wsize, threshold, integration=IntegrationType.MEAN, sampling=2.0):
UnaryPredicate1D.__init__(self)
self._wsize = wsize
self._threshold = threshold
self._integration = integration
self._func = DensityF1D(self._wsize, self._integration, sampling)
self._func2 = DensityF1D(self._wsize, IntegrationType.MAX, sampling)
def __call__(self, inter):
c = self._func(inter)
m = self._func2(inter)
if c < self._threshold:
return 1
if m > 4*c:
if c < 1.5*self._threshold:
return 1
return 0
Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(),NotUP1D(QuantitativeInvisibilityUP1D(0)))
Operators.select(pyHigherLengthUP1D(40))
## selects lines having a high anisotropic a priori density
Operators.select(pyHighDensityAnisotropyUP1D(0.3,4))
Operators.sort(pyLengthBP1D())
shaders_list = [
SamplingShader(2.0),
ConstantThicknessShader(2),
ConstantColorShader(0.2,0.2,0.25,1),
]
## uniform culling
Operators.create(pyDensityUP1D(3.0,2.0e-2, IntegrationType.MEAN, 0.1), shaders_list)
| gpl-3.0 |
hryamzik/ansible | lib/ansible/modules/network/nxos/nxos_install_os.py | 19714 | #!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'network'}
DOCUMENTATION = '''
---
module: nxos_install_os
extends_documentation_fragment: nxos
short_description: Set boot options like boot, kickstart image and issu.
description:
- Install an operating system by setting the boot options like boot
image and kickstart image and optionally select to install using
ISSU (In Server Software Upgrade).
notes:
- Tested against the following platforms and images
- N9k 7.0(3)I4(6), 7.0(3)I5(3), 7.0(3)I6(1), 7.0(3)I7(1), 7.0(3)F2(2), 7.0(3)F3(2)
- N3k 6.0(2)A8(6), 6.0(2)A8(8), 7.0(3)I6(1), 7.0(3)I7(1)
- N7k 7.3(0)D1(1), 8.0(1), 8.2(1)
- This module requires both the ANSIBLE_PERSISTENT_CONNECT_TIMEOUT and
ANSIBLE_PERSISTENT_COMMAND_TIMEOUT timers to be set to 600 seconds or higher.
The module will exit if the timers are not set properly.
- Do not include full file paths, just the name of the file(s) stored on
the top level flash directory.
- This module attempts to install the software immediately,
which may trigger a reboot.
- In check mode, the module will indicate if an upgrade is needed and
whether or not the upgrade is disruptive or non-disruptive(ISSU).
author:
- Jason Edelman (@jedelman8)
- Gabriele Gerbibo (@GGabriele)
version_added: 2.2
options:
system_image_file:
description:
- Name of the system (or combined) image file on flash.
required: true
kickstart_image_file:
description:
- Name of the kickstart image file on flash.
(Not required on all Nexus platforms)
issu:
version_added: "2.5"
description:
- Upgrade using In Service Software Upgrade (ISSU).
(Only supported on N9k platforms)
- Selecting 'required' or 'yes' means that upgrades will only
proceed if the switch is capable of ISSU.
- Selecting 'desired' means that upgrades will use ISSU if possible
but will fall back to disruptive upgrade if needed.
- Selecting 'no' means do not use ISSU. Forced disruptive.
choices: ['required','desired', 'yes', 'no']
default: 'no'
'''
EXAMPLES = '''
- name: Install OS on N9k
check_mode: no
nxos_install_os:
system_image_file: nxos.7.0.3.I6.1.bin
issu: desired
- name: Wait for device to come back up with new image
wait_for:
port: 22
state: started
timeout: 500
delay: 60
host: "{{ inventory_hostname }}"
- name: Check installed OS for newly installed version
nxos_command:
commands: ['show version | json']
provider: "{{ connection }}"
register: output
- assert:
that:
- output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)'
'''
RETURN = '''
install_state:
description: Boot and install information.
returned: always
type: dictionary
sample: {
"install_state": [
"Compatibility check is done:",
"Module bootable Impact Install-type Reason",
"------ -------- -------------- ------------ ------",
" 1 yes non-disruptive reset ",
"Images will be upgraded according to following table:",
"Module Image Running-Version(pri:alt) New-Version Upg-Required",
"------ ---------- ---------------------------------------- -------------------- ------------",
" 1 nxos 7.0(3)I6(1) 7.0(3)I7(1) yes",
" 1 bios v4.4.0(07/12/2017) v4.4.0(07/12/2017) no"
],
}
'''
import re
from time import sleep
from ansible.module_utils.network.nxos.nxos import load_config, run_commands
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
# Output options are 'text' or 'json'
def execute_show_command(module, command, output='text'):
cmds = [{
'command': command,
'output': output,
}]
return run_commands(module, cmds)
def get_platform(module):
"""Determine platform type"""
data = execute_show_command(module, 'show inventory', 'json')
pid = data[0]['TABLE_inv']['ROW_inv'][0]['productid']
if re.search(r'N3K', pid):
type = 'N3K'
elif re.search(r'N5K', pid):
type = 'N5K'
elif re.search(r'N6K', pid):
type = 'N6K'
elif re.search(r'N7K', pid):
type = 'N7K'
elif re.search(r'N9K', pid):
type = 'N9K'
else:
type = 'unknown'
return type
def parse_show_install(data):
"""Helper method to parse the output of the 'show install all impact' or
'install all' commands.
Sample Output:
Installer will perform impact only check. Please wait.
Verifying image bootflash:/nxos.7.0.3.F2.2.bin for boot variable "nxos".
[####################] 100% -- SUCCESS
Verifying image type.
[####################] 100% -- SUCCESS
Preparing "bios" version info using image bootflash:/nxos.7.0.3.F2.2.bin.
[####################] 100% -- SUCCESS
Preparing "nxos" version info using image bootflash:/nxos.7.0.3.F2.2.bin.
[####################] 100% -- SUCCESS
Performing module support checks.
[####################] 100% -- SUCCESS
Notifying services about system upgrade.
[####################] 100% -- SUCCESS
Compatibility check is done:
Module bootable Impact Install-type Reason
------ -------- -------------- ------------ ------
8 yes disruptive reset Incompatible image for ISSU
21 yes disruptive reset Incompatible image for ISSU
Images will be upgraded according to following table:
Module Image Running-Version(pri:alt) New-Version Upg-Required
------ ---------- ---------------------------------------- ------------
8 lcn9k 7.0(3)F3(2) 7.0(3)F2(2) yes
8 bios v01.17 v01.17 no
21 lcn9k 7.0(3)F3(2) 7.0(3)F2(2) yes
21 bios v01.70 v01.70 no
"""
if len(data) > 0:
data = massage_install_data(data)
ud = {'raw': data}
ud['processed'] = []
ud['disruptive'] = False
ud['upgrade_needed'] = False
ud['error'] = False
ud['install_in_progress'] = False
ud['server_error'] = False
ud['upgrade_succeeded'] = False
ud['use_impact_data'] = False
# Check for server errors
if isinstance(data, int):
if data == -1:
ud['server_error'] = True
elif data >= 500:
ud['server_error'] = True
elif data == -32603:
ud['server_error'] = True
return ud
else:
ud['list_data'] = data.split('\n')
for x in ud['list_data']:
# Check for errors and exit if found.
if re.search(r'Pre-upgrade check failed', x):
ud['error'] = True
break
if re.search(r'[I|i]nvalid command', x):
ud['error'] = True
break
if re.search(r'No install all data found', x):
ud['error'] = True
break
# Check for potentially transient conditions
if re.search(r'Another install procedure may be in progress', x):
ud['install_in_progress'] = True
break
if re.search(r'Backend processing error', x):
ud['server_error'] = True
break
if re.search(r'^(-1|5\d\d)$', x):
ud['server_error'] = True
break
# Check for messages indicating a successful upgrade.
if re.search(r'Finishing the upgrade', x):
ud['upgrade_succeeded'] = True
break
if re.search(r'Install has been successful', x):
ud['upgrade_succeeded'] = True
break
if re.search(r'Switching over onto standby', x):
ud['upgrade_succeeded'] = True
break
# We get these messages when the upgrade is non-disruptive and
# we loose connection with the switchover but far enough along that
# we can be confident the upgrade succeeded.
if re.search(r'timeout trying to send command: install', x):
ud['upgrade_succeeded'] = True
ud['use_impact_data'] = True
break
if re.search(r'[C|c]onnection failure: timed out', x):
ud['upgrade_succeeded'] = True
ud['use_impact_data'] = True
break
# Begin normal parsing.
if re.search(r'----|Module|Images will|Compatibility', x):
ud['processed'].append(x)
continue
# Check to see if upgrade will be disruptive or non-disruptive and
# build dictionary of individual modules and their status.
# Sample Line:
#
# Module bootable Impact Install-type Reason
# ------ -------- ---------- ------------ ------
# 8 yes disruptive reset Incompatible image
rd = r'(\d+)\s+(\S+)\s+(disruptive|non-disruptive)\s+(\S+)'
mo = re.search(rd, x)
if mo:
ud['processed'].append(x)
key = 'm%s' % mo.group(1)
field = 'disruptive'
if mo.group(3) == 'non-disruptive':
ud[key] = {field: False}
else:
ud[field] = True
ud[key] = {field: True}
field = 'bootable'
if mo.group(2) == 'yes':
ud[key].update({field: True})
else:
ud[key].update({field: False})
continue
# Check to see if switch needs an upgrade and build a dictionary
# of individual modules and their individual upgrade status.
# Sample Line:
#
# Module Image Running-Version(pri:alt) New-Version Upg-Required
# ------ ----- ---------------------------------------- ------------
# 8 lcn9k 7.0(3)F3(2) 7.0(3)F2(2) yes
mo = re.search(r'(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(yes|no)', x)
if mo:
ud['processed'].append(x)
key = 'm%s_%s' % (mo.group(1), mo.group(2))
field = 'upgrade_needed'
if mo.group(5) == 'yes':
ud[field] = True
ud[key] = {field: True}
else:
ud[key] = {field: False}
continue
return ud
def massage_install_data(data):
# Transport cli returns a list containing one result item.
# Transport nxapi returns a list containing two items. The second item
# contains the data we are interested in.
default_error_msg = 'No install all data found'
if len(data) == 1:
result_data = data[0]
elif len(data) == 2:
result_data = data[1]
else:
result_data = default_error_msg
# Further processing may be needed for result_data
if len(data) == 2 and isinstance(data[1], dict):
if 'clierror' in data[1].keys():
result_data = data[1]['clierror']
elif 'code' in data[1].keys() and data[1]['code'] == '500':
# We encountered a backend processing error for nxapi
result_data = data[1]['msg']
else:
result_data = default_error_msg
return result_data
def build_install_cmd_set(issu, image, kick, type):
commands = ['terminal dont-ask']
if re.search(r'required|desired|yes', issu):
issu_cmd = 'non-disruptive'
else:
issu_cmd = ''
if type == 'impact':
rootcmd = 'show install all impact'
else:
rootcmd = 'install all'
if kick is None:
commands.append(
'%s nxos %s %s' % (rootcmd, image, issu_cmd))
else:
commands.append(
'%s system %s kickstart %s' % (rootcmd, image, kick))
return commands
def parse_show_version(data):
version_data = {'raw': data[0].split('\n')}
version_data['version'] = ''
version_data['error'] = False
for x in version_data['raw']:
mo = re.search(r'(kickstart|system|NXOS):\s+version\s+(\S+)', x)
if mo:
version_data['version'] = mo.group(2)
continue
if version_data['version'] == '':
version_data['error'] = True
return version_data
def check_mode_legacy(module, issu, image, kick=None):
"""Some platforms/images/transports don't support the 'install all impact'
command so we need to use a different method."""
current = execute_show_command(module, 'show version', 'json')[0]
# Call parse_show_data on empty string to create the default upgrade
# data stucture dictionary
data = parse_show_install('')
upgrade_msg = 'No upgrade required'
# Process System Image
data['error'] = False
tsver = 'show version image bootflash:%s' % image
target_image = parse_show_version(execute_show_command(module, tsver))
if target_image['error']:
data['error'] = True
data['raw'] = target_image['raw']
if current['kickstart_ver_str'] != target_image['version'] and not data['error']:
data['upgrade_needed'] = True
data['disruptive'] = True
upgrade_msg = 'Switch upgraded: system: %s' % tsver
# Process Kickstart Image
if kick is not None and not data['error']:
tkver = 'show version image bootflash:%s' % kick
target_kick = parse_show_version(execute_show_command(module, tkver))
if target_kick['error']:
data['error'] = True
data['raw'] = target_kick['raw']
if current['kickstart_ver_str'] != target_kick['version'] and not data['error']:
data['upgrade_needed'] = True
data['disruptive'] = True
upgrade_msg = upgrade_msg + ' kickstart: %s' % tkver
data['processed'] = upgrade_msg
return data
def check_mode_nextgen(module, issu, image, kick=None):
"""Use the 'install all impact' command for check_mode"""
opts = {'ignore_timeout': True}
commands = build_install_cmd_set(issu, image, kick, 'impact')
data = parse_show_install(load_config(module, commands, True, opts))
# If an error is encountered when issu is 'desired' then try again
# but set issu to 'no'
if data['error'] and issu == 'desired':
issu = 'no'
commands = build_install_cmd_set(issu, image, kick, 'impact')
# The system may be busy from the previous call to check_mode so loop
# until it's done.
data = check_install_in_progress(module, commands, opts)
if data['server_error']:
data['error'] = True
return data
def check_install_in_progress(module, commands, opts):
for attempt in range(20):
data = parse_show_install(load_config(module, commands, True, opts))
if data['install_in_progress']:
sleep(1)
continue
break
return data
def check_mode(module, issu, image, kick=None):
"""Check switch upgrade impact using 'show install all impact' command"""
data = check_mode_nextgen(module, issu, image, kick)
if data['server_error']:
# We encountered an unrecoverable error in the attempt to get upgrade
# impact data from the 'show install all impact' command.
# Fallback to legacy method.
data = check_mode_legacy(module, issu, image, kick)
return data
def do_install_all(module, issu, image, kick=None):
"""Perform the switch upgrade using the 'install all' command"""
impact_data = check_mode(module, issu, image, kick)
if module.check_mode:
# Check mode set in the playbook so just return the impact data.
msg = '*** SWITCH WAS NOT UPGRADED: IMPACT DATA ONLY ***'
impact_data['processed'].append(msg)
return impact_data
if impact_data['error']:
# Check mode discovered an error so return with this info.
return impact_data
elif not impact_data['upgrade_needed']:
# The switch is already upgraded. Nothing more to do.
return impact_data
else:
# If we get here, check_mode returned no errors and the switch
# needs to be upgraded.
if impact_data['disruptive']:
# Check mode indicated that ISSU is not possible so issue the
# upgrade command without the non-disruptive flag.
issu = 'no'
commands = build_install_cmd_set(issu, image, kick, 'install')
opts = {'ignore_timeout': True}
# The system may be busy from the call to check_mode so loop until
# it's done.
upgrade = check_install_in_progress(module, commands, opts)
# Special case: If we encounter a server error at this stage
# it means the command was sent and the upgrade was started but
# we will need to use the impact data instead of the current install
# data.
if upgrade['server_error']:
upgrade['upgrade_succeeded'] = True
upgrade['use_impact_data'] = True
if upgrade['use_impact_data']:
if upgrade['upgrade_succeeded']:
upgrade = impact_data
upgrade['upgrade_succeeded'] = True
else:
upgrade = impact_data
upgrade['upgrade_succeeded'] = False
if not upgrade['upgrade_succeeded']:
upgrade['error'] = True
return upgrade
def main():
argument_spec = dict(
system_image_file=dict(required=True),
kickstart_image_file=dict(required=False),
issu=dict(choices=['required', 'desired', 'no', 'yes'], default='no'),
)
argument_spec.update(nxos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
warnings = list()
check_args(module, warnings)
# Get system_image_file(sif), kickstart_image_file(kif) and
# issu settings from module params.
sif = module.params['system_image_file']
kif = module.params['kickstart_image_file']
issu = module.params['issu']
if kif == 'null' or kif == '':
kif = None
install_result = do_install_all(module, issu, sif, kick=kif)
if install_result['error']:
msg = "Failed to upgrade device using image "
if kif:
msg = msg + "files: kickstart: %s, system: %s" % (kif, sif)
else:
msg = msg + "file: system: %s" % sif
module.fail_json(msg=msg, raw_data=install_result['list_data'])
state = install_result['processed']
changed = install_result['upgrade_needed']
module.exit_json(changed=changed, install_state=state, warnings=warnings)
if __name__ == '__main__':
main()
| gpl-3.0 |
tomours/dolibarr | htdocs/compta/paiement_charge.php | 10955 | <?php
/* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2016 Frédéric France <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/paiement_charge.php
* \ingroup tax
* \brief Page to add payment of a tax
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("bills");
$chid=GETPOST("id", 'int');
$action=GETPOST('action', 'alpha');
$amounts = array();
// Security check
$socid=0;
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
}
/*
* Actions
*/
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes'))
{
$error=0;
if ($_POST["cancel"])
{
$loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid;
header("Location: ".$loc);
exit;
}
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
if (! $_POST["paiementtype"] > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
$action = 'create';
}
if ($datepaye == '')
{
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")), null, 'errors');
$error++;
$action = 'create';
}
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
$action = 'create';
}
if (! $error)
{
$paymentid = 0;
// Read possible payments
foreach ($_POST as $key => $value)
{
if (substr($key,0,7) == 'amount_')
{
$other_chid = substr($key,7);
$amounts[$other_chid] = price2num($_POST[$key]);
}
}
if (count($amounts) <= 0)
{
$error++;
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
$action='create';
}
if (! $error)
{
$db->begin();
// Create a line of payments
$paiement = new PaymentSocialContribution($db);
$paiement->chid = $chid;
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Tableau de montant
$paiement->paiementtype = $_POST["paiementtype"];
$paiement->num_paiement = $_POST["num_paiement"];
$paiement->note = $_POST["note"];
if (! $error)
{
$paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0));
if ($paymentid < 0)
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action='create';
}
}
if (! $error)
{
$result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)', GETPOST('accountid','int'),'','');
if (! ($result > 0))
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action='create';
}
}
if (! $error)
{
$db->commit();
$loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid;
header('Location: '.$loc);
exit;
}
else
{
$db->rollback();
}
}
}
}
/*
* View
*/
llxHeader();
$form=new Form($db);
// Formulaire de creation d'un paiement de charge
if ($action == 'create')
{
$charge = new ChargeSociales($db);
$charge->fetch($chid);
$charge->accountid=$charge->fk_account?$charge->fk_account:$charge->accountid;
$charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype;
$total = $charge->amount;
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
//Add js for AutoFill
print ' $(document).ready(function () {';
print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
var amount = $(this).data("value");
document.getElementById($(this).data(\'rowid\')).value = amount ;
});';
print ' });'."\n";
print ' </script>'."\n";
}
print load_fiche_titre($langs->trans("DoPayment"));
print "<br>\n";
if ($mesg)
{
print "<div class=\"error\">$mesg</div>";
}
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$chid.'">';
print '<input type="hidden" name="chid" value="'.$chid.'">';
print '<input type="hidden" name="action" value="add_payment">';
dol_fiche_head('', '');
print '<table class="border" width="100%">';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
$sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
$sql.= " WHERE p.fk_charge = ".$chid;
$resql = $db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
}
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
$form->select_date($datepayment,'','','','',"add_payment",1,1);
print "</td>";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype");
print "</td>\n";
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list
print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';
dol_fiche_end();
/*
* Autres charges impayees
*/
$num = 1;
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
//print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td align="left">'.$langs->trans("DateDue").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td align="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td align="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td align="center">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
$var=true;
$total=0;
$totalrecu=0;
while ($i < $num)
{
$objp = $charge;
print '<tr class="oddeven">';
if ($objp->date_ech > 0)
{
print "<td align=\"left\">".dol_print_date($objp->date_ech,'day')."</td>\n";
}
else
{
print "<td align=\"center\"><b>!!!</b></td>\n";
}
print '<td align="right">'.price($objp->amount)."</td>";
print '<td align="right">'.price($sumpaid)."</td>";
print '<td align="right">'.price($objp->amount - $sumpaid)."</td>";
print '<td align="center">';
if ($sumpaid < $objp->amount)
{
$namef = "amount_".$objp->id;
$nameRemain = "remain_".$objp->id;
if (!empty($conf->use_javascript_ajax))
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
$remaintopay=$objp->amount - $sumpaid;
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">';
}
else
{
print '-';
}
print "</td>";
print "</tr>\n";
$total+=$objp->total;
$total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am;
$i++;
}
if ($i > 1)
{
// Print total
print "<tr ".$bc[!$var].">";
print '<td colspan="2" align="left">'.$langs->trans("Total").':</td>';
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
print "<td align=\"right\"><b>".price($total_ttc - $totalrecu)."</b></td>";
print '<td align="center"> </td>';
print "</tr>\n";
}
print "</table>";
// Bouton Save payment
print '<br><div class="center"><input type="checkbox" checked name="closepaidcontrib"> '.$langs->trans("ClosePaidContributionsAutomatically");
print '<br><input type="submit" class="button" name="save" value="'.$langs->trans('ToMakePayment').'">';
print ' ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
}
llxFooter();
$db->close();
| gpl-3.0 |
fqez/JdeRobot | src/libs/comm_py/comm/ice/navdataIceClient.py | 4847 | #
# Copyright (C) 1997-2016 JDE Developers Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# Authors :
# Aitor Martinez Fernandez <[email protected]>
#
import traceback
import jderobot
import threading
import Ice
from .threadSensor import ThreadSensor
from jderobotTypes import NavdataData
class NavData:
def __init__(self, jdrc, prefix):
self.lock = threading.Lock()
try:
ic = jdrc.getIc()
proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy")
base = ic.stringToProxy(proxyStr)
self.proxy = jderobot.NavdataPrx.checkedCast(base)
self.navData = NavdataData()
self.update()
if not self.proxy:
print ('Interface ' + prefix + ' not configured')
except Ice.ConnectionRefusedException:
print(prefix + ': connection refused')
except:
traceback.print_exc()
exit(-1)
def update(self):
if self.hasproxy():
localNavdata = self.proxy.getNavdata()
navdataData = NavdataData()
navdataData.vehicle = localNavdata.vehicle
navdataData.state = localNavdata.state
navdataData.batteryPercent = localNavdata.batteryPercent
navdataData.magX = localNavdata.magX
navdataData.magY = localNavdata.magY
navdataData.magZ = localNavdata.magZ
navdataData.pressure = localNavdata.pressure
navdataData.temp = localNavdata.temp
navdataData.windSpeed = localNavdata.windSpeed
navdataData.windAngle = localNavdata.windAngle
navdataData.windCompAngle = localNavdata.windCompAngle
navdataData.rotX = localNavdata.rotX
navdataData.rotY = localNavdata.rotY
navdataData.rotZ = localNavdata.rotZ
navdataData.altd = localNavdata.altd
navdataData.vx = localNavdata.vx
navdataData.vy = localNavdata.vy
navdataData.vz = localNavdata.vz
navdataData.ax = localNavdata.ax
navdataData.ay = localNavdata.ay
navdataData.az = localNavdata.az
navdataData.tagsCount = localNavdata.tagsCount
navdataData.tagsType = localNavdata.tagsType
navdataData.tagsXc = localNavdata.tagsXc
navdataData.tagsYc = localNavdata.tagsYc
navdataData.tagsWidth = localNavdata.tagsWidth
navdataData.tagsHeight = localNavdata.tagsHeight
navdataData.tagsOrientation = localNavdata.tagsOrientation
navdataData.tagsDistance = localNavdata.tagsDistance
navdataData.timeStamp = localNavdata.tm
self.lock.acquire()
self.navData = navdataData
self.lock.release()
def hasproxy (self):
'''
Returns if proxy has ben created or not.
@return if proxy has ben created or not (Boolean)
'''
return hasattr(self,"proxy") and self.proxy
def getNavdata(self):
if self.hasproxy():
self.lock.acquire()
navData = self.navData
self.lock.release()
return navData
return None
class NavdataIceClient:
def __init__(self,ic,prefix, start = False):
self.navdata = NavData(ic,prefix)
self.kill_event = threading.Event()
self.thread = ThreadSensor(self.navdata, self.kill_event)
self.thread.daemon = True
if start:
self.start()
def start(self):
'''
Starts the client. If client is stopped you can not start again, Threading.Thread raised error
'''
self.kill_event.clear()
self.thread.start()
def stop(self):
'''
Stops the client. If client is stopped you can not start again, Threading.Thread raised error
'''
self.kill_event.set()
def getNavData(self):
return self.navdata.getNavdata()
def hasproxy (self):
'''
Returns if proxy has ben created or not.
@return if proxy has ben created or not (Boolean)
'''
return self.navdata.hasproxy() | gpl-3.0 |
Yukarumya/Yukarum-Redfoxes | security/nss/gtests/util_gtest/util_utf8_unittest.cc | 39251 | // -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vim: set ts=2 et sw=2 tw=80:
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
#include "secport.h"
#include "gtest/gtest.h"
#include "prnetdb.h"
#include <stdint.h>
#include <string.h>
#include <string>
namespace nss_test {
// Structures to represent test cases. These are small enough that
// passing by value isn't a problem.
struct Ucs4Case {
PRUint32 c;
const char *utf8;
};
struct Ucs2Case {
PRUint16 c;
const char *utf8;
};
struct Utf16Case {
PRUint32 c;
PRUint16 w[2];
};
struct Utf16BadCase {
PRUint16 w[3];
};
// Test classes for parameterized tests:
class Ucs4Test : public ::testing::TestWithParam<Ucs4Case> {};
class Ucs2Test : public ::testing::TestWithParam<Ucs2Case> {};
class Utf16Test : public ::testing::TestWithParam<Utf16Case> {};
class BadUtf8Test : public ::testing::TestWithParam<const char *> {};
class BadUtf16Test : public ::testing::TestWithParam<Utf16BadCase> {};
class Iso88591Test : public ::testing::TestWithParam<Ucs2Case> {};
// Tests of sec_port_ucs4_utf8_conversion_function, by itself, on
// valid inputs:
TEST_P(Ucs4Test, ToUtf8) {
const Ucs4Case testCase = GetParam();
PRUint32 nc = PR_htonl(testCase.c);
unsigned char utf8[8] = {0};
unsigned int len = 0;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_FALSE, (unsigned char *)&nc, sizeof(nc), utf8, sizeof(utf8), &len);
ASSERT_TRUE(result);
ASSERT_LT(len, sizeof(utf8));
EXPECT_EQ(std::string(testCase.utf8), std::string((char *)utf8, len));
EXPECT_EQ('\0', utf8[len]);
}
TEST_P(Ucs4Test, FromUtf8) {
const Ucs4Case testCase = GetParam();
PRUint32 nc;
unsigned int len = 0;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_TRUE, (unsigned char *)testCase.utf8, strlen(testCase.utf8),
(unsigned char *)&nc, sizeof(nc), &len);
ASSERT_TRUE(result);
ASSERT_EQ(sizeof(nc), len);
EXPECT_EQ(testCase.c, PR_ntohl(nc));
}
TEST_P(Ucs4Test, DestTooSmall) {
const Ucs4Case testCase = GetParam();
PRUint32 nc = PR_htonl(testCase.c);
unsigned char utf8[8];
unsigned char *utf8end = utf8 + sizeof(utf8);
unsigned int len = strlen(testCase.utf8) - 1;
ASSERT_LE(len, sizeof(utf8));
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_FALSE, (unsigned char *)&nc, sizeof(nc), utf8end - len, len, &len);
ASSERT_FALSE(result);
ASSERT_EQ(strlen(testCase.utf8), len);
}
// Tests of sec_port_ucs2_utf8_conversion_function, by itself, on
// valid inputs:
TEST_P(Ucs2Test, ToUtf8) {
const Ucs2Case testCase = GetParam();
PRUint16 nc = PR_htons(testCase.c);
unsigned char utf8[8] = {0};
unsigned int len = 0;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)&nc, sizeof(nc), utf8, sizeof(utf8), &len);
ASSERT_TRUE(result);
ASSERT_LT(len, sizeof(utf8));
EXPECT_EQ(std::string(testCase.utf8), std::string((char *)utf8, len));
EXPECT_EQ('\0', utf8[len]);
}
TEST_P(Ucs2Test, FromUtf8) {
const Ucs2Case testCase = GetParam();
PRUint16 nc;
unsigned int len = 0;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_TRUE, (unsigned char *)testCase.utf8, strlen(testCase.utf8),
(unsigned char *)&nc, sizeof(nc), &len);
ASSERT_EQ(PR_TRUE, result);
ASSERT_EQ(sizeof(nc), len);
EXPECT_EQ(testCase.c, PR_ntohs(nc));
}
TEST_P(Ucs2Test, DestTooSmall) {
const Ucs2Case testCase = GetParam();
PRUint16 nc = PR_htons(testCase.c);
unsigned char utf8[8];
unsigned char *utf8end = utf8 + sizeof(utf8);
unsigned int len = strlen(testCase.utf8) - 1;
ASSERT_LE(len, sizeof(utf8));
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)&nc, sizeof(nc), utf8end - len, len, &len);
ASSERT_EQ(result, PR_FALSE);
ASSERT_EQ(strlen(testCase.utf8), len);
}
// Tests using UTF-16 and UCS-4 conversion together:
TEST_P(Utf16Test, From16To32) {
const Utf16Case testCase = GetParam();
PRUint16 from[2] = {PR_htons(testCase.w[0]), PR_htons(testCase.w[1])};
PRUint32 to;
unsigned char utf8[8];
unsigned int len = 0;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from, sizeof(from), utf8, sizeof(utf8), &len);
ASSERT_EQ(PR_TRUE, result);
result = sec_port_ucs4_utf8_conversion_function(
PR_TRUE, utf8, len, (unsigned char *)&to, sizeof(to), &len);
ASSERT_EQ(PR_TRUE, result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(testCase.c, PR_ntohl(to));
}
TEST_P(Utf16Test, From32To16) {
const Utf16Case testCase = GetParam();
PRUint32 from = PR_htonl(testCase.c);
unsigned char utf8[8];
unsigned int len = 0;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from, sizeof(from), utf8, sizeof(utf8), &len);
ASSERT_EQ(PR_TRUE, result);
const std::string utf8copy((char *)utf8, len);
PRUint16 to[2];
result = sec_port_ucs2_utf8_conversion_function(
PR_TRUE, utf8, len, (unsigned char *)&to, sizeof(to), &len);
ASSERT_EQ(PR_TRUE, result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(testCase.w[0], PR_ntohs(to[0]));
EXPECT_EQ(testCase.w[1], PR_ntohs(to[1]));
}
TEST_P(Utf16Test, SameUtf8) {
const Utf16Case testCase = GetParam();
PRUint32 from32 = PR_htonl(testCase.c);
unsigned char utf8from32[8];
unsigned int lenFrom32 = 0;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from32, sizeof(from32), utf8from32,
sizeof(utf8from32), &lenFrom32);
ASSERT_TRUE(result);
ASSERT_LE(lenFrom32, sizeof(utf8from32));
PRUint16 from16[2] = {PR_htons(testCase.w[0]), PR_htons(testCase.w[1])};
unsigned char utf8from16[8];
unsigned int lenFrom16 = 0;
result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from16, sizeof(from16), utf8from16,
sizeof(utf8from16), &lenFrom16);
ASSERT_TRUE(result);
ASSERT_LE(lenFrom16, sizeof(utf8from16));
EXPECT_EQ(std::string((char *)utf8from32, lenFrom32),
std::string((char *)utf8from16, lenFrom16));
}
// Tests of invalid UTF-8 input:
TEST_P(BadUtf8Test, HasNoUcs2) {
const char *const utf8 = GetParam();
unsigned char destBuf[30];
unsigned int len = 0;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_TRUE, (unsigned char *)utf8, strlen(utf8), destBuf, sizeof(destBuf),
&len);
EXPECT_FALSE(result);
}
TEST_P(BadUtf8Test, HasNoUcs4) {
const char *const utf8 = GetParam();
unsigned char destBuf[30];
unsigned int len = 0;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_TRUE, (unsigned char *)utf8, strlen(utf8), destBuf, sizeof(destBuf),
&len);
EXPECT_FALSE(result);
}
// Tests of invalid UTF-16 input:
TEST_P(BadUtf16Test, HasNoUtf8) {
const Utf16BadCase testCase = GetParam();
Utf16BadCase srcBuf;
unsigned int len;
static const size_t maxLen = PR_ARRAY_SIZE(srcBuf.w);
size_t srcLen = 0;
while (testCase.w[srcLen] != 0) {
srcBuf.w[srcLen] = PR_htons(testCase.w[srcLen]);
srcLen++;
ASSERT_LT(srcLen, maxLen);
}
unsigned char destBuf[18];
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)srcBuf.w, srcLen * sizeof(PRUint16), destBuf,
sizeof(destBuf), &len);
EXPECT_FALSE(result);
}
// Tests of sec_port_iso88591_utf8_conversion_function on valid inputs:
TEST_P(Iso88591Test, ToUtf8) {
const Ucs2Case testCase = GetParam();
unsigned char iso88591 = testCase.c;
unsigned char utf8[3] = {0};
unsigned int len = 0;
ASSERT_EQ(testCase.c, (PRUint16)iso88591);
PRBool result = sec_port_iso88591_utf8_conversion_function(
&iso88591, 1, utf8, sizeof(utf8), &len);
ASSERT_TRUE(result);
ASSERT_LT(len, sizeof(utf8));
EXPECT_EQ(std::string(testCase.utf8), std::string((char *)utf8, len));
EXPECT_EQ(0U, utf8[len]);
}
// Tests for the various representations of NUL (which the above
// NUL-terminated test cases omitted):
TEST(Utf8Zeroes, From32To8) {
unsigned int len;
PRUint32 from = 0;
unsigned char to;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from, sizeof(from), &to, sizeof(to), &len);
ASSERT_TRUE(result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(0U, to);
}
TEST(Utf8Zeroes, From16To8) {
unsigned int len;
PRUint16 from = 0;
unsigned char to;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_FALSE, (unsigned char *)&from, sizeof(from), &to, sizeof(to), &len);
ASSERT_TRUE(result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(0U, to);
}
TEST(Utf8Zeroes, From8To32) {
unsigned int len;
unsigned char from = 0;
PRUint32 to;
PRBool result = sec_port_ucs4_utf8_conversion_function(
PR_TRUE, &from, sizeof(from), (unsigned char *)&to, sizeof(to), &len);
ASSERT_TRUE(result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(0U, to);
}
TEST(Utf8Zeroes, From8To16) {
unsigned int len;
unsigned char from = 0;
PRUint16 to;
PRBool result = sec_port_ucs2_utf8_conversion_function(
PR_TRUE, &from, sizeof(from), (unsigned char *)&to, sizeof(to), &len);
ASSERT_TRUE(result);
ASSERT_EQ(sizeof(to), len);
EXPECT_EQ(0U, to);
}
// UCS-4 <-> UTF-8 cases
const Ucs4Case kUcs4Cases[] = {
{0x00000001, "\x01"},
{0x00000002, "\x02"},
{0x00000003, "\x03"},
{0x00000004, "\x04"},
{0x00000007, "\x07"},
{0x00000008, "\x08"},
{0x0000000F, "\x0F"},
{0x00000010, "\x10"},
{0x0000001F, "\x1F"},
{0x00000020, "\x20"},
{0x0000003F, "\x3F"},
{0x00000040, "\x40"},
{0x0000007F, "\x7F"},
{0x00000080, "\xC2\x80"},
{0x00000081, "\xC2\x81"},
{0x00000082, "\xC2\x82"},
{0x00000084, "\xC2\x84"},
{0x00000088, "\xC2\x88"},
{0x00000090, "\xC2\x90"},
{0x000000A0, "\xC2\xA0"},
{0x000000C0, "\xC3\x80"},
{0x000000FF, "\xC3\xBF"},
{0x00000100, "\xC4\x80"},
{0x00000101, "\xC4\x81"},
{0x00000102, "\xC4\x82"},
{0x00000104, "\xC4\x84"},
{0x00000108, "\xC4\x88"},
{0x00000110, "\xC4\x90"},
{0x00000120, "\xC4\xA0"},
{0x00000140, "\xC5\x80"},
{0x00000180, "\xC6\x80"},
{0x000001FF, "\xC7\xBF"},
{0x00000200, "\xC8\x80"},
{0x00000201, "\xC8\x81"},
{0x00000202, "\xC8\x82"},
{0x00000204, "\xC8\x84"},
{0x00000208, "\xC8\x88"},
{0x00000210, "\xC8\x90"},
{0x00000220, "\xC8\xA0"},
{0x00000240, "\xC9\x80"},
{0x00000280, "\xCA\x80"},
{0x00000300, "\xCC\x80"},
{0x000003FF, "\xCF\xBF"},
{0x00000400, "\xD0\x80"},
{0x00000401, "\xD0\x81"},
{0x00000402, "\xD0\x82"},
{0x00000404, "\xD0\x84"},
{0x00000408, "\xD0\x88"},
{0x00000410, "\xD0\x90"},
{0x00000420, "\xD0\xA0"},
{0x00000440, "\xD1\x80"},
{0x00000480, "\xD2\x80"},
{0x00000500, "\xD4\x80"},
{0x00000600, "\xD8\x80"},
{0x000007FF, "\xDF\xBF"},
{0x00000800, "\xE0\xA0\x80"},
{0x00000801, "\xE0\xA0\x81"},
{0x00000802, "\xE0\xA0\x82"},
{0x00000804, "\xE0\xA0\x84"},
{0x00000808, "\xE0\xA0\x88"},
{0x00000810, "\xE0\xA0\x90"},
{0x00000820, "\xE0\xA0\xA0"},
{0x00000840, "\xE0\xA1\x80"},
{0x00000880, "\xE0\xA2\x80"},
{0x00000900, "\xE0\xA4\x80"},
{0x00000A00, "\xE0\xA8\x80"},
{0x00000C00, "\xE0\xB0\x80"},
{0x00000FFF, "\xE0\xBF\xBF"},
{0x00001000, "\xE1\x80\x80"},
{0x00001001, "\xE1\x80\x81"},
{0x00001002, "\xE1\x80\x82"},
{0x00001004, "\xE1\x80\x84"},
{0x00001008, "\xE1\x80\x88"},
{0x00001010, "\xE1\x80\x90"},
{0x00001020, "\xE1\x80\xA0"},
{0x00001040, "\xE1\x81\x80"},
{0x00001080, "\xE1\x82\x80"},
{0x00001100, "\xE1\x84\x80"},
{0x00001200, "\xE1\x88\x80"},
{0x00001400, "\xE1\x90\x80"},
{0x00001800, "\xE1\xA0\x80"},
{0x00001FFF, "\xE1\xBF\xBF"},
{0x00002000, "\xE2\x80\x80"},
{0x00002001, "\xE2\x80\x81"},
{0x00002002, "\xE2\x80\x82"},
{0x00002004, "\xE2\x80\x84"},
{0x00002008, "\xE2\x80\x88"},
{0x00002010, "\xE2\x80\x90"},
{0x00002020, "\xE2\x80\xA0"},
{0x00002040, "\xE2\x81\x80"},
{0x00002080, "\xE2\x82\x80"},
{0x00002100, "\xE2\x84\x80"},
{0x00002200, "\xE2\x88\x80"},
{0x00002400, "\xE2\x90\x80"},
{0x00002800, "\xE2\xA0\x80"},
{0x00003000, "\xE3\x80\x80"},
{0x00003FFF, "\xE3\xBF\xBF"},
{0x00004000, "\xE4\x80\x80"},
{0x00004001, "\xE4\x80\x81"},
{0x00004002, "\xE4\x80\x82"},
{0x00004004, "\xE4\x80\x84"},
{0x00004008, "\xE4\x80\x88"},
{0x00004010, "\xE4\x80\x90"},
{0x00004020, "\xE4\x80\xA0"},
{0x00004040, "\xE4\x81\x80"},
{0x00004080, "\xE4\x82\x80"},
{0x00004100, "\xE4\x84\x80"},
{0x00004200, "\xE4\x88\x80"},
{0x00004400, "\xE4\x90\x80"},
{0x00004800, "\xE4\xA0\x80"},
{0x00005000, "\xE5\x80\x80"},
{0x00006000, "\xE6\x80\x80"},
{0x00007FFF, "\xE7\xBF\xBF"},
{0x00008000, "\xE8\x80\x80"},
{0x00008001, "\xE8\x80\x81"},
{0x00008002, "\xE8\x80\x82"},
{0x00008004, "\xE8\x80\x84"},
{0x00008008, "\xE8\x80\x88"},
{0x00008010, "\xE8\x80\x90"},
{0x00008020, "\xE8\x80\xA0"},
{0x00008040, "\xE8\x81\x80"},
{0x00008080, "\xE8\x82\x80"},
{0x00008100, "\xE8\x84\x80"},
{0x00008200, "\xE8\x88\x80"},
{0x00008400, "\xE8\x90\x80"},
{0x00008800, "\xE8\xA0\x80"},
{0x00009000, "\xE9\x80\x80"},
{0x0000A000, "\xEA\x80\x80"},
{0x0000C000, "\xEC\x80\x80"},
{0x0000FFFF, "\xEF\xBF\xBF"},
{0x00010000, "\xF0\x90\x80\x80"},
{0x00010001, "\xF0\x90\x80\x81"},
{0x00010002, "\xF0\x90\x80\x82"},
{0x00010004, "\xF0\x90\x80\x84"},
{0x00010008, "\xF0\x90\x80\x88"},
{0x00010010, "\xF0\x90\x80\x90"},
{0x00010020, "\xF0\x90\x80\xA0"},
{0x00010040, "\xF0\x90\x81\x80"},
{0x00010080, "\xF0\x90\x82\x80"},
{0x00010100, "\xF0\x90\x84\x80"},
{0x00010200, "\xF0\x90\x88\x80"},
{0x00010400, "\xF0\x90\x90\x80"},
{0x00010800, "\xF0\x90\xA0\x80"},
{0x00011000, "\xF0\x91\x80\x80"},
{0x00012000, "\xF0\x92\x80\x80"},
{0x00014000, "\xF0\x94\x80\x80"},
{0x00018000, "\xF0\x98\x80\x80"},
{0x0001FFFF, "\xF0\x9F\xBF\xBF"},
{0x00020000, "\xF0\xA0\x80\x80"},
{0x00020001, "\xF0\xA0\x80\x81"},
{0x00020002, "\xF0\xA0\x80\x82"},
{0x00020004, "\xF0\xA0\x80\x84"},
{0x00020008, "\xF0\xA0\x80\x88"},
{0x00020010, "\xF0\xA0\x80\x90"},
{0x00020020, "\xF0\xA0\x80\xA0"},
{0x00020040, "\xF0\xA0\x81\x80"},
{0x00020080, "\xF0\xA0\x82\x80"},
{0x00020100, "\xF0\xA0\x84\x80"},
{0x00020200, "\xF0\xA0\x88\x80"},
{0x00020400, "\xF0\xA0\x90\x80"},
{0x00020800, "\xF0\xA0\xA0\x80"},
{0x00021000, "\xF0\xA1\x80\x80"},
{0x00022000, "\xF0\xA2\x80\x80"},
{0x00024000, "\xF0\xA4\x80\x80"},
{0x00028000, "\xF0\xA8\x80\x80"},
{0x00030000, "\xF0\xB0\x80\x80"},
{0x0003FFFF, "\xF0\xBF\xBF\xBF"},
{0x00040000, "\xF1\x80\x80\x80"},
{0x00040001, "\xF1\x80\x80\x81"},
{0x00040002, "\xF1\x80\x80\x82"},
{0x00040004, "\xF1\x80\x80\x84"},
{0x00040008, "\xF1\x80\x80\x88"},
{0x00040010, "\xF1\x80\x80\x90"},
{0x00040020, "\xF1\x80\x80\xA0"},
{0x00040040, "\xF1\x80\x81\x80"},
{0x00040080, "\xF1\x80\x82\x80"},
{0x00040100, "\xF1\x80\x84\x80"},
{0x00040200, "\xF1\x80\x88\x80"},
{0x00040400, "\xF1\x80\x90\x80"},
{0x00040800, "\xF1\x80\xA0\x80"},
{0x00041000, "\xF1\x81\x80\x80"},
{0x00042000, "\xF1\x82\x80\x80"},
{0x00044000, "\xF1\x84\x80\x80"},
{0x00048000, "\xF1\x88\x80\x80"},
{0x00050000, "\xF1\x90\x80\x80"},
{0x00060000, "\xF1\xA0\x80\x80"},
{0x0007FFFF, "\xF1\xBF\xBF\xBF"},
{0x00080000, "\xF2\x80\x80\x80"},
{0x00080001, "\xF2\x80\x80\x81"},
{0x00080002, "\xF2\x80\x80\x82"},
{0x00080004, "\xF2\x80\x80\x84"},
{0x00080008, "\xF2\x80\x80\x88"},
{0x00080010, "\xF2\x80\x80\x90"},
{0x00080020, "\xF2\x80\x80\xA0"},
{0x00080040, "\xF2\x80\x81\x80"},
{0x00080080, "\xF2\x80\x82\x80"},
{0x00080100, "\xF2\x80\x84\x80"},
{0x00080200, "\xF2\x80\x88\x80"},
{0x00080400, "\xF2\x80\x90\x80"},
{0x00080800, "\xF2\x80\xA0\x80"},
{0x00081000, "\xF2\x81\x80\x80"},
{0x00082000, "\xF2\x82\x80\x80"},
{0x00084000, "\xF2\x84\x80\x80"},
{0x00088000, "\xF2\x88\x80\x80"},
{0x00090000, "\xF2\x90\x80\x80"},
{0x000A0000, "\xF2\xA0\x80\x80"},
{0x000C0000, "\xF3\x80\x80\x80"},
{0x000FFFFF, "\xF3\xBF\xBF\xBF"},
{0x00100000, "\xF4\x80\x80\x80"},
{0x00100001, "\xF4\x80\x80\x81"},
{0x00100002, "\xF4\x80\x80\x82"},
{0x00100004, "\xF4\x80\x80\x84"},
{0x00100008, "\xF4\x80\x80\x88"},
{0x00100010, "\xF4\x80\x80\x90"},
{0x00100020, "\xF4\x80\x80\xA0"},
{0x00100040, "\xF4\x80\x81\x80"},
{0x00100080, "\xF4\x80\x82\x80"},
{0x00100100, "\xF4\x80\x84\x80"},
{0x00100200, "\xF4\x80\x88\x80"},
{0x00100400, "\xF4\x80\x90\x80"},
{0x00100800, "\xF4\x80\xA0\x80"},
{0x00101000, "\xF4\x81\x80\x80"},
{0x00102000, "\xF4\x82\x80\x80"},
{0x00104000, "\xF4\x84\x80\x80"},
{0x00108000, "\xF4\x88\x80\x80"},
{0x0010FFFF, "\xF4\x8F\xBF\xBF"},
};
// UCS-2 <-> UTF-8 cases (divided into ISO-8859-1 vs. not).
const Ucs2Case kIso88591Cases[] = {
{0x0001, "\x01"}, {0x0002, "\x02"}, {0x0003, "\x03"},
{0x0004, "\x04"}, {0x0007, "\x07"}, {0x0008, "\x08"},
{0x000F, "\x0F"}, {0x0010, "\x10"}, {0x001F, "\x1F"},
{0x0020, "\x20"}, {0x003F, "\x3F"}, {0x0040, "\x40"},
{0x007F, "\x7F"},
{0x0080, "\xC2\x80"}, {0x0081, "\xC2\x81"}, {0x0082, "\xC2\x82"},
{0x0084, "\xC2\x84"}, {0x0088, "\xC2\x88"}, {0x0090, "\xC2\x90"},
{0x00A0, "\xC2\xA0"}, {0x00C0, "\xC3\x80"}, {0x00FF, "\xC3\xBF"},
};
const Ucs2Case kUcs2Cases[] = {
{0x0100, "\xC4\x80"}, {0x0101, "\xC4\x81"},
{0x0102, "\xC4\x82"}, {0x0104, "\xC4\x84"},
{0x0108, "\xC4\x88"}, {0x0110, "\xC4\x90"},
{0x0120, "\xC4\xA0"}, {0x0140, "\xC5\x80"},
{0x0180, "\xC6\x80"}, {0x01FF, "\xC7\xBF"},
{0x0200, "\xC8\x80"}, {0x0201, "\xC8\x81"},
{0x0202, "\xC8\x82"}, {0x0204, "\xC8\x84"},
{0x0208, "\xC8\x88"}, {0x0210, "\xC8\x90"},
{0x0220, "\xC8\xA0"}, {0x0240, "\xC9\x80"},
{0x0280, "\xCA\x80"}, {0x0300, "\xCC\x80"},
{0x03FF, "\xCF\xBF"}, {0x0400, "\xD0\x80"},
{0x0401, "\xD0\x81"}, {0x0402, "\xD0\x82"},
{0x0404, "\xD0\x84"}, {0x0408, "\xD0\x88"},
{0x0410, "\xD0\x90"}, {0x0420, "\xD0\xA0"},
{0x0440, "\xD1\x80"}, {0x0480, "\xD2\x80"},
{0x0500, "\xD4\x80"}, {0x0600, "\xD8\x80"},
{0x07FF, "\xDF\xBF"},
{0x0800, "\xE0\xA0\x80"}, {0x0801, "\xE0\xA0\x81"},
{0x0802, "\xE0\xA0\x82"}, {0x0804, "\xE0\xA0\x84"},
{0x0808, "\xE0\xA0\x88"}, {0x0810, "\xE0\xA0\x90"},
{0x0820, "\xE0\xA0\xA0"}, {0x0840, "\xE0\xA1\x80"},
{0x0880, "\xE0\xA2\x80"}, {0x0900, "\xE0\xA4\x80"},
{0x0A00, "\xE0\xA8\x80"}, {0x0C00, "\xE0\xB0\x80"},
{0x0FFF, "\xE0\xBF\xBF"}, {0x1000, "\xE1\x80\x80"},
{0x1001, "\xE1\x80\x81"}, {0x1002, "\xE1\x80\x82"},
{0x1004, "\xE1\x80\x84"}, {0x1008, "\xE1\x80\x88"},
{0x1010, "\xE1\x80\x90"}, {0x1020, "\xE1\x80\xA0"},
{0x1040, "\xE1\x81\x80"}, {0x1080, "\xE1\x82\x80"},
{0x1100, "\xE1\x84\x80"}, {0x1200, "\xE1\x88\x80"},
{0x1400, "\xE1\x90\x80"}, {0x1800, "\xE1\xA0\x80"},
{0x1FFF, "\xE1\xBF\xBF"}, {0x2000, "\xE2\x80\x80"},
{0x2001, "\xE2\x80\x81"}, {0x2002, "\xE2\x80\x82"},
{0x2004, "\xE2\x80\x84"}, {0x2008, "\xE2\x80\x88"},
{0x2010, "\xE2\x80\x90"}, {0x2020, "\xE2\x80\xA0"},
{0x2040, "\xE2\x81\x80"}, {0x2080, "\xE2\x82\x80"},
{0x2100, "\xE2\x84\x80"}, {0x2200, "\xE2\x88\x80"},
{0x2400, "\xE2\x90\x80"}, {0x2800, "\xE2\xA0\x80"},
{0x3000, "\xE3\x80\x80"}, {0x3FFF, "\xE3\xBF\xBF"},
{0x4000, "\xE4\x80\x80"}, {0x4001, "\xE4\x80\x81"},
{0x4002, "\xE4\x80\x82"}, {0x4004, "\xE4\x80\x84"},
{0x4008, "\xE4\x80\x88"}, {0x4010, "\xE4\x80\x90"},
{0x4020, "\xE4\x80\xA0"}, {0x4040, "\xE4\x81\x80"},
{0x4080, "\xE4\x82\x80"}, {0x4100, "\xE4\x84\x80"},
{0x4200, "\xE4\x88\x80"}, {0x4400, "\xE4\x90\x80"},
{0x4800, "\xE4\xA0\x80"}, {0x5000, "\xE5\x80\x80"},
{0x6000, "\xE6\x80\x80"}, {0x7FFF, "\xE7\xBF\xBF"},
{0x8000, "\xE8\x80\x80"}, {0x8001, "\xE8\x80\x81"},
{0x8002, "\xE8\x80\x82"}, {0x8004, "\xE8\x80\x84"},
{0x8008, "\xE8\x80\x88"}, {0x8010, "\xE8\x80\x90"},
{0x8020, "\xE8\x80\xA0"}, {0x8040, "\xE8\x81\x80"},
{0x8080, "\xE8\x82\x80"}, {0x8100, "\xE8\x84\x80"},
{0x8200, "\xE8\x88\x80"}, {0x8400, "\xE8\x90\x80"},
{0x8800, "\xE8\xA0\x80"}, {0x9000, "\xE9\x80\x80"},
{0xA000, "\xEA\x80\x80"}, {0xC000, "\xEC\x80\x80"},
{0xFB01, "\xEF\xAC\x81"}, {0xFFFF, "\xEF\xBF\xBF"}};
// UTF-16 <-> UCS-4 cases
const Utf16Case kUtf16Cases[] = {{0x00010000, {0xD800, 0xDC00}},
{0x00010001, {0xD800, 0xDC01}},
{0x00010002, {0xD800, 0xDC02}},
{0x00010003, {0xD800, 0xDC03}},
{0x00010004, {0xD800, 0xDC04}},
{0x00010007, {0xD800, 0xDC07}},
{0x00010008, {0xD800, 0xDC08}},
{0x0001000F, {0xD800, 0xDC0F}},
{0x00010010, {0xD800, 0xDC10}},
{0x0001001F, {0xD800, 0xDC1F}},
{0x00010020, {0xD800, 0xDC20}},
{0x0001003F, {0xD800, 0xDC3F}},
{0x00010040, {0xD800, 0xDC40}},
{0x0001007F, {0xD800, 0xDC7F}},
{0x00010080, {0xD800, 0xDC80}},
{0x00010081, {0xD800, 0xDC81}},
{0x00010082, {0xD800, 0xDC82}},
{0x00010084, {0xD800, 0xDC84}},
{0x00010088, {0xD800, 0xDC88}},
{0x00010090, {0xD800, 0xDC90}},
{0x000100A0, {0xD800, 0xDCA0}},
{0x000100C0, {0xD800, 0xDCC0}},
{0x000100FF, {0xD800, 0xDCFF}},
{0x00010100, {0xD800, 0xDD00}},
{0x00010101, {0xD800, 0xDD01}},
{0x00010102, {0xD800, 0xDD02}},
{0x00010104, {0xD800, 0xDD04}},
{0x00010108, {0xD800, 0xDD08}},
{0x00010110, {0xD800, 0xDD10}},
{0x00010120, {0xD800, 0xDD20}},
{0x00010140, {0xD800, 0xDD40}},
{0x00010180, {0xD800, 0xDD80}},
{0x000101FF, {0xD800, 0xDDFF}},
{0x00010200, {0xD800, 0xDE00}},
{0x00010201, {0xD800, 0xDE01}},
{0x00010202, {0xD800, 0xDE02}},
{0x00010204, {0xD800, 0xDE04}},
{0x00010208, {0xD800, 0xDE08}},
{0x00010210, {0xD800, 0xDE10}},
{0x00010220, {0xD800, 0xDE20}},
{0x00010240, {0xD800, 0xDE40}},
{0x00010280, {0xD800, 0xDE80}},
{0x00010300, {0xD800, 0xDF00}},
{0x000103FF, {0xD800, 0xDFFF}},
{0x00010400, {0xD801, 0xDC00}},
{0x00010401, {0xD801, 0xDC01}},
{0x00010402, {0xD801, 0xDC02}},
{0x00010404, {0xD801, 0xDC04}},
{0x00010408, {0xD801, 0xDC08}},
{0x00010410, {0xD801, 0xDC10}},
{0x00010420, {0xD801, 0xDC20}},
{0x00010440, {0xD801, 0xDC40}},
{0x00010480, {0xD801, 0xDC80}},
{0x00010500, {0xD801, 0xDD00}},
{0x00010600, {0xD801, 0xDE00}},
{0x000107FF, {0xD801, 0xDFFF}},
{0x00010800, {0xD802, 0xDC00}},
{0x00010801, {0xD802, 0xDC01}},
{0x00010802, {0xD802, 0xDC02}},
{0x00010804, {0xD802, 0xDC04}},
{0x00010808, {0xD802, 0xDC08}},
{0x00010810, {0xD802, 0xDC10}},
{0x00010820, {0xD802, 0xDC20}},
{0x00010840, {0xD802, 0xDC40}},
{0x00010880, {0xD802, 0xDC80}},
{0x00010900, {0xD802, 0xDD00}},
{0x00010A00, {0xD802, 0xDE00}},
{0x00010C00, {0xD803, 0xDC00}},
{0x00010FFF, {0xD803, 0xDFFF}},
{0x00011000, {0xD804, 0xDC00}},
{0x00011001, {0xD804, 0xDC01}},
{0x00011002, {0xD804, 0xDC02}},
{0x00011004, {0xD804, 0xDC04}},
{0x00011008, {0xD804, 0xDC08}},
{0x00011010, {0xD804, 0xDC10}},
{0x00011020, {0xD804, 0xDC20}},
{0x00011040, {0xD804, 0xDC40}},
{0x00011080, {0xD804, 0xDC80}},
{0x00011100, {0xD804, 0xDD00}},
{0x00011200, {0xD804, 0xDE00}},
{0x00011400, {0xD805, 0xDC00}},
{0x00011800, {0xD806, 0xDC00}},
{0x00011FFF, {0xD807, 0xDFFF}},
{0x00012000, {0xD808, 0xDC00}},
{0x00012001, {0xD808, 0xDC01}},
{0x00012002, {0xD808, 0xDC02}},
{0x00012004, {0xD808, 0xDC04}},
{0x00012008, {0xD808, 0xDC08}},
{0x00012010, {0xD808, 0xDC10}},
{0x00012020, {0xD808, 0xDC20}},
{0x00012040, {0xD808, 0xDC40}},
{0x00012080, {0xD808, 0xDC80}},
{0x00012100, {0xD808, 0xDD00}},
{0x00012200, {0xD808, 0xDE00}},
{0x00012400, {0xD809, 0xDC00}},
{0x00012800, {0xD80A, 0xDC00}},
{0x00013000, {0xD80C, 0xDC00}},
{0x00013FFF, {0xD80F, 0xDFFF}},
{0x00014000, {0xD810, 0xDC00}},
{0x00014001, {0xD810, 0xDC01}},
{0x00014002, {0xD810, 0xDC02}},
{0x00014004, {0xD810, 0xDC04}},
{0x00014008, {0xD810, 0xDC08}},
{0x00014010, {0xD810, 0xDC10}},
{0x00014020, {0xD810, 0xDC20}},
{0x00014040, {0xD810, 0xDC40}},
{0x00014080, {0xD810, 0xDC80}},
{0x00014100, {0xD810, 0xDD00}},
{0x00014200, {0xD810, 0xDE00}},
{0x00014400, {0xD811, 0xDC00}},
{0x00014800, {0xD812, 0xDC00}},
{0x00015000, {0xD814, 0xDC00}},
{0x00016000, {0xD818, 0xDC00}},
{0x00017FFF, {0xD81F, 0xDFFF}},
{0x00018000, {0xD820, 0xDC00}},
{0x00018001, {0xD820, 0xDC01}},
{0x00018002, {0xD820, 0xDC02}},
{0x00018004, {0xD820, 0xDC04}},
{0x00018008, {0xD820, 0xDC08}},
{0x00018010, {0xD820, 0xDC10}},
{0x00018020, {0xD820, 0xDC20}},
{0x00018040, {0xD820, 0xDC40}},
{0x00018080, {0xD820, 0xDC80}},
{0x00018100, {0xD820, 0xDD00}},
{0x00018200, {0xD820, 0xDE00}},
{0x00018400, {0xD821, 0xDC00}},
{0x00018800, {0xD822, 0xDC00}},
{0x00019000, {0xD824, 0xDC00}},
{0x0001A000, {0xD828, 0xDC00}},
{0x0001C000, {0xD830, 0xDC00}},
{0x0001FFFF, {0xD83F, 0xDFFF}},
{0x00020000, {0xD840, 0xDC00}},
{0x00020001, {0xD840, 0xDC01}},
{0x00020002, {0xD840, 0xDC02}},
{0x00020004, {0xD840, 0xDC04}},
{0x00020008, {0xD840, 0xDC08}},
{0x00020010, {0xD840, 0xDC10}},
{0x00020020, {0xD840, 0xDC20}},
{0x00020040, {0xD840, 0xDC40}},
{0x00020080, {0xD840, 0xDC80}},
{0x00020100, {0xD840, 0xDD00}},
{0x00020200, {0xD840, 0xDE00}},
{0x00020400, {0xD841, 0xDC00}},
{0x00020800, {0xD842, 0xDC00}},
{0x00021000, {0xD844, 0xDC00}},
{0x00022000, {0xD848, 0xDC00}},
{0x00024000, {0xD850, 0xDC00}},
{0x00028000, {0xD860, 0xDC00}},
{0x0002FFFF, {0xD87F, 0xDFFF}},
{0x00030000, {0xD880, 0xDC00}},
{0x00030001, {0xD880, 0xDC01}},
{0x00030002, {0xD880, 0xDC02}},
{0x00030004, {0xD880, 0xDC04}},
{0x00030008, {0xD880, 0xDC08}},
{0x00030010, {0xD880, 0xDC10}},
{0x00030020, {0xD880, 0xDC20}},
{0x00030040, {0xD880, 0xDC40}},
{0x00030080, {0xD880, 0xDC80}},
{0x00030100, {0xD880, 0xDD00}},
{0x00030200, {0xD880, 0xDE00}},
{0x00030400, {0xD881, 0xDC00}},
{0x00030800, {0xD882, 0xDC00}},
{0x00031000, {0xD884, 0xDC00}},
{0x00032000, {0xD888, 0xDC00}},
{0x00034000, {0xD890, 0xDC00}},
{0x00038000, {0xD8A0, 0xDC00}},
{0x0003FFFF, {0xD8BF, 0xDFFF}},
{0x00040000, {0xD8C0, 0xDC00}},
{0x00040001, {0xD8C0, 0xDC01}},
{0x00040002, {0xD8C0, 0xDC02}},
{0x00040004, {0xD8C0, 0xDC04}},
{0x00040008, {0xD8C0, 0xDC08}},
{0x00040010, {0xD8C0, 0xDC10}},
{0x00040020, {0xD8C0, 0xDC20}},
{0x00040040, {0xD8C0, 0xDC40}},
{0x00040080, {0xD8C0, 0xDC80}},
{0x00040100, {0xD8C0, 0xDD00}},
{0x00040200, {0xD8C0, 0xDE00}},
{0x00040400, {0xD8C1, 0xDC00}},
{0x00040800, {0xD8C2, 0xDC00}},
{0x00041000, {0xD8C4, 0xDC00}},
{0x00042000, {0xD8C8, 0xDC00}},
{0x00044000, {0xD8D0, 0xDC00}},
{0x00048000, {0xD8E0, 0xDC00}},
{0x0004FFFF, {0xD8FF, 0xDFFF}},
{0x00050000, {0xD900, 0xDC00}},
{0x00050001, {0xD900, 0xDC01}},
{0x00050002, {0xD900, 0xDC02}},
{0x00050004, {0xD900, 0xDC04}},
{0x00050008, {0xD900, 0xDC08}},
{0x00050010, {0xD900, 0xDC10}},
{0x00050020, {0xD900, 0xDC20}},
{0x00050040, {0xD900, 0xDC40}},
{0x00050080, {0xD900, 0xDC80}},
{0x00050100, {0xD900, 0xDD00}},
{0x00050200, {0xD900, 0xDE00}},
{0x00050400, {0xD901, 0xDC00}},
{0x00050800, {0xD902, 0xDC00}},
{0x00051000, {0xD904, 0xDC00}},
{0x00052000, {0xD908, 0xDC00}},
{0x00054000, {0xD910, 0xDC00}},
{0x00058000, {0xD920, 0xDC00}},
{0x00060000, {0xD940, 0xDC00}},
{0x00070000, {0xD980, 0xDC00}},
{0x0007FFFF, {0xD9BF, 0xDFFF}},
{0x00080000, {0xD9C0, 0xDC00}},
{0x00080001, {0xD9C0, 0xDC01}},
{0x00080002, {0xD9C0, 0xDC02}},
{0x00080004, {0xD9C0, 0xDC04}},
{0x00080008, {0xD9C0, 0xDC08}},
{0x00080010, {0xD9C0, 0xDC10}},
{0x00080020, {0xD9C0, 0xDC20}},
{0x00080040, {0xD9C0, 0xDC40}},
{0x00080080, {0xD9C0, 0xDC80}},
{0x00080100, {0xD9C0, 0xDD00}},
{0x00080200, {0xD9C0, 0xDE00}},
{0x00080400, {0xD9C1, 0xDC00}},
{0x00080800, {0xD9C2, 0xDC00}},
{0x00081000, {0xD9C4, 0xDC00}},
{0x00082000, {0xD9C8, 0xDC00}},
{0x00084000, {0xD9D0, 0xDC00}},
{0x00088000, {0xD9E0, 0xDC00}},
{0x0008FFFF, {0xD9FF, 0xDFFF}},
{0x00090000, {0xDA00, 0xDC00}},
{0x00090001, {0xDA00, 0xDC01}},
{0x00090002, {0xDA00, 0xDC02}},
{0x00090004, {0xDA00, 0xDC04}},
{0x00090008, {0xDA00, 0xDC08}},
{0x00090010, {0xDA00, 0xDC10}},
{0x00090020, {0xDA00, 0xDC20}},
{0x00090040, {0xDA00, 0xDC40}},
{0x00090080, {0xDA00, 0xDC80}},
{0x00090100, {0xDA00, 0xDD00}},
{0x00090200, {0xDA00, 0xDE00}},
{0x00090400, {0xDA01, 0xDC00}},
{0x00090800, {0xDA02, 0xDC00}},
{0x00091000, {0xDA04, 0xDC00}},
{0x00092000, {0xDA08, 0xDC00}},
{0x00094000, {0xDA10, 0xDC00}},
{0x00098000, {0xDA20, 0xDC00}},
{0x000A0000, {0xDA40, 0xDC00}},
{0x000B0000, {0xDA80, 0xDC00}},
{0x000C0000, {0xDAC0, 0xDC00}},
{0x000D0000, {0xDB00, 0xDC00}},
{0x000FFFFF, {0xDBBF, 0xDFFF}},
{0x0010FFFF, {0xDBFF, 0xDFFF}}
};
// Invalid UTF-8 sequences
const char *const kUtf8BadCases[] = {
"\xC0\x80",
"\xC1\xBF",
"\xE0\x80\x80",
"\xE0\x9F\xBF",
"\xF0\x80\x80\x80",
"\xF0\x8F\xBF\xBF",
"\xF4\x90\x80\x80",
"\xF7\xBF\xBF\xBF",
"\xF8\x80\x80\x80\x80",
"\xF8\x88\x80\x80\x80",
"\xF8\x92\x80\x80\x80",
"\xF8\x9F\xBF\xBF\xBF",
"\xF8\xA0\x80\x80\x80",
"\xF8\xA8\x80\x80\x80",
"\xF8\xB0\x80\x80\x80",
"\xF8\xBF\xBF\xBF\xBF",
"\xF9\x80\x80\x80\x88",
"\xF9\x84\x80\x80\x80",
"\xF9\xBF\xBF\xBF\xBF",
"\xFA\x80\x80\x80\x80",
"\xFA\x90\x80\x80\x80",
"\xFB\xBF\xBF\xBF\xBF",
"\xFC\x84\x80\x80\x80\x81",
"\xFC\x85\x80\x80\x80\x80",
"\xFC\x86\x80\x80\x80\x80",
"\xFC\x87\xBF\xBF\xBF\xBF",
"\xFC\x88\xA0\x80\x80\x80",
"\xFC\x89\x80\x80\x80\x80",
"\xFC\x8A\x80\x80\x80\x80",
"\xFC\x90\x80\x80\x80\x82",
"\xFD\x80\x80\x80\x80\x80",
"\xFD\xBF\xBF\xBF\xBF\xBF",
"\x80",
"\xC3",
"\xC3\xC3\x80",
"\xED\xA0\x80",
"\xED\xBF\x80",
"\xED\xBF\xBF",
"\xED\xA0\x80\xE0\xBF\xBF",
};
// Invalid UTF-16 sequences (0-terminated)
const Utf16BadCase kUtf16BadCases[] = {
// Leading surrogate not followed by trailing surrogate:
{{0xD800, 0, 0}},
{{0xD800, 0x41, 0}},
{{0xD800, 0xfe, 0}},
{{0xD800, 0x3bb, 0}},
{{0xD800, 0xD800, 0}},
{{0xD800, 0xFEFF, 0}},
{{0xD800, 0xFFFD, 0}},
// Trailing surrogate, not preceded by a leading one.
{{0xDC00, 0, 0}},
{{0xDE6D, 0xD834, 0}},
};
// Parameterized test instantiations:
INSTANTIATE_TEST_CASE_P(Ucs4TestCases, Ucs4Test,
::testing::ValuesIn(kUcs4Cases));
INSTANTIATE_TEST_CASE_P(Iso88591TestCases, Ucs2Test,
::testing::ValuesIn(kIso88591Cases));
INSTANTIATE_TEST_CASE_P(Ucs2TestCases, Ucs2Test,
::testing::ValuesIn(kUcs2Cases));
INSTANTIATE_TEST_CASE_P(Utf16TestCases, Utf16Test,
::testing::ValuesIn(kUtf16Cases));
INSTANTIATE_TEST_CASE_P(BadUtf8TestCases, BadUtf8Test,
::testing::ValuesIn(kUtf8BadCases));
INSTANTIATE_TEST_CASE_P(BadUtf16TestCases, BadUtf16Test,
::testing::ValuesIn(kUtf16BadCases));
INSTANTIATE_TEST_CASE_P(Iso88591TestCases, Iso88591Test,
::testing::ValuesIn(kIso88591Cases));
;
} // namespace nss_test
| mpl-2.0 |
pradeepbhadani/terraform | terraform/variables_test.go | 5313 | package terraform
import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/terraform/tfdiags"
"github.com/go-test/deep"
"github.com/zclconf/go-cty/cty"
)
func TestVariables(t *testing.T) {
tests := map[string]struct {
Module string
Override map[string]cty.Value
Want InputValues
}{
"config only": {
"vars-basic",
nil,
InputValues{
"a": &InputValue{
Value: cty.StringVal("foo"),
SourceType: ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "testdata/vars-basic/main.tf",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
End: tfdiags.SourcePos{Line: 1, Column: 13, Byte: 12},
},
},
"b": &InputValue{
Value: cty.ListValEmpty(cty.DynamicPseudoType),
SourceType: ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "testdata/vars-basic/main.tf",
Start: tfdiags.SourcePos{Line: 6, Column: 1, Byte: 58},
End: tfdiags.SourcePos{Line: 6, Column: 13, Byte: 70},
},
},
"c": &InputValue{
Value: cty.MapValEmpty(cty.DynamicPseudoType),
SourceType: ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "testdata/vars-basic/main.tf",
Start: tfdiags.SourcePos{Line: 11, Column: 1, Byte: 111},
End: tfdiags.SourcePos{Line: 11, Column: 13, Byte: 123},
},
},
},
},
"override": {
"vars-basic",
map[string]cty.Value{
"a": cty.StringVal("bar"),
"b": cty.ListVal([]cty.Value{
cty.StringVal("foo"),
cty.StringVal("bar"),
}),
"c": cty.MapVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
},
InputValues{
"a": &InputValue{
Value: cty.StringVal("bar"),
SourceType: ValueFromCaller,
},
"b": &InputValue{
Value: cty.ListVal([]cty.Value{
cty.StringVal("foo"),
cty.StringVal("bar"),
}),
SourceType: ValueFromCaller,
},
"c": &InputValue{
Value: cty.MapVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
SourceType: ValueFromCaller,
},
},
},
"bools: config only": {
"vars-basic-bool",
nil,
InputValues{
"a": &InputValue{
Value: cty.True,
SourceType: ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "testdata/vars-basic-bool/main.tf",
Start: tfdiags.SourcePos{Line: 4, Column: 1, Byte: 177},
End: tfdiags.SourcePos{Line: 4, Column: 13, Byte: 189},
},
},
"b": &InputValue{
Value: cty.False,
SourceType: ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "testdata/vars-basic-bool/main.tf",
Start: tfdiags.SourcePos{Line: 8, Column: 1, Byte: 214},
End: tfdiags.SourcePos{Line: 8, Column: 13, Byte: 226},
},
},
},
},
"bools: override with string": {
"vars-basic-bool",
map[string]cty.Value{
"a": cty.StringVal("foo"),
"b": cty.StringVal("bar"),
},
InputValues{
"a": &InputValue{
Value: cty.StringVal("foo"),
SourceType: ValueFromCaller,
},
"b": &InputValue{
Value: cty.StringVal("bar"),
SourceType: ValueFromCaller,
},
},
},
"bools: override with bool": {
"vars-basic-bool",
map[string]cty.Value{
"a": cty.False,
"b": cty.True,
},
InputValues{
"a": &InputValue{
Value: cty.False,
SourceType: ValueFromCaller,
},
"b": &InputValue{
Value: cty.True,
SourceType: ValueFromCaller,
},
},
},
}
for name, test := range tests {
// Wrapped in a func so we can get defers to work
t.Run(name, func(t *testing.T) {
m := testModule(t, test.Module)
fromConfig := DefaultVariableValues(m.Module.Variables)
overrides := InputValuesFromCaller(test.Override)
got := fromConfig.Override(overrides)
if !got.Identical(test.Want) {
t.Errorf("wrong result\ngot: %swant: %s", spew.Sdump(got), spew.Sdump(test.Want))
}
for _, problem := range deep.Equal(got, test.Want) {
t.Errorf(problem)
}
})
}
}
func TestSMCUserVariables(t *testing.T) {
c := testModule(t, "smc-uservars")
// No variables set
diags := checkInputVariables(c.Module.Variables, nil)
if !diags.HasErrors() {
t.Fatal("check succeeded, but want errors")
}
// Required variables set, optional variables unset
// This is still an error at this layer, since it's the caller's
// responsibility to have already merged in any default values.
diags = checkInputVariables(c.Module.Variables, InputValues{
"foo": &InputValue{
Value: cty.StringVal("bar"),
SourceType: ValueFromCLIArg,
},
})
if !diags.HasErrors() {
t.Fatal("check succeeded, but want errors")
}
// All variables set
diags = checkInputVariables(c.Module.Variables, InputValues{
"foo": &InputValue{
Value: cty.StringVal("bar"),
SourceType: ValueFromCLIArg,
},
"bar": &InputValue{
Value: cty.StringVal("baz"),
SourceType: ValueFromCLIArg,
},
"map": &InputValue{
Value: cty.StringVal("baz"), // okay because config has no type constraint
SourceType: ValueFromCLIArg,
},
})
if diags.HasErrors() {
//t.Fatal("check succeeded, but want errors")
t.Fatalf("unexpected errors: %s", diags.Err())
}
}
| mpl-2.0 |
riadhchtara/fxa-password-manager | tests/functional/oauth_webchannel_keys.js | 14818 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
define([
'intern',
'intern!object',
'intern/chai!assert',
'require',
'intern/node_modules/dojo/node!xmlhttprequest',
'app/bower_components/fxa-js-client/fxa-client',
'tests/lib/helpers',
'tests/functional/lib/helpers',
'tests/functional/lib/fx-desktop'
], function (intern, registerSuite, assert, require, nodeXMLHttpRequest,
FxaClient, TestHelpers, FunctionalHelpers, FxDesktopHelpers) {
var config = intern.config;
var AUTH_SERVER_ROOT = config.fxaAuthRoot;
var SYNC_URL = config.fxaContentRoot + 'signin?context=fx_desktop_v1&service=sync';
var PASSWORD = 'password';
var TOO_YOUNG_YEAR = new Date().getFullYear() - 13;
var OLD_ENOUGH_YEAR = TOO_YOUNG_YEAR - 1;
var email;
var client;
var ANIMATION_DELAY_MS = 1000;
var CHANNEL_DELAY = 4000; // how long it takes for the WebChannel indicator to appear
var TIMEOUT = 90 * 1000;
var listenForSyncCommands = FxDesktopHelpers.listenForFxaCommands;
var testIsBrowserNotifiedOfSyncLogin = FxDesktopHelpers.testIsBrowserNotifiedOfLogin;
/**
* This suite tests the WebChannel functionality for delivering encryption keys
* in the OAuth signin and signup cases. It uses a CustomEvent "WebChannelMessageToChrome"
* to finish OAuth flows
*/
function testIsBrowserNotifiedOfLogin(context, options) {
options = options || {};
return FunctionalHelpers.testIsBrowserNotified(context, 'oauth_complete', function (data) {
assert.ok(data.redirect);
assert.ok(data.code);
assert.ok(data.state);
// All of these flows should produce encryption keys.
assert.ok(data.keys);
assert.equal(data.closeWindow, options.shouldCloseTab);
});
}
function openFxaFromRpAndRequestKeys(context, page, additionalQueryParams) {
var queryParams = '&webChannelId=test&keys=true';
for (var key in additionalQueryParams) {
queryParams += ('&' + key + '=' + additionalQueryParams[key]);
}
return FunctionalHelpers.openFxaFromRp(context, page, queryParams);
}
registerSuite({
name: 'oauth web channel keys',
beforeEach: function () {
email = TestHelpers.createEmail();
client = new FxaClient(AUTH_SERVER_ROOT, {
xhr: nodeXMLHttpRequest.XMLHttpRequest
});
return FunctionalHelpers.clearBrowserState(this, {
contentServer: true,
'123done': true
});
},
'signup, verify same browser, in a different tab, with original tab open': function () {
var self = this;
self.timeout = TIMEOUT;
var messageReceived = false;
return openFxaFromRpAndRequestKeys(self, 'signup')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return FunctionalHelpers.fillOutSignUp(self, email, PASSWORD, OLD_ENOUGH_YEAR);
})
.findByCssSelector('#fxa-confirm-header')
.end()
.then(function () {
return FunctionalHelpers.openVerificationLinkSameBrowser(
self, email, 0);
})
.switchToWindow('newwindow')
.execute(FunctionalHelpers.listenForWebChannelMessage)
// wait for the verified window in the new tab
.findById('fxa-sign-up-complete-header')
.setFindTimeout(CHANNEL_DELAY)
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.end()
.then(function () {
messageReceived = true;
}, function () {
// element was not found
})
.closeCurrentWindow()
// switch to the original window
.switchToWindow('')
.setFindTimeout(CHANNEL_DELAY)
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.then(function () {
messageReceived = true;
}, function () {
// element was not found
})
.then(function () {
assert.isTrue(messageReceived, 'expected to receive a WebChannel event in either tab');
})
.setFindTimeout(config.pageLoadTimeout)
.findById('fxa-sign-up-complete-header')
.end();
},
'signup, verify same browser, original tab closed navigated to another page': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signup')
.then(function () {
return FunctionalHelpers.fillOutSignUp(self, email, PASSWORD, OLD_ENOUGH_YEAR);
})
.findByCssSelector('#fxa-confirm-header')
.end()
.then(FunctionalHelpers.openExternalSite(self))
.then(function () {
return FunctionalHelpers.openVerificationLinkSameBrowser(self, email, 0);
})
.switchToWindow('newwindow')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.findById('fxa-sign-up-complete-header')
.end()
.closeCurrentWindow()
// switch to the original window
.switchToWindow('');
},
'signup, verify same browser, replace original tab': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signup')
.then(function () {
return FunctionalHelpers.fillOutSignUp(self, email, PASSWORD, OLD_ENOUGH_YEAR);
})
.findByCssSelector('#fxa-confirm-header')
.end()
.then(function () {
return FunctionalHelpers.getVerificationLink(email, 0);
})
.then(function (verificationLink) {
return self.remote.get(require.toUrl(verificationLink))
.execute(FunctionalHelpers.listenForWebChannelMessage);
})
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.findById('fxa-sign-up-complete-header')
.end();
},
'signup, verify different browser, from original tab\'s P.O.V.': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signup')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return FunctionalHelpers.fillOutSignUp(self, email, PASSWORD, OLD_ENOUGH_YEAR);
})
.findByCssSelector('#fxa-confirm-header')
.end()
.then(function () {
return FunctionalHelpers.openVerificationLinkDifferentBrowser(client, email);
})
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.findById('fxa-sign-up-complete-header')
.end();
},
'password reset, verify same browser': function () {
var self = this;
self.timeout = TIMEOUT;
var messageReceived = false;
return openFxaFromRpAndRequestKeys(self, 'signin')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return client.signUp(email, PASSWORD, { preVerified: true });
})
.findByCssSelector('.reset-password')
.click()
.end()
.then(function () {
return FunctionalHelpers.fillOutResetPassword(self, email);
})
.findByCssSelector('#fxa-confirm-reset-password-header')
.end()
.then(function () {
return FunctionalHelpers.openVerificationLinkSameBrowser(
self, email, 0);
})
// Complete the password reset in the new tab
.switchToWindow('newwindow')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return FunctionalHelpers.fillOutCompleteResetPassword(
self, PASSWORD, PASSWORD);
})
// this tab should get the reset password complete header.
.findByCssSelector('#fxa-reset-password-complete-header')
.end()
.setFindTimeout(CHANNEL_DELAY)
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.end()
.then(function () {
messageReceived = true;
}, function () {
// element was not found
})
.sleep(ANIMATION_DELAY_MS)
.findByCssSelector('.error').isDisplayed()
.then(function (isDisplayed) {
assert.isFalse(isDisplayed);
})
.end()
.closeCurrentWindow()
// switch to the original window
.switchToWindow('')
.setFindTimeout(CHANNEL_DELAY)
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.then(function () {
messageReceived = true;
}, function () {
// element was not found
})
.then(function () {
assert.isTrue(messageReceived, 'expected to receive a WebChannel event in either tab');
})
.setFindTimeout(config.pageLoadTimeout)
// the original tab should automatically sign in
.findByCssSelector('#fxa-reset-password-complete-header')
.end();
},
'password reset, verify same browser, original tab closed': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signin')
.then(function () {
return client.signUp(email, PASSWORD, { preVerified: true });
})
.findByCssSelector('.reset-password')
.click()
.end()
.then(function () {
return FunctionalHelpers.fillOutResetPassword(self, email);
})
.findByCssSelector('#fxa-confirm-reset-password-header')
.end()
.then(FunctionalHelpers.openExternalSite(self))
.then(function () {
return FunctionalHelpers.openVerificationLinkSameBrowser(self, email, 0);
})
.switchToWindow('newwindow')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return FunctionalHelpers.fillOutCompleteResetPassword(
self, PASSWORD, PASSWORD);
})
// the tab should automatically sign in
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.findByCssSelector('#fxa-reset-password-complete-header')
.end()
.closeCurrentWindow()
// switch to the original window
.switchToWindow('');
},
'password reset, verify same browser, replace original tab': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signin')
.then(function () {
return client.signUp(email, PASSWORD, { preVerified: true });
})
.findByCssSelector('.reset-password')
.click()
.end()
.then(function () {
return FunctionalHelpers.fillOutResetPassword(self, email);
})
.findByCssSelector('#fxa-confirm-reset-password-header')
.end()
.then(function () {
return FunctionalHelpers.getVerificationLink(email, 0);
})
.then(function (verificationLink) {
return self.remote.get(require.toUrl(verificationLink))
.execute(FunctionalHelpers.listenForWebChannelMessage);
})
.then(function () {
return FunctionalHelpers.fillOutCompleteResetPassword(
self, PASSWORD, PASSWORD);
})
// the tab should automatically sign in
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: false }))
.findByCssSelector('#fxa-reset-password-complete-header')
.end();
},
'password reset, verify in different browser, from the original tab\'s P.O.V.': function () {
var self = this;
self.timeout = TIMEOUT;
return openFxaFromRpAndRequestKeys(self, 'signin')
.execute(FunctionalHelpers.listenForWebChannelMessage)
.then(function () {
return client.signUp(email, PASSWORD, { preVerified: true });
})
.findByCssSelector('.reset-password')
.click()
.end()
.then(function () {
return FunctionalHelpers.fillOutResetPassword(self, email);
})
.findByCssSelector('#fxa-confirm-reset-password-header')
.end()
.then(function () {
return FunctionalHelpers.openPasswordResetLinkDifferentBrowser(
client, email, PASSWORD);
})
// user verified in a new browser, they have to enter
// their updated credentials in the original tab.
.findByCssSelector('#fxa-signin-header')
.end()
.then(FunctionalHelpers.visibleByQSA('.success'))
.end()
.findByCssSelector('#password')
.type(PASSWORD)
.end()
.findByCssSelector('button[type=submit]')
.click()
.end()
// user is signed in
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: true }))
// no screen transition, Loop will close this screen.
.findByCssSelector('#fxa-signin-header')
.end();
},
'signin a verified account and requesting keys after signing in to sync': function () {
var self = this;
self.timeout = TIMEOUT;
return client.signUp(email, PASSWORD, { preVerified: true })
.then(function () {
return self.remote
.get(require.toUrl(SYNC_URL))
.setFindTimeout(intern.config.pageLoadTimeout)
.execute(listenForSyncCommands)
.findByCssSelector('#fxa-signin-header')
.end()
.then(function () {
return FunctionalHelpers.fillOutSignIn(self, email, PASSWORD);
})
.then(function () {
return testIsBrowserNotifiedOfSyncLogin(self, email, { checkVerified: true });
})
.then(function () {
return openFxaFromRpAndRequestKeys(self, 'signin');
})
.findByCssSelector('#fxa-signin-header')
.end()
.execute(FunctionalHelpers.listenForWebChannelMessage)
// In a keyless oauth flow, the user could just click to confirm
// without re-entering their password. Since we need the password
// to derive the keys, this flow must prompt for it.
.findByCssSelector('input[type=password]')
.click()
.clearValue()
.type(PASSWORD)
.end()
.findByCssSelector('button[type="submit"]')
.click()
.end()
.then(testIsBrowserNotifiedOfLogin(self, { shouldCloseTab: true }));
});
}
});
});
| mpl-2.0 |
techdragon/Postgres-XL | src/interfaces/ecpg/pgtypeslib/datetime.c | 15437 | /* src/interfaces/ecpg/pgtypeslib/datetime.c */
#include "postgres_fe.h"
#include <time.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include "extern.h"
#include "dt.h"
#include "pgtypes_error.h"
#include "pgtypes_date.h"
date *
PGTYPESdate_new(void)
{
date *result;
result = (date *) pgtypes_alloc(sizeof(date));
/* result can be NULL if we run out of memory */
return result;
}
void
PGTYPESdate_free(date * d)
{
free(d);
}
date
PGTYPESdate_from_timestamp(timestamp dt)
{
date dDate;
dDate = 0; /* suppress compiler warning */
if (!TIMESTAMP_NOT_FINITE(dt))
{
#ifdef HAVE_INT64_TIMESTAMP
/* Microseconds to days */
dDate = (dt / USECS_PER_DAY);
#else
/* Seconds to days */
dDate = (dt / (double) SECS_PER_DAY);
#endif
}
return dDate;
}
date
PGTYPESdate_from_asc(char *str, char **endptr)
{
date dDate;
fsec_t fsec;
struct tm tt,
*tm = &tt;
int dtype;
int nf;
char *field[MAXDATEFIELDS];
int ftype[MAXDATEFIELDS];
char lowstr[MAXDATELEN + MAXDATEFIELDS];
char *realptr;
char **ptr = (endptr != NULL) ? endptr : &realptr;
bool EuroDates = FALSE;
errno = 0;
if (strlen(str) > MAXDATELEN)
{
errno = PGTYPES_DATE_BAD_DATE;
return INT_MIN;
}
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, EuroDates) != 0)
{
errno = PGTYPES_DATE_BAD_DATE;
return INT_MIN;
}
switch (dtype)
{
case DTK_DATE:
break;
case DTK_EPOCH:
if (GetEpochTime(tm) < 0)
{
errno = PGTYPES_DATE_BAD_DATE;
return INT_MIN;
}
break;
default:
errno = PGTYPES_DATE_BAD_DATE;
return INT_MIN;
}
dDate = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1));
return dDate;
}
char *
PGTYPESdate_to_asc(date dDate)
{
struct tm tt,
*tm = &tt;
char buf[MAXDATELEN + 1];
int DateStyle = 1;
bool EuroDates = FALSE;
j2date(dDate + date2j(2000, 1, 1), &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));
EncodeDateOnly(tm, DateStyle, buf, EuroDates);
return pgtypes_strdup(buf);
}
void
PGTYPESdate_julmdy(date jd, int *mdy)
{
int y,
m,
d;
j2date((int) (jd + date2j(2000, 1, 1)), &y, &m, &d);
mdy[0] = m;
mdy[1] = d;
mdy[2] = y;
}
void
PGTYPESdate_mdyjul(int *mdy, date * jdate)
{
/* month is mdy[0] */
/* day is mdy[1] */
/* year is mdy[2] */
*jdate = (date) (date2j(mdy[2], mdy[0], mdy[1]) - date2j(2000, 1, 1));
}
int
PGTYPESdate_dayofweek(date dDate)
{
/*
* Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3 Thursday: 4
* Friday: 5 Saturday: 6
*/
return (int) (dDate + date2j(2000, 1, 1) + 1) % 7;
}
void
PGTYPESdate_today(date * d)
{
struct tm ts;
GetCurrentDateTime(&ts);
if (errno == 0)
*d = date2j(ts.tm_year, ts.tm_mon, ts.tm_mday) - date2j(2000, 1, 1);
return;
}
#define PGTYPES_DATE_NUM_MAX_DIGITS 20 /* should suffice for most
* years... */
#define PGTYPES_FMTDATE_DAY_DIGITS_LZ 1 /* LZ means "leading zeroes" */
#define PGTYPES_FMTDATE_DOW_LITERAL_SHORT 2
#define PGTYPES_FMTDATE_MONTH_DIGITS_LZ 3
#define PGTYPES_FMTDATE_MONTH_LITERAL_SHORT 4
#define PGTYPES_FMTDATE_YEAR_DIGITS_SHORT 5
#define PGTYPES_FMTDATE_YEAR_DIGITS_LONG 6
int
PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
{
static struct
{
char *format;
int component;
} mapping[] =
{
/*
* format items have to be sorted according to their length, since the
* first pattern that matches gets replaced by its value
*/
{
"ddd", PGTYPES_FMTDATE_DOW_LITERAL_SHORT
},
{
"dd", PGTYPES_FMTDATE_DAY_DIGITS_LZ
},
{
"mmm", PGTYPES_FMTDATE_MONTH_LITERAL_SHORT
},
{
"mm", PGTYPES_FMTDATE_MONTH_DIGITS_LZ
},
{
"yyyy", PGTYPES_FMTDATE_YEAR_DIGITS_LONG
},
{
"yy", PGTYPES_FMTDATE_YEAR_DIGITS_SHORT
},
{
NULL, 0
}
};
union un_fmt_comb replace_val;
int replace_type;
int i;
int dow;
char *start_pattern;
struct tm tm;
/* copy the string over */
strcpy(outbuf, fmtstring);
/* get the date */
j2date(dDate + date2j(2000, 1, 1), &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday));
dow = PGTYPESdate_dayofweek(dDate);
for (i = 0; mapping[i].format != NULL; i++)
{
while ((start_pattern = strstr(outbuf, mapping[i].format)) != NULL)
{
switch (mapping[i].component)
{
case PGTYPES_FMTDATE_DOW_LITERAL_SHORT:
replace_val.str_val = pgtypes_date_weekdays_short[dow];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
case PGTYPES_FMTDATE_DAY_DIGITS_LZ:
replace_val.uint_val = tm.tm_mday;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
case PGTYPES_FMTDATE_MONTH_LITERAL_SHORT:
replace_val.str_val = months[tm.tm_mon - 1];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
case PGTYPES_FMTDATE_MONTH_DIGITS_LZ:
replace_val.uint_val = tm.tm_mon;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
case PGTYPES_FMTDATE_YEAR_DIGITS_LONG:
replace_val.uint_val = tm.tm_year;
replace_type = PGTYPES_TYPE_UINT_4_LZ;
break;
case PGTYPES_FMTDATE_YEAR_DIGITS_SHORT:
replace_val.uint_val = tm.tm_year % 100;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
default:
/*
* should not happen, set something anyway
*/
replace_val.str_val = " ";
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
}
switch (replace_type)
{
case PGTYPES_TYPE_STRING_MALLOCED:
case PGTYPES_TYPE_STRING_CONSTANT:
memcpy(start_pattern, replace_val.str_val,
strlen(replace_val.str_val));
if (replace_type == PGTYPES_TYPE_STRING_MALLOCED)
free(replace_val.str_val);
break;
case PGTYPES_TYPE_UINT:
{
char *t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%u", replace_val.uint_val);
memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
case PGTYPES_TYPE_UINT_2_LZ:
{
char *t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%02u", replace_val.uint_val);
memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
case PGTYPES_TYPE_UINT_4_LZ:
{
char *t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%04u", replace_val.uint_val);
memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
default:
/*
* doesn't happen (we set replace_type to
* PGTYPES_TYPE_STRING_CONSTANT in case of an error above)
*/
break;
}
}
}
return 0;
}
/*
* PGTYPESdate_defmt_asc
*
* function works as follows:
* - first we analyze the parameters
* - if this is a special case with no delimiters, add delimters
* - find the tokens. First we look for numerical values. If we have found
* less than 3 tokens, we check for the months' names and thereafter for
* the abbreviations of the months' names.
* - then we see which parameter should be the date, the month and the
* year and from these values we calculate the date
*/
#define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */
int
PGTYPESdate_defmt_asc(date * d, const char *fmt, char *str)
{
/*
* token[2] = { 4,6 } means that token 2 starts at position 4 and ends at
* (including) position 6
*/
int token[3][2];
int token_values[3] = {-1, -1, -1};
char *fmt_token_order;
char *fmt_ystart,
*fmt_mstart,
*fmt_dstart;
unsigned int i;
int reading_digit;
int token_count;
char *str_copy;
struct tm tm;
tm.tm_year = tm.tm_mon = tm.tm_mday = 0; /* keep compiler quiet */
if (!d || !str || !fmt)
{
errno = PGTYPES_DATE_ERR_EARGS;
return -1;
}
/* analyze the fmt string */
fmt_ystart = strstr(fmt, "yy");
fmt_mstart = strstr(fmt, "mm");
fmt_dstart = strstr(fmt, "dd");
if (!fmt_ystart || !fmt_mstart || !fmt_dstart)
{
errno = PGTYPES_DATE_ERR_EARGS;
return -1;
}
if (fmt_ystart < fmt_mstart)
{
/* y m */
if (fmt_dstart < fmt_ystart)
{
/* d y m */
fmt_token_order = "dym";
}
else if (fmt_dstart > fmt_mstart)
{
/* y m d */
fmt_token_order = "ymd";
}
else
{
/* y d m */
fmt_token_order = "ydm";
}
}
else
{
/* fmt_ystart > fmt_mstart */
/* m y */
if (fmt_dstart < fmt_mstart)
{
/* d m y */
fmt_token_order = "dmy";
}
else if (fmt_dstart > fmt_ystart)
{
/* m y d */
fmt_token_order = "myd";
}
else
{
/* m d y */
fmt_token_order = "mdy";
}
}
/*
* handle the special cases where there is no delimiter between the
* digits. If we see this:
*
* only digits, 6 or 8 bytes then it might be ddmmyy and ddmmyyyy (or
* similar)
*
* we reduce it to a string with delimiters and continue processing
*/
/* check if we have only digits */
reading_digit = 1;
for (i = 0; str[i]; i++)
{
if (!isdigit((unsigned char) str[i]))
{
reading_digit = 0;
break;
}
}
if (reading_digit)
{
int frag_length[3];
int target_pos;
i = strlen(str);
if (i != 8 && i != 6)
{
errno = PGTYPES_DATE_ERR_ENOSHORTDATE;
return -1;
}
/* okay, this really is the special case */
/*
* as long as the string, one additional byte for the terminator and 2
* for the delimiters between the 3 fiedls
*/
str_copy = pgtypes_alloc(strlen(str) + 1 + 2);
if (!str_copy)
return -1;
/* determine length of the fragments */
if (i == 6)
{
frag_length[0] = 2;
frag_length[1] = 2;
frag_length[2] = 2;
}
else
{
if (fmt_token_order[0] == 'y')
{
frag_length[0] = 4;
frag_length[1] = 2;
frag_length[2] = 2;
}
else if (fmt_token_order[1] == 'y')
{
frag_length[0] = 2;
frag_length[1] = 4;
frag_length[2] = 2;
}
else
{
frag_length[0] = 2;
frag_length[1] = 2;
frag_length[2] = 4;
}
}
target_pos = 0;
/*
* XXX: Here we could calculate the positions of the tokens and save
* the for loop down there where we again check with isdigit() for
* digits.
*/
for (i = 0; i < 3; i++)
{
int start_pos = 0;
if (i >= 1)
start_pos += frag_length[0];
if (i == 2)
start_pos += frag_length[1];
strncpy(str_copy + target_pos, str + start_pos,
frag_length[i]);
target_pos += frag_length[i];
if (i != 2)
{
str_copy[target_pos] = ' ';
target_pos++;
}
}
str_copy[target_pos] = '\0';
}
else
{
str_copy = pgtypes_strdup(str);
if (!str_copy)
return -1;
/* convert the whole string to lower case */
for (i = 0; str_copy[i]; i++)
str_copy[i] = (char) pg_tolower((unsigned char) str_copy[i]);
}
/* look for numerical tokens */
reading_digit = 0;
token_count = 0;
for (i = 0; i < strlen(str_copy); i++)
{
if (!isdigit((unsigned char) str_copy[i]) && reading_digit)
{
/* the token is finished */
token[token_count][1] = i - 1;
reading_digit = 0;
token_count++;
}
else if (isdigit((unsigned char) str_copy[i]) && !reading_digit)
{
/* we have found a token */
token[token_count][0] = i;
reading_digit = 1;
}
}
/*
* we're at the end of the input string, but maybe we are still reading a
* number...
*/
if (reading_digit)
{
token[token_count][1] = i - 1;
token_count++;
}
if (token_count < 2)
{
/*
* not all tokens found, no way to find 2 missing tokens with string
* matches
*/
free(str_copy);
errno = PGTYPES_DATE_ERR_ENOSHORTDATE;
return -1;
}
if (token_count != 3)
{
/*
* not all tokens found but we may find another one with string
* matches by testing for the months names and months abbreviations
*/
char *month_lower_tmp = pgtypes_alloc(PGTYPES_DATE_MONTH_MAXLENGTH);
char *start_pos;
int j;
int offset;
int found = 0;
char **list;
if (!month_lower_tmp)
{
/* free variables we alloc'ed before */
free(str_copy);
return -1;
}
list = pgtypes_date_months;
for (i = 0; list[i]; i++)
{
for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++)
{
month_lower_tmp[j] = (char) pg_tolower((unsigned char) list[i][j]);
if (!month_lower_tmp[j])
{
/* properly terminated */
break;
}
}
if ((start_pos = strstr(str_copy, month_lower_tmp)))
{
offset = start_pos - str_copy;
/*
* sort the new token into the numeric tokens, shift them if
* necessary
*/
if (offset < token[0][0])
{
token[2][0] = token[1][0];
token[2][1] = token[1][1];
token[1][0] = token[0][0];
token[1][1] = token[0][1];
token_count = 0;
}
else if (offset < token[1][0])
{
token[2][0] = token[1][0];
token[2][1] = token[1][1];
token_count = 1;
}
else
token_count = 2;
token[token_count][0] = offset;
token[token_count][1] = offset + strlen(month_lower_tmp) - 1;
/*
* the value is the index of the month in the array of months
* + 1 (January is month 0)
*/
token_values[token_count] = i + 1;
found = 1;
break;
}
/*
* evil[tm] hack: if we read the pgtypes_date_months and haven't
* found a match, reset list to point to pgtypes_date_months_short
* and reset the counter variable i
*/
if (list == pgtypes_date_months)
{
if (list[i + 1] == NULL)
{
list = months;
i = -1;
}
}
}
if (!found)
{
free(month_lower_tmp);
free(str_copy);
errno = PGTYPES_DATE_ERR_ENOTDMY;
return -1;
}
/*
* here we found a month. token[token_count] and
* token_values[token_count] reflect the month's details.
*
* only the month can be specified with a literal. Here we can do a
* quick check if the month is at the right position according to the
* format string because we can check if the token that we expect to
* be the month is at the position of the only token that already has
* a value. If we wouldn't check here we could say "December 4 1990"
* with a fmt string of "dd mm yy" for 12 April 1990.
*/
if (fmt_token_order[token_count] != 'm')
{
/* deal with the error later on */
token_values[token_count] = -1;
}
free(month_lower_tmp);
}
/* terminate the tokens with ASCII-0 and get their values */
for (i = 0; i < 3; i++)
{
*(str_copy + token[i][1] + 1) = '\0';
/* A month already has a value set, check for token_value == -1 */
if (token_values[i] == -1)
{
errno = 0;
token_values[i] = strtol(str_copy + token[i][0], (char **) NULL, 10);
/* strtol sets errno in case of an error */
if (errno)
token_values[i] = -1;
}
if (fmt_token_order[i] == 'd')
tm.tm_mday = token_values[i];
else if (fmt_token_order[i] == 'm')
tm.tm_mon = token_values[i];
else if (fmt_token_order[i] == 'y')
tm.tm_year = token_values[i];
}
free(str_copy);
if (tm.tm_mday < 1 || tm.tm_mday > 31)
{
errno = PGTYPES_DATE_BAD_DAY;
return -1;
}
if (tm.tm_mon < 1 || tm.tm_mon > MONTHS_PER_YEAR)
{
errno = PGTYPES_DATE_BAD_MONTH;
return -1;
}
if (tm.tm_mday == 31 && (tm.tm_mon == 4 || tm.tm_mon == 6 || tm.tm_mon == 9 || tm.tm_mon == 11))
{
errno = PGTYPES_DATE_BAD_DAY;
return -1;
}
if (tm.tm_mon == 2 && tm.tm_mday > 29)
{
errno = PGTYPES_DATE_BAD_DAY;
return -1;
}
*d = date2j(tm.tm_year, tm.tm_mon, tm.tm_mday) - date2j(2000, 1, 1);
return 0;
}
| mpl-2.0 |
riadhchtara/fxa-password-manager | tests/functional/force_auth.js | 4537 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
define([
'intern',
'intern!object',
'intern/chai!assert',
'require',
'intern/node_modules/dojo/node!xmlhttprequest',
'app/bower_components/fxa-js-client/fxa-client',
'tests/lib/helpers',
'tests/functional/lib/helpers'
], function (intern, registerSuite, assert, require, nodeXMLHttpRequest, FxaClient, TestHelpers, FunctionalHelpers) {
var config = intern.config;
var AUTH_SERVER_ROOT = config.fxaAuthRoot;
var FORCE_AUTH_URL = config.fxaContentRoot + 'force_auth';
var PASSWORD = 'password';
var email;
var client;
function openFxa(context, email) {
return context.remote
.setFindTimeout(intern.config.pageLoadTimeout)
.get(require.toUrl(FORCE_AUTH_URL + '?email=' + email))
.findByCssSelector('#fxa-force-auth-header')
.end();
}
function attemptSignIn(context) {
return context.remote
// user should be at the force-auth screen
.findByCssSelector('#fxa-force-auth-header')
.end()
.findByCssSelector('input[type=password]')
.click()
.type(PASSWORD)
.end()
.findByCssSelector('button[type="submit"]')
.click()
.end();
}
registerSuite({
name: 'force_auth with an existing user',
beforeEach: function () {
email = TestHelpers.createEmail();
client = new FxaClient(AUTH_SERVER_ROOT, {
xhr: nodeXMLHttpRequest.XMLHttpRequest
});
var self = this;
return client.signUp(email, PASSWORD, { preVerified: true })
.then(function () {
// clear localStorage to avoid polluting other tests.
return FunctionalHelpers.clearBrowserState(self);
});
},
'sign in via force-auth': function () {
var self = this;
return openFxa(self, email)
.then(function () {
return attemptSignIn(self);
})
.findById('fxa-settings-header')
.end();
},
'forgot password flow via force-auth goes directly to confirm email screen': function () {
var self = this;
return openFxa(self, email)
.findByCssSelector('.reset-password')
.click()
.end()
.findById('fxa-confirm-reset-password-header')
.end()
// user remembers her password, clicks the "sign in" link. They
// should go back to the /force_auth screen.
.findByClassName('sign-in')
.click()
.end()
.findById('fxa-force-auth-header');
},
'visiting the tos/pp links saves information for return': function () {
var self = this;
return testRepopulateFields.call(self, '/legal/terms', 'fxa-tos-header')
.then(function () {
return testRepopulateFields.call(self, '/legal/privacy', 'fxa-pp-header');
});
}
});
registerSuite({
name: 'force_auth with an unregistered user',
beforeEach: function () {
email = TestHelpers.createEmail();
// clear localStorage to avoid polluting other tests.
return FunctionalHelpers.clearBrowserState(this);
},
'sign in shows an error message': function () {
var self = this;
return openFxa(self, email)
.then(function () {
return attemptSignIn(self);
})
.then(FunctionalHelpers.visibleByQSA('.error'))
.end();
},
'reset password shows an error message': function () {
var self = this;
return openFxa(self, email)
.findByCssSelector('a[href="/confirm_reset_password"]')
.click()
.end()
.then(FunctionalHelpers.visibleByQSA('.error'))
.end();
}
});
function testRepopulateFields(dest, header) {
var self = this;
return openFxa(self, email)
.findByCssSelector('input[type=password]')
.clearValue()
.click()
.type(PASSWORD)
.end()
.findByCssSelector('a[href="' + dest + '"]')
.click()
.end()
.findById(header)
.end()
.findByCssSelector('.back')
.click()
.end()
.findById('fxa-force-auth-header')
.end()
.findByCssSelector('input[type=password]')
.getProperty('value')
.then(function (resultText) {
// check the email address was re-populated
assert.equal(resultText, PASSWORD);
})
.end();
}
});
| mpl-2.0 |
kostaspl/SpiderMonkey38 | mfbt/double-conversion/utils.h | 10527 | // Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef DOUBLE_CONVERSION_UTILS_H_
#define DOUBLE_CONVERSION_UTILS_H_
#include <stdlib.h>
#include <string.h>
#include "mozilla/Assertions.h"
#ifndef ASSERT
#define ASSERT(condition) MOZ_ASSERT(condition)
#endif
#ifndef UNIMPLEMENTED
#define UNIMPLEMENTED() MOZ_CRASH()
#endif
#ifndef UNREACHABLE
#define UNREACHABLE() MOZ_CRASH()
#endif
// Double operations detection based on target architecture.
// Linux uses a 80bit wide floating point stack on x86. This induces double
// rounding, which in turn leads to wrong results.
// An easy way to test if the floating-point operations are correct is to
// evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then
// the result is equal to 89255e-22.
// The best way to test this, is to create a division-function and to compare
// the output of the division with the expected result. (Inlining must be
// disabled.)
// On Linux,x86 89255e-22 != Div_double(89255.0/1e22)
#if defined(_M_X64) || defined(__x86_64__) || \
defined(__ARMEL__) || defined(__avr32__) || \
defined(__hppa__) || defined(__ia64__) || \
defined(__mips__) || \
defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \
defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
defined(__SH4__) || defined(__alpha__) || \
defined(_MIPS_ARCH_MIPS32R2) || \
defined(__AARCH64EL__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
#if defined(_WIN32)
// Windows uses a 64bit wide floating point stack.
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#else
#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
#endif // _WIN32
#else
#error Target architecture was not detected as supported by Double-Conversion.
#endif
#include <stdint.h>
// The following macro works on both 32 and 64-bit platforms.
// Usage: instead of writing 0x1234567890123456
// write UINT64_2PART_C(0x12345678,90123456);
#define UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
// The expression ARRAY_SIZE(a) is a compile-time constant of type
// size_t which represents the number of elements of the given
// array. You should only use ARRAY_SIZE on statically allocated
// arrays.
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
// A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class
#ifndef DISALLOW_COPY_AND_ASSIGN
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif
// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
//
// This should be used in the private: declarations for a class
// that wants to prevent anyone from instantiating it. This is
// especially useful for classes containing only static methods.
#ifndef DISALLOW_IMPLICIT_CONSTRUCTORS
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName(); \
DISALLOW_COPY_AND_ASSIGN(TypeName)
#endif
namespace double_conversion {
static const int kCharSize = sizeof(char);
// Returns the maximum of the two parameters.
template <typename T>
static T Max(T a, T b) {
return a < b ? b : a;
}
// Returns the minimum of the two parameters.
template <typename T>
static T Min(T a, T b) {
return a < b ? a : b;
}
inline int StrLength(const char* string) {
size_t length = strlen(string);
ASSERT(length == static_cast<size_t>(static_cast<int>(length)));
return static_cast<int>(length);
}
// This is a simplified version of V8's Vector class.
template <typename T>
class Vector {
public:
Vector() : start_(NULL), length_(0) {}
Vector(T* data, int length) : start_(data), length_(length) {
ASSERT(length == 0 || (length > 0 && data != NULL));
}
// Returns a vector using the same backing storage as this one,
// spanning from and including 'from', to but not including 'to'.
Vector<T> SubVector(int from, int to) {
ASSERT(to <= length_);
ASSERT(from < to);
ASSERT(0 <= from);
return Vector<T>(start() + from, to - from);
}
// Returns the length of the vector.
int length() const { return length_; }
// Returns whether or not the vector is empty.
bool is_empty() const { return length_ == 0; }
// Returns the pointer to the start of the data in the vector.
T* start() const { return start_; }
// Access individual vector elements - checks bounds in debug mode.
T& operator[](int index) const {
ASSERT(0 <= index && index < length_);
return start_[index];
}
T& first() { return start_[0]; }
T& last() { return start_[length_ - 1]; }
private:
T* start_;
int length_;
};
// Helper class for building result strings in a character buffer. The
// purpose of the class is to use safe operations that checks the
// buffer bounds on all operations in debug mode.
class StringBuilder {
public:
StringBuilder(char* buffer, int size)
: buffer_(buffer, size), position_(0) { }
~StringBuilder() { if (!is_finalized()) Finalize(); }
int size() const { return buffer_.length(); }
// Get the current position in the builder.
int position() const {
ASSERT(!is_finalized());
return position_;
}
// Reset the position.
void Reset() { position_ = 0; }
// Add a single character to the builder. It is not allowed to add
// 0-characters; use the Finalize() method to terminate the string
// instead.
void AddCharacter(char c) {
ASSERT(c != '\0');
ASSERT(!is_finalized() && position_ < buffer_.length());
buffer_[position_++] = c;
}
// Add an entire string to the builder. Uses strlen() internally to
// compute the length of the input string.
void AddString(const char* s) {
AddSubstring(s, StrLength(s));
}
// Add the first 'n' characters of the given string 's' to the
// builder. The input string must have enough characters.
void AddSubstring(const char* s, int n) {
ASSERT(!is_finalized() && position_ + n < buffer_.length());
ASSERT(static_cast<size_t>(n) <= strlen(s));
memmove(&buffer_[position_], s, n * kCharSize);
position_ += n;
}
// Add character padding to the builder. If count is non-positive,
// nothing is added to the builder.
void AddPadding(char c, int count) {
for (int i = 0; i < count; i++) {
AddCharacter(c);
}
}
// Finalize the string by 0-terminating it and returning the buffer.
char* Finalize() {
ASSERT(!is_finalized() && position_ < buffer_.length());
buffer_[position_] = '\0';
// Make sure nobody managed to add a 0-character to the
// buffer while building the string.
ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_));
position_ = -1;
ASSERT(is_finalized());
return buffer_.start();
}
private:
Vector<char> buffer_;
int position_;
bool is_finalized() const { return position_ < 0; }
DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
};
// The type-based aliasing rule allows the compiler to assume that pointers of
// different types (for some definition of different) never alias each other.
// Thus the following code does not work:
//
// float f = foo();
// int fbits = *(int*)(&f);
//
// The compiler 'knows' that the int pointer can't refer to f since the types
// don't match, so the compiler may cache f in a register, leaving random data
// in fbits. Using C++ style casts makes no difference, however a pointer to
// char data is assumed to alias any other pointer. This is the 'memcpy
// exception'.
//
// Bit_cast uses the memcpy exception to move the bits from a variable of one
// type of a variable of another type. Of course the end result is likely to
// be implementation dependent. Most compilers (gcc-4.2 and MSVC 2005)
// will completely optimize BitCast away.
//
// There is an additional use for BitCast.
// Recent gccs will warn when they see casts that may result in breakage due to
// the type-based aliasing rule. If you have checked that there is no breakage
// you can use BitCast to cast one pointer type to another. This confuses gcc
// enough that it can no longer see that you have cast one pointer type to
// another thus avoiding the warning.
template <class Dest, class Source>
inline Dest BitCast(const Source& source) {
static_assert(sizeof(Dest) == sizeof(Source),
"BitCast's source and destination types must be the same size");
Dest dest;
memmove(&dest, &source, sizeof(dest));
return dest;
}
template <class Dest, class Source>
inline Dest BitCast(Source* source) {
return BitCast<Dest>(reinterpret_cast<uintptr_t>(source));
}
} // namespace double_conversion
#endif // DOUBLE_CONVERSION_UTILS_H_
| mpl-2.0 |
buddhaCode/shopware | _sql/migrations/109-add-translations.php | 25497 | <?php
class Migrations_Migration109 Extends Shopware\Components\Migrations\AbstractMigration
{
public function up()
{
$sql = <<<'EOD'
SET @formID = (SELECT id FROM s_core_config_forms WHERE `name`='Mail');
SET @localeID = (SELECT id FROM s_core_locales WHERE locale='en_GB');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_encoding');
UPDATE s_core_config_elements SET `label`='Encoding der Nachricht', description='8bit, 7bit, base64, binary und quoted-printable' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Message encoding', '8bit, 7bit, base64, binary or quoted-printable');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_hostname');
UPDATE s_core_config_elements SET `label`='Hostname für die Message-ID', description='Wird im Header mittels HELO verwendet. Andernfalls wird der Wert aus SERVER_NAME oder "localhost.localdomain" genutzt.' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Message ID hostname', 'Will be received in headers on a default HELO string. If not defined, the value returned from SERVER_NAME, "localhost.localdomain" will be used.');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_mailer');
UPDATE s_core_config_elements SET `label`='Methode zum Senden der Mail', description='mail, SMTP oder file' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Sending method', 'mail, SMTP or file');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_port');
UPDATE s_core_config_elements SET `label`='Standard Port', description='Setzt den Standard SMTP Server-Port' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Default port', 'Sets the default SMTP server port.');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_smtpsecure');
UPDATE s_core_config_elements SET `label`='Verbindungs Präfix', description='"", ssl, oder tls' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Connection prefix', '"", ssl, or tls');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_host');
UPDATE s_core_config_elements SET label='Mail Host', `description`='Es kann auch ein anderer Port über dieses Muster genutzt werden: [hostname:port] - Bsp.: smtp1.example.com:25' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Mail host', 'You can also specify a different port by using this format: [hostname:port] - e.g., smtp1.example.com:25');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_auth');
UPDATE s_core_config_elements SET `label`='Verbindungs-Authentifizierung', description='plain, login oder crammd5' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'Connection auth', 'plain, login or crammd5');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_username');
UPDATE s_core_config_elements SET `label`='SMTP Benutzername' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'SMTP username', NULL);
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='mailer_password');
UPDATE s_core_config_elements SET `label`='SMTP Passwort' WHERE id=@elementID;
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label, description) VALUES(@elementID, @localeID, 'SMTP password', NULL);
SET @formID = (SELECT id FROM s_core_config_forms WHERE label='InputFilter');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='own_filter');
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label) VALUES(@elementID, @localeID, 'Own filter');
SET @formID = (SELECT id FROM s_core_config_forms WHERE label='Anmeldung / Registrierung');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='accountPasswordCheck');
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label) VALUES(@elementID, @localeID, 'Check current password at password-change requests');
SET @formID = (SELECT id FROM s_core_config_forms WHERE label='Newsletter');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='MailCampaignsPerCall');
INSERT IGNORE INTO s_core_config_element_translations (element_id, locale_id, label) VALUES(@elementID, @localeID, 'Number of mails sent per call');
UPDATE s_core_config_element_translations SET description = 'Remind the customer about the review after purchase' WHERE label='Automatically reminder customer to submit reviews';
SET @formID = (SELECT id FROM s_core_config_forms WHERE `name`='LastArticles');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='show');
UPDATE s_core_config_element_translations SET `label`='Display recently viewed items' WHERE element_id=@elementID AND label='Show';
SET @formID = (SELECT id FROM s_core_config_forms WHERE `name`='AdvancedMenu');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='show');
UPDATE s_core_config_element_translations SET `label`='Activate expandable menu in storefront' WHERE element_id=@elementID AND label='Show';
SET @formID = (SELECT id FROM s_core_config_forms WHERE `name`='Compare');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='show');
UPDATE s_core_config_element_translations SET `label`='Display item comparison' WHERE element_id=@elementID AND label='Show';
SET @formID = (SELECT id FROM s_core_config_forms WHERE `name`='TagCloud');
SET @elementID = (SELECT id FROM s_core_config_elements WHERE form_id=@formID AND `name`='show');
UPDATE s_core_config_element_translations SET `label`='Display tag cloud' WHERE element_id=@elementID AND label='Show';
UPDATE s_core_config_form_translations SET label='Basic information' WHERE label='Master data';
UPDATE s_core_config_form_translations SET label='Country areas' WHERE label='Country-Areas';
UPDATE s_core_config_form_translations SET label='Shop page groups' WHERE label='Shop pages-groups';
UPDATE s_core_config_form_translations SET label='Input filter' WHERE label='InputFilter';
UPDATE s_core_config_form_translations SET label='Items' WHERE label='Product';
UPDATE s_core_config_form_translations SET label='Item numbers' WHERE label='Product numbers';
UPDATE s_core_config_form_translations SET label='Item open text fields' WHERE label='Product open text fields';
UPDATE s_core_config_form_translations SET label='Customer reviews' WHERE label='Product evaluations';
UPDATE s_core_config_form_translations SET label='Recently viewed items' WHERE label='Product process';
UPDATE s_core_config_form_translations SET label='Item comparison' WHERE label='Product comparison';
UPDATE s_core_config_form_translations SET label='Categories / lists' WHERE label='Categories/lists';
UPDATE s_core_config_form_translations SET label='Top seller / novelties' WHERE label='Top seller/novelties';
UPDATE s_core_config_form_translations SET label='Cross selling / item details' WHERE label='Cross Selling/Product details';
UPDATE s_core_config_form_translations SET label='Shopping cart / item details' WHERE label='Shopping cart/aticle details';
UPDATE s_core_config_form_translations SET label='Login / registration' WHERE label='Login/registration';
UPDATE s_core_config_form_translations SET label='Smart Search' WHERE label='Search';
UPDATE s_core_config_form_translations SET label='Discounts / surcharges' WHERE label='Discounts/surcharges';
UPDATE s_core_config_form_translations SET label='Email settings' WHERE label='e-mail settings';
UPDATE s_core_config_form_translations SET label='Shipping costs module' WHERE label='Shipping costs-module';
UPDATE s_core_config_form_translations SET label='SEO / router settings' WHERE label='SEO/Router settings';
UPDATE s_core_config_form_translations SET label='Item recommendations' WHERE label='Product recommendations';
UPDATE s_core_config_form_translations SET label='Additional settings' WHERE label='Further settings';
UPDATE s_core_config_element_translations SET label='Category buffer time' WHERE label='Categories buffering time';
UPDATE s_core_config_element_translations SET label='Price buffer time' WHERE label='Prices buffering time';
UPDATE s_core_config_element_translations SET label='Top seller buffer time' WHERE label='Top seller buffering time';
UPDATE s_core_config_element_translations SET label='Manufacturer buffer time' WHERE label='Manufacturer buffering time';
UPDATE s_core_config_element_translations SET label='Item detail buffer time' WHERE label='Product detail buffering time';
UPDATE s_core_config_element_translations SET label='Country list buffer time' WHERE label='Country list buffering time';
UPDATE s_core_config_element_translations SET label='Translation buffer time' WHERE label='Translations buffering time';
UPDATE s_core_config_element_translations SET label='Warning: This may negatively affect performance!' WHERE description='Warning: This might have negative effects on your performance!';
UPDATE s_core_config_element_translations SET label='Log errors in database' WHERE label='Write error in database';
UPDATE s_core_config_element_translations SET label='Notify shop owners' WHERE label='Send error to shop owner';
UPDATE s_core_config_element_translations SET label='Activate Remote File Inclusion protection' WHERE label='Activate RemoteFileInclusion-protection';
UPDATE s_core_config_element_translations SET label='Customer reviews must be approved' WHERE label='Product evaluations neey,d to be unlocked';
UPDATE s_core_config_element_translations SET label='Deactivate customer reviews' WHERE label='Deactivate product evaluations%';
UPDATE s_core_config_element_translations SET label='Size of display' WHERE label='Size of preview picture';
UPDATE s_core_config_element_translations SET label='Number of days items are displayed' WHERE label='Storage period in days';
UPDATE s_core_config_element_translations SET label='Maximum number of items to display' WHERE label='Number of products in process (recently viewed)';
UPDATE s_core_config_element_translations SET label='Number of tiers' WHERE label='Number of levels';
UPDATE s_core_config_element_translations SET label='Maximum number of items to be compared' WHERE label='Maximum number of products to be compared';
UPDATE s_core_config_element_translations SET label='Number of ranks' WHERE label='Number of steps';
UPDATE s_core_config_element_translations SET label='Time period (in days) considered' WHERE label='Considered time in days';
UPDATE s_core_config_element_translations SET label='Items per page' WHERE label='Products per page';
UPDATE s_core_config_element_translations SET label='Maximum number of pages per category' WHERE label='Categories max. number of pages';
UPDATE s_core_config_element_translations SET label='Selection of items per page' WHERE label='Selection of products per page';
UPDATE s_core_config_element_translations SET label='Available template categories' WHERE label='Available templates categories';
UPDATE s_core_config_element_translations SET label='Jump to detail if only one item is available' WHERE label='Jump to detail if only one product is available';
UPDATE s_core_config_element_translations SET label='Number of days items are considered new' WHERE label='Mark products as new (days)';
UPDATE s_core_config_element_translations SET label='Number of days considered for top sellers' WHERE label='Mark products as top seller';
UPDATE s_core_config_element_translations SET label='Number of items displayed as novelties' WHERE label='Number of products shown under novelties';
UPDATE s_core_config_element_translations SET label='Number of similar items for cross selling' WHERE label='Number of similar products for cross selling';
UPDATE s_core_config_element_translations SET label='Number of items "customers also bought"' WHERE label='Number of customers also bought"products cross selling"';
UPDATE s_core_config_element_translations SET label='Number of automatically determined similar products (detail page)' WHERE label='Number of automatically determined similar products (detail page)';
UPDATE s_core_config_element_translations SET label='Maximum number of items selectable via pull-down menu' WHERE label='Max. number of selectable products/products via pulldown menu';
UPDATE s_core_config_element_translations SET label='Text for unavailable items' WHERE label='Text for non-available products';
UPDATE s_core_config_element_translations SET label='Minimum shopping cart value for offering individual requests' WHERE label='Min. shopping cart value from which option of individual request is offered';
UPDATE s_core_config_element_translations SET label='Check stock in real time on detail page' WHERE label='Check stock level on detail page in real time';
UPDATE s_core_config_element_translations SET label='Maximum number of variants per item' WHERE label='Max. number of configurator variants per product';
UPDATE s_core_config_element_translations SET label='Deactivate out-of-stock items' WHERE label='Deactivate sales products without stock level';
UPDATE s_core_config_element_translations SET label='Display main items in bundles' WHERE label='Show main products in bundles';
UPDATE s_core_config_element_translations SET label='Display inventory shortages in shopping cart' WHERE label='Show in shopping cart if stock level is undershot';
UPDATE s_core_config_element_translations SET label='Available templates for detail page' WHERE label='Available templates detail page';
UPDATE s_core_config_element_translations SET label='Available templates for blog detail page' WHERE label='Available templates blog detail page';
UPDATE s_core_config_element_translations SET label='Minimum password length (registration)' WHERE label='Min. lenth of password (registration)';
UPDATE s_core_config_element_translations SET label='Standard payment method ID (registration)' WHERE label='Standard payment method (Id) (registration)';
UPDATE s_core_config_element_translations SET label='Standard recipient group ID for registered customers (system / newsletter)' WHERE label='Standard group of recipients (ID) for registered customers (System/newsletter)';
UPDATE s_core_config_element_translations SET label='Generate customer numbers automatically' WHERE label='Shopware generates customer numbers';
UPDATE s_core_config_element_translations SET label='Deactivate AGB terms checkbox on checkout page' WHERE label='Deactivate terms-checkbox on checkout page.';
UPDATE s_core_config_element_translations SET label='Default payment method ID' WHERE label='Fallback payment type (ID)';
UPDATE s_core_config_element_translations SET label='Data protection conditions must be accepted via checkbox' WHERE label='Data protection regulations need to be accepted over checkbox';
UPDATE s_core_config_element_translations SET label='Deactivate "no customer account"' WHERE label='deactivate No customer account';
UPDATE s_core_config_element_translations SET label='Maximum search term length' WHERE label='Max. length of search term';
UPDATE s_core_config_element_translations SET label='Number of live search results' WHERE label='Number of results live search';
UPDATE s_core_config_element_translations SET label='Maximum distance allowed for string matching (%)' WHERE label='Max. distance for fuzzy search (percentage)';
UPDATE s_core_config_element_translations SET label='Last update (dd.mm.yyyy)' WHERE label='Date of the last update';
UPDATE s_core_config_element_translations SET label='Minimum relevance for top items (%)' WHERE label='Min. relevance for top products (percentage)';
UPDATE s_core_config_element_translations SET label='Maximum distance allowed for partial names (%)' WHERE label='Max. distance for partial names (percentage)';
UPDATE s_core_config_element_translations SET label='Vouchers designated as' WHERE label='Designation vouchers';
UPDATE s_core_config_element_translations SET label='Discounts designated as' WHERE label='Designation discounts';
UPDATE s_core_config_element_translations SET label='Shortages designated as' WHERE label='Designation of reduced quantities';
UPDATE s_core_config_element_translations SET label='Surcharges on payment methods designated as' WHERE label='Designation for percental surcharge on payment method';
UPDATE s_core_config_element_translations SET label='Order number for discounts' WHERE label='Discounts order number';
UPDATE s_core_config_element_translations SET label='Order number for shortages' WHERE label='Reduced quantities order number';
UPDATE s_core_config_element_translations SET label='Order number for deduction dispatch rule' WHERE label='Deduction dispatch rule (order number)';
UPDATE s_core_config_element_translations SET label='Deduction dispatch rule designated as' WHERE label='Deduction dispatch rules (designation)';
UPDATE s_core_config_element_translations SET label='All-inclusive surcharges on payment methods designated as' WHERE label='Lump sum for payment method (description)';
UPDATE s_core_config_element_translations SET label='Order number for all-inclusive surcharges on payment methods designated as' WHERE label='Lump sum for payment method (order number)';
UPDATE s_core_config_element_translations SET label='Send registration confirmation to shop owner in CC' WHERE label='Send registration confirmation to shop owner in CC.';
UPDATE s_core_config_element_translations SET label='Double opt in for newsletter subscriptions' WHERE label='Double-opt-in for newsletter subscriptions';
UPDATE s_core_config_element_translations SET label='Double opt in for customer reviews' WHERE label='Double-opt-in for product evaluations';
UPDATE s_core_config_element_translations SET label='Order status - Changes to CC addresses' WHERE label='Order status - Chnages CC address';
UPDATE s_core_config_element_translations SET label='Block orders with no available shipping type' WHERE label='Block order with no available shipping type';
UPDATE s_core_config_element_translations SET label='Redirect to starting page in case of unavailable categories / items' WHERE label='Redirect to starting page in case of non-available categories/products ';
UPDATE s_core_config_element_translations SET label='Prepare meta description of categories / items' WHERE label='Prepare meta description od products/categories';
UPDATE s_core_config_element_translations SET label='SEO nofollow queries' WHERE label='SEO-Nofollow-Querys';
UPDATE s_core_config_element_translations SET label='SEO nofollow viewports' WHERE label='SEO-Nofollow Viewports';
UPDATE s_core_config_element_translations SET label='Remove unnecessary blank spaces or line breaks' WHERE label='Remove needless blank spaces or line breaks';
UPDATE s_core_config_element_translations SET label='Query aliases' WHERE label='Query-Aliase';
UPDATE s_core_config_element_translations SET label='SEO follow backlinks' WHERE label='SEO-Follow Backlinks';
UPDATE s_core_config_element_translations SET label='Use SEO canonical tags' WHERE label='Use SEO Canonical Tags';
UPDATE s_core_config_element_translations SET label='Last update (dd.mm.yyyy)' WHERE label='Date of last update';
UPDATE s_core_config_element_translations SET label='SEO URLs caching timetable' WHERE label='SEO-URLs caching time table';
UPDATE s_core_config_element_translations SET label='SEO URLs item template' WHERE label='SEO URLs product template';
UPDATE s_core_config_element_translations SET label='SEO URLs blog template' WHERE label='SEO-URLs blog template';
UPDATE s_core_config_element_translations SET label='SEO URLs landing page template' WHERE label='SEO-URLs landingpage template';
UPDATE s_core_config_element_translations SET label='Display "customers also bought" recommendations' WHERE label='Show Customers-also-bought-recommendation';
UPDATE s_core_config_element_translations SET label='Number of items per page in the list' WHERE label='Number of products per page in the list';
UPDATE s_core_config_element_translations SET label='Maximum number of pages in the list' WHERE label='Max. number of pages in the list.';
UPDATE s_core_config_element_translations SET label='Display "customers also viewed" recommendations' WHERE label='Show customers-also-viewed-recommendation';
UPDATE s_core_config_element_translations SET label='Number of items per page in the list' WHERE label='Number of products par page in the list';
UPDATE s_core_config_element_translations SET label='Display shop cancellation policy' WHERE label='Shop cancellation policy';
UPDATE s_core_config_element_translations SET label='Display newsletter registration' WHERE label='Show newsletter registration';
UPDATE s_core_config_element_translations SET label='Display bank detail notice' WHERE label='Show bank detail notice';
UPDATE s_core_config_element_translations SET label='Display further notices' WHERE label='Show further notices';
UPDATE s_core_config_element_translations SET label='Display further options' WHERE label='Show further options';
UPDATE s_core_config_element_translations SET label='Display "free with purchase" items' WHERE label='Show premium products';
UPDATE s_core_config_element_translations SET label='Display country descriptions' WHERE label='Show country descriptions';
UPDATE s_core_config_element_translations SET label='Display information for net orders' WHERE label='Show information for net orders';
UPDATE s_core_config_element_translations SET label='Display item details in modal box' WHERE label='Show product details in modal box';
UPDATE s_core_config_element_translations SET label='Shopping cart header background color' WHERE label='Background color of shopping cart-header';
UPDATE s_core_config_element_translations SET label='Shopping cart header text color' WHERE label='Text color of shopping cart header';
UPDATE s_core_config_element_translations SET label='Google Analytics ID' WHERE label='Google Analytics-ID';
UPDATE s_core_config_element_translations SET label='Google Conversion ID' WHERE label='Google Conversion-ID';
UPDATE s_core_config_element_translations SET label='Anonymous IP address' WHERE label='Anonymise IP address';
UPDATE s_core_config_element_translations SET label='Confirm customer email addresses', description='Customers must enter email addresses twice, in order to avoid typing mistakes.' WHERE label='E-mail address must be entered twice.';
UPDATE s_core_config_element_translations SET label='Hide "add to shopping cart" option if item is out-of-stock', description='Customers can choose to be informed per email when an item is "now in stock".' WHERE label='Hide shopping cart with e-mail notification';
UPDATE s_core_config_element_translations SET label='Automatically reminder customer to submit reviews', description='' WHERE label='Send automatical reminder of product evaluation';
UPDATE s_core_config_element_translations SET label='Days to wait before sending reminder', description='' WHERE label='Days until the reminder e-mail will be sent';
UPDATE s_core_config_element_translations SET label='Customer reviews must be approved' WHERE label='Product evaluations need to be unlocked';
UPDATE s_core_config_element_translations SET label='Item detail buffer time' WHERE label='Product detail page buffering time';
UPDATE s_core_config_element_translations SET label='Automatic item number suggestions' WHERE label='Automatical suggestion of product number';
UPDATE s_core_config_element_translations SET label='Prefix for automatically generated item numbers' WHERE label='Prefix für automatically generated product number';
UPDATE s_core_config_element_translations SET label='Require country with shipping address' WHERE label='Check country with shipping address';
INSERT IGNORE INTO s_core_translations (objecttype, objectdata, objectkey, objectlanguage) VALUES ('config_payment', 'a:4:{i:4;a:2:{s:11:"description";s:7:"Invoice";s:21:"additionalDescription";s:141:"Payment by invoice. Shopware provides automatic invoicing for all customers on orders after the first, in order to avoid defaults on payment.";}i:2;a:2:{s:11:"description";s:5:"Debit";s:21:"additionalDescription";s:15:"Additional text";}i:3;a:2:{s:11:"description";s:16:"Cash on delivery";s:21:"additionalDescription";s:25:"(including 2.00 Euro VAT)";}i:5;a:2:{s:11:"description";s:15:"Paid in advance";s:21:"additionalDescription";s:57:"The goods are delivered directly upon receipt of payment.";}}', 1, @localeID);
EOD;
$this->addSql($sql);
}
}
| agpl-3.0 |
SamuelMoraesF/Gitorious | app/controllers/groups_controller.rb | 3916 | # encoding: utf-8
#--
# Copyright (C) 2012-2013 Gitorious AS
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#++
class GroupsController < ApplicationController
before_filter :login_required, :except => [:index, :show]
before_filter :find_group_and_ensure_group_adminship, :only => [:edit, :update, :avatar]
before_filter :check_if_only_site_admins_can_create, :only => [:new, :create]
renders_in_global_context
def index
begin
groups, total_pages, page = paginated_groups
rescue RangeError
flash[:error] = "Page #{params[:page] || 1} does not exist"
redirect_to(groups_path, :status => 307) and return
end
render("index", :locals => {
:groups => groups,
:page => page,
:total_pages => total_pages
})
end
def show
group = Team.find_by_name!(params[:id])
events = paginate(:action => "show", :id => params[:id]) do
filter_paginated(params[:page], 30) do |page|
Team.events(group, page)
end
end
return if params.key?(:page) && events.length == 0
render("show", :locals => {
:group => group,
:mainlines => filter(group.repositories.mainlines),
:clones => filter(group.repositories.clones),
:projects => filter(group.projects),
:memberships => Team.memberships(group),
:events => events
})
end
def new
render("new", :locals => { :group => Team.new_group })
end
def edit
render("edit", :locals => { :group => @group })
end
def update
Team.update_group(@group, params)
flash[:success] = 'Team was updated'
redirect_to(group_path(@group))
rescue ActiveRecord::RecordInvalid
render(:action => "edit", :locals => { :group => @group })
end
def create
group = Team.create_group(params, current_user)
group.save!
flash[:success] = I18n.t("groups_controller.group_created")
redirect_to group_path(group)
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound
render("new", :locals => { :group => group })
end
def destroy
begin
Team.destroy_group(params[:id], current_user)
flash[:success] = "The team was deleted"
redirect_to(groups_path)
rescue Team::DestroyGroupError => e
flash[:error] = e.message
redirect_to(group_path(params[:id]))
end
end
# DELETE avatar
def avatar
Team.delete_avatar(@group)
flash[:success] = "The team image was deleted"
redirect_to(group_path(@group))
end
protected
def find_group_and_ensure_group_adminship
@group = Team.find_by_name!(params[:id])
unless admin?(current_user, @group)
access_denied and return
end
end
def check_if_only_site_admins_can_create
if Gitorious.restrict_team_creation_to_site_admins?
unless site_admin?(current_user)
flash[:error] = "Only site administrators may create teams"
redirect_to(:action => "index")
return false
end
end
end
def paginated_groups
page = (params[:page] || 1).to_i
groups, pages = JustPaginate.paginate(page, 50, Team.count) do |range|
Team.offset(range.first).limit(range.count).order_by_name
end
[groups, pages, page]
end
end
| agpl-3.0 |
bashrc/gnusocial-debian | src/plugins/BitlyUrl/BitlyUrlPlugin.php | 7232 | <?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Plugin to use bit.ly URL shortening services.
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugin
* @package StatusNet
* @author Craig Andrews <[email protected]>
* @author Brion Vibber <[email protected]>
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
* @copyright 2010 StatusNet, Inc http://status.net/
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
exit(1);
}
class BitlyUrlPlugin extends UrlShortenerPlugin
{
public $shortenerName = 'bit.ly';
public $serviceUrl = 'http://api.bit.ly/v3/shorten?longUrl=%s';
public $login; // To set a site-default when admins or users don't override it.
public $apiKey;
function onInitializePlugin(){
parent::onInitializePlugin();
if(!isset($this->serviceUrl)){
// TRANS: Exception thrown when bit.ly URL shortening plugin was configured incorrectly.
throw new Exception(_m('You must specify a serviceUrl for bit.ly URL shortening.'));
}
}
/**
* Add bit.ly to the list of available URL shorteners if it's configured,
* otherwise leave it out.
*
* @param array $shorteners
* @return boolean hook return value
*/
function onGetUrlShorteners(&$shorteners)
{
if ($this->getLogin() && $this->getApiKey()) {
return parent::onGetUrlShorteners($shorteners);
}
return true;
}
/**
* Short a URL
* @param url
* @return string shortened version of the url, or null if URL shortening failed
*/
protected function shorten($url) {
common_log(LOG_INFO, "bit.ly call for $url");
$response = $this->query($url);
common_log(LOG_INFO, "bit.ly answer for $url is ".$response->getBody());
return $this->decode($url, $response);
}
/**
* Get the user's or site-wide default bit.ly login name.
*
* @return string
*/
protected function getLogin()
{
$login = common_config('bitly', 'default_login');
if (!$login) {
$login = $this->login;
}
return $login;
}
/**
* Get the user's or site-wide default bit.ly API key.
*
* @return string
*/
protected function getApiKey()
{
$key = common_config('bitly', 'default_apikey');
if (!$key) {
$key = $this->apiKey;
}
return $key;
}
/**
* Inject API key into query before sending out...
*
* @param string $url
* @return HTTPResponse
*/
protected function query($url)
{
// http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/shorten
$params = http_build_query(array(
'login' => $this->getLogin(),
'apiKey' => $this->getApiKey()), '', '&');
$serviceUrl = sprintf($this->serviceUrl, urlencode($url)) . '&' . $params;
$request = HTTPClient::start();
return $request->get($serviceUrl);
}
/**
* JSON decode for API result
*/
protected function decode($url, $response)
{
$msg = "bit.ly returned unknown response with unknown message for $url";
if ($response->isOk()) {
$body = $response->getBody();
common_log(LOG_INFO, $body);
$json = json_decode($body, true);
if ($json['status_code'] == 200) {
if (isset($json['data']['url'])) {
common_log(LOG_INFO, "bit.ly returned ".$json['data']['url']." as short URL for $url");
return $json['data']['url'];
}
$msg = "bit.ly returned ".$json['status_code']." response, but didn't find expected URL $url in $body";
}else{
$msg = "bit.ly returned ".$json['status_code']." response with ".$json['status_txt']." for $url";
}
}
common_log(LOG_ERR, $msg);
return null;
}
function onPluginVersion(array &$versions)
{
$versions[] = array('name' => sprintf('BitlyUrl (%s)', $this->shortenerName),
'version' => GNUSOCIAL_VERSION,
'author' => 'Craig Andrews, Brion Vibber',
'homepage' => 'http://status.net/wiki/Plugin:BitlyUrl',
'rawdescription' =>
// TRANS: Plugin description. %1$s is the URL shortening service base URL (for example "bit.ly").
sprintf(_m('Uses <a href="http://%1$s/">%1$s</a> URL-shortener service.'),
$this->shortenerName));
return true;
}
/**
* Hook for RouterInitialized event.
*
* @param URLMapper $m path-to-action mapper
* @return boolean hook return
*/
public function onRouterInitialized(URLMapper $m)
{
$m->connect('panel/bitly',
array('action' => 'bitlyadminpanel'));
return true;
}
/**
* If the plugin's installed, this should be accessible to admins.
*/
function onAdminPanelCheck($name, &$isOK)
{
if ($name == 'bitly') {
$isOK = true;
return false;
}
return true;
}
/**
* Add the bit.ly admin panel to the list...
*/
function onEndAdminPanelNav($nav)
{
if (AdminPanelAction::canAdmin('bitly')) {
$action_name = $nav->action->trimmed('action');
$nav->out->menuItem(common_local_url('bitlyadminpanel'),
// TRANS: Menu item in administration menus for bit.ly URL shortening settings.
_m('bit.ly'),
// TRANS: Title for menu item in administration menus for bit.ly URL shortening settings.
_m('bit.ly URL shortening.'),
$action_name == 'bitlyadminpanel',
'nav_bitly_admin_panel');
}
return true;
}
/**
* Internal hook point to check the default global credentials so
* the admin form knows if we have a fallback or not.
*
* @param string $login
* @param string $apiKey
* @return boolean hook return value
*/
function onBitlyDefaultCredentials(&$login, &$apiKey)
{
$login = $this->login;
$apiKey = $this->apiKey;
return false;
}
}
| agpl-3.0 |
ygol/odoo | addons/website_event_crm_questions/models/event_registration.py | 1282 | # -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
class EventRegistration(models.Model):
_inherit = 'event.registration'
def _get_lead_description_registration(self, prefix='', line_suffix=''):
"""Add the questions and answers linked to the registrations into the description of the lead."""
reg_description = super(EventRegistration, self)._get_lead_description_registration(prefix=prefix, line_suffix=line_suffix)
if not self.registration_answer_ids:
return reg_description
answer_descriptions = []
for answer in self.registration_answer_ids:
answer_value = answer.value_answer_id.name if answer.question_type == "simple_choice" else answer.value_text_box
answer_value = "\n".join([" %s" % line for line in answer_value.split('\n')])
answer_descriptions.append(" - %s\n%s" % (answer.question_id.title, answer_value))
return "%s\n%s\n%s" % (reg_description, _("Questions"), '\n'.join(answer_descriptions))
def _get_lead_description_fields(self):
res = super(EventRegistration, self)._get_lead_description_fields()
res.append('registration_answer_ids')
return res
| agpl-3.0 |
andy32323/inspectIT | inspectIT/src/info/novatec/inspectit/rcp/InspectITImages.java | 13358 | package info.novatec.inspectit.rcp;
/**
* Defines all the images for the InspectIT UI. Note that all images are automatically added to the
* registry on the inspectIT start up.
*
* Please note that this is NOT all the images available. There are so many additional images that
* you can find at
* https://inspectit-performance.atlassian.net/wiki/display/DEV/Icons+and+banners?preview=%2F5019224
* %2F9109584%2Ffugue-icons-3.5.5.zip
*
* @author Ivan Senic
* @author Stefan Siegl
*/
public interface InspectITImages {
// NOCHKALL: We will not javadoc comment each image.
// images created by us
String IMG_SERVER_ONLINE = InspectITConstants.ICON_PATH_SELFMADE + "server_online.png";
String IMG_SERVER_OFFLINE = InspectITConstants.ICON_PATH_SELFMADE + "server_offline.png";
String IMG_SERVER_ONLINE_SMALL = InspectITConstants.ICON_PATH_SELFMADE + "server_online_16x16.png";
String IMG_SERVER_OFFLINE_SMALL = InspectITConstants.ICON_PATH_SELFMADE + "server_offline_16x16.png";
String IMG_SERVER_REFRESH = InspectITConstants.ICON_PATH_SELFMADE + "server_refresh.png";
String IMG_SERVER_REFRESH_SMALL = InspectITConstants.ICON_PATH_SELFMADE + "server_refresh_16x16.png";
String IMG_SERVER_ADD = InspectITConstants.ICON_PATH_SELFMADE + "server_add.png";
String IMG_RETURN = InspectITConstants.ICON_PATH_SELFMADE + "return.png";
String IMG_PARAMETER = InspectITConstants.ICON_PATH_SELFMADE + "parameter.png";
String IMG_FIELD = InspectITConstants.ICON_PATH_SELFMADE + "field.png";
// images from Eclipse, license EPL 1.0
String IMG_ACTIVITY = InspectITConstants.ICON_PATH_ECLIPSE + "debugtt_obj.gif";
String IMG_ADD = InspectITConstants.ICON_PATH_ECLIPSE + "add_obj.gif";
String IMG_ALERT = InspectITConstants.ICON_PATH_ECLIPSE + "alert_obj.gif";
String IMG_ANNOTATION = InspectITConstants.ICON_PATH_ECLIPSE + "annotation_obj.gif";
String IMG_CALL_HIERARCHY = InspectITConstants.ICON_PATH_ECLIPSE + "call_hierarchy.gif";
String IMG_CHECKMARK = InspectITConstants.ICON_PATH_ECLIPSE + "complete_status.gif";
String IMG_CLASS = InspectITConstants.ICON_PATH_ECLIPSE + "class_obj.gif";
String IMG_CLASS_OVERVIEW = InspectITConstants.ICON_PATH_ECLIPSE + "class_obj.gif";
String IMG_CLOSE = InspectITConstants.ICON_PATH_ECLIPSE + "remove_co.gif";
String IMG_COLLAPSE = InspectITConstants.ICON_PATH_ECLIPSE + "collapseall.gif";
String IMG_COMPILATION_OVERVIEW = InspectITConstants.ICON_PATH_ECLIPSE + "workset.gif";
String IMG_CONFIGURATION = InspectITConstants.ICON_PATH_ECLIPSE + "config_obj.gif";
String IMG_COPY = InspectITConstants.ICON_PATH_ECLIPSE + "copy_edit.gif";
String IMG_DELETE = InspectITConstants.ICON_PATH_ECLIPSE + "delete_obj.gif";
String IMG_DISABLED = InspectITConstants.ICON_PATH_ECLIPSE + "disabled_co.gif";
String IMG_EXCEPTION_SENSOR = InspectITConstants.ICON_PATH_ECLIPSE + "exceptiontracer.gif";
String IMG_EXCEPTION_TREE = InspectITConstants.ICON_PATH_ECLIPSE + "exceptiontree.gif";
String IMG_EXPORT = InspectITConstants.ICON_PATH_ECLIPSE + "export.gif";
String IMG_FILTER = InspectITConstants.ICON_PATH_ECLIPSE + "filter_ps.gif";
String IMG_FOLDER = InspectITConstants.ICON_PATH_ECLIPSE + "prj_obj.gif";
String IMG_FONT = InspectITConstants.ICON_PATH_ECLIPSE + "font.gif";
String IMG_HELP = InspectITConstants.ICON_PATH_ECLIPSE + "help.gif";
String IMG_HTTP = InspectITConstants.ICON_PATH_ECLIPSE + "discovery.gif";
String IMG_HTTP_AGGREGATION_REQUESTMESSAGE = InspectITConstants.ICON_PATH_ECLIPSE + "showcat_co.gif";
String IMG_HTTP_TAGGED = InspectITConstants.ICON_PATH_ECLIPSE + "gel_sc_obj.gif";
String IMG_HOME = InspectITConstants.ICON_PATH_ECLIPSE + "home_nav.gif";
String IMG_IMPORT = InspectITConstants.ICON_PATH_ECLIPSE + "import.gif";
String IMG_INFORMATION = InspectITConstants.ICON_PATH_ECLIPSE + "info_obj.gif";
String IMG_INTERFACE = InspectITConstants.ICON_PATH_ECLIPSE + "int_obj.gif";
String IMG_ITEM_NA_GREY = InspectITConstants.ICON_PATH_ECLIPSE + "remove_exc.gif";
String IMG_LIVE_MODE = InspectITConstants.ICON_PATH_ECLIPSE + "start_task.gif";
String IMG_METHOD_PUBLIC = InspectITConstants.ICON_PATH_ECLIPSE + "methpub_obj.gif";
String IMG_METHOD_PROTECTED = InspectITConstants.ICON_PATH_ECLIPSE + "methpro_obj.gif";
String IMG_METHOD_DEFAULT = InspectITConstants.ICON_PATH_ECLIPSE + "methdef_obj.gif";
String IMG_METHOD_PRIVATE = InspectITConstants.ICON_PATH_ECLIPSE + "methpri_obj.gif";
String IMG_NEXT = InspectITConstants.ICON_PATH_ECLIPSE + "next_nav.gif";
String IMG_OVERLAY_UP = InspectITConstants.ICON_PATH_ECLIPSE + "over_co.gif";
String IMG_PACKAGE = InspectITConstants.ICON_PATH_ECLIPSE + "package_obj.gif";
String IMG_PREVIOUS = InspectITConstants.ICON_PATH_ECLIPSE + "prev_nav.gif";
String IMG_PRIORITY = InspectITConstants.ICON_PATH_ECLIPSE + "ihigh_obj.gif";
String IMG_PROPERTIES = InspectITConstants.ICON_PATH_ECLIPSE + "properties.gif";
String IMG_PROGRESS_VIEW = InspectITConstants.ICON_PATH_ECLIPSE + "pview.gif";
String IMG_READ = InspectITConstants.ICON_PATH_ECLIPSE + "read_obj.gif";
String IMG_REFRESH = InspectITConstants.ICON_PATH_ECLIPSE + "refresh.gif";
String IMG_REMOVE = InspectITConstants.ICON_PATH_ECLIPSE + "remove_correction.gif";
String IMG_RESTART = InspectITConstants.ICON_PATH_ECLIPSE + "term_restart.gif";
String IMG_SEARCH = InspectITConstants.ICON_PATH_ECLIPSE + "insp_sbook.gif";
String IMG_SHOW_ALL = InspectITConstants.ICON_PATH_ECLIPSE + "all_instances.gif";
String IMG_STACKTRACE = InspectITConstants.ICON_PATH_ECLIPSE + "stacktrace.gif";
String IMG_TERMINATE = InspectITConstants.ICON_PATH_ECLIPSE + "terminate_co.gif";
String IMG_TEST_MAPPINGS = InspectITConstants.ICON_PATH_ECLIPSE + "test.gif";
String IMG_THREADS_OVERVIEW = InspectITConstants.ICON_PATH_ECLIPSE + "debugt_obj.gif";
String IMG_TIMESTAMP = InspectITConstants.ICON_PATH_ECLIPSE + "dates.gif";
String IMG_TRASH = InspectITConstants.ICON_PATH_ECLIPSE + "trash.gif";
String IMG_WARNING = InspectITConstants.ICON_PATH_ECLIPSE + "warning_obj.gif";
String IMG_WINDOW = InspectITConstants.ICON_PATH_ECLIPSE + "defaultview_misc.gif";
// wizard banners, all from Eclipse, license EPL 1.0
String IMG_WIZBAN_ADD = InspectITConstants.WIZBAN_ICON_PATH + "add_wiz.png";
String IMG_WIZBAN_DOWNLOAD = InspectITConstants.WIZBAN_ICON_PATH + "download_wiz.png";
String IMG_WIZBAN_EDIT = InspectITConstants.WIZBAN_ICON_PATH + "edit_wiz.png";
String IMG_WIZBAN_ERROR = InspectITConstants.WIZBAN_ICON_PATH + "error_wiz.png";
String IMG_WIZBAN_EXPORT = InspectITConstants.WIZBAN_ICON_PATH + "export_wiz.png";
String IMG_WIZBAN_IMPORT = InspectITConstants.WIZBAN_ICON_PATH + "import_wiz.png";
String IMG_WIZBAN_LABEL = InspectITConstants.WIZBAN_ICON_PATH + "label_wiz.png";
String IMG_WIZBAN_RECORD = InspectITConstants.WIZBAN_ICON_PATH + "record_wiz.png";
String IMG_WIZBAN_SERVER = InspectITConstants.WIZBAN_ICON_PATH + "server_wiz.png";
String IMG_WIZBAN_STORAGE = InspectITConstants.WIZBAN_ICON_PATH + "storage_wiz.png";
String IMG_WIZBAN_UPLOAD = InspectITConstants.WIZBAN_ICON_PATH + "upload_wiz.png";
// images originally from Eclipse we modified (resized, added smth, etc), license EPL 1.0
String IMG_AGENT = InspectITConstants.ICON_PATH_ECLIPSE + "agent.gif";
String IMG_AGENT_ACTIVE = InspectITConstants.ICON_PATH_ECLIPSE + "agent_active.gif";
String IMG_AGENT_NOT_ACTIVE = InspectITConstants.ICON_PATH_ECLIPSE + "agent_na.gif";
String IMG_AGENT_NOT_SENDING = InspectITConstants.ICON_PATH_ECLIPSE + "agent_not_sending.gif";
String IMG_AGENT_NO_KEEPALIVE = InspectITConstants.ICON_PATH_ECLIPSE + "agent_no_keepalive.png";
String IMG_BUFFER_CLEAR = InspectITConstants.ICON_PATH_ECLIPSE + "buffer_clear.gif";
String IMG_BUFFER_COPY = InspectITConstants.ICON_PATH_ECLIPSE + "buffer_copy.gif";
String IMG_BUSINESS = InspectITConstants.ICON_PATH_ECLIPSE + "business.gif";
String IMG_CALENDAR = InspectITConstants.ICON_PATH_ECLIPSE + "calendar.gif";
String IMG_CATALOG = InspectITConstants.ICON_PATH_ECLIPSE + "catalog.gif";
String IMG_CHART_BAR = InspectITConstants.ICON_PATH_ECLIPSE + "graph_bar.gif";
String IMG_CHART_PIE = InspectITConstants.ICON_PATH_ECLIPSE + "graph_pie.gif";
String IMG_CLASS_EXCLUDE = InspectITConstants.ICON_PATH_ECLIPSE + "class_exclude.gif";
String IMG_EDIT = InspectITConstants.ICON_PATH_ECLIPSE + "edit.gif";
String IMG_FLAG = InspectITConstants.ICON_PATH_ECLIPSE + "flag.gif";
String IMG_HTTP_URL = InspectITConstants.ICON_PATH_ECLIPSE + "url.gif";
String IMG_LABEL = InspectITConstants.ICON_PATH_ECLIPSE + "label.gif";
String IMG_LABEL_ADD = InspectITConstants.ICON_PATH_ECLIPSE + "label_add.gif";
String IMG_LABEL_DELETE = InspectITConstants.ICON_PATH_ECLIPSE + "label_delete.gif";
String IMG_LOCATE_IN_HIERARCHY = InspectITConstants.ICON_PATH_ECLIPSE + "locate_in_hierarchy.gif";
String IMG_LOG = InspectITConstants.ICON_PATH_ECLIPSE + "log.gif";
String IMG_METHOD = InspectITConstants.ICON_PATH_ECLIPSE + "method.gif";
String IMG_MESSAGE = InspectITConstants.ICON_PATH_ECLIPSE + "message.gif";
String IMG_NUMBER = InspectITConstants.ICON_PATH_ECLIPSE + "number.gif";
String IMG_OVERLAY_ERROR = InspectITConstants.ICON_PATH_ECLIPSE + "overlay_error.gif";
String IMG_OVERLAY_PRIORITY = InspectITConstants.ICON_PATH_ECLIPSE + "overlay_priority.gif";
String IMG_PREFERENCES = InspectITConstants.ICON_PATH_ECLIPSE + "preferences.gif";
String IMG_RECORD = InspectITConstants.ICON_PATH_ECLIPSE + "record.gif";
String IMG_RECORD_GRAY = InspectITConstants.ICON_PATH_ECLIPSE + "record_gray.gif";
String IMG_RECORD_SCHEDULED = InspectITConstants.ICON_PATH_ECLIPSE + "record_schedule.gif";
String IMG_RECORD_STOP = InspectITConstants.ICON_PATH_ECLIPSE + "record_term.gif";
String IMG_OPTIONS = InspectITConstants.ICON_PATH_ECLIPSE + "options.gif";
String IMG_SERVER_INSTACE = InspectITConstants.ICON_PATH_ECLIPSE + "server_instance.gif";
String IMG_STORAGE = InspectITConstants.ICON_PATH_ECLIPSE + "storage.gif";
String IMG_STORAGE_AVAILABLE = InspectITConstants.ICON_PATH_ECLIPSE + "storage_available.gif";
String IMG_STORAGE_CLOSED = InspectITConstants.ICON_PATH_ECLIPSE + "storage_readable.gif";
String IMG_STORAGE_DOWNLOADED = InspectITConstants.ICON_PATH_ECLIPSE + "storage_download.gif";
String IMG_STORAGE_FINALIZE = InspectITConstants.ICON_PATH_ECLIPSE + "storage_finalize.gif";
String IMG_STORAGE_NOT_AVAILABLE = InspectITConstants.ICON_PATH_ECLIPSE + "storage_na.gif";
String IMG_STORAGE_OPENED = InspectITConstants.ICON_PATH_ECLIPSE + "storage_writable.gif";
String IMG_STORAGE_OVERLAY = InspectITConstants.ICON_PATH_ECLIPSE + "storage_overlay.gif";
String IMG_STORAGE_RECORDING = InspectITConstants.ICON_PATH_ECLIPSE + "storage_recording.gif";
String IMG_STORAGE_UPLOAD = InspectITConstants.ICON_PATH_ECLIPSE + "storage_upload.gif";
String IMG_SUPERCLASS = InspectITConstants.ICON_PATH_ECLIPSE + "class_hierarchy.gif";
String IMG_TIME = InspectITConstants.ICON_PATH_ECLIPSE + "time.gif";
String IMG_TIME_DELTA = InspectITConstants.ICON_PATH_ECLIPSE + "time_delta.gif";
String IMG_TIMEFRAME = InspectITConstants.ICON_PATH_ECLIPSE + "timeframe.gif";
String IMG_TIMER = InspectITConstants.ICON_PATH_ECLIPSE + "method_time.gif";
String IMG_TOOL = InspectITConstants.ICON_PATH_ECLIPSE + "build.gif";
String IMG_TRANSFORM = InspectITConstants.ICON_PATH_ECLIPSE + "transform.gif";
String IMG_USER = InspectITConstants.ICON_PATH_ECLIPSE + "user.gif";
// Fugue set - license Creative Commons v3.0
String IMG_ADDRESSBOOK = InspectITConstants.ICON_PATH_FUGUE + "address-book.png";
String IMG_ADDRESSBOOK_BLUE = InspectITConstants.ICON_PATH_FUGUE + "address-book-blue.png";
String IMG_ADDRESSBOOK_PLUS = InspectITConstants.ICON_PATH_FUGUE + "address-book-plus.png";
String IMG_BLOCK = InspectITConstants.ICON_PATH_FUGUE + "block.png";
String IMG_COMPASS = InspectITConstants.ICON_PATH_FUGUE + "compass.png";
String IMG_CPU_OVERVIEW = InspectITConstants.ICON_PATH_FUGUE + "processor.png";
String IMG_DATABASE = InspectITConstants.ICON_PATH_FUGUE + "database-sql.png";
String IMG_INSTRUMENTATION_BROWSER = InspectITConstants.ICON_PATH_FUGUE + "blue-document-tree.png";
String IMG_INSTRUMENTATION_BROWSER_INACTIVE = InspectITConstants.ICON_PATH_FUGUE + "document-tree.png";
String IMG_INVOCATION = InspectITConstants.ICON_PATH_FUGUE + "arrow-switch.png";
String IMG_MEMORY_OVERVIEW = InspectITConstants.ICON_PATH_FUGUE + "memory.png";
String IMG_SYSTEM_OVERVIEW = InspectITConstants.ICON_PATH_FUGUE + "system-monitor.png";
String IMG_VM_SUMMARY = InspectITConstants.ICON_PATH_FUGUE + "resource-monitor.png";
String IMG_LOGGING_LEVEL = InspectITConstants.ICON_PATH_FUGUE + "traffic-light-single.png";
String IMG_BEAN = InspectITConstants.ICON_PATH_FUGUE + "bean.png";
String IMG_BLUE_DOCUMENT_TABLE = InspectITConstants.ICON_PATH_FUGUE + "blue-document-table.png";
String IMG_BOOK = InspectITConstants.ICON_PATH_FUGUE + "book.png";
String IMG_DUMMY = InspectITConstants.ICON_PATH_FUGUE + "dummy-happy.png";
String IMG_COUNTER = InspectITConstants.ICON_PATH_FUGUE + "counter.png";
// labels just pointing to existing ones
String IMG_ASSIGNEE_LABEL_ICON = IMG_USER;
String IMG_DATE_LABEL_ICON = IMG_CALENDAR;
String IMG_MOUNTEDBY_LABEL_ICON = IMG_READ;
String IMG_RATING_LABEL_ICON = IMG_PRIORITY;
String IMG_STATUS_LABEL_ICON = IMG_ALERT;
String IMG_USECASE_LABEL_ICON = IMG_BUSINESS;
String IMG_USER_LABEL_ICON = IMG_DISABLED;
} | agpl-3.0 |
fxcebx/community-edition | projects/repository/source/java/org/alfresco/repo/template/NamePathResultsMap.java | 3099 | /*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.util.List;
import java.util.StringTokenizer;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* A special Map that executes an XPath against the parent Node as part of the get()
* Map interface implementation.
*
* @author Kevin Roast
*/
public class NamePathResultsMap extends BasePathResultsMap
{
/**
* Constructor
*
* @param parent The parent TemplateNode to execute searches from
* @param services The ServiceRegistry to use
*/
public NamePathResultsMap(TemplateNode parent, ServiceRegistry services)
{
super(parent, services);
}
/**
* @see java.util.Map#get(java.lang.Object)
*/
public Object get(Object key)
{
String path = key.toString();
StringBuilder xpath = new StringBuilder(path.length() << 1);
StringTokenizer t = new StringTokenizer(path, "/");
int count = 0;
QueryParameterDefinition[] params = new QueryParameterDefinition[t.countTokens()];
DataTypeDefinition ddText =
this.services.getDictionaryService().getDataType(DataTypeDefinition.TEXT);
NamespaceService ns = this.services.getNamespaceService();
while (t.hasMoreTokens())
{
if (xpath.length() != 0)
{
xpath.append('/');
}
String strCount = Integer.toString(count);
xpath.append("*[@cm:name=$cm:name")
.append(strCount)
.append(']');
params[count++] = new QueryParameterDefImpl(
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "name" + strCount, ns),
ddText,
true,
t.nextToken());
}
List<TemplateNode> nodes = getChildrenByXPath(xpath.toString(), params, true);
return (nodes.size() != 0) ? nodes.get(0) : null;
}
}
| lgpl-3.0 |
JacquesOlivierLachaud/DGtal | src/DGtal/io/readers/SurfaceMeshReader.h | 4202 | /**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
#pragma once
/**
* @file SurfaceMeshReader.h
* @author Jacques-Olivier Lachaud (\c [email protected] )
* Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
*
* @date 2020/07/11
*
* Header file for class SurfaceMeshReader
*
* This file is part of the DGtal library.
*/
#if defined(SurfaceMeshReader_RECURSES)
#error Recursive header files inclusion detected in SurfaceMeshReader.h
#else // defined(SurfaceMeshReader_RECURSES)
/** Prevents recursive inclusion of headers. */
#define SurfaceMeshReader_RECURSES
#if !defined SurfaceMeshReader_h
/** Prevents repeated inclusion of headers. */
#define SurfaceMeshReader_h
//////////////////////////////////////////////////////////////////////////////
// Inclusions
#include <iostream>
#include <sstream>
#include <string>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/SurfaceMesh.h"
namespace DGtal
{
/////////////////////////////////////////////////////////////////////////////
// template class SurfaceMeshReader
/**
Description of template class 'SurfaceMeshReader' <p> \brief Aim:
An helper class for reading mesh files (Wavefront OBJ at this point) and creating a SurfaceMesh.
@tparam TRealPoint an arbitrary model of RealPoint.
@tparam TRealVector an arbitrary model of RealVector.
*/
template < typename TRealPoint, typename TRealVector >
struct SurfaceMeshReader
{
typedef TRealPoint RealPoint;
typedef TRealVector RealVector;
typedef SurfaceMeshReader< RealPoint, RealVector > Self;
static const Dimension dimension = RealPoint::dimension;
BOOST_STATIC_ASSERT( ( dimension == 3 ) );
typedef DGtal::SurfaceMesh< RealPoint, RealVector > SurfaceMesh;
typedef typename SurfaceMesh::Size Size;
typedef typename SurfaceMesh::Index Index;
typedef typename SurfaceMesh::Vertices Vertices;
typedef typename SurfaceMesh::Faces Faces;
/// Checks that every index in \a indices are different from the others.
/// @param indices a vector of integer indices
/// @return 'true' iff the integer indices are all pairwise different.
static bool verifyIndicesUniqueness( const std::vector< Index > &indices );
/// Splits a string \a str into several strings according to a
/// delimiter \a delim.
/// @param[in] str any string.
/// @param[in] delim any delimiter character.
/// @return the vector of split strings.
static
std::vector< std::string > split( const std::string& str, char delim = ' ');
/// Reads an input file as an OBJ file format and outputs the
/// corresponding surface mesh.
///
/// @param[in,out] input the input stream where the OBJ file is read.
/// @param[out] smesh the output surface mesh.
///
/// @return 'true' if both reading the input stream was ok and the
/// created mesh is ok.
static
bool readOBJ( std::istream & input, SurfaceMesh & smesh );
};
} // namespace DGtal
///////////////////////////////////////////////////////////////////////////////
// Includes inline functions.
#include "SurfaceMeshReader.ih"
// //
///////////////////////////////////////////////////////////////////////////////
#endif // !defined SurfaceMeshReader_h
#undef SurfaceMeshReader_RECURSES
#endif // else defined(SurfaceMeshReader_RECURSES)
| lgpl-3.0 |
avplayer/AVCamera | third_party/include/ffmpeg/libavformat/avio.h | 18682 | /*
* copyright (c) 2001 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFORMAT_AVIO_H
#define AVFORMAT_AVIO_H
/**
* @file
* @ingroup lavf_io
* Buffered I/O operations
*/
#include <stdint.h>
#include "libavutil/common.h"
#include "libavutil/dict.h"
#include "libavutil/log.h"
#include "libavformat/version.h"
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
/**
* Callback for checking whether to abort blocking functions.
* AVERROR_EXIT is returned in this case by the interrupted
* function. During blocking operations, callback is called with
* opaque as parameter. If the callback returns 1, the
* blocking operation will be aborted.
*
* No members can be added to this struct without a major bump, if
* new elements have been added after this struct in AVFormatContext
* or AVIOContext.
*/
typedef struct AVIOInterruptCB {
int (*callback)(void*);
void *opaque;
} AVIOInterruptCB;
/**
* Bytestream IO Context.
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
* version bump.
* sizeof(AVIOContext) must not be used outside libav*.
*
* @note None of the function pointers in AVIOContext should be called
* directly, they should only be set by the client application
* when implementing custom I/O. Normally these are set to the
* function pointers specified in avio_alloc_context()
*/
typedef struct AVIOContext {
/**
* A class for private options.
*
* If this AVIOContext is created by avio_open2(), av_class is set and
* passes the options down to protocols.
*
* If this AVIOContext is manually allocated, then av_class may be set by
* the caller.
*
* warning -- this field can be NULL, be sure to not pass this AVIOContext
* to any av_opt_* functions in that case.
*/
const AVClass *av_class;
unsigned char *buffer; /**< Start of the buffer. */
int buffer_size; /**< Maximum buffer size */
unsigned char *buf_ptr; /**< Current position in the buffer */
unsigned char *buf_end; /**< End of the data, may be less than
buffer+buffer_size if the read function returned
less data than requested, e.g. for streams where
no more data has been received yet. */
void *opaque; /**< A private pointer, passed to the read/write/seek/...
functions. */
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
int64_t (*seek)(void *opaque, int64_t offset, int whence);
int64_t pos; /**< position in the file of the current buffer */
int must_flush; /**< true if the next seek should flush */
int eof_reached; /**< true if eof reached */
int write_flag; /**< true if open for writing */
int max_packet_size;
unsigned long checksum;
unsigned char *checksum_ptr;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
int error; /**< contains the error code or 0 if no error happened */
/**
* Pause or resume playback for network streaming protocols - e.g. MMS.
*/
int (*read_pause)(void *opaque, int pause);
/**
* Seek to a given timestamp in stream with the specified stream_index.
* Needed for some network streaming protocols which don't support seeking
* to byte position.
*/
int64_t (*read_seek)(void *opaque, int stream_index,
int64_t timestamp, int flags);
/**
* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
*/
int seekable;
/**
* max filesize, used to limit allocations
* This field is internal to libavformat and access from outside is not allowed.
*/
int64_t maxsize;
/**
* avio_read and avio_write should if possible be satisfied directly
* instead of going through a buffer, and avio_seek will always
* call the underlying seek function directly.
*/
int direct;
/**
* Bytes read statistic
* This field is internal to libavformat and access from outside is not allowed.
*/
int64_t bytes_read;
/**
* seek statistic
* This field is internal to libavformat and access from outside is not allowed.
*/
int seek_count;
/**
* writeout statistic
* This field is internal to libavformat and access from outside is not allowed.
*/
int writeout_count;
/**
* Original buffer size
* used internally after probing and ensure seekback to reset the buffer size
* This field is internal to libavformat and access from outside is not allowed.
*/
int orig_buffer_size;
} AVIOContext;
/* unbuffered I/O */
/**
* Return the name of the protocol that will handle the passed URL.
*
* NULL is returned if no protocol could be found for the given URL.
*
* @return Name of the protocol or NULL.
*/
const char *avio_find_protocol_name(const char *url);
/**
* Return AVIO_FLAG_* access flags corresponding to the access permissions
* of the resource in url, or a negative value corresponding to an
* AVERROR code in case of failure. The returned access flags are
* masked by the value in flags.
*
* @note This function is intrinsically unsafe, in the sense that the
* checked resource may change its existence or permission status from
* one call to another. Thus you should not trust the returned value,
* unless you are sure that no other processes are accessing the
* checked resource.
*/
int avio_check(const char *url, int flags);
/**
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
* freed with av_free().
*
* @param buffer Memory block for input/output operations via AVIOContext.
* The buffer must be allocated with av_malloc() and friends.
* @param buffer_size The buffer size is very important for performance.
* For protocols with fixed blocksize it should be set to this blocksize.
* For others a typical size is a cache page, e.g. 4kb.
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
* @param opaque An opaque pointer to user-specific data.
* @param read_packet A function for refilling the buffer, may be NULL.
* @param write_packet A function for writing the buffer contents, may be NULL.
* The function may not change the input buffers content.
* @param seek A function for seeking to specified byte position, may be NULL.
*
* @return Allocated AVIOContext or NULL on failure.
*/
AVIOContext *avio_alloc_context(
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
void avio_w8(AVIOContext *s, int b);
void avio_write(AVIOContext *s, const unsigned char *buf, int size);
void avio_wl64(AVIOContext *s, uint64_t val);
void avio_wb64(AVIOContext *s, uint64_t val);
void avio_wl32(AVIOContext *s, unsigned int val);
void avio_wb32(AVIOContext *s, unsigned int val);
void avio_wl24(AVIOContext *s, unsigned int val);
void avio_wb24(AVIOContext *s, unsigned int val);
void avio_wl16(AVIOContext *s, unsigned int val);
void avio_wb16(AVIOContext *s, unsigned int val);
/**
* Write a NULL-terminated string.
* @return number of bytes written.
*/
int avio_put_str(AVIOContext *s, const char *str);
/**
* Convert an UTF-8 string to UTF-16LE and write it.
* @return number of bytes written.
*/
int avio_put_str16le(AVIOContext *s, const char *str);
/**
* Passing this as the "whence" parameter to a seek function causes it to
* return the filesize without seeking anywhere. Supporting this is optional.
* If it is not supported then the seek function will return <0.
*/
#define AVSEEK_SIZE 0x10000
/**
* Oring this flag as into the "whence" parameter to a seek function causes it to
* seek by any means (like reopening and linear reading) or other normally unreasonable
* means that can be extremely slow.
* This may be ignored by the seek code.
*/
#define AVSEEK_FORCE 0x20000
/**
* fseek() equivalent for AVIOContext.
* @return new position or AVERROR.
*/
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
/**
* Skip given number of bytes forward
* @return new position or AVERROR.
*/
int64_t avio_skip(AVIOContext *s, int64_t offset);
/**
* ftell() equivalent for AVIOContext.
* @return position or AVERROR.
*/
static av_always_inline int64_t avio_tell(AVIOContext *s)
{
return avio_seek(s, 0, SEEK_CUR);
}
/**
* Get the filesize.
* @return filesize or AVERROR
*/
int64_t avio_size(AVIOContext *s);
/**
* feof() equivalent for AVIOContext.
* @return non zero if and only if end of file
*/
int avio_feof(AVIOContext *s);
#if FF_API_URL_FEOF
/**
* @deprecated use avio_feof()
*/
attribute_deprecated
int url_feof(AVIOContext *s);
#endif
/** @warning currently size is limited */
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
/**
* Force flushing of buffered data.
*
* For write streams, force the buffered data to be immediately written to the output,
* without to wait to fill the internal buffer.
*
* For read streams, discard all currently buffered data, and advance the
* reported file position to that of the underlying stream. This does not
* read new data, and does not perform any seeks.
*/
void avio_flush(AVIOContext *s);
/**
* Read size bytes from AVIOContext into buf.
* @return number of bytes read or AVERROR
*/
int avio_read(AVIOContext *s, unsigned char *buf, int size);
/**
* @name Functions for reading from AVIOContext
* @{
*
* @note return 0 if EOF, so you cannot use it if EOF handling is
* necessary
*/
int avio_r8 (AVIOContext *s);
unsigned int avio_rl16(AVIOContext *s);
unsigned int avio_rl24(AVIOContext *s);
unsigned int avio_rl32(AVIOContext *s);
uint64_t avio_rl64(AVIOContext *s);
unsigned int avio_rb16(AVIOContext *s);
unsigned int avio_rb24(AVIOContext *s);
unsigned int avio_rb32(AVIOContext *s);
uint64_t avio_rb64(AVIOContext *s);
/**
* @}
*/
/**
* Read a string from pb into buf. The reading will terminate when either
* a NULL character was encountered, maxlen bytes have been read, or nothing
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
* will be truncated if buf is too small.
* Note that the string is not interpreted or validated in any way, it
* might get truncated in the middle of a sequence for multi-byte encodings.
*
* @return number of bytes read (is always <= maxlen).
* If reading ends on EOF or error, the return value will be one more than
* bytes actually read.
*/
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
/**
* Read a UTF-16 string from pb and convert it to UTF-8.
* The reading will terminate when either a null or invalid character was
* encountered or maxlen bytes have been read.
* @return number of bytes read (is always <= maxlen)
*/
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
/**
* @name URL open modes
* The flags argument to avio_open must be one of the following
* constants, optionally ORed with other flags.
* @{
*/
#define AVIO_FLAG_READ 1 /**< read-only */
#define AVIO_FLAG_WRITE 2 /**< write-only */
#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */
/**
* @}
*/
/**
* Use non-blocking mode.
* If this flag is set, operations on the context will return
* AVERROR(EAGAIN) if they can not be performed immediately.
* If this flag is not set, operations on the context will never return
* AVERROR(EAGAIN).
* Note that this flag does not affect the opening/connecting of the
* context. Connecting a protocol will always block if necessary (e.g. on
* network protocols) but never hang (e.g. on busy devices).
* Warning: non-blocking protocols is work-in-progress; this flag may be
* silently ignored.
*/
#define AVIO_FLAG_NONBLOCK 8
/**
* Use direct mode.
* avio_read and avio_write should if possible be satisfied directly
* instead of going through a buffer, and avio_seek will always
* call the underlying seek function directly.
*/
#define AVIO_FLAG_DIRECT 0x8000
/**
* Create and initialize a AVIOContext for accessing the
* resource indicated by url.
* @note When the resource indicated by url has been opened in
* read+write mode, the AVIOContext can be used only for writing.
*
* @param s Used to return the pointer to the created AVIOContext.
* In case of failure the pointed to value is set to NULL.
* @param url resource to access
* @param flags flags which control how the resource indicated by url
* is to be opened
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
int avio_open(AVIOContext **s, const char *url, int flags);
/**
* Create and initialize a AVIOContext for accessing the
* resource indicated by url.
* @note When the resource indicated by url has been opened in
* read+write mode, the AVIOContext can be used only for writing.
*
* @param s Used to return the pointer to the created AVIOContext.
* In case of failure the pointed to value is set to NULL.
* @param url resource to access
* @param flags flags which control how the resource indicated by url
* is to be opened
* @param int_cb an interrupt callback to be used at the protocols level
* @param options A dictionary filled with protocol-private options. On return
* this parameter will be destroyed and replaced with a dict containing options
* that were not found. May be NULL.
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code in case of failure
*/
int avio_open2(AVIOContext **s, const char *url, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options);
/**
* Close the resource accessed by the AVIOContext s and free it.
* This function can only be used if s was opened by avio_open().
*
* The internal buffer is automatically flushed before closing the
* resource.
*
* @return 0 on success, an AVERROR < 0 on error.
* @see avio_closep
*/
int avio_close(AVIOContext *s);
/**
* Close the resource accessed by the AVIOContext *s, free it
* and set the pointer pointing to it to NULL.
* This function can only be used if s was opened by avio_open().
*
* The internal buffer is automatically flushed before closing the
* resource.
*
* @return 0 on success, an AVERROR < 0 on error.
* @see avio_close
*/
int avio_closep(AVIOContext **s);
/**
* Open a write only memory stream.
*
* @param s new IO context
* @return zero if no error.
*/
int avio_open_dyn_buf(AVIOContext **s);
/**
* Return the written size and a pointer to the buffer. The buffer
* must be freed with av_free().
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
*
* @param s IO context
* @param pbuffer pointer to a byte buffer
* @return the length of the byte buffer
*/
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
/**
* Iterate through names of available protocols.
*
* @param opaque A private pointer representing current protocol.
* It must be a pointer to NULL on first iteration and will
* be updated by successive calls to avio_enum_protocols.
* @param output If set to 1, iterate over output protocols,
* otherwise over input protocols.
*
* @return A static string containing the name of current protocol or NULL
*/
const char *avio_enum_protocols(void **opaque, int output);
/**
* Pause and resume playing - only meaningful if using a network streaming
* protocol (e.g. MMS).
*
* @param h IO context from which to call the read_pause function pointer
* @param pause 1 for pause, 0 for resume
*/
int avio_pause(AVIOContext *h, int pause);
/**
* Seek to a given timestamp relative to some component stream.
* Only meaningful if using a network streaming protocol (e.g. MMS.).
*
* @param h IO context from which to call the seek function pointers
* @param stream_index The stream index that the timestamp is relative to.
* If stream_index is (-1) the timestamp should be in AV_TIME_BASE
* units from the beginning of the presentation.
* If a stream_index >= 0 is used and the protocol does not support
* seeking based on component streams, the call will fail.
* @param timestamp timestamp in AVStream.time_base units
* or if there is no stream specified then in AV_TIME_BASE units.
* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
* and AVSEEK_FLAG_ANY. The protocol may silently ignore
* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
* fail if used and not supported.
* @return >= 0 on success
* @see AVInputFormat::read_seek
*/
int64_t avio_seek_time(AVIOContext *h, int stream_index,
int64_t timestamp, int flags);
/* Avoid a warning. The header can not be included because it breaks c++. */
struct AVBPrint;
/**
* Read contents of h into print buffer, up to max_size bytes, or up to EOF.
*
* @return 0 for success (max_size bytes read or EOF reached), negative error
* code otherwise
*/
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);
#endif /* AVFORMAT_AVIO_H */
| lgpl-3.0 |
nguyentienlong/community-edition | projects/repository/source/java/org/alfresco/repo/content/caching/quota/QuotaManagerStrategy.java | 2059 | /*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.content.caching.quota;
/**
* Disk quota managers for the CachingContentStore must implement this interface.
*
* @author Matt Ward
*/
public interface QuotaManagerStrategy
{
/**
* Called immediately before writing a cache file or (when cacheOnInBound is set to true
* for the CachingContentStore) before handing a ContentWriter to a content producer.
* <p>
* In the latter case, the contentSize will be unknown (0), since the content
* length hasn't been established yet.
*
* @param contentSize The size of the content that will be written or 0 if not known.
* @return true to allow the cache file to be written, false to veto.
*/
boolean beforeWritingCacheFile(long contentSize);
/**
* Called immediately after writing a cache file - specifying the size of the file that was written.
* The return value allows implementations control over whether the new cache file is kept (true) or
* immediately removed (false).
*
* @param contentSize The size of the content that was written.
* @return true to allow the cache file to remain, false to immediately delete.
*/
boolean afterWritingCacheFile(long contentSize);
}
| lgpl-3.0 |
edewit/aerogear-unifiedpush-server | migrator/src/test/java/org/jboss/aerogear/unifiedpush/migrator/EmbeddedMysqlDatabase.java | 2351 | /**
* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.aerogear.unifiedpush.migrator;
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import com.mysql.management.MysqldResource;
import com.mysql.management.MysqldResourceI;
public class EmbeddedMysqlDatabase {
private MysqldResource mysqldResource;
private String url;
public void start(String databaseName) {
String tmpDir = System.getProperty("java.io.tmpdir");
File baseDir = new File(tmpDir, databaseName);
FileUtils.deleteQuietly(baseDir);
int port = getFreePort();
Map<String, String> databaseOptions = new HashMap<>();
databaseOptions.put(MysqldResourceI.PORT, Integer.toString(port));
mysqldResource = new MysqldResource(baseDir);
mysqldResource.start("mysql", databaseOptions);
url = "jdbc:mysql://localhost:" + port + "/" + databaseName + "?" + "createDatabaseIfNotExist=true";
}
public void close() {
if (mysqldResource != null) {
mysqldResource.shutdown();
FileUtils.deleteQuietly(mysqldResource.getBaseDir());
}
}
public String getUrl() {
return url;
}
private int getFreePort() {
ServerSocket socket = null;
try {
socket = new ServerSocket(0);
return socket.getLocalPort();
} catch (IOException e) {
} finally {
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
}
}
}
return -1;
}
} | apache-2.0 |
smmribeiro/intellij-community | platform/platform-tests/testSrc/com/intellij/openapi/module/ModulesConfigurationTest.java | 3474 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.module;
import com.intellij.configurationStore.StateStorageManagerKt;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.impl.ProjectLoadingErrorsHeadlessNotifier;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.testFramework.HeavyPlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class ModulesConfigurationTest extends HeavyPlatformTestCase {
public void testAddRemoveModule() throws IOException {
Pair<Path, Path> result = createProjectWithModule();
Path projectDir = result.getFirst();
Project reloaded = PlatformTestUtil.loadAndOpenProject(projectDir, getTestRootDisposable());
ModuleManager moduleManager = ModuleManager.getInstance(reloaded);
Module module = assertOneElement(moduleManager.getModules());
moduleManager.disposeModule(module);
closeProject(reloaded, true);
reloaded = PlatformTestUtil.loadAndOpenProject(projectDir, getTestRootDisposable());
assertEmpty(ModuleManager.getInstance(reloaded).getModules());
closeProject(reloaded, false);
}
// because of external storage, imls file can be missed on disk and it is not error
public void testRemoveFailedToLoadModule() throws IOException {
Pair<Path, Path> result = createProjectWithModule();
Path projectDir = result.getFirst();
Path moduleFile = result.getSecond();
assertThat(moduleFile).exists();
WriteAction.run(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(moduleFile.toString())).delete(this));
List<ConfigurationErrorDescription> errors = new ArrayList<>();
ProjectLoadingErrorsHeadlessNotifier.setErrorHandler(getTestRootDisposable(), errors::add);
Project reloaded = PlatformTestUtil.loadAndOpenProject(projectDir, getTestRootDisposable());
ModuleManager moduleManager = ModuleManager.getInstance(reloaded);
assertThat(moduleManager.getModules()).hasSize(1);
assertThat(errors).isEmpty();
closeProject(reloaded, true);
errors.clear();
reloaded = PlatformTestUtil.loadAndOpenProject(projectDir, getTestRootDisposable());
assertEmpty(errors);
closeProject(reloaded, false);
}
private @NotNull Pair<Path, Path> createProjectWithModule() throws IOException {
Path projectDir = FileUtil.createTempDirectory("project", null).toPath();
Project project = PlatformTestUtil.loadAndOpenProject(projectDir, getTestRootDisposable());
Path moduleFile = projectDir.resolve("module.iml");
WriteAction.run(() -> ModuleManager.getInstance(project).newModule(moduleFile.toString(), EmptyModuleType.EMPTY_MODULE));
closeProject(project, true);
return new Pair<>(projectDir, moduleFile);
}
private static void closeProject(@NotNull Project project, boolean isSave) {
if (isSave) {
StateStorageManagerKt.saveComponentManager(project, true);
}
PlatformTestUtil.forceCloseProjectWithoutSaving(project);
}
}
| apache-2.0 |
jwren/intellij-community | plugins/InspectionGadgets/src/inspectionDescriptions/ForeachStatement.html | 532 | <html>
<body>
Reports enhanced <code>for</code> statements.
Such <code>for</code> statements are not supported by Java of version 1.4 and older.
<p>Example:</p>
<pre><code>
for (int x: Arrays.asList(1, 2, 3)) {
System.out.println(x);
}
</code></pre>
<p>After the quick-fix is applied: </p>
<pre><code>
for (Iterator<Integer> iterator = Arrays.asList(1, 2, 3).iterator(); iterator.hasNext(); ) {
final int x = iterator.next();
System.out.println(x);
}
</code></pre>
<!-- tooltip end -->
<p>
</body>
</html> | apache-2.0 |
Guneet-Dhillon/mxnet | src/operator/upsampling-inl.h | 12124 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*!
* \file upsampling-inl.h
* \brief
* \author Bing Xu
*/
#ifndef MXNET_OPERATOR_UPSAMPLING_INL_H_
#define MXNET_OPERATOR_UPSAMPLING_INL_H_
#include <dmlc/logging.h>
#include <dmlc/parameter.h>
#include <mxnet/operator.h>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include "./operator_common.h"
namespace mxnet {
namespace op {
namespace up_enum {
enum UpSamplingOpInputs {kData, kWeight};
enum UpSamplingOpOutputs {kOut};
enum UpSamplingType {kNearest, kBilinear};
enum UpSamplingMultiInputMode {kConcat, kSum};
} // namespace up_enum
struct UpSamplingParam : public dmlc::Parameter<UpSamplingParam> {
index_t scale;
index_t num_filter;
int sample_type;
int num_args;
int multi_input_mode;
uint64_t workspace;
DMLC_DECLARE_PARAMETER(UpSamplingParam) {
DMLC_DECLARE_FIELD(scale)
.set_range(1, 1000)
.describe("Up sampling scale");
DMLC_DECLARE_FIELD(num_filter)
.describe("Input filter. Only used by bilinear sample_type.")
.set_default(0);
DMLC_DECLARE_FIELD(sample_type)
.add_enum("nearest", up_enum::kNearest)
.add_enum("bilinear", up_enum::kBilinear)
.describe("upsampling method");
DMLC_DECLARE_FIELD(multi_input_mode)
.add_enum("concat", up_enum::kConcat)
.add_enum("sum", up_enum::kSum)
.set_default(up_enum::kConcat)
.describe("How to handle multiple input. concat means concatenate upsampled "
"images along the channel dimension. sum means add all images together, "
"only available for nearest neighbor upsampling.");
DMLC_DECLARE_FIELD(num_args).set_lower_bound(1)
.describe("Number of inputs to be upsampled. For nearest neighbor "
"upsampling, this can be 1-N; the size of output will be"
"(scale*h_0,scale*w_0) and all other inputs will be upsampled to the"
"same size. For bilinear upsampling this must be 2; 1 input and 1 weight.");
DMLC_DECLARE_FIELD(workspace).set_default(512).set_range(0, 8192)
.describe("Tmp workspace for deconvolution (MB)");
}
}; // struct UpSamplingParam
template<typename xpu, typename DType>
class UpSamplingNearestOp : public Operator {
public:
explicit UpSamplingNearestOp(UpSamplingParam p) {
this->param_ = p;
}
virtual void Forward(const OpContext &ctx,
const std::vector<TBlob> &in_data,
const std::vector<OpReqType> &req,
const std::vector<TBlob> &out_data,
const std::vector<TBlob> &aux_args) {
using namespace mshadow;
using namespace mshadow::expr;
CHECK_EQ(in_data.size(), static_cast<size_t>(param_.num_args));
CHECK_EQ(out_data.size(), 1U);
if (req[up_enum::kOut] == kNullOp) {
return;
}
Stream<xpu> *s = ctx.get_stream<xpu>();
Tensor<xpu, 4, DType> out = out_data[up_enum::kOut].get<xpu, 4, DType>(s);
if (param_.num_args > 1) {
int begin = 0;
for (int i = 0; i < param_.num_args; ++i) {
Tensor<xpu, 4, DType> data = in_data[i].get<xpu, 4, DType>(s);
int end = begin + data.size(1);
int scale = out_data[up_enum::kOut].size(2)/in_data[i].size(2);
if (param_.multi_input_mode == up_enum::kSum) {
if (i == 0) {
Assign(out, req[up_enum::kOut], upsampling_nearest(data, scale));
} else {
out += upsampling_nearest(data, scale);
}
} else {
Assign(slice<1>(out, begin, end), req[up_enum::kOut], upsampling_nearest(data, scale));
}
begin = end;
}
} else {
Tensor<xpu, 4, DType> data = in_data[up_enum::kData].get<xpu, 4, DType>(s);
Assign(out, req[up_enum::kOut], upsampling_nearest(data, param_.scale));
}
}
virtual void Backward(const OpContext &ctx,
const std::vector<TBlob> &out_grad,
const std::vector<TBlob> &in_data,
const std::vector<TBlob> &out_data,
const std::vector<OpReqType> &req,
const std::vector<TBlob> &in_grad,
const std::vector<TBlob> &aux_args) {
using namespace mshadow;
using namespace mshadow::expr;
CHECK_EQ(out_grad.size(), 1U);
CHECK_EQ(in_grad.size(), static_cast<size_t>(param_.num_args));
Stream<xpu> *s = ctx.get_stream<xpu>();
Tensor<xpu, 4, DType> grad = out_grad[up_enum::kOut].get<xpu, 4, DType>(s);
if (param_.num_args > 1) {
int begin = 0;
for (int i = 0; i < param_.num_args; ++i) {
Tensor<xpu, 4, DType> input_grad = in_grad[i].get<xpu, 4, DType>(s);
mshadow::Shape<2> in_shape = Shape2(input_grad.shape_[2], input_grad.shape_[3]);
int end = begin + input_grad.size(1);
int scale = grad.size(2)/in_shape[0];
if (param_.multi_input_mode == up_enum::kSum) {
Assign(input_grad, req[i],
pool<mshadow::red::sum>(grad,
in_shape,
scale,
scale,
scale,
scale));
} else {
Assign(input_grad, req[i],
pool<mshadow::red::sum>(slice<1>(grad, begin, end),
in_shape,
scale,
scale,
scale,
scale));
}
begin = end;
}
} else {
Tensor<xpu, 4, DType> input_grad = in_grad[up_enum::kData].get<xpu, 4, DType>(s);
mshadow::Shape<2> in_shape = Shape2(input_grad.shape_[2], input_grad.shape_[3]);
Assign(input_grad, req[up_enum::kData],
pool<mshadow::red::sum>(grad,
in_shape,
param_.scale,
param_.scale,
param_.scale,
param_.scale));
}
}
private:
UpSamplingParam param_;
}; // class UpSamplingNearestOp
template<typename xpu>
Operator *CreateOp(UpSamplingParam param, int dtype);
#if DMLC_USE_CXX11
class UpSamplingProp : public OperatorProperty {
public:
void Init(const std::vector<std::pair<std::string, std::string> >& kwargs) override {
param_.Init(kwargs);
}
std::map<std::string, std::string> GetParams() const override {
return param_.__DICT__();
}
std::vector<std::string> ListArguments() const override {
if (param_.sample_type == up_enum::kNearest) {
std::vector<std::string> ret;
for (int i = 0; i < param_.num_args; ++i) {
ret.push_back(std::string("arg") + std::to_string(i));
}
return ret;
} else {
return {"data", "weight"};
}
}
bool InferShape(std::vector<TShape> *in_shape,
std::vector<TShape> *out_shape,
std::vector<TShape> *aux_shape) const override {
CHECK_GE(in_shape->size(), 1U);
const TShape &dshape = (*in_shape)[0];
TShape oshape = dshape;
if (param_.sample_type == up_enum::kNearest) {
CHECK_EQ(in_shape->size(), static_cast<size_t>(param_.num_args));
oshape[1] = 0;
for (auto& shape : *in_shape) {
CHECK_EQ(shape.ndim(), 4U) << \
"UpSamplingNearest: Input data should be 4D in (batch, channel, y, x)";
int oh = dshape[2]*param_.scale, ow = dshape[3]*param_.scale;
CHECK_EQ(oh%shape[2], 0U) << "UpSamplingNearest: input height of " << shape[2] << \
"does not divide output height of " << oh;
CHECK_EQ(ow%shape[3], 0U) << "UpSamplingNearest: input width of " << shape[3] << \
"does not divide output width of " << ow;
if (param_.multi_input_mode == up_enum::kSum) {
CHECK(oshape[1] == 0 || oshape[1] == shape[1]) << \
"Number of channels must be the same when multi_input_mode==sum";
oshape[1] = shape[1];
} else {
oshape[1] += shape[1];
}
}
} else {
CHECK_EQ(in_shape->size(), 2U) << "Input:[data, weight]";
CHECK_EQ(dshape.ndim(), 4U) << \
"UpSamplingBilinear: Input data should be 4D in (batch, channel, y, x)";
if (dshape.ndim() == 0) return false;
int kernel = 2 * param_.scale - param_.scale % 2;
SHAPE_ASSIGN_CHECK(*in_shape,
up_enum::kWeight,
mshadow::Shape4(dshape[1], 1, kernel, kernel));
oshape = dshape;
}
oshape[2] = dshape[2] * param_.scale;
oshape[3] = dshape[3] * param_.scale;
out_shape->clear();
out_shape->push_back(oshape);
return true;
}
bool InferType(std::vector<int> *in_type,
std::vector<int> *out_type,
std::vector<int> *aux_type) const override {
CHECK_GE(in_type->size(), 1U);
int dtype = (*in_type)[0];
CHECK_NE(dtype, -1) << "First input must have specified type";
for (index_t i = 0; i < in_type->size(); ++i) {
if ((*in_type)[i] == -1) {
(*in_type)[i] = dtype;
} else {
CHECK_EQ((*in_type)[i], dtype) << "This layer requires uniform type. "
<< "Expected " << dtype << " v.s. given "
<< (*in_type)[i] << " at " << ListArguments()[i];
}
}
out_type->clear();
out_type->push_back(dtype);
return true;
}
OperatorProperty* Copy() const override {
auto ptr = new UpSamplingProp();
ptr->param_ = this->param_;
return ptr;
}
std::string TypeString() const override {
return "UpSampling";
}
std::vector<int> DeclareBackwardDependency(
const std::vector<int> &out_grad,
const std::vector<int> &in_data,
const std::vector<int> &out_data) const override {
if (param_.sample_type == up_enum::kNearest) {
return {out_grad[up_enum::kOut]};
} else {
return {out_grad[up_enum::kOut], in_data[up_enum::kData], in_data[up_enum::kWeight]};
}
}
std::vector<std::pair<int, void*> > BackwardInplaceOption(
const std::vector<int> &out_grad,
const std::vector<int> &in_data,
const std::vector<int> &out_data,
const std::vector<void*> &in_grad) const override {
return {};
}
std::vector<ResourceRequest> ForwardResource(
const std::vector<TShape> &in_shape) const override {
if (param_.sample_type == up_enum::kNearest) {
return {};
} else {
return {ResourceRequest::kTempSpace};
}
}
std::vector<ResourceRequest> BackwardResource(
const std::vector<TShape> &in_shape) const override {
if (param_.sample_type == up_enum::kNearest) {
return {};
} else {
return {ResourceRequest::kTempSpace};
}
}
Operator* CreateOperator(Context ctx) const override {
LOG(FATAL) << "Not Implemented";
return NULL;
}
Operator* CreateOperatorEx(Context ctx, std::vector<TShape> *in_shape,
std::vector<int> *in_type) const override;
private:
UpSamplingParam param_;
}; // class UpSamplingProp
#endif // DMLC_USE_CXX11
} // namespace op
} // namespace mxnet
#endif // MXNET_OPERATOR_UPSAMPLING_INL_H_
| apache-2.0 |
hinerm/ITK | Modules/Filtering/LabelMap/include/itkBinaryShapeKeepNObjectsImageFilter.h | 7742 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __itkBinaryShapeKeepNObjectsImageFilter_h
#define __itkBinaryShapeKeepNObjectsImageFilter_h
#include "itkShapeLabelObject.h"
#include "itkBinaryImageToLabelMapFilter.h"
#include "itkShapeLabelMapFilter.h"
#include "itkShapeKeepNObjectsLabelMapFilter.h"
#include "itkLabelMapToBinaryImageFilter.h"
namespace itk
{
/** \class BinaryShapeKeepNObjectsImageFilter
* \brief keep N objects according to their shape attributes
*
* BinaryShapeKeepNObjectsImageFilter keep the N objects in a binary image
* with the highest (or lowest) attribute value. The attributes are the ones
* of the ShapeLabelObject.
*
* \author Gaetan Lehmann. Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France.
*
* This implementation was taken from the Insight Journal paper:
* http://hdl.handle.net/1926/584 or
* http://www.insight-journal.org/browse/publication/176
*
* \sa ShapeLabelObject, LabelShapeKeepNObjectsImageFilter, BinaryStatisticsKeepNObjectsImageFilter
* \ingroup ImageEnhancement MathematicalMorphologyImageFilters
* \ingroup ITKLabelMap
*/
template< class TInputImage >
class ITK_EXPORT BinaryShapeKeepNObjectsImageFilter:
public ImageToImageFilter< TInputImage, TInputImage >
{
public:
/** Standard class typedefs. */
typedef BinaryShapeKeepNObjectsImageFilter Self;
typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
/** Some convenient typedefs. */
typedef TInputImage InputImageType;
typedef TInputImage OutputImageType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
/** ImageDimension constants */
itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(ImageDimension, unsigned int,
TInputImage::ImageDimension);
typedef SizeValueType LabelType;
typedef ShapeLabelObject< LabelType, itkGetStaticConstMacro(ImageDimension) > LabelObjectType;
typedef LabelMap< LabelObjectType > LabelMapType;
typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType;
typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension) >
ShapeLabelFilterOutput;
typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput > LabelObjectValuatorType;
typedef typename LabelObjectType::AttributeType AttributeType;
typedef ShapeKeepNObjectsLabelMapFilter< LabelMapType > KeepNObjectsType;
typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType > BinarizerType;
/** Standard New method. */
itkNewMacro(Self);
/** Runtime information support. */
itkTypeMacro(BinaryShapeKeepNObjectsImageFilter,
ImageToImageFilter);
/**
* Set/Get whether the connected components are defined strictly by
* face connectivity or by face+edge+vertex connectivity. Default is
* FullyConnectedOff. For objects that are 1 pixel wide, use
* FullyConnectedOn.
*/
itkSetMacro(FullyConnected, bool);
itkGetConstReferenceMacro(FullyConnected, bool);
itkBooleanMacro(FullyConnected);
#ifdef ITK_USE_CONCEPT_CHECKING
/** Begin concept checking */
itkConceptMacro( InputEqualityComparableCheck,
( Concept::EqualityComparable< InputImagePixelType > ) );
itkConceptMacro( IntConvertibleToInputCheck,
( Concept::Convertible< int, InputImagePixelType > ) );
itkConceptMacro( InputOStreamWritableCheck,
( Concept::OStreamWritable< InputImagePixelType > ) );
/** End concept checking */
#endif
/**
* Set/Get the value used as "background" in the output image.
* Defaults to NumericTraits<PixelType>::NonpositiveMin().
*/
itkSetMacro(BackgroundValue, OutputImagePixelType);
itkGetConstMacro(BackgroundValue, OutputImagePixelType);
/**
* Set/Get the value used as "foreground" in the output image.
* Defaults to NumericTraits<PixelType>::max().
*/
itkSetMacro(ForegroundValue, OutputImagePixelType);
itkGetConstMacro(ForegroundValue, OutputImagePixelType);
/**
* Set/Get the number of objects to keep
*/
itkGetConstMacro(NumberOfObjects, SizeValueType);
itkSetMacro(NumberOfObjects, SizeValueType);
/**
* Set/Get the ordering of the objects. By default, the ones with the
* highest value are kept. Turming ReverseOrdering to true make this filter
* keep the objects with the smallest values
*/
itkGetConstMacro(ReverseOrdering, bool);
itkSetMacro(ReverseOrdering, bool);
itkBooleanMacro(ReverseOrdering);
/**
* Set/Get the attribute to use to select the object to keep. The default
* is "NumberOfPixels".
*/
itkGetConstMacro(Attribute, AttributeType);
itkSetMacro(Attribute, AttributeType);
void SetAttribute(const std::string & s)
{
this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
}
protected:
BinaryShapeKeepNObjectsImageFilter();
~BinaryShapeKeepNObjectsImageFilter() {}
void PrintSelf(std::ostream & os, Indent indent) const;
/** BinaryShapeKeepNObjectsImageFilter needs the entire input be
* available. Thus, it needs to provide an implementation of
* GenerateInputRequestedRegion(). */
void GenerateInputRequestedRegion();
/** BinaryShapeKeepNObjectsImageFilter will produce the entire output. */
void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
/** Single-threaded version of GenerateData. This filter delegates
* to GrayscaleGeodesicErodeImageFilter. */
void GenerateData();
private:
BinaryShapeKeepNObjectsImageFilter(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
bool m_FullyConnected;
OutputImagePixelType m_BackgroundValue;
OutputImagePixelType m_ForegroundValue;
SizeValueType m_NumberOfObjects;
bool m_ReverseOrdering;
AttributeType m_Attribute;
}; // end of class
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkBinaryShapeKeepNObjectsImageFilter.hxx"
#endif
#endif
| apache-2.0 |
cshaxu/voldemort | src/java/voldemort/server/niosocket/NioSocketService.java | 14098 | /*
* Copyright 2009 Mustard Grain, Inc., 2009-2010 LinkedIn, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package voldemort.server.niosocket;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import voldemort.VoldemortException;
import voldemort.annotations.jmx.JmxGetter;
import voldemort.common.service.ServiceType;
import voldemort.server.AbstractSocketService;
import voldemort.server.StatusManager;
import voldemort.server.protocol.RequestHandlerFactory;
import voldemort.utils.DaemonThreadFactory;
/**
* NioSocketService is an NIO-based socket service, comparable to the
* blocking-IO-based socket service.
* <p/>
* The NIO server is enabled in the server.properties file by setting the
* "enable.nio.connector" property to "true". If you want to adjust the number
* of SelectorManager instances that are used, change "nio.connector.selectors"
* to a positive integer value. Otherwise, the number of selectors will be equal
* to the number of CPUs visible to the JVM.
* <p/>
* This code uses the NIO APIs directly. It would be a good idea to consider
* some of the NIO frameworks to handle this more cleanly, efficiently, and to
* handle corner cases.
*
*
* @see voldemort.server.socket.SocketService
*/
public class NioSocketService extends AbstractSocketService {
private static final int SHUTDOWN_TIMEOUT_MS = 15000;
private final RequestHandlerFactory requestHandlerFactory;
private final ServerSocketChannel serverSocketChannel;
private final InetSocketAddress endpoint;
private final NioSelectorManager[] selectorManagers;
private final ExecutorService selectorManagerThreadPool;
private final int socketBufferSize;
private final int acceptorBacklog;
private final StatusManager statusManager;
private final Thread acceptorThread;
private final Logger logger = Logger.getLogger(getClass());
public NioSocketService(RequestHandlerFactory requestHandlerFactory,
int port,
int socketBufferSize,
int selectors,
String serviceName,
boolean enableJmx,
int acceptorBacklog) {
super(ServiceType.SOCKET, port, serviceName, enableJmx);
this.requestHandlerFactory = requestHandlerFactory;
this.socketBufferSize = socketBufferSize;
this.acceptorBacklog = acceptorBacklog;
try {
this.serverSocketChannel = ServerSocketChannel.open();
} catch(IOException e) {
throw new VoldemortException(e);
}
this.endpoint = new InetSocketAddress(port);
this.selectorManagers = new NioSelectorManager[selectors];
String threadFactoryPrefix = "voldemort-" + serviceName;
this.selectorManagerThreadPool = Executors.newFixedThreadPool(selectorManagers.length,
new DaemonThreadFactory(threadFactoryPrefix));
this.statusManager = new StatusManager((ThreadPoolExecutor) this.selectorManagerThreadPool);
this.acceptorThread = new Thread(new Acceptor(), threadFactoryPrefix + ".Acceptor");
}
@Override
public StatusManager getStatusManager() {
return statusManager;
}
@Override
protected void startInner() {
if(logger.isEnabledFor(Level.INFO))
logger.info("Starting Voldemort NIO socket server (" + serviceName + ") on port "
+ port);
try {
for(int i = 0; i < selectorManagers.length; i++) {
selectorManagers[i] = new NioSelectorManager(endpoint,
requestHandlerFactory,
socketBufferSize);
selectorManagerThreadPool.execute(selectorManagers[i]);
}
serverSocketChannel.socket().bind(endpoint, acceptorBacklog);
serverSocketChannel.socket().setReceiveBufferSize(socketBufferSize);
serverSocketChannel.socket().setReuseAddress(true);
acceptorThread.start();
} catch(Exception e) {
throw new VoldemortException(e);
}
enableJmx(this);
}
@Override
protected void stopInner() {
if(logger.isEnabledFor(Level.INFO))
logger.info("Stopping Voldemort NIO socket server (" + serviceName + ") on port "
+ port);
try {
// Signal the thread to stop accepting new connections...
if(logger.isTraceEnabled())
logger.trace("Interrupted acceptor thread, waiting " + SHUTDOWN_TIMEOUT_MS
+ " ms for termination");
acceptorThread.interrupt();
acceptorThread.join(SHUTDOWN_TIMEOUT_MS);
if(acceptorThread.isAlive()) {
if(logger.isEnabledFor(Level.WARN))
logger.warn("Acceptor thread pool did not stop cleanly after "
+ SHUTDOWN_TIMEOUT_MS + " ms");
}
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
try {
// We close instead of interrupting the thread pool. Why? Because as
// of 0.70, the SelectorManager services RequestHandler in the same
// thread as itself. So, if we interrupt the SelectorManager in the
// thread pool, we interrupt the request. In some RequestHandler
// implementations interruptions are not handled gracefully and/or
// indicate other errors which cause odd side effects. So we
// implement a non-interrupt-based shutdown via close.
for(int i = 0; i < selectorManagers.length; i++) {
try {
selectorManagers[i].close();
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
}
// As per the above comment - we use shutdown and *not* shutdownNow
// to avoid using interrupts to signal shutdown.
selectorManagerThreadPool.shutdown();
if(logger.isTraceEnabled())
logger.trace("Shut down SelectorManager thread pool acceptor, waiting "
+ SHUTDOWN_TIMEOUT_MS + " ms for termination");
boolean terminated = selectorManagerThreadPool.awaitTermination(SHUTDOWN_TIMEOUT_MS,
TimeUnit.MILLISECONDS);
if(!terminated) {
if(logger.isEnabledFor(Level.WARN))
logger.warn("SelectorManager thread pool did not stop cleanly after "
+ SHUTDOWN_TIMEOUT_MS + " ms");
}
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
try {
serverSocketChannel.socket().close();
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
try {
serverSocketChannel.close();
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
}
private class Acceptor implements Runnable {
public void run() {
if(logger.isInfoEnabled())
logger.info("Server now listening for connections on port " + port);
AtomicInteger counter = new AtomicInteger();
while(true) {
if(Thread.currentThread().isInterrupted()) {
if(logger.isInfoEnabled())
logger.info("Acceptor thread interrupted");
break;
}
try {
SocketChannel socketChannel = serverSocketChannel.accept();
if(socketChannel == null) {
if(logger.isEnabledFor(Level.WARN))
logger.warn("Claimed accept but nothing to select");
continue;
}
NioSelectorManager selectorManager = selectorManagers[counter.getAndIncrement()
% selectorManagers.length];
selectorManager.accept(socketChannel);
} catch(ClosedByInterruptException e) {
// If you're *really* interested...
if(logger.isTraceEnabled())
logger.trace("Acceptor thread interrupted, closing");
break;
} catch(Exception e) {
if(logger.isEnabledFor(Level.WARN))
logger.warn(e.getMessage(), e);
}
}
if(logger.isInfoEnabled())
logger.info("Server has stopped listening for connections on port " + port);
}
}
@JmxGetter(name = "numActiveConnections", description = "total number of active connections across selector managers")
public final int getNumActiveConnections() {
int sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getNumActiveConnections();
}
return sum;
}
@JmxGetter(name = "numQueuedConnections", description = "total number of connections pending for registration with selector managers")
public final int getNumQueuedConnections() {
int sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getNumQueuedConnections();
}
return sum;
}
@JmxGetter(name = "selectCountAvg", description = "average number of connections selected in each select() call")
public final double getSelectCountAvg() {
double sum = 0.0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getSelectCountHistogram().getAverage();
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "selectCount99th", description = "99th percentile of number of connections selected in each select() call")
public final double getSelectCount99th() {
double sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getSelectCountHistogram().getQuantile(0.99);
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "selectTimeMsAvg", description = "average time spent in the select() call")
public final double getSelectTimeMsAvg() {
double sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getSelectTimeMsHistogram().getAverage();
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "selectTimeMs99th", description = "99th percentile of time spent in the select() call")
public final double getSelectTimeMs99th() {
double sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getSelectTimeMsHistogram().getQuantile(0.99);
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "processingTimeMsAvg", description = "average time spent processing all read/write requests, in a select() loop")
public final double getProcessingTimeMsAvg() {
double sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getProcessingTimeMsHistogram().getAverage();
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "processingTimeMs99th", description = "99th percentile of time spent processing all the read/write requests, in a select() loop")
public final double getprocessingTimeMs99th() {
double sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getProcessingTimeMsHistogram().getQuantile(0.99);
}
return sum / selectorManagers.length;
}
@JmxGetter(name = "commReadBufferSize", description = "total amount of memory consumed by all the communication read buffers, in bytes")
public final double getCommReadBufferSize() {
long sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getCommBufferSizeStats().getCommReadBufferSizeTracker().longValue();
}
return sum;
}
@JmxGetter(name = "commWriteBufferSize", description = "total amount of memory consumed by all the communication write buffers, in bytes")
public final double getCommWriteBufferSize() {
long sum = 0;
for(NioSelectorManager manager: selectorManagers) {
sum += manager.getCommBufferSizeStats().getCommWriteBufferSizeTracker().longValue();
}
return sum;
}
}
| apache-2.0 |
phiroict/docker | datacenter/ucp/1.1/installation/install-production.md | 9080 | ---
description: Learn how to install Docker Universal Control Plane on production
keywords: Universal Control Plane, UCP, install
redirect_from:
- /ucp/production-install/
- /ucp/installation/install-production/
title: Install UCP for production
---
Docker Universal Control Plane (UCP) is a containerized application that can be
installed on-premises or on a cloud infrastructure.
If you're installing Docker Datacenter on Azure, [follow this guide](https://success.docker.com/?cid=ddc-on-azure).
## Step 1: Validate the system requirements
The first step in installing UCP, is ensuring your
infrastructure has all the [requirements UCP needs to run](system-requirements.md).
## Step 2: Install CS Docker on all nodes
UCP is a containerized application that requires CS Docker Engine 1.10.0 or
above to run. It is recommended to install the exact same version of the
CS Docker Engine on all nodes.
So on each host that you want to be part of the UCP cluster,
[install CS Docker Engine 1.10.0 or above](/cs-engine/install.md).
In the case where you are creating a VM template with CS Engine already
installed, make sure that `/etc/docker/key.json` is not included in the image.
You can do this by simply removing `/etc/docker/key.json`. You can then restart
Docker on each node, which will generate new `/etc/docker/key.json` files.
## Step 3: Customize named volumes
Docker UCP uses [named volumes](../architecture.md) to persist data. If you want
to customize the volume drivers and flags of these volumes, you can create the
volumes before installing UCP.
If the volumes don't exist, when installing UCP they are created with the
default volume driver and flags.
## Step 4: Customize the server certificates
The UCP cluster uses TLS to secure all communications. Two Certificate
Authorities (CA) are used for this:
* Cluster root CA: generates certificates for new nodes joining the cluster and
admin user bundles.
* Client root CA: generates non-admin user bundles.
You can customize UCP to use certificates signed by an external Certificate
Authority. These certificates are used instead of the ones generated by the
client root CA. That way you can use a certificate from a CA that your
browsers and client tools already trust.
If you want to use your own certificates:
1. Log into the host where you intend to install UCP.
2. Create a volume with the name `ucp-controller-server-certs`.
3. Add the following files to `/var/lib/docker/volumes/ucp-controller-server-certs/_data/`:
| File | Description |
|:---------|:----------------------------------------------------------------------------------|
| ca.pem | Your root CA certificate. |
| cert.pem | Your signed UCP controller certificate followed by any intermediate certificates. |
| key.pem | Your UCP controller private key. |
## Step 5: Install the UCP controller
To install UCP you use the `docker/ucp` image. This image has commands to
install, configure, and backup UCP. To find what commands and options are
available, check the [reference documentation](../reference/install.md).
To install UCP:
1. Log in to the machine where you want to install UCP.
2. Use the `docker/ucp install` command to install UCP.
In this example we'll be running the install command interactively, so that
the command prompts for the necessary configuration values.
You can also use flags to pass values to the install command.
```none
$ docker run --rm -it --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp install -i \
--host-address <$UCP_PUBLIC_IP>
```
Where:
* i, specify to run the install command interactively,
* host-address, is the public IP where users or a load balancer can access
UCP,
* Also, include the `--external-server-cert` flag if you're using server
certificates signed by an external CA.
When installing Docker UCP, overlay networking is automatically configured
for you. If you are running Docker CS Engine 1.10, or have custom
configurations on your Docker CS Engine, you need to restart the Docker
daemon at this point.
3. Check that the UCP web application is running.
In your browser, navigate to the address where you've installed UCP.
If you're not using an external CA, your browser warns that UCP is
an unsafe site. This happens because you're accessing UCP using HTTPS
but the certificates used by UCP are not trusted by your browser.

## Step 6: License your installation
Now that your UCP controller is installed, you need to license it.
[Learn how to license your installation](license.md).
## Step 7: Backup the controller CAs
For a highly available installation, you can add more controller nodes to
the UCP cluster. The controller nodes are replicas of each other.
For this, you need to make the CAs on each controller node use the same
root certificates and keys.
To create a backup of the CAs used on the controller node:
1. Log into the controller node using ssh.
2. Run the docker/ucp backup command.
```none
$ docker run --rm -i --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp backup \
--interactive \
--root-ca-only \
--passphrase "secret" > /tmp/backup.tar
```
[Learn more about the backup command](../high-availability/replicate-cas.md).
## Step 8: Add controller replicas to the UCP cluster
This step is optional.
For a highly available installation, you can add more controller nodes to
the UCP cluster. For that, use the `docker/ucp join --replica` command.
[Learn more about the join command](../reference/join.md).
For each node that you want to install as a controller replica:
1. Log into that node using ssh.
2. Make sure you transfer the backup.tar from the previous step to this node.
3. Use the join command with the replica option:
In this example we'll be running the join command interactively, so that
the command prompts for the necessary configuration values. We'll also
be passing the backup.tar file from the previous step in order to ensure
that the CAs are replicated to the new controller node.
```none
$ docker run --rm -it --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $BACKUP_PATH/backup.tar:/backup.tar \
docker/ucp join \
--interactive \
--replica \
--passphrase "secret"
```
4. Since UCP configures your Docker Engine for multi-host networking, it might
prompt you to restart the Docker daemon. To make the installation faster, join
all replica nodes first, and only then restart the Docker daemon on those nodes.
5. Repeat steps 1 and 2 on the other nodes you want to set up as replicas.
Make sure you set up 3, 5, or 7 controllers.
6. Check the cluster state.
The Dashboard page of UCP should list all your controller nodes.

## Step 9: Ensure controllers know about each other
Internally, each controller node has a key-value store that keeps track of
the controllers that are part of the cluster.
When you installed and joined replica controllers, the Docker daemon on that
host was configured to use that key-value store.
To make the cluster fault-tolerant and be able to recover faster with less
downtime, you need to configure the Docker daemon on each controller node to
know about the key-value store that is running on the other nodes.
For each controller node:
1. Log into that node using ssh.
2. Run the engine-discovery command.
```none
$ docker run --rm -it \
--name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp engine-discovery \
--update
```
## Step 10: Add more nodes to the UCP cluster
Now you can add additional nodes to your UCP cluster. These are the nodes that
will be running your containers.
For each node that you want to add to your UCP cluster:
1. Log into that node.
2. Use the join command, to join the node to the cluster:
```none
$ docker run --rm -it --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp join -i
```
3. Repeat steps 1 and 2 on the other nodes you want to add to your UCP cluster.
4. Check the cluster state.
The Dashboard page of UCP should list all your controller nodes.

## Step 11. Download a client certificate bundle
To validate that your cluster is correctly configured, you should try accessing
the cluster with the Docker CLI client. For this, you'll need to get a client
certificate bundle.
[Learn more about user bundles](../access-ucp/cli-based-access.md).
## Where to go next
* [Deploy an app from the UI](../applications/deploy-app-ui.md)
* [Monitor a UCP cluster](../monitor/monitor-ucp.md)
| apache-2.0 |
armink/rt-thread | bsp/lpc55sxx/Libraries/drivers/drv_adc.c | 3151 | /*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-04-20 tyustli the first version.
* 2019-07-15 Magicoe The first version for LPC55S6x
*
*/
#include <rtthread.h>
#ifdef BSP_USING_ADC
#if !defined(BSP_USING_ADC0_CH0)
#error "Please define at least one BSP_USING_ADCx_CH0"
#endif
#define LOG_TAG "drv.adc"
#include <drv_log.h>
#include "drv_adc.h"
#include "fsl_power.h"
#include "fsl_lpadc.h"
#include <rtdevice.h>
static rt_err_t lpc_lpadc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
{
return RT_EOK;
}
static rt_err_t lpc_lpadc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
{
lpadc_conv_trigger_config_t mLpadcTriggerConfigStruct;
lpadc_conv_command_config_t mLpadcCommandConfigStruct;
lpadc_conv_result_t mLpadcResultConfigStruct;
ADC_Type *base;
base = (ADC_Type *)(device->parent.user_data);
/* Set conversion CMD configuration. */
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct);
mLpadcCommandConfigStruct.channelNumber = channel;
LPADC_SetConvCommandConfig(base, 1U, &mLpadcCommandConfigStruct);
/* Set trigger configuration. */
LPADC_GetDefaultConvTriggerConfig(&mLpadcTriggerConfigStruct);
mLpadcTriggerConfigStruct.targetCommandId = 1U;
mLpadcTriggerConfigStruct.enableHardwareTrigger = false;
LPADC_SetConvTriggerConfig(base, 0U, &mLpadcTriggerConfigStruct); /* Configurate the trigger0. */
LPADC_DoSoftwareTrigger(base, 1U); /* 1U is trigger0 mask. */
while (!LPADC_GetConvResult(base, &mLpadcResultConfigStruct, 0U));
*value = ((mLpadcResultConfigStruct.convValue) >> 3U);
return RT_EOK;
}
static struct rt_adc_ops lpc_adc_ops =
{
.enabled = lpc_lpadc_enabled,
.convert = lpc_lpadc_convert,
};
#if defined(BSP_USING_ADC0_CH0)
static struct rt_adc_device adc0_device;
#endif /* BSP_USING_ADC0_CH0 */
int rt_hw_adc_init(void)
{
int result = RT_EOK;
#if defined(BSP_USING_ADC0_CH0)
lpadc_config_t mLpadcConfigStruct;
CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 16U, true);
CLOCK_AttachClk(kMAIN_CLK_to_ADC_CLK);
/* Disable LDOGPADC power down */
POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC);
LPADC_GetDefaultConfig(&mLpadcConfigStruct);
mLpadcConfigStruct.enableAnalogPreliminary = true;
mLpadcConfigStruct.referenceVoltageSource = kLPADC_ReferenceVoltageAlt2;
mLpadcConfigStruct.conversionAverageMode = kLPADC_ConversionAverage128;
LPADC_Init(ADC0, &mLpadcConfigStruct);
/* Request offset calibration. */
//LPADC_DoOffsetCalibration(ADC0);
LPADC_SetOffsetValue(ADC0, 10U, 10U);
/* Request gain calibration. */
LPADC_DoAutoCalibration(ADC0);
result = rt_hw_adc_register(&adc0_device, "adc0", &lpc_adc_ops, ADC0);
if (result != RT_EOK)
{
LOG_E("register adc0 device failed error code = %d\n", result);
}
#endif /* BSP_USING_ADC0_CH0 */
return result;
}
INIT_DEVICE_EXPORT(rt_hw_adc_init);
#endif /* BSP_USING_ADC */
| apache-2.0 |
molobrakos/home-assistant | homeassistant/components/upcloud/binary_sensor.py | 896 | """Support for monitoring the state of UpCloud servers."""
import logging
import voluptuous as vol
from homeassistant.components.binary_sensor import (
PLATFORM_SCHEMA, BinarySensorDevice)
import homeassistant.helpers.config_validation as cv
from . import CONF_SERVERS, DATA_UPCLOUD, UpCloudServerEntity
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string]),
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the UpCloud server binary sensor."""
upcloud = hass.data[DATA_UPCLOUD]
servers = config.get(CONF_SERVERS)
devices = [UpCloudBinarySensor(upcloud, uuid) for uuid in servers]
add_entities(devices, True)
class UpCloudBinarySensor(UpCloudServerEntity, BinarySensorDevice):
"""Representation of an UpCloud server sensor."""
| apache-2.0 |
http-418/chef-bach | cookbooks/bach_repository/attributes/hannibal.rb | 263 | default[:hannibal][:hbase_version] = '1.1.3'
default[:hannibal][:checksum]["1.1.3"] = '1e4f4030374a34d9f92dc9605505d421615ab12a9e02a10ed690576ab644f705'
default[:hannibal][:download_url] = 'https://github.com/amithkanand/hannibal/releases/download/v.0.12.0-apha'
| apache-2.0 |
WebJustDevelopment/keycloak | testsuite/integration-arquillian/src/test/java/org/keycloak/testsuite/admin/test/session/TokensTest.java | 2242 | /*
* JBoss, Home of Professional Open Source
*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.admin.test.session;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.keycloak.testsuite.admin.page.settings.TokensPage;
import static org.jboss.arquillian.graphene.Graphene.waitModel;
import org.keycloak.testsuite.admin.AbstractKeycloakTest;
import static org.keycloak.testsuite.admin.util.SeleniumUtils.waitGuiForElement;
/**
*
* @author Petr Mensik
*/
public class TokensTest extends AbstractKeycloakTest<TokensPage> {
private static final int TIMEOUT = 10;
private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
@Before
public void beforeTokensTest() {
navigation.tokens();
}
@Test
public void testTimeoutForRealmSession() throws InterruptedException {
page.setSessionTimeout(TIMEOUT, TIME_UNIT);
TIME_UNIT.sleep(TIMEOUT + 2); //add 2 secs to timeout
driver.navigate().refresh();
waitGuiForElement(loginPage.getLoginPageHeader(), "Home page should be visible after session timeout");
loginPage.loginAsAdmin();
page.setSessionTimeout(30, TimeUnit.MINUTES);
}
@Test
public void testLifespanOfRealmSession() {
page.setSessionTimeoutLifespan(TIMEOUT, TIME_UNIT);
logOut();
loginAsAdmin();
waitModel().withTimeout(TIMEOUT + 2, TIME_UNIT) //adds 2 seconds to the timeout
.pollingEvery(1, TIME_UNIT)
.until("Home page should be visible after session timeout")
.element(loginPage.getLoginPageHeader())
.is()
.present();
loginPage.loginAsAdmin();
navigation.tokens();
page.setSessionTimeoutLifespan(10, TimeUnit.HOURS);
}
}
| apache-2.0 |
kingthorin/zap-extensions | addOns/imagelocationscanner/src/main/java/org/zaproxy/zap/extension/imagelocationscanner/ExtensionImageLocationScanner.java | 1403 | /*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2018 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.zaproxy.zap.extension.imagelocationscanner;
import org.parosproxy.paros.Constant;
import org.parosproxy.paros.extension.ExtensionAdaptor;
public class ExtensionImageLocationScanner extends ExtensionAdaptor {
@Override
public String getName() {
return "ExtensionImageLocationScanner";
}
@Override
public String getUIName() {
return Constant.messages.getString("imagelocationscanner.ui.name");
}
@Override
public String getDescription() {
return Constant.messages.getString("imagelocationscanner.addon.desc");
}
@Override
public boolean canUnload() {
return true;
}
}
| apache-2.0 |
Mainflux/mainflux-lite | vendor/github.com/ory/dockertest/docker/pkg/term/proxy.go | 2026 | package term // import "github.com/ory/dockertest/docker/pkg/term"
import (
"io"
)
// EscapeError is special error which returned by a TTY proxy reader's Read()
// method in case its detach escape sequence is read.
type EscapeError struct{}
func (EscapeError) Error() string {
return "read escape sequence"
}
// escapeProxy is used only for attaches with a TTY. It is used to proxy
// stdin keypresses from the underlying reader and look for the passed in
// escape key sequence to signal a detach.
type escapeProxy struct {
escapeKeys []byte
escapeKeyPos int
r io.Reader
}
// NewEscapeProxy returns a new TTY proxy reader which wraps the given reader
// and detects when the specified escape keys are read, in which case the Read
// method will return an error of type EscapeError.
func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader {
return &escapeProxy{
escapeKeys: escapeKeys,
r: r,
}
}
func (r *escapeProxy) Read(buf []byte) (int, error) {
nr, err := r.r.Read(buf)
preserve := func() {
// this preserves the original key presses in the passed in buffer
nr += r.escapeKeyPos
preserve := make([]byte, 0, r.escapeKeyPos+len(buf))
preserve = append(preserve, r.escapeKeys[:r.escapeKeyPos]...)
preserve = append(preserve, buf...)
r.escapeKeyPos = 0
copy(buf[0:nr], preserve)
}
if nr != 1 || err != nil {
if r.escapeKeyPos > 0 {
preserve()
}
return nr, err
}
if buf[0] != r.escapeKeys[r.escapeKeyPos] {
if r.escapeKeyPos > 0 {
preserve()
}
return nr, nil
}
if r.escapeKeyPos == len(r.escapeKeys)-1 {
return 0, EscapeError{}
}
// Looks like we've got an escape key, but we need to match again on the next
// read.
// Store the current escape key we found so we can look for the next one on
// the next read.
// Since this is an escape key, make sure we don't let the caller read it
// If later on we find that this is not the escape sequence, we'll add the
// keys back
r.escapeKeyPos++
return nr - r.escapeKeyPos, nil
}
| apache-2.0 |
ceejatec/ns_server | deps/triq/README.markdown | 3275 | # Welcome to Triq -- Trifork QuickCheck for Erlang
[](https://travis-ci.org/krestenkrab/triq)
Triq (pronounced "Trick Check") is a free alternative to [QuviQ
eqc](http://www.quviq.com/). Triq's API is modelled closely after
`eqc`, so I recommend their tutorials and slides for an introduction
to QuickCheck. Notice that QuviQ `eqc` has many features not found in
`triq`, but it is open source licensed under the Apache license. For
instance, `eqc` has features for reporting, management, probably a
much better shrinking mechanism, cool C integration, and
professional support.
## Installation
To use `triq`, you download the latest version from
[here](http://github.com/krestenkrab/triq/downloads), and untar it
into your erlang lib directory (typically
`/usr/local/lib/erlang/lib`):
```sh
prompt$ cd /usr/local/lib/erlang/lib
propmt$ tar xvzf triq-0.1.0.tgz
...
```
And you're all set.
Or, checkout the triq source code and soft link / copy into your Erlang lib directory:
```sh
prompt$ git clone git://github.com/krestenkrab/triq.git
prompt$ cd triq
prompt$ ln -s . /usr/local/lib/erlang/lib/triq-0.1.0
```
Next, to use `triq`, include the header file:
```erlang
-include_lib("triq/include/triq.hrl").
```
And you're ready to write property tests. An example property could be:
```erlang
prop_append() ->
?FORALL({Xs,Ys},{list(int()),list(int())},
lists:reverse(Xs++Ys)
==
lists:reverse(Ys) ++ lists:reverse(Xs)).
```
To test this property, run `triq:check/1`, thus:
```erlang
1> triq:check(prop_append()).
......................................................................
..............................
Ran 100 tests
true
2>
```
If the test fails, it will try to shrink the result; here is an example:
```erlang
prop_delete() ->
?FORALL(L,list(int()),
?IMPLIES(L /= [],
?FORALL(I,elements(L),
?WHENFAIL(io:format("L=~p, I=~p~n", [L,I]),
not lists:member(I,lists:delete(I,L)))))).
```
Which runs like this:
```erlang
1> triq:check(triq_tests:prop_delete()).
x....Failed!
L=[4,5,5], I=5
Failed after 5 tests with false
Simplified:
L = [0,0]
I = 0
false
2>
```
You can get the values used for the failing test with `counterexample`,
and reuse the same test values with `check/2`:
```erlang
3> A = triq:counterexample(triq_tests:xprop_delete()).
x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFailed!
L=[3,2,1,1,1], I=1
Failed after 101 tests with false
Simplified:
L = [0,0]
I = 0
[[0,0],0]
4> A.
[[0,0],0]
5> triq:check(triq_tests:xprop_delete(), A).
Failed!
L=[0,0], I=0
Failed after 1 tests with false
Simplified:
L = [0,0]
I = 0
false
6>
```
Modules compiled with the `triq.hrl` header, auto-export all functions named `prop_*`,
and have a function added called `check/0` which runs `triq:check/1` on all the properties in the module.
```erlang
1> mymodule:check().
```
A handy addition that I use is to also add an `eunit` test, which tests it:
```erlang
property_test() -> true == check().
```
Which can then automatically be run using your favourite `eunit` runner.
Good luck!
| apache-2.0 |
nakul02/incubator-systemml | src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextFrameTest.java | 26005 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sysml.test.integration.mlcontext;
import static org.apache.sysml.api.mlcontext.ScriptFactory.dml;
import static org.apache.sysml.api.mlcontext.ScriptFactory.pydml;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.rdd.RDD;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.RowFactory;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.apache.sysml.api.mlcontext.FrameFormat;
import org.apache.sysml.api.mlcontext.FrameMetadata;
import org.apache.sysml.api.mlcontext.FrameSchema;
import org.apache.sysml.api.mlcontext.MLContext.ExplainLevel;
import org.apache.sysml.api.mlcontext.MLResults;
import org.apache.sysml.api.mlcontext.MatrixFormat;
import org.apache.sysml.api.mlcontext.MatrixMetadata;
import org.apache.sysml.api.mlcontext.Script;
import org.apache.sysml.parser.Expression.ValueType;
import org.apache.sysml.runtime.instructions.spark.utils.FrameRDDConverterUtils;
import org.apache.sysml.runtime.instructions.spark.utils.RDDConverterUtils;
import org.apache.sysml.test.integration.mlcontext.MLContextTest.CommaSeparatedValueStringToDoubleArrayRow;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import scala.collection.Iterator;
public class MLContextFrameTest extends MLContextTestBase {
public static enum SCRIPT_TYPE {
DML, PYDML
}
public static enum IO_TYPE {
ANY, FILE, JAVA_RDD_STR_CSV, JAVA_RDD_STR_IJV, RDD_STR_CSV, RDD_STR_IJV, DATAFRAME
}
private static String CSV_DELIM = ",";
@BeforeClass
public static void setUpClass() {
MLContextTestBase.setUpClass();
ml.setExplainLevel(ExplainLevel.RECOMPILE_HOPS);
}
@Test
public void testFrameJavaRDD_CSV_DML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.DML, IO_TYPE.JAVA_RDD_STR_CSV, IO_TYPE.ANY);
}
@Test
public void testFrameJavaRDD_CSV_DML_OutJavaRddCSV() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.DML, IO_TYPE.JAVA_RDD_STR_CSV, IO_TYPE.JAVA_RDD_STR_CSV);
}
@Test
public void testFrameJavaRDD_CSV_PYDML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.PYDML, IO_TYPE.JAVA_RDD_STR_CSV, IO_TYPE.ANY);
}
@Test
public void testFrameRDD_CSV_PYDML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.PYDML, IO_TYPE.RDD_STR_CSV, IO_TYPE.ANY);
}
@Test
public void testFrameJavaRDD_CSV_PYDML_OutRddIJV() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.PYDML, IO_TYPE.JAVA_RDD_STR_CSV, IO_TYPE.RDD_STR_IJV);
}
@Test
public void testFrameJavaRDD_IJV_DML() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.DML, IO_TYPE.JAVA_RDD_STR_IJV, IO_TYPE.ANY);
}
@Test
public void testFrameRDD_IJV_DML() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.DML, IO_TYPE.RDD_STR_IJV, IO_TYPE.ANY);
}
@Test
public void testFrameJavaRDD_IJV_DML_OutRddCSV() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.DML, IO_TYPE.JAVA_RDD_STR_IJV, IO_TYPE.RDD_STR_CSV);
}
@Test
public void testFrameJavaRDD_IJV_PYDML() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.PYDML, IO_TYPE.JAVA_RDD_STR_IJV, IO_TYPE.ANY);
}
@Test
public void testFrameJavaRDD_IJV_PYDML_OutJavaRddIJV() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.PYDML, IO_TYPE.JAVA_RDD_STR_IJV, IO_TYPE.JAVA_RDD_STR_IJV);
}
@Test
public void testFrameFile_CSV_DML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.DML, IO_TYPE.FILE, IO_TYPE.ANY);
}
@Test
public void testFrameFile_CSV_PYDML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.PYDML, IO_TYPE.FILE, IO_TYPE.ANY);
}
@Test
public void testFrameFile_IJV_DML() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.DML, IO_TYPE.FILE, IO_TYPE.ANY);
}
@Test
public void testFrameFile_IJV_PYDML() {
testFrame(FrameFormat.IJV, SCRIPT_TYPE.PYDML, IO_TYPE.FILE, IO_TYPE.ANY);
}
@Test
public void testFrameDataFrame_CSV_DML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.DML, IO_TYPE.DATAFRAME, IO_TYPE.ANY);
}
@Test
public void testFrameDataFrame_CSV_PYDML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.PYDML, IO_TYPE.DATAFRAME, IO_TYPE.ANY);
}
@Test
public void testFrameDataFrameOutDataFrame_CSV_DML() {
testFrame(FrameFormat.CSV, SCRIPT_TYPE.DML, IO_TYPE.DATAFRAME, IO_TYPE.DATAFRAME);
}
public void testFrame(FrameFormat format, SCRIPT_TYPE script_type, IO_TYPE inputType, IO_TYPE outputType) {
System.out.println("MLContextTest - Frame JavaRDD<String> for format: " + format + " Script: " + script_type);
List<String> listA = new ArrayList<String>();
List<String> listB = new ArrayList<String>();
FrameMetadata fmA = null, fmB = null;
Script script = null;
ValueType[] schemaA = { ValueType.INT, ValueType.STRING, ValueType.DOUBLE, ValueType.BOOLEAN };
List<ValueType> lschemaA = Arrays.asList(schemaA);
FrameSchema fschemaA = new FrameSchema(lschemaA);
ValueType[] schemaB = { ValueType.STRING, ValueType.DOUBLE, ValueType.BOOLEAN };
List<ValueType> lschemaB = Arrays.asList(schemaB);
FrameSchema fschemaB = new FrameSchema(lschemaB);
if (inputType != IO_TYPE.FILE) {
if (format == FrameFormat.CSV) {
listA.add("1,Str2,3.0,true");
listA.add("4,Str5,6.0,false");
listA.add("7,Str8,9.0,true");
listB.add("Str12,13.0,true");
listB.add("Str25,26.0,false");
fmA = new FrameMetadata(FrameFormat.CSV, fschemaA, 3, 4);
fmB = new FrameMetadata(FrameFormat.CSV, fschemaB, 2, 3);
} else if (format == FrameFormat.IJV) {
listA.add("1 1 1");
listA.add("1 2 Str2");
listA.add("1 3 3.0");
listA.add("1 4 true");
listA.add("2 1 4");
listA.add("2 2 Str5");
listA.add("2 3 6.0");
listA.add("2 4 false");
listA.add("3 1 7");
listA.add("3 2 Str8");
listA.add("3 3 9.0");
listA.add("3 4 true");
listB.add("1 1 Str12");
listB.add("1 2 13.0");
listB.add("1 3 true");
listB.add("2 1 Str25");
listB.add("2 2 26.0");
listB.add("2 3 false");
fmA = new FrameMetadata(FrameFormat.IJV, fschemaA, 3, 4);
fmB = new FrameMetadata(FrameFormat.IJV, fschemaB, 2, 3);
}
JavaRDD<String> javaRDDA = sc.parallelize(listA);
JavaRDD<String> javaRDDB = sc.parallelize(listB);
if (inputType == IO_TYPE.DATAFRAME) {
JavaRDD<Row> javaRddRowA = FrameRDDConverterUtils.csvToRowRDD(sc, javaRDDA, CSV_DELIM, schemaA);
JavaRDD<Row> javaRddRowB = FrameRDDConverterUtils.csvToRowRDD(sc, javaRDDB, CSV_DELIM, schemaB);
// Create DataFrame
StructType dfSchemaA = FrameRDDConverterUtils.convertFrameSchemaToDFSchema(schemaA, false);
Dataset<Row> dataFrameA = spark.createDataFrame(javaRddRowA, dfSchemaA);
StructType dfSchemaB = FrameRDDConverterUtils.convertFrameSchemaToDFSchema(schemaB, false);
Dataset<Row> dataFrameB = spark.createDataFrame(javaRddRowB, dfSchemaB);
if (script_type == SCRIPT_TYPE.DML)
script = dml("A[2:3,2:4]=B;C=A[2:3,2:3]").in("A", dataFrameA, fmA).in("B", dataFrameB, fmB).out("A")
.out("C");
else if (script_type == SCRIPT_TYPE.PYDML)
// DO NOT USE ; at the end of any statment, it throws NPE
script = pydml("A[$X:$Y,$X:$Z]=B\nC=A[$X:$Y,$X:$Y]").in("A", dataFrameA, fmA)
.in("B", dataFrameB, fmB)
// Value for ROW index gets incremented at script
// level to adjust index in PyDML, but not for
// Column Index
.in("$X", 1).in("$Y", 3).in("$Z", 4).out("A").out("C");
} else {
if (inputType == IO_TYPE.JAVA_RDD_STR_CSV || inputType == IO_TYPE.JAVA_RDD_STR_IJV) {
if (script_type == SCRIPT_TYPE.DML)
script = dml("A[2:3,2:4]=B;C=A[2:3,2:3]").in("A", javaRDDA, fmA).in("B", javaRDDB, fmB).out("A")
.out("C");
else if (script_type == SCRIPT_TYPE.PYDML)
// DO NOT USE ; at the end of any statment, it throws
// NPE
script = pydml("A[$X:$Y,$X:$Z]=B\nC=A[$X:$Y,$X:$Y]").in("A", javaRDDA, fmA)
.in("B", javaRDDB, fmB)
// Value for ROW index gets incremented at
// script level to adjust index in PyDML, but
// not for Column Index
.in("$X", 1).in("$Y", 3).in("$Z", 4).out("A").out("C");
} else if (inputType == IO_TYPE.RDD_STR_CSV || inputType == IO_TYPE.RDD_STR_IJV) {
RDD<String> rddA = JavaRDD.toRDD(javaRDDA);
RDD<String> rddB = JavaRDD.toRDD(javaRDDB);
if (script_type == SCRIPT_TYPE.DML)
script = dml("A[2:3,2:4]=B;C=A[2:3,2:3]").in("A", rddA, fmA).in("B", rddB, fmB).out("A")
.out("C");
else if (script_type == SCRIPT_TYPE.PYDML)
// DO NOT USE ; at the end of any statment, it throws
// NPE
script = pydml("A[$X:$Y,$X:$Z]=B\nC=A[$X:$Y,$X:$Y]").in("A", rddA, fmA).in("B", rddB, fmB)
// Value for ROW index gets incremented at
// script level to adjust index in PyDML, but
// not for Column Index
.in("$X", 1).in("$Y", 3).in("$Z", 4).out("A").out("C");
}
}
} else { // Input type is file
String fileA = null, fileB = null;
if (format == FrameFormat.CSV) {
fileA = baseDirectory + File.separator + "FrameA.csv";
fileB = baseDirectory + File.separator + "FrameB.csv";
} else if (format == FrameFormat.IJV) {
fileA = baseDirectory + File.separator + "FrameA.ijv";
fileB = baseDirectory + File.separator + "FrameB.ijv";
}
if (script_type == SCRIPT_TYPE.DML)
script = dml("A=read($A); B=read($B);A[2:3,2:4]=B;C=A[2:3,2:3];A[1,1]=234").in("$A", fileA, fmA)
.in("$B", fileB, fmB).out("A").out("C");
else if (script_type == SCRIPT_TYPE.PYDML)
// DO NOT USE ; at the end of any statment, it throws NPE
script = pydml("A=load($A)\nB=load($B)\nA[$X:$Y,$X:$Z]=B\nC=A[$X:$Y,$X:$Y]").in("$A", fileA)
.in("$B", fileB)
// Value for ROW index gets incremented at script level
// to adjust index in PyDML, but not for Column Index
.in("$X", 1).in("$Y", 3).in("$Z", 4).out("A").out("C");
}
MLResults mlResults = ml.execute(script);
//Validate output schema
List<ValueType> lschemaOutA = Arrays.asList(mlResults.getFrameObject("A").getSchema());
List<ValueType> lschemaOutC = Arrays.asList(mlResults.getFrameObject("C").getSchema());
Assert.assertEquals(ValueType.INT, lschemaOutA.get(0));
Assert.assertEquals(ValueType.STRING, lschemaOutA.get(1));
Assert.assertEquals(ValueType.DOUBLE, lschemaOutA.get(2));
Assert.assertEquals(ValueType.BOOLEAN, lschemaOutA.get(3));
Assert.assertEquals(ValueType.STRING, lschemaOutC.get(0));
Assert.assertEquals(ValueType.DOUBLE, lschemaOutC.get(1));
if (outputType == IO_TYPE.JAVA_RDD_STR_CSV) {
JavaRDD<String> javaRDDStringCSVA = mlResults.getJavaRDDStringCSV("A");
List<String> linesA = javaRDDStringCSVA.collect();
Assert.assertEquals("1,Str2,3.0,true", linesA.get(0));
Assert.assertEquals("4,Str12,13.0,true", linesA.get(1));
Assert.assertEquals("7,Str25,26.0,false", linesA.get(2));
JavaRDD<String> javaRDDStringCSVC = mlResults.getJavaRDDStringCSV("C");
List<String> linesC = javaRDDStringCSVC.collect();
Assert.assertEquals("Str12,13.0", linesC.get(0));
Assert.assertEquals("Str25,26.0", linesC.get(1));
} else if (outputType == IO_TYPE.JAVA_RDD_STR_IJV) {
JavaRDD<String> javaRDDStringIJVA = mlResults.getJavaRDDStringIJV("A");
List<String> linesA = javaRDDStringIJVA.collect();
Assert.assertEquals("1 1 1", linesA.get(0));
Assert.assertEquals("1 2 Str2", linesA.get(1));
Assert.assertEquals("1 3 3.0", linesA.get(2));
Assert.assertEquals("1 4 true", linesA.get(3));
Assert.assertEquals("2 1 4", linesA.get(4));
Assert.assertEquals("2 2 Str12", linesA.get(5));
Assert.assertEquals("2 3 13.0", linesA.get(6));
Assert.assertEquals("2 4 true", linesA.get(7));
JavaRDD<String> javaRDDStringIJVC = mlResults.getJavaRDDStringIJV("C");
List<String> linesC = javaRDDStringIJVC.collect();
Assert.assertEquals("1 1 Str12", linesC.get(0));
Assert.assertEquals("1 2 13.0", linesC.get(1));
Assert.assertEquals("2 1 Str25", linesC.get(2));
Assert.assertEquals("2 2 26.0", linesC.get(3));
} else if (outputType == IO_TYPE.RDD_STR_CSV) {
RDD<String> rddStringCSVA = mlResults.getRDDStringCSV("A");
Iterator<String> iteratorA = rddStringCSVA.toLocalIterator();
Assert.assertEquals("1,Str2,3.0,true", iteratorA.next());
Assert.assertEquals("4,Str12,13.0,true", iteratorA.next());
Assert.assertEquals("7,Str25,26.0,false", iteratorA.next());
RDD<String> rddStringCSVC = mlResults.getRDDStringCSV("C");
Iterator<String> iteratorC = rddStringCSVC.toLocalIterator();
Assert.assertEquals("Str12,13.0", iteratorC.next());
Assert.assertEquals("Str25,26.0", iteratorC.next());
} else if (outputType == IO_TYPE.RDD_STR_IJV) {
RDD<String> rddStringIJVA = mlResults.getRDDStringIJV("A");
Iterator<String> iteratorA = rddStringIJVA.toLocalIterator();
Assert.assertEquals("1 1 1", iteratorA.next());
Assert.assertEquals("1 2 Str2", iteratorA.next());
Assert.assertEquals("1 3 3.0", iteratorA.next());
Assert.assertEquals("1 4 true", iteratorA.next());
Assert.assertEquals("2 1 4", iteratorA.next());
Assert.assertEquals("2 2 Str12", iteratorA.next());
Assert.assertEquals("2 3 13.0", iteratorA.next());
Assert.assertEquals("2 4 true", iteratorA.next());
Assert.assertEquals("3 1 7", iteratorA.next());
Assert.assertEquals("3 2 Str25", iteratorA.next());
Assert.assertEquals("3 3 26.0", iteratorA.next());
Assert.assertEquals("3 4 false", iteratorA.next());
RDD<String> rddStringIJVC = mlResults.getRDDStringIJV("C");
Iterator<String> iteratorC = rddStringIJVC.toLocalIterator();
Assert.assertEquals("1 1 Str12", iteratorC.next());
Assert.assertEquals("1 2 13.0", iteratorC.next());
Assert.assertEquals("2 1 Str25", iteratorC.next());
Assert.assertEquals("2 2 26.0", iteratorC.next());
} else if (outputType == IO_TYPE.DATAFRAME) {
Dataset<Row> dataFrameA = mlResults.getDataFrame("A").drop(RDDConverterUtils.DF_ID_COLUMN);
StructType dfschemaA = dataFrameA.schema();
StructField structTypeA = dfschemaA.apply(0);
Assert.assertEquals(DataTypes.LongType, structTypeA.dataType());
structTypeA = dfschemaA.apply(1);
Assert.assertEquals(DataTypes.StringType, structTypeA.dataType());
structTypeA = dfschemaA.apply(2);
Assert.assertEquals(DataTypes.DoubleType, structTypeA.dataType());
structTypeA = dfschemaA.apply(3);
Assert.assertEquals(DataTypes.BooleanType, structTypeA.dataType());
List<Row> listAOut = dataFrameA.collectAsList();
Row row1 = listAOut.get(0);
Assert.assertEquals("Mismatch with expected value", Long.valueOf(1), row1.get(0));
Assert.assertEquals("Mismatch with expected value", "Str2", row1.get(1));
Assert.assertEquals("Mismatch with expected value", 3.0, row1.get(2));
Assert.assertEquals("Mismatch with expected value", true, row1.get(3));
Row row2 = listAOut.get(1);
Assert.assertEquals("Mismatch with expected value", Long.valueOf(4), row2.get(0));
Assert.assertEquals("Mismatch with expected value", "Str12", row2.get(1));
Assert.assertEquals("Mismatch with expected value", 13.0, row2.get(2));
Assert.assertEquals("Mismatch with expected value", true, row2.get(3));
Dataset<Row> dataFrameC = mlResults.getDataFrame("C").drop(RDDConverterUtils.DF_ID_COLUMN);
StructType dfschemaC = dataFrameC.schema();
StructField structTypeC = dfschemaC.apply(0);
Assert.assertEquals(DataTypes.StringType, structTypeC.dataType());
structTypeC = dfschemaC.apply(1);
Assert.assertEquals(DataTypes.DoubleType, structTypeC.dataType());
List<Row> listCOut = dataFrameC.collectAsList();
Row row3 = listCOut.get(0);
Assert.assertEquals("Mismatch with expected value", "Str12", row3.get(0));
Assert.assertEquals("Mismatch with expected value", 13.0, row3.get(1));
Row row4 = listCOut.get(1);
Assert.assertEquals("Mismatch with expected value", "Str25", row4.get(0));
Assert.assertEquals("Mismatch with expected value", 26.0, row4.get(1));
} else {
String[][] frameA = mlResults.getFrameAs2DStringArray("A");
Assert.assertEquals("Str2", frameA[0][1]);
Assert.assertEquals("3.0", frameA[0][2]);
Assert.assertEquals("13.0", frameA[1][2]);
Assert.assertEquals("true", frameA[1][3]);
Assert.assertEquals("Str25", frameA[2][1]);
String[][] frameC = mlResults.getFrameAs2DStringArray("C");
Assert.assertEquals("Str12", frameC[0][0]);
Assert.assertEquals("Str25", frameC[1][0]);
Assert.assertEquals("13.0", frameC[0][1]);
Assert.assertEquals("26.0", frameC[1][1]);
}
}
@Test
public void testOutputFrameDML() {
System.out.println("MLContextFrameTest - output frame DML");
String s = "M = read($Min, data_type='frame', format='csv');";
String csvFile = baseDirectory + File.separator + "one-two-three-four.csv";
Script script = dml(s).in("$Min", csvFile).out("M");
String[][] frame = ml.execute(script).getFrameAs2DStringArray("M");
Assert.assertEquals("one", frame[0][0]);
Assert.assertEquals("two", frame[0][1]);
Assert.assertEquals("three", frame[1][0]);
Assert.assertEquals("four", frame[1][1]);
}
@Test
public void testOutputFramePYDML() {
System.out.println("MLContextFrameTest - output frame PYDML");
String s = "M = load($Min, data_type='frame', format='csv')";
String csvFile = baseDirectory + File.separator + "one-two-three-four.csv";
Script script = pydml(s).in("$Min", csvFile).out("M");
String[][] frame = ml.execute(script).getFrameAs2DStringArray("M");
Assert.assertEquals("one", frame[0][0]);
Assert.assertEquals("two", frame[0][1]);
Assert.assertEquals("three", frame[1][0]);
Assert.assertEquals("four", frame[1][1]);
}
@Test
public void testInputFrameAndMatrixOutputMatrix() {
System.out.println("MLContextFrameTest - input frame and matrix, output matrix");
List<String> dataA = new ArrayList<String>();
dataA.add("Test1,4.0");
dataA.add("Test2,5.0");
dataA.add("Test3,6.0");
JavaRDD<String> javaRddStringA = sc.parallelize(dataA);
ValueType[] schema = { ValueType.STRING, ValueType.DOUBLE };
List<String> dataB = new ArrayList<String>();
dataB.add("1.0");
dataB.add("2.0");
JavaRDD<String> javaRddStringB = sc.parallelize(dataB);
JavaRDD<Row> javaRddRowA = FrameRDDConverterUtils.csvToRowRDD(sc, javaRddStringA, CSV_DELIM, schema);
JavaRDD<Row> javaRddRowB = javaRddStringB.map(new CommaSeparatedValueStringToDoubleArrayRow());
List<StructField> fieldsA = new ArrayList<StructField>();
fieldsA.add(DataTypes.createStructField("1", DataTypes.StringType, true));
fieldsA.add(DataTypes.createStructField("2", DataTypes.DoubleType, true));
StructType schemaA = DataTypes.createStructType(fieldsA);
Dataset<Row> dataFrameA = spark.createDataFrame(javaRddRowA, schemaA);
List<StructField> fieldsB = new ArrayList<StructField>();
fieldsB.add(DataTypes.createStructField("1", DataTypes.DoubleType, true));
StructType schemaB = DataTypes.createStructType(fieldsB);
Dataset<Row> dataFrameB = spark.createDataFrame(javaRddRowB, schemaB);
String dmlString = "[tA, tAM] = transformencode (target = A, spec = \"{ids: true ,recode: [ 1, 2 ]}\");\n"
+ "C = tA %*% B;\n" + "M = s * C;";
Script script = dml(dmlString)
.in("A", dataFrameA,
new FrameMetadata(FrameFormat.CSV, dataFrameA.count(), (long) dataFrameA.columns().length))
.in("B", dataFrameB,
new MatrixMetadata(MatrixFormat.CSV, dataFrameB.count(), (long) dataFrameB.columns().length))
.in("s", 2).out("M");
MLResults results = ml.execute(script);
double[][] matrix = results.getMatrixAs2DDoubleArray("M");
Assert.assertEquals(6.0, matrix[0][0], 0.0);
Assert.assertEquals(12.0, matrix[1][0], 0.0);
Assert.assertEquals(18.0, matrix[2][0], 0.0);
}
@Test
public void testInputFrameAndMatrixOutputMatrixAndFrame() {
System.out.println("MLContextFrameTest - input frame and matrix, output matrix and frame");
Row[] rowsA = {RowFactory.create("Doc1", "Feat1", 10), RowFactory.create("Doc1", "Feat2", 20), RowFactory.create("Doc2", "Feat1", 31)};
JavaRDD<Row> javaRddRowA = sc. parallelize( Arrays.asList(rowsA));
List<StructField> fieldsA = new ArrayList<StructField>();
fieldsA.add(DataTypes.createStructField("myID", DataTypes.StringType, true));
fieldsA.add(DataTypes.createStructField("FeatureName", DataTypes.StringType, true));
fieldsA.add(DataTypes.createStructField("FeatureValue", DataTypes.IntegerType, true));
StructType schemaA = DataTypes.createStructType(fieldsA);
Dataset<Row> dataFrameA = spark.createDataFrame(javaRddRowA, schemaA);
String dmlString = "[tA, tAM] = transformencode (target = A, spec = \"{ids: false ,recode: [ myID, FeatureName ]}\");";
Script script = dml(dmlString)
.in("A", dataFrameA,
new FrameMetadata(FrameFormat.CSV, dataFrameA.count(), (long) dataFrameA.columns().length))
.out("tA").out("tAM");
MLResults results = ml.execute(script);
double[][] matrixtA = results.getMatrixAs2DDoubleArray("tA");
Assert.assertEquals(10.0, matrixtA[0][2], 0.0);
Assert.assertEquals(20.0, matrixtA[1][2], 0.0);
Assert.assertEquals(31.0, matrixtA[2][2], 0.0);
Dataset<Row> dataFrame_tA = results.getMatrix("tA").toDF();
System.out.println("Number of matrix tA rows = " + dataFrame_tA.count());
dataFrame_tA.printSchema();
dataFrame_tA.show();
Dataset<Row> dataFrame_tAM = results.getFrame("tAM").toDF();
System.out.println("Number of frame tAM rows = " + dataFrame_tAM.count());
dataFrame_tAM.printSchema();
dataFrame_tAM.show();
}
@Test
public void testTransform() {
System.out.println("MLContextFrameTest - transform");
Row[] rowsA = {RowFactory.create("\"`@(\"(!&",2,"20news-bydate-train/comp.os.ms-windows.misc/9979"),
RowFactory.create("\"`@(\"\"(!&\"",3,"20news-bydate-train/comp.os.ms-windows.misc/9979")};
JavaRDD<Row> javaRddRowA = sc. parallelize( Arrays.asList(rowsA));
List<StructField> fieldsA = new ArrayList<StructField>();
fieldsA.add(DataTypes.createStructField("featureName", DataTypes.StringType, true));
fieldsA.add(DataTypes.createStructField("featureValue", DataTypes.IntegerType, true));
fieldsA.add(DataTypes.createStructField("id", DataTypes.StringType, true));
StructType schemaA = DataTypes.createStructType(fieldsA);
Dataset<Row> dataFrameA = spark.createDataFrame(javaRddRowA, schemaA);
String dmlString = "[tA, tAM] = transformencode (target = A, spec = \"{ids: false ,recode: [ featureName, id ]}\");";
Script script = dml(dmlString)
.in("A", dataFrameA,
new FrameMetadata(FrameFormat.CSV, dataFrameA.count(), (long) dataFrameA.columns().length))
.out("tA").out("tAM");
ml.setExplain(true);
ml.setExplainLevel(ExplainLevel.RECOMPILE_HOPS);
MLResults results = ml.execute(script);
double[][] matrixtA = results.getMatrixAs2DDoubleArray("tA");
Assert.assertEquals(1.0, matrixtA[0][2], 0.0);
Dataset<Row> dataFrame_tA = results.getMatrix("tA").toDF();
System.out.println("Number of matrix tA rows = " + dataFrame_tA.count());
dataFrame_tA.printSchema();
dataFrame_tA.show();
Dataset<Row> dataFrame_tAM = results.getFrame("tAM").toDF();
System.out.println("Number of frame tAM rows = " + dataFrame_tAM.count());
dataFrame_tAM.printSchema();
dataFrame_tAM.show();
}
// NOTE: the ordering of the frame values seem to come out differently here
// than in the scala shell,
// so this should be investigated or explained.
// @Test
// public void testInputFrameOutputMatrixAndFrame() {
// System.out.println("MLContextFrameTest - input frame, output matrix and
// frame");
//
// List<String> dataA = new ArrayList<String>();
// dataA.add("Test1,Test4");
// dataA.add("Test2,Test5");
// dataA.add("Test3,Test6");
// JavaRDD<String> javaRddStringA = sc.parallelize(dataA);
//
// JavaRDD<Row> javaRddRowA = javaRddStringA.map(new
// CommaSeparatedValueStringToRow());
//
// List<StructField> fieldsA = new ArrayList<StructField>();
// fieldsA.add(DataTypes.createStructField("1", DataTypes.StringType,
// true));
// fieldsA.add(DataTypes.createStructField("2", DataTypes.StringType,
// true));
// StructType schemaA = DataTypes.createStructType(fieldsA);
// DataFrame dataFrameA = spark.createDataFrame(javaRddRowA, schemaA);
//
// String dmlString = "[tA, tAM] = transformencode (target = A, spec =
// \"{ids: true ,recode: [ 1, 2 ]}\");\n";
//
// Script script = dml(dmlString)
// .in("A", dataFrameA,
// new FrameMetadata(FrameFormat.CSV, dataFrameA.count(), (long)
// dataFrameA.columns().length))
// .out("tA", "tAM");
// MLResults results = ml.execute(script);
// double[][] matrix = results.getMatrixAs2DDoubleArray("tA");
// Assert.assertEquals(1.0, matrix[0][0], 0.0);
// Assert.assertEquals(1.0, matrix[0][1], 0.0);
// Assert.assertEquals(2.0, matrix[1][0], 0.0);
// Assert.assertEquals(2.0, matrix[1][1], 0.0);
// Assert.assertEquals(3.0, matrix[2][0], 0.0);
// Assert.assertEquals(3.0, matrix[2][1], 0.0);
//
// TODO: Add asserts for frame if ordering is as expected
// String[][] frame = results.getFrameAs2DStringArray("tAM");
// for (int i = 0; i < frame.length; i++) {
// for (int j = 0; j < frame[i].length; j++) {
// System.out.println("[" + i + "][" + j + "]:" + frame[i][j]);
// }
// }
// }
}
| apache-2.0 |
anishalex/youlog | oauthComponents/google-oauth-java-client-dev/google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/AuthorizationCodeInstalledApp.java | 5421 | /*
* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.extensions.java6.auth.oauth2;
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.auth.oauth2.TokenResponse;
import com.google.api.client.util.Preconditions;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* OAuth 2.0 authorization code flow for an installed Java application that persists end-user
* credentials.
*
* <p>
* Implementation is thread-safe.
* </p>
*
* @since 1.11
* @author Yaniv Inbar
*/
public class AuthorizationCodeInstalledApp {
/** Authorization code flow. */
private final AuthorizationCodeFlow flow;
/** Verification code receiver. */
private final VerificationCodeReceiver receiver;
private static final Logger LOGGER =
Logger.getLogger(AuthorizationCodeInstalledApp.class.getName());
/**
* @param flow authorization code flow
* @param receiver verification code receiver
*/
public AuthorizationCodeInstalledApp(
AuthorizationCodeFlow flow, VerificationCodeReceiver receiver) {
this.flow = Preconditions.checkNotNull(flow);
this.receiver = Preconditions.checkNotNull(receiver);
}
/**
* Authorizes the installed application to access user's protected data.
*
* @param userId user ID or {@code null} if not using a persisted credential store
* @return credential
*/
public Credential authorize(String userId) throws IOException {
try {
Credential credential = flow.loadCredential(userId);
if (credential != null
&& (credential.getRefreshToken() != null || credential.getExpiresInSeconds() > 60)) {
return credential;
}
// open in browser
String redirectUri = receiver.getRedirectUri();
AuthorizationCodeRequestUrl authorizationUrl =
flow.newAuthorizationUrl().setRedirectUri(redirectUri);
onAuthorization(authorizationUrl);
// receive authorization code and exchange it for an access token
String code = receiver.waitForCode();
TokenResponse response = flow.newTokenRequest(code).setRedirectUri(redirectUri).execute();
// store credential and return it
return flow.createAndStoreCredential(response, userId);
} finally {
receiver.stop();
}
}
/**
* Handles user authorization by redirecting to the OAuth 2.0 authorization server.
*
* <p>
* Default implementation is to call {@code browse(authorizationUrl.build())}. Subclasses may
* override to provide optional parameters such as the recommended state parameter. Sample
* implementation:
* </p>
*
* <pre>
@Override
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {
authorizationUrl.setState("xyz");
super.onAuthorization(authorizationUrl);
}
* </pre>
*
* @param authorizationUrl authorization URL
* @throws IOException I/O exception
*/
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {
browse(authorizationUrl.build());
}
/**
* Open a browser at the given URL using {@link Desktop} if available, or alternatively output the
* URL to {@link System#out} for command-line applications.
*
* @param url URL to browse
*/
public static void browse(String url) {
Preconditions.checkNotNull(url);
// Ask user to open in their browser using copy-paste
System.out.println("Please open the following address in your browser:");
System.out.println(" " + url);
// Attempt to open it in the browser
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
System.out.println("Attempting to open that address in the default browser now...");
desktop.browse(URI.create(url));
}
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to open browser", e);
} catch (InternalError e) {
// A bug in a JRE can cause Desktop.isDesktopSupported() to throw an
// InternalError rather than returning false. The error reads,
// "Can't connect to X11 window server using ':0.0' as the value of the
// DISPLAY variable." The exact error message may vary slightly.
LOGGER.log(Level.WARNING, "Unable to open browser", e);
}
}
/** Returns the authorization code flow. */
public final AuthorizationCodeFlow getFlow() {
return flow;
}
/** Returns the verification code receiver. */
public final VerificationCodeReceiver getReceiver() {
return receiver;
}
}
| apache-2.0 |
malmiron/incubator-airflow | airflow/contrib/operators/sagemaker_tuning_operator.py | 4191 | # -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from airflow.contrib.hooks.aws_hook import AwsHook
from airflow.contrib.operators.sagemaker_base_operator import SageMakerBaseOperator
from airflow.utils.decorators import apply_defaults
from airflow.exceptions import AirflowException
class SageMakerTuningOperator(SageMakerBaseOperator):
"""
Initiate a SageMaker hyperparameter tuning job.
This operator returns The ARN of the tuning job created in Amazon SageMaker.
:param config: The configuration necessary to start a tuning job (templated).
For details of the configuration parameter see
:py:meth:`SageMaker.Client.create_hyper_parameter_tuning_job`
:type config: dict
:param aws_conn_id: The AWS connection ID to use.
:type aws_conn_id: str
:param wait_for_completion: Set to True to wait until the tuning job finishes.
:type wait_for_completion: bool
:param check_interval: If wait is set to True, the time interval, in seconds,
that this operation waits to check the status of the tuning job.
:type check_interval: int
:param max_ingestion_time: If wait is set to True, the operation fails
if the tuning job doesn't finish within max_ingestion_time seconds. If you
set this parameter to None, the operation does not timeout.
:type max_ingestion_time: int
"""
integer_fields = [
['HyperParameterTuningJobConfig', 'ResourceLimits', 'MaxNumberOfTrainingJobs'],
['HyperParameterTuningJobConfig', 'ResourceLimits', 'MaxParallelTrainingJobs'],
['TrainingJobDefinition', 'ResourceConfig', 'InstanceCount'],
['TrainingJobDefinition', 'ResourceConfig', 'VolumeSizeInGB'],
['TrainingJobDefinition', 'StoppingCondition', 'MaxRuntimeInSeconds']
]
@apply_defaults
def __init__(self,
config,
wait_for_completion=True,
check_interval=30,
max_ingestion_time=None,
*args, **kwargs):
super(SageMakerTuningOperator, self).__init__(config=config,
*args, **kwargs)
self.config = config
self.wait_for_completion = wait_for_completion
self.check_interval = check_interval
self.max_ingestion_time = max_ingestion_time
def expand_role(self):
if 'TrainingJobDefinition' in self.config:
config = self.config['TrainingJobDefinition']
if 'RoleArn' in config:
hook = AwsHook(self.aws_conn_id)
config['RoleArn'] = hook.expand_role(config['RoleArn'])
def execute(self, context):
self.preprocess_config()
self.log.info(
'Creating SageMaker Hyper-Parameter Tuning Job %s', self.config['HyperParameterTuningJobName']
)
response = self.hook.create_tuning_job(
self.config,
wait_for_completion=self.wait_for_completion,
check_interval=self.check_interval,
max_ingestion_time=self.max_ingestion_time
)
if response['ResponseMetadata']['HTTPStatusCode'] != 200:
raise AirflowException('Sagemaker Tuning Job creation failed: %s' % response)
else:
return {
'Tuning': self.hook.describe_tuning_job(
self.config['HyperParameterTuningJobName']
)
}
| apache-2.0 |
ksx123/session | redis/redis.go | 5335 | // Copyright 2013 Beego Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package session
import (
"fmt"
"strings"
"sync"
"time"
"github.com/Unknwon/com"
"gopkg.in/ini.v1"
"gopkg.in/redis.v2"
"github.com/macaron-contrib/session"
)
// RedisStore represents a redis session store implementation.
type RedisStore struct {
c *redis.Client
sid string
duration time.Duration
lock sync.RWMutex
data map[interface{}]interface{}
}
// NewRedisStore creates and returns a redis session store.
func NewRedisStore(c *redis.Client, sid string, dur time.Duration, kv map[interface{}]interface{}) *RedisStore {
return &RedisStore{
c: c,
sid: sid,
duration: dur,
data: kv,
}
}
// Set sets value to given key in session.
func (s *RedisStore) Set(key, val interface{}) error {
s.lock.Lock()
defer s.lock.Unlock()
s.data[key] = val
return nil
}
// Get gets value by given key in session.
func (s *RedisStore) Get(key interface{}) interface{} {
s.lock.RLock()
defer s.lock.RUnlock()
return s.data[key]
}
// Delete delete a key from session.
func (s *RedisStore) Delete(key interface{}) error {
s.lock.Lock()
defer s.lock.Unlock()
delete(s.data, key)
return nil
}
// ID returns current session ID.
func (s *RedisStore) ID() string {
return s.sid
}
// Release releases resource and save data to provider.
func (s *RedisStore) Release() error {
data, err := session.EncodeGob(s.data)
if err != nil {
return err
}
return s.c.SetEx(s.sid, s.duration, string(data)).Err()
}
// Flush deletes all session data.
func (s *RedisStore) Flush() error {
s.lock.Lock()
defer s.lock.Unlock()
s.data = make(map[interface{}]interface{})
return nil
}
// RedisProvider represents a redis session provider implementation.
type RedisProvider struct {
c *redis.Client
duration time.Duration
}
// Init initializes redis session provider.
// configs: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
func (p *RedisProvider) Init(maxlifetime int64, configs string) (err error) {
p.duration, err = time.ParseDuration(fmt.Sprintf("%ds", maxlifetime))
if err != nil {
return err
}
cfg, err := ini.Load([]byte(strings.Replace(configs, ",", "\n", -1)))
if err != nil {
return err
}
opt := &redis.Options{
Network: "tcp",
}
for k, v := range cfg.Section("").KeysHash() {
switch k {
case "network":
opt.Network = v
case "addr":
opt.Addr = v
case "password":
opt.Password = v
case "db":
opt.DB = com.StrTo(v).MustInt64()
case "pool_size":
opt.PoolSize = com.StrTo(v).MustInt()
case "idle_timeout":
opt.IdleTimeout, err = time.ParseDuration(v + "s")
if err != nil {
return fmt.Errorf("error parsing idle timeout: %v", err)
}
default:
return fmt.Errorf("session/redis: unsupported option '%s'", k)
}
}
p.c = redis.NewClient(opt)
return p.c.Ping().Err()
}
// Read returns raw session store by session ID.
func (p *RedisProvider) Read(sid string) (session.RawStore, error) {
if !p.Exist(sid) {
if err := p.c.Set(sid, "").Err(); err != nil {
return nil, err
}
}
var kv map[interface{}]interface{}
kvs, err := p.c.Get(sid).Result()
if err != nil {
return nil, err
}
if len(kvs) == 0 {
kv = make(map[interface{}]interface{})
} else {
kv, err = session.DecodeGob([]byte(kvs))
if err != nil {
return nil, err
}
}
return NewRedisStore(p.c, sid, p.duration, kv), nil
}
// Exist returns true if session with given ID exists.
func (p *RedisProvider) Exist(sid string) bool {
has, err := p.c.Exists(sid).Result()
return err == nil && has
}
// Destory deletes a session by session ID.
func (p *RedisProvider) Destory(sid string) error {
return p.c.Del(sid).Err()
}
// Regenerate regenerates a session store from old session ID to new one.
func (p *RedisProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error) {
if p.Exist(sid) {
return nil, fmt.Errorf("new sid '%s' already exists", sid)
} else if !p.Exist(oldsid) {
// Make a fake old session.
if err = p.c.SetEx(oldsid, p.duration, "").Err(); err != nil {
return nil, err
}
}
if err = p.c.Rename(oldsid, sid).Err(); err != nil {
return nil, err
}
var kv map[interface{}]interface{}
kvs, err := p.c.Get(sid).Result()
if err != nil {
return nil, err
}
if len(kvs) == 0 {
kv = make(map[interface{}]interface{})
} else {
kv, err = session.DecodeGob([]byte(kvs))
if err != nil {
return nil, err
}
}
return NewRedisStore(p.c, sid, p.duration, kv), nil
}
// Count counts and returns number of sessions.
func (p *RedisProvider) Count() int {
return int(p.c.DbSize().Val())
}
// GC calls GC to clean expired sessions.
func (_ *RedisProvider) GC() {}
func init() {
session.Register("redis", &RedisProvider{})
}
| apache-2.0 |
JSDemos/android-sdk-20 | src/android/support/v7/internal/view/menu/MenuItemWrapperICS.java | 13747 | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.support.v7.internal.view.menu;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.v4.internal.view.SupportMenuItem;
import android.support.v4.view.ActionProvider;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.view.CollapsibleActionView;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.widget.FrameLayout;
import java.lang.reflect.Method;
/**
* @hide
*/
public class MenuItemWrapperICS extends BaseMenuWrapper<android.view.MenuItem> implements SupportMenuItem {
static final String LOG_TAG = "MenuItemWrapper";
private final boolean mEmulateProviderVisibilityOverride;
// Tracks the last requested visibility
private boolean mLastRequestVisible;
// Reflection Method to call setExclusiveCheckable
private Method mSetExclusiveCheckableMethod;
MenuItemWrapperICS(android.view.MenuItem object, boolean emulateProviderVisibilityOverride) {
super(object);
mLastRequestVisible = object.isVisible();
mEmulateProviderVisibilityOverride = emulateProviderVisibilityOverride;
}
MenuItemWrapperICS(android.view.MenuItem object) {
this(object, true);
}
@Override
public int getItemId() {
return mWrappedObject.getItemId();
}
@Override
public int getGroupId() {
return mWrappedObject.getGroupId();
}
@Override
public int getOrder() {
return mWrappedObject.getOrder();
}
@Override
public MenuItem setTitle(CharSequence title) {
mWrappedObject.setTitle(title);
return this;
}
@Override
public MenuItem setTitle(int title) {
mWrappedObject.setTitle(title);
return this;
}
@Override
public CharSequence getTitle() {
return mWrappedObject.getTitle();
}
@Override
public MenuItem setTitleCondensed(CharSequence title) {
mWrappedObject.setTitleCondensed(title);
return this;
}
@Override
public CharSequence getTitleCondensed() {
return mWrappedObject.getTitleCondensed();
}
@Override
public MenuItem setIcon(Drawable icon) {
mWrappedObject.setIcon(icon);
return this;
}
@Override
public MenuItem setIcon(int iconRes) {
mWrappedObject.setIcon(iconRes);
return this;
}
@Override
public Drawable getIcon() {
return mWrappedObject.getIcon();
}
@Override
public MenuItem setIntent(Intent intent) {
mWrappedObject.setIntent(intent);
return this;
}
@Override
public Intent getIntent() {
return mWrappedObject.getIntent();
}
@Override
public MenuItem setShortcut(char numericChar, char alphaChar) {
mWrappedObject.setShortcut(numericChar, alphaChar);
return this;
}
@Override
public MenuItem setNumericShortcut(char numericChar) {
mWrappedObject.setNumericShortcut(numericChar);
return this;
}
@Override
public char getNumericShortcut() {
return mWrappedObject.getNumericShortcut();
}
@Override
public MenuItem setAlphabeticShortcut(char alphaChar) {
mWrappedObject.setAlphabeticShortcut(alphaChar);
return this;
}
@Override
public char getAlphabeticShortcut() {
return mWrappedObject.getAlphabeticShortcut();
}
@Override
public MenuItem setCheckable(boolean checkable) {
mWrappedObject.setCheckable(checkable);
return this;
}
@Override
public boolean isCheckable() {
return mWrappedObject.isCheckable();
}
@Override
public MenuItem setChecked(boolean checked) {
mWrappedObject.setChecked(checked);
return this;
}
@Override
public boolean isChecked() {
return mWrappedObject.isChecked();
}
@Override
public MenuItem setVisible(boolean visible) {
if (mEmulateProviderVisibilityOverride) {
mLastRequestVisible = visible;
// If we need to be visible, we need to check whether the ActionProvider overrides it
if (checkActionProviderOverrideVisibility()) {
return this;
}
}
return wrappedSetVisible(visible);
}
@Override
public boolean isVisible() {
return mWrappedObject.isVisible();
}
@Override
public MenuItem setEnabled(boolean enabled) {
mWrappedObject.setEnabled(enabled);
return this;
}
@Override
public boolean isEnabled() {
return mWrappedObject.isEnabled();
}
@Override
public boolean hasSubMenu() {
return mWrappedObject.hasSubMenu();
}
@Override
public SubMenu getSubMenu() {
return getSubMenuWrapper(mWrappedObject.getSubMenu());
}
@Override
public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
mWrappedObject.setOnMenuItemClickListener(menuItemClickListener != null ?
new OnMenuItemClickListenerWrapper(menuItemClickListener) : null);
return this;
}
@Override
public ContextMenu.ContextMenuInfo getMenuInfo() {
return mWrappedObject.getMenuInfo();
}
@Override
public void setShowAsAction(int actionEnum) {
mWrappedObject.setShowAsAction(actionEnum);
}
@Override
public MenuItem setShowAsActionFlags(int actionEnum) {
mWrappedObject.setShowAsActionFlags(actionEnum);
return this;
}
@Override
public MenuItem setActionView(View view) {
if (view instanceof CollapsibleActionView) {
view = new CollapsibleActionViewWrapper(view);
}
mWrappedObject.setActionView(view);
return this;
}
@Override
public MenuItem setActionView(int resId) {
// Make framework menu item inflate the view
mWrappedObject.setActionView(resId);
View actionView = mWrappedObject.getActionView();
if (actionView instanceof CollapsibleActionView) {
// If the inflated Action View is support-collapsible, wrap it
mWrappedObject.setActionView(new CollapsibleActionViewWrapper(actionView));
}
return this;
}
@Override
public View getActionView() {
View actionView = mWrappedObject.getActionView();
if (actionView instanceof CollapsibleActionViewWrapper) {
return ((CollapsibleActionViewWrapper) actionView).getWrappedView();
}
return actionView;
}
@Override
public MenuItem setActionProvider(android.view.ActionProvider provider) {
mWrappedObject.setActionProvider(provider);
if (provider != null && mEmulateProviderVisibilityOverride) {
checkActionProviderOverrideVisibility();
}
return this;
}
@Override
public android.view.ActionProvider getActionProvider() {
return mWrappedObject.getActionProvider();
}
@Override
public boolean expandActionView() {
return mWrappedObject.expandActionView();
}
@Override
public boolean collapseActionView() {
return mWrappedObject.collapseActionView();
}
@Override
public boolean isActionViewExpanded() {
return mWrappedObject.isActionViewExpanded();
}
@Override
public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener listener) {
mWrappedObject.setOnActionExpandListener(listener);
return this;
}
@Override
public SupportMenuItem setSupportOnActionExpandListener(
MenuItemCompat.OnActionExpandListener listener) {
mWrappedObject.setOnActionExpandListener(listener != null ?
new OnActionExpandListenerWrapper(listener) : null);
return null;
}
@Override
public SupportMenuItem setSupportActionProvider(ActionProvider actionProvider) {
mWrappedObject.setActionProvider(actionProvider != null ?
createActionProviderWrapper(actionProvider) : null);
return this;
}
@Override
public ActionProvider getSupportActionProvider() {
ActionProviderWrapper providerWrapper =
(ActionProviderWrapper) mWrappedObject.getActionProvider();
return providerWrapper != null ? providerWrapper.mInner : null;
}
public void setExclusiveCheckable(boolean checkable) {
try {
if (mSetExclusiveCheckableMethod == null) {
mSetExclusiveCheckableMethod = mWrappedObject.getClass()
.getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
}
mSetExclusiveCheckableMethod.invoke(mWrappedObject, checkable);
} catch (Exception e) {
Log.w(LOG_TAG, "Error while calling setExclusiveCheckable", e);
}
}
ActionProviderWrapper createActionProviderWrapper(ActionProvider provider) {
return new ActionProviderWrapper(provider);
}
/**
* @return true if the ActionProvider has overriden the visibility
*/
final boolean checkActionProviderOverrideVisibility() {
if (mLastRequestVisible) {
ActionProvider provider = getSupportActionProvider();
if (provider != null && provider.overridesItemVisibility() && !provider.isVisible()) {
wrappedSetVisible(false);
return true;
}
}
return false;
}
final MenuItem wrappedSetVisible(boolean visible) {
return mWrappedObject.setVisible(visible);
}
private class OnMenuItemClickListenerWrapper extends BaseWrapper<OnMenuItemClickListener>
implements android.view.MenuItem.OnMenuItemClickListener {
OnMenuItemClickListenerWrapper(OnMenuItemClickListener object) {
super(object);
}
@Override
public boolean onMenuItemClick(android.view.MenuItem item) {
return mWrappedObject.onMenuItemClick(getMenuItemWrapper(item));
}
}
private class OnActionExpandListenerWrapper extends BaseWrapper<MenuItemCompat.OnActionExpandListener>
implements android.view.MenuItem.OnActionExpandListener {
OnActionExpandListenerWrapper(MenuItemCompat.OnActionExpandListener object) {
super(object);
}
@Override
public boolean onMenuItemActionExpand(android.view.MenuItem item) {
return mWrappedObject.onMenuItemActionExpand(getMenuItemWrapper(item));
}
@Override
public boolean onMenuItemActionCollapse(android.view.MenuItem item) {
return mWrappedObject.onMenuItemActionCollapse(getMenuItemWrapper(item));
}
}
class ActionProviderWrapper extends android.view.ActionProvider {
final ActionProvider mInner;
public ActionProviderWrapper(ActionProvider inner) {
super(inner.getContext());
mInner = inner;
if (mEmulateProviderVisibilityOverride) {
mInner.setVisibilityListener(new ActionProvider.VisibilityListener() {
@Override
public void onActionProviderVisibilityChanged(boolean isVisible) {
if (mInner.overridesItemVisibility() && mLastRequestVisible) {
wrappedSetVisible(isVisible);
}
}
});
}
}
@Override
public View onCreateActionView() {
if (mEmulateProviderVisibilityOverride) {
// This is a convenient place to hook in and check if we need to override the
// visibility after being created.
checkActionProviderOverrideVisibility();
}
return mInner.onCreateActionView();
}
@Override
public boolean onPerformDefaultAction() {
return mInner.onPerformDefaultAction();
}
@Override
public boolean hasSubMenu() {
return mInner.hasSubMenu();
}
@Override
public void onPrepareSubMenu(android.view.SubMenu subMenu) {
mInner.onPrepareSubMenu(getSubMenuWrapper(subMenu));
}
}
static class CollapsibleActionViewWrapper extends FrameLayout
implements android.view.CollapsibleActionView {
final CollapsibleActionView mWrappedView;
CollapsibleActionViewWrapper(View actionView) {
super(actionView.getContext());
mWrappedView = (CollapsibleActionView) actionView;
addView(actionView);
}
@Override
public void onActionViewExpanded() {
mWrappedView.onActionViewExpanded();
}
@Override
public void onActionViewCollapsed() {
mWrappedView.onActionViewCollapsed();
}
View getWrappedView() {
return (View) mWrappedView;
}
}
}
| apache-2.0 |
pweil-/origin | vendor/github.com/Azure/azure-sdk-for-go/services/preview/costmanagement/mgmt/2019-10-01/costmanagement/costmanagementapi/interfaces.go | 2746 | package costmanagementapi
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/azure-sdk-for-go/services/preview/costmanagement/mgmt/2019-10-01/costmanagement"
"github.com/Azure/go-autorest/autorest"
)
// DimensionsClientAPI contains the set of methods on the DimensionsClient type.
type DimensionsClientAPI interface {
ListByScope(ctx context.Context, scope string, filter string, expand string, skiptoken string, top *int32) (result costmanagement.DimensionsListResult, err error)
}
var _ DimensionsClientAPI = (*costmanagement.DimensionsClient)(nil)
// QueryClientAPI contains the set of methods on the QueryClient type.
type QueryClientAPI interface {
UsageByScope(ctx context.Context, scope string, parameters costmanagement.QueryDefinition) (result costmanagement.QueryResult, err error)
}
var _ QueryClientAPI = (*costmanagement.QueryClient)(nil)
// ExportsClientAPI contains the set of methods on the ExportsClient type.
type ExportsClientAPI interface {
CreateOrUpdate(ctx context.Context, scope string, exportName string, parameters costmanagement.Export) (result costmanagement.Export, err error)
Delete(ctx context.Context, scope string, exportName string) (result autorest.Response, err error)
Execute(ctx context.Context, scope string, exportName string) (result autorest.Response, err error)
Get(ctx context.Context, scope string, exportName string) (result costmanagement.Export, err error)
GetExecutionHistory(ctx context.Context, scope string, exportName string) (result costmanagement.ExportExecutionListResult, err error)
List(ctx context.Context, scope string) (result costmanagement.ExportListResult, err error)
}
var _ ExportsClientAPI = (*costmanagement.ExportsClient)(nil)
// OperationsClientAPI contains the set of methods on the OperationsClient type.
type OperationsClientAPI interface {
List(ctx context.Context) (result costmanagement.OperationListResultPage, err error)
}
var _ OperationsClientAPI = (*costmanagement.OperationsClient)(nil)
| apache-2.0 |
cockroachdb/etcd | vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go | 166962 | // mkerrors.sh -Wall -Werror -static -I/tmp/include
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build ppc64,linux
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
package unix
import "syscall"
const (
AAFS_MAGIC = 0x5a3c69f0
ADFS_SUPER_MAGIC = 0xadf5
AFFS_SUPER_MAGIC = 0xadff
AFS_FS_MAGIC = 0x6b414653
AFS_SUPER_MAGIC = 0x5346414f
AF_ALG = 0x26
AF_APPLETALK = 0x5
AF_ASH = 0x12
AF_ATMPVC = 0x8
AF_ATMSVC = 0x14
AF_AX25 = 0x3
AF_BLUETOOTH = 0x1f
AF_BRIDGE = 0x7
AF_CAIF = 0x25
AF_CAN = 0x1d
AF_DECnet = 0xc
AF_ECONET = 0x13
AF_FILE = 0x1
AF_IB = 0x1b
AF_IEEE802154 = 0x24
AF_INET = 0x2
AF_INET6 = 0xa
AF_IPX = 0x4
AF_IRDA = 0x17
AF_ISDN = 0x22
AF_IUCV = 0x20
AF_KCM = 0x29
AF_KEY = 0xf
AF_LLC = 0x1a
AF_LOCAL = 0x1
AF_MAX = 0x2d
AF_MPLS = 0x1c
AF_NETBEUI = 0xd
AF_NETLINK = 0x10
AF_NETROM = 0x6
AF_NFC = 0x27
AF_PACKET = 0x11
AF_PHONET = 0x23
AF_PPPOX = 0x18
AF_QIPCRTR = 0x2a
AF_RDS = 0x15
AF_ROSE = 0xb
AF_ROUTE = 0x10
AF_RXRPC = 0x21
AF_SECURITY = 0xe
AF_SMC = 0x2b
AF_SNA = 0x16
AF_TIPC = 0x1e
AF_UNIX = 0x1
AF_UNSPEC = 0x0
AF_VSOCK = 0x28
AF_WANPIPE = 0x19
AF_X25 = 0x9
AF_XDP = 0x2c
ALG_OP_DECRYPT = 0x0
ALG_OP_ENCRYPT = 0x1
ALG_SET_AEAD_ASSOCLEN = 0x4
ALG_SET_AEAD_AUTHSIZE = 0x5
ALG_SET_IV = 0x2
ALG_SET_KEY = 0x1
ALG_SET_OP = 0x3
ANON_INODE_FS_MAGIC = 0x9041934
ARPHRD_6LOWPAN = 0x339
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CAIF = 0x336
ARPHRD_CAN = 0x118
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_MONITOR = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IP6GRE = 0x337
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETLINK = 0x338
ARPHRD_NETROM = 0x0
ARPHRD_NONE = 0xfffe
ARPHRD_PHONET = 0x334
ARPHRD_PHONET_PIPE = 0x335
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_RAWIP = 0x207
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_VSOCKMON = 0x33a
ARPHRD_X25 = 0x10f
AUTOFS_SUPER_MAGIC = 0x187
B0 = 0x0
B1000000 = 0x17
B110 = 0x3
B115200 = 0x11
B1152000 = 0x18
B1200 = 0x9
B134 = 0x4
B150 = 0x5
B1500000 = 0x19
B1800 = 0xa
B19200 = 0xe
B200 = 0x6
B2000000 = 0x1a
B230400 = 0x12
B2400 = 0xb
B2500000 = 0x1b
B300 = 0x7
B3000000 = 0x1c
B3500000 = 0x1d
B38400 = 0xf
B4000000 = 0x1e
B460800 = 0x13
B4800 = 0xc
B50 = 0x1
B500000 = 0x14
B57600 = 0x10
B576000 = 0x15
B600 = 0x8
B75 = 0x2
B921600 = 0x16
B9600 = 0xd
BALLOON_KVM_MAGIC = 0x13661366
BDEVFS_MAGIC = 0x62646576
BINDERFS_SUPER_MAGIC = 0x6c6f6f70
BINFMTFS_MAGIC = 0x42494e4d
BLKBSZGET = 0x40081270
BLKBSZSET = 0x80081271
BLKFLSBUF = 0x20001261
BLKFRAGET = 0x20001265
BLKFRASET = 0x20001264
BLKGETSIZE = 0x20001260
BLKGETSIZE64 = 0x40081272
BLKPBSZGET = 0x2000127b
BLKRAGET = 0x20001263
BLKRASET = 0x20001262
BLKROGET = 0x2000125e
BLKROSET = 0x2000125d
BLKRRPART = 0x2000125f
BLKSECTGET = 0x20001267
BLKSECTSET = 0x20001266
BLKSSZGET = 0x20001268
BOTHER = 0x1f
BPF_A = 0x10
BPF_ABS = 0x20
BPF_ADD = 0x0
BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff
BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38
BPF_ALU = 0x4
BPF_ALU64 = 0x7
BPF_AND = 0x50
BPF_ANY = 0x0
BPF_ARSH = 0xc0
BPF_B = 0x10
BPF_BUILD_ID_SIZE = 0x14
BPF_CALL = 0x80
BPF_DEVCG_ACC_MKNOD = 0x1
BPF_DEVCG_ACC_READ = 0x2
BPF_DEVCG_ACC_WRITE = 0x4
BPF_DEVCG_DEV_BLOCK = 0x1
BPF_DEVCG_DEV_CHAR = 0x2
BPF_DIV = 0x30
BPF_DW = 0x18
BPF_END = 0xd0
BPF_EXIST = 0x2
BPF_EXIT = 0x90
BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1
BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4
BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2
BPF_FROM_BE = 0x8
BPF_FROM_LE = 0x0
BPF_FS_MAGIC = 0xcafe4a11
BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = 0x2
BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = 0x4
BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8
BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10
BPF_F_ADJ_ROOM_FIXED_GSO = 0x1
BPF_F_ALLOW_MULTI = 0x2
BPF_F_ALLOW_OVERRIDE = 0x1
BPF_F_ANY_ALIGNMENT = 0x2
BPF_F_CLONE = 0x200
BPF_F_CTXLEN_MASK = 0xfffff00000000
BPF_F_CURRENT_CPU = 0xffffffff
BPF_F_CURRENT_NETNS = -0x1
BPF_F_DONT_FRAGMENT = 0x4
BPF_F_FAST_STACK_CMP = 0x200
BPF_F_HDR_FIELD_MASK = 0xf
BPF_F_INDEX_MASK = 0xffffffff
BPF_F_INGRESS = 0x1
BPF_F_INVALIDATE_HASH = 0x2
BPF_F_LOCK = 0x4
BPF_F_MARK_ENFORCE = 0x40
BPF_F_MARK_MANGLED_0 = 0x20
BPF_F_MMAPABLE = 0x400
BPF_F_NO_COMMON_LRU = 0x2
BPF_F_NO_PREALLOC = 0x1
BPF_F_NUMA_NODE = 0x4
BPF_F_PSEUDO_HDR = 0x10
BPF_F_QUERY_EFFECTIVE = 0x1
BPF_F_RDONLY = 0x8
BPF_F_RDONLY_PROG = 0x80
BPF_F_RECOMPUTE_CSUM = 0x1
BPF_F_REUSE_STACKID = 0x400
BPF_F_SEQ_NUMBER = 0x8
BPF_F_SKIP_FIELD_MASK = 0xff
BPF_F_STACK_BUILD_ID = 0x20
BPF_F_STRICT_ALIGNMENT = 0x1
BPF_F_SYSCTL_BASE_NAME = 0x1
BPF_F_TEST_RND_HI32 = 0x4
BPF_F_TEST_STATE_FREQ = 0x8
BPF_F_TUNINFO_IPV6 = 0x1
BPF_F_USER_BUILD_ID = 0x800
BPF_F_USER_STACK = 0x100
BPF_F_WRONLY = 0x10
BPF_F_WRONLY_PROG = 0x100
BPF_F_ZERO_CSUM_TX = 0x2
BPF_F_ZERO_SEED = 0x40
BPF_H = 0x8
BPF_IMM = 0x0
BPF_IND = 0x40
BPF_JA = 0x0
BPF_JEQ = 0x10
BPF_JGE = 0x30
BPF_JGT = 0x20
BPF_JLE = 0xb0
BPF_JLT = 0xa0
BPF_JMP = 0x5
BPF_JMP32 = 0x6
BPF_JNE = 0x50
BPF_JSET = 0x40
BPF_JSGE = 0x70
BPF_JSGT = 0x60
BPF_JSLE = 0xd0
BPF_JSLT = 0xc0
BPF_K = 0x0
BPF_LD = 0x0
BPF_LDX = 0x1
BPF_LEN = 0x80
BPF_LL_OFF = -0x200000
BPF_LSH = 0x60
BPF_MAJOR_VERSION = 0x1
BPF_MAXINSNS = 0x1000
BPF_MEM = 0x60
BPF_MEMWORDS = 0x10
BPF_MINOR_VERSION = 0x1
BPF_MISC = 0x7
BPF_MOD = 0x90
BPF_MOV = 0xb0
BPF_MSH = 0xa0
BPF_MUL = 0x20
BPF_NEG = 0x80
BPF_NET_OFF = -0x100000
BPF_NOEXIST = 0x1
BPF_OBJ_NAME_LEN = 0x10
BPF_OR = 0x40
BPF_PSEUDO_CALL = 0x1
BPF_PSEUDO_MAP_FD = 0x1
BPF_PSEUDO_MAP_VALUE = 0x2
BPF_RET = 0x6
BPF_RSH = 0x70
BPF_SK_STORAGE_GET_F_CREATE = 0x1
BPF_SOCK_OPS_ALL_CB_FLAGS = 0xf
BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2
BPF_SOCK_OPS_RTO_CB_FLAG = 0x1
BPF_SOCK_OPS_RTT_CB_FLAG = 0x8
BPF_SOCK_OPS_STATE_CB_FLAG = 0x4
BPF_ST = 0x2
BPF_STX = 0x3
BPF_SUB = 0x10
BPF_TAG_SIZE = 0x8
BPF_TAX = 0x0
BPF_TO_BE = 0x8
BPF_TO_LE = 0x0
BPF_TXA = 0x80
BPF_W = 0x0
BPF_X = 0x8
BPF_XADD = 0xc0
BPF_XOR = 0xa0
BRKINT = 0x2
BS0 = 0x0
BS1 = 0x8000
BSDLY = 0x8000
BTRFS_SUPER_MAGIC = 0x9123683e
BTRFS_TEST_MAGIC = 0x73727279
CAN_BCM = 0x2
CAN_EFF_FLAG = 0x80000000
CAN_EFF_ID_BITS = 0x1d
CAN_EFF_MASK = 0x1fffffff
CAN_ERR_FLAG = 0x20000000
CAN_ERR_MASK = 0x1fffffff
CAN_INV_FILTER = 0x20000000
CAN_ISOTP = 0x6
CAN_J1939 = 0x7
CAN_MAX_DLC = 0x8
CAN_MAX_DLEN = 0x8
CAN_MCNET = 0x5
CAN_MTU = 0x10
CAN_NPROTO = 0x8
CAN_RAW = 0x1
CAN_RAW_FILTER_MAX = 0x200
CAN_RTR_FLAG = 0x40000000
CAN_SFF_ID_BITS = 0xb
CAN_SFF_MASK = 0x7ff
CAN_TP16 = 0x3
CAN_TP20 = 0x4
CAP_AUDIT_CONTROL = 0x1e
CAP_AUDIT_READ = 0x25
CAP_AUDIT_WRITE = 0x1d
CAP_BLOCK_SUSPEND = 0x24
CAP_CHOWN = 0x0
CAP_DAC_OVERRIDE = 0x1
CAP_DAC_READ_SEARCH = 0x2
CAP_FOWNER = 0x3
CAP_FSETID = 0x4
CAP_IPC_LOCK = 0xe
CAP_IPC_OWNER = 0xf
CAP_KILL = 0x5
CAP_LAST_CAP = 0x25
CAP_LEASE = 0x1c
CAP_LINUX_IMMUTABLE = 0x9
CAP_MAC_ADMIN = 0x21
CAP_MAC_OVERRIDE = 0x20
CAP_MKNOD = 0x1b
CAP_NET_ADMIN = 0xc
CAP_NET_BIND_SERVICE = 0xa
CAP_NET_BROADCAST = 0xb
CAP_NET_RAW = 0xd
CAP_SETFCAP = 0x1f
CAP_SETGID = 0x6
CAP_SETPCAP = 0x8
CAP_SETUID = 0x7
CAP_SYSLOG = 0x22
CAP_SYS_ADMIN = 0x15
CAP_SYS_BOOT = 0x16
CAP_SYS_CHROOT = 0x12
CAP_SYS_MODULE = 0x10
CAP_SYS_NICE = 0x17
CAP_SYS_PACCT = 0x14
CAP_SYS_PTRACE = 0x13
CAP_SYS_RAWIO = 0x11
CAP_SYS_RESOURCE = 0x18
CAP_SYS_TIME = 0x19
CAP_SYS_TTY_CONFIG = 0x1a
CAP_WAKE_ALARM = 0x23
CBAUD = 0xff
CBAUDEX = 0x0
CFLUSH = 0xf
CGROUP2_SUPER_MAGIC = 0x63677270
CGROUP_SUPER_MAGIC = 0x27e0eb
CIBAUD = 0xff0000
CLOCAL = 0x8000
CLOCK_BOOTTIME = 0x7
CLOCK_BOOTTIME_ALARM = 0x9
CLOCK_DEFAULT = 0x0
CLOCK_EXT = 0x1
CLOCK_INT = 0x2
CLOCK_MONOTONIC = 0x1
CLOCK_MONOTONIC_COARSE = 0x6
CLOCK_MONOTONIC_RAW = 0x4
CLOCK_PROCESS_CPUTIME_ID = 0x2
CLOCK_REALTIME = 0x0
CLOCK_REALTIME_ALARM = 0x8
CLOCK_REALTIME_COARSE = 0x5
CLOCK_TAI = 0xb
CLOCK_THREAD_CPUTIME_ID = 0x3
CLOCK_TXFROMRX = 0x4
CLOCK_TXINT = 0x3
CLONE_ARGS_SIZE_VER0 = 0x40
CLONE_ARGS_SIZE_VER1 = 0x50
CLONE_CHILD_CLEARTID = 0x200000
CLONE_CHILD_SETTID = 0x1000000
CLONE_CLEAR_SIGHAND = 0x100000000
CLONE_DETACHED = 0x400000
CLONE_FILES = 0x400
CLONE_FS = 0x200
CLONE_IO = 0x80000000
CLONE_NEWCGROUP = 0x2000000
CLONE_NEWIPC = 0x8000000
CLONE_NEWNET = 0x40000000
CLONE_NEWNS = 0x20000
CLONE_NEWPID = 0x20000000
CLONE_NEWUSER = 0x10000000
CLONE_NEWUTS = 0x4000000
CLONE_PARENT = 0x8000
CLONE_PARENT_SETTID = 0x100000
CLONE_PIDFD = 0x1000
CLONE_PTRACE = 0x2000
CLONE_SETTLS = 0x80000
CLONE_SIGHAND = 0x800
CLONE_SYSVSEM = 0x40000
CLONE_THREAD = 0x10000
CLONE_UNTRACED = 0x800000
CLONE_VFORK = 0x4000
CLONE_VM = 0x100
CMSPAR = 0x40000000
CODA_SUPER_MAGIC = 0x73757245
CR0 = 0x0
CR1 = 0x1000
CR2 = 0x2000
CR3 = 0x3000
CRAMFS_MAGIC = 0x28cd3d45
CRDLY = 0x3000
CREAD = 0x800
CRTSCTS = 0x80000000
CRYPTO_MAX_NAME = 0x40
CRYPTO_MSG_MAX = 0x15
CRYPTO_NR_MSGTYPES = 0x6
CRYPTO_REPORT_MAXSIZE = 0x160
CS5 = 0x0
CS6 = 0x100
CS7 = 0x200
CS8 = 0x300
CSIGNAL = 0xff
CSIZE = 0x300
CSTART = 0x11
CSTATUS = 0x0
CSTOP = 0x13
CSTOPB = 0x400
CSUSP = 0x1a
DAXFS_MAGIC = 0x64646178
DEBUGFS_MAGIC = 0x64626720
DEVLINK_CMD_ESWITCH_MODE_GET = 0x1d
DEVLINK_CMD_ESWITCH_MODE_SET = 0x1e
DEVLINK_GENL_MCGRP_CONFIG_NAME = "config"
DEVLINK_GENL_NAME = "devlink"
DEVLINK_GENL_VERSION = 0x1
DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 0x14
DEVPTS_SUPER_MAGIC = 0x1cd1
DMA_BUF_MAGIC = 0x444d4142
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
DT_FIFO = 0x1
DT_LNK = 0xa
DT_REG = 0x8
DT_SOCK = 0xc
DT_UNKNOWN = 0x0
DT_WHT = 0xe
ECHO = 0x8
ECHOCTL = 0x40
ECHOE = 0x2
ECHOK = 0x4
ECHOKE = 0x1
ECHONL = 0x10
ECHOPRT = 0x20
ECRYPTFS_SUPER_MAGIC = 0xf15f
EFD_CLOEXEC = 0x80000
EFD_NONBLOCK = 0x800
EFD_SEMAPHORE = 0x1
EFIVARFS_MAGIC = 0xde5e81e4
EFS_SUPER_MAGIC = 0x414a53
ENCODING_DEFAULT = 0x0
ENCODING_FM_MARK = 0x3
ENCODING_FM_SPACE = 0x4
ENCODING_MANCHESTER = 0x5
ENCODING_NRZ = 0x1
ENCODING_NRZI = 0x2
EPOLLERR = 0x8
EPOLLET = 0x80000000
EPOLLEXCLUSIVE = 0x10000000
EPOLLHUP = 0x10
EPOLLIN = 0x1
EPOLLMSG = 0x400
EPOLLONESHOT = 0x40000000
EPOLLOUT = 0x4
EPOLLPRI = 0x2
EPOLLRDBAND = 0x80
EPOLLRDHUP = 0x2000
EPOLLRDNORM = 0x40
EPOLLWAKEUP = 0x20000000
EPOLLWRBAND = 0x200
EPOLLWRNORM = 0x100
EPOLL_CLOEXEC = 0x80000
EPOLL_CTL_ADD = 0x1
EPOLL_CTL_DEL = 0x2
EPOLL_CTL_MOD = 0x3
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
ETH_P_1588 = 0x88f7
ETH_P_8021AD = 0x88a8
ETH_P_8021AH = 0x88e7
ETH_P_8021Q = 0x8100
ETH_P_80221 = 0x8917
ETH_P_802_2 = 0x4
ETH_P_802_3 = 0x1
ETH_P_802_3_MIN = 0x600
ETH_P_802_EX1 = 0x88b5
ETH_P_AARP = 0x80f3
ETH_P_AF_IUCV = 0xfbfb
ETH_P_ALL = 0x3
ETH_P_AOE = 0x88a2
ETH_P_ARCNET = 0x1a
ETH_P_ARP = 0x806
ETH_P_ATALK = 0x809b
ETH_P_ATMFATE = 0x8884
ETH_P_ATMMPOA = 0x884c
ETH_P_AX25 = 0x2
ETH_P_BATMAN = 0x4305
ETH_P_BPQ = 0x8ff
ETH_P_CAIF = 0xf7
ETH_P_CAN = 0xc
ETH_P_CANFD = 0xd
ETH_P_CONTROL = 0x16
ETH_P_CUST = 0x6006
ETH_P_DDCMP = 0x6
ETH_P_DEC = 0x6000
ETH_P_DIAG = 0x6005
ETH_P_DNA_DL = 0x6001
ETH_P_DNA_RC = 0x6002
ETH_P_DNA_RT = 0x6003
ETH_P_DSA = 0x1b
ETH_P_DSA_8021Q = 0xdadb
ETH_P_ECONET = 0x18
ETH_P_EDSA = 0xdada
ETH_P_ERSPAN = 0x88be
ETH_P_ERSPAN2 = 0x22eb
ETH_P_FCOE = 0x8906
ETH_P_FIP = 0x8914
ETH_P_HDLC = 0x19
ETH_P_HSR = 0x892f
ETH_P_IBOE = 0x8915
ETH_P_IEEE802154 = 0xf6
ETH_P_IEEEPUP = 0xa00
ETH_P_IEEEPUPAT = 0xa01
ETH_P_IFE = 0xed3e
ETH_P_IP = 0x800
ETH_P_IPV6 = 0x86dd
ETH_P_IPX = 0x8137
ETH_P_IRDA = 0x17
ETH_P_LAT = 0x6004
ETH_P_LINK_CTL = 0x886c
ETH_P_LLDP = 0x88cc
ETH_P_LOCALTALK = 0x9
ETH_P_LOOP = 0x60
ETH_P_LOOPBACK = 0x9000
ETH_P_MACSEC = 0x88e5
ETH_P_MAP = 0xf9
ETH_P_MOBITEX = 0x15
ETH_P_MPLS_MC = 0x8848
ETH_P_MPLS_UC = 0x8847
ETH_P_MVRP = 0x88f5
ETH_P_NCSI = 0x88f8
ETH_P_NSH = 0x894f
ETH_P_PAE = 0x888e
ETH_P_PAUSE = 0x8808
ETH_P_PHONET = 0xf5
ETH_P_PPPTALK = 0x10
ETH_P_PPP_DISC = 0x8863
ETH_P_PPP_MP = 0x8
ETH_P_PPP_SES = 0x8864
ETH_P_PREAUTH = 0x88c7
ETH_P_PRP = 0x88fb
ETH_P_PUP = 0x200
ETH_P_PUPAT = 0x201
ETH_P_QINQ1 = 0x9100
ETH_P_QINQ2 = 0x9200
ETH_P_QINQ3 = 0x9300
ETH_P_RARP = 0x8035
ETH_P_SCA = 0x6007
ETH_P_SLOW = 0x8809
ETH_P_SNAP = 0x5
ETH_P_TDLS = 0x890d
ETH_P_TEB = 0x6558
ETH_P_TIPC = 0x88ca
ETH_P_TRAILER = 0x1c
ETH_P_TR_802_2 = 0x11
ETH_P_TSN = 0x22f0
ETH_P_WAN_PPP = 0x7
ETH_P_WCCP = 0x883e
ETH_P_X25 = 0x805
ETH_P_XDSA = 0xf8
EXABYTE_ENABLE_NEST = 0xf0
EXT2_SUPER_MAGIC = 0xef53
EXT3_SUPER_MAGIC = 0xef53
EXT4_SUPER_MAGIC = 0xef53
EXTA = 0xe
EXTB = 0xf
EXTPROC = 0x10000000
F2FS_SUPER_MAGIC = 0xf2f52010
FALLOC_FL_COLLAPSE_RANGE = 0x8
FALLOC_FL_INSERT_RANGE = 0x20
FALLOC_FL_KEEP_SIZE = 0x1
FALLOC_FL_NO_HIDE_STALE = 0x4
FALLOC_FL_PUNCH_HOLE = 0x2
FALLOC_FL_UNSHARE_RANGE = 0x40
FALLOC_FL_ZERO_RANGE = 0x10
FANOTIFY_METADATA_VERSION = 0x3
FAN_ACCESS = 0x1
FAN_ACCESS_PERM = 0x20000
FAN_ALLOW = 0x1
FAN_ALL_CLASS_BITS = 0xc
FAN_ALL_EVENTS = 0x3b
FAN_ALL_INIT_FLAGS = 0x3f
FAN_ALL_MARK_FLAGS = 0xff
FAN_ALL_OUTGOING_EVENTS = 0x3403b
FAN_ALL_PERM_EVENTS = 0x30000
FAN_ATTRIB = 0x4
FAN_AUDIT = 0x10
FAN_CLASS_CONTENT = 0x4
FAN_CLASS_NOTIF = 0x0
FAN_CLASS_PRE_CONTENT = 0x8
FAN_CLOEXEC = 0x1
FAN_CLOSE = 0x18
FAN_CLOSE_NOWRITE = 0x10
FAN_CLOSE_WRITE = 0x8
FAN_CREATE = 0x100
FAN_DELETE = 0x200
FAN_DELETE_SELF = 0x400
FAN_DENY = 0x2
FAN_ENABLE_AUDIT = 0x40
FAN_EVENT_INFO_TYPE_FID = 0x1
FAN_EVENT_METADATA_LEN = 0x18
FAN_EVENT_ON_CHILD = 0x8000000
FAN_MARK_ADD = 0x1
FAN_MARK_DONT_FOLLOW = 0x4
FAN_MARK_FILESYSTEM = 0x100
FAN_MARK_FLUSH = 0x80
FAN_MARK_IGNORED_MASK = 0x20
FAN_MARK_IGNORED_SURV_MODIFY = 0x40
FAN_MARK_INODE = 0x0
FAN_MARK_MOUNT = 0x10
FAN_MARK_ONLYDIR = 0x8
FAN_MARK_REMOVE = 0x2
FAN_MODIFY = 0x2
FAN_MOVE = 0xc0
FAN_MOVED_FROM = 0x40
FAN_MOVED_TO = 0x80
FAN_MOVE_SELF = 0x800
FAN_NOFD = -0x1
FAN_NONBLOCK = 0x2
FAN_ONDIR = 0x40000000
FAN_OPEN = 0x20
FAN_OPEN_EXEC = 0x1000
FAN_OPEN_EXEC_PERM = 0x40000
FAN_OPEN_PERM = 0x10000
FAN_Q_OVERFLOW = 0x4000
FAN_REPORT_FID = 0x200
FAN_REPORT_TID = 0x100
FAN_UNLIMITED_MARKS = 0x20
FAN_UNLIMITED_QUEUE = 0x10
FD_CLOEXEC = 0x1
FD_SETSIZE = 0x400
FF0 = 0x0
FF1 = 0x4000
FFDLY = 0x4000
FLUSHO = 0x800000
FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8
FSCRYPT_KEY_DESC_PREFIX = "fscrypt:"
FSCRYPT_KEY_DESC_PREFIX_SIZE = 0x8
FSCRYPT_KEY_IDENTIFIER_SIZE = 0x10
FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY = 0x1
FSCRYPT_KEY_REMOVAL_STATUS_FLAG_OTHER_USERS = 0x2
FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR = 0x1
FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER = 0x2
FSCRYPT_KEY_STATUS_ABSENT = 0x1
FSCRYPT_KEY_STATUS_FLAG_ADDED_BY_SELF = 0x1
FSCRYPT_KEY_STATUS_INCOMPLETELY_REMOVED = 0x3
FSCRYPT_KEY_STATUS_PRESENT = 0x2
FSCRYPT_MAX_KEY_SIZE = 0x40
FSCRYPT_MODE_ADIANTUM = 0x9
FSCRYPT_MODE_AES_128_CBC = 0x5
FSCRYPT_MODE_AES_128_CTS = 0x6
FSCRYPT_MODE_AES_256_CTS = 0x4
FSCRYPT_MODE_AES_256_XTS = 0x1
FSCRYPT_POLICY_FLAGS_PAD_16 = 0x2
FSCRYPT_POLICY_FLAGS_PAD_32 = 0x3
FSCRYPT_POLICY_FLAGS_PAD_4 = 0x0
FSCRYPT_POLICY_FLAGS_PAD_8 = 0x1
FSCRYPT_POLICY_FLAGS_PAD_MASK = 0x3
FSCRYPT_POLICY_FLAGS_VALID = 0xf
FSCRYPT_POLICY_FLAG_DIRECT_KEY = 0x4
FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 = 0x8
FSCRYPT_POLICY_V1 = 0x0
FSCRYPT_POLICY_V2 = 0x2
FS_ENCRYPTION_MODE_ADIANTUM = 0x9
FS_ENCRYPTION_MODE_AES_128_CBC = 0x5
FS_ENCRYPTION_MODE_AES_128_CTS = 0x6
FS_ENCRYPTION_MODE_AES_256_CBC = 0x3
FS_ENCRYPTION_MODE_AES_256_CTS = 0x4
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
FS_ENCRYPTION_MODE_INVALID = 0x0
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
FS_IOC_ADD_ENCRYPTION_KEY = 0xc0506617
FS_IOC_GET_ENCRYPTION_KEY_STATUS = 0xc080661a
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
FS_IOC_GET_ENCRYPTION_POLICY_EX = 0xc0096616
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
FS_IOC_REMOVE_ENCRYPTION_KEY = 0xc0406618
FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS = 0xc0406619
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
FS_KEY_DESCRIPTOR_SIZE = 0x8
FS_KEY_DESC_PREFIX = "fscrypt:"
FS_KEY_DESC_PREFIX_SIZE = 0x8
FS_MAX_KEY_SIZE = 0x40
FS_POLICY_FLAGS_PAD_16 = 0x2
FS_POLICY_FLAGS_PAD_32 = 0x3
FS_POLICY_FLAGS_PAD_4 = 0x0
FS_POLICY_FLAGS_PAD_8 = 0x1
FS_POLICY_FLAGS_PAD_MASK = 0x3
FS_POLICY_FLAGS_VALID = 0xf
FUTEXFS_SUPER_MAGIC = 0xbad1dea
F_ADD_SEALS = 0x409
F_DUPFD = 0x0
F_DUPFD_CLOEXEC = 0x406
F_EXLCK = 0x4
F_GETFD = 0x1
F_GETFL = 0x3
F_GETLEASE = 0x401
F_GETLK = 0x5
F_GETLK64 = 0xc
F_GETOWN = 0x9
F_GETOWN_EX = 0x10
F_GETPIPE_SZ = 0x408
F_GETSIG = 0xb
F_GET_FILE_RW_HINT = 0x40d
F_GET_RW_HINT = 0x40b
F_GET_SEALS = 0x40a
F_LOCK = 0x1
F_NOTIFY = 0x402
F_OFD_GETLK = 0x24
F_OFD_SETLK = 0x25
F_OFD_SETLKW = 0x26
F_OK = 0x0
F_RDLCK = 0x0
F_SEAL_FUTURE_WRITE = 0x10
F_SEAL_GROW = 0x4
F_SEAL_SEAL = 0x1
F_SEAL_SHRINK = 0x2
F_SEAL_WRITE = 0x8
F_SETFD = 0x2
F_SETFL = 0x4
F_SETLEASE = 0x400
F_SETLK = 0x6
F_SETLK64 = 0xd
F_SETLKW = 0x7
F_SETLKW64 = 0xe
F_SETOWN = 0x8
F_SETOWN_EX = 0xf
F_SETPIPE_SZ = 0x407
F_SETSIG = 0xa
F_SET_FILE_RW_HINT = 0x40e
F_SET_RW_HINT = 0x40c
F_SHLCK = 0x8
F_TEST = 0x3
F_TLOCK = 0x2
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GENL_ADMIN_PERM = 0x1
GENL_CMD_CAP_DO = 0x2
GENL_CMD_CAP_DUMP = 0x4
GENL_CMD_CAP_HASPOL = 0x8
GENL_HDRLEN = 0x4
GENL_ID_CTRL = 0x10
GENL_ID_PMCRAID = 0x12
GENL_ID_VFS_DQUOT = 0x11
GENL_MAX_ID = 0x3ff
GENL_MIN_ID = 0x10
GENL_NAMSIZ = 0x10
GENL_START_ALLOC = 0x13
GENL_UNS_ADMIN_PERM = 0x10
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HDIO_DRIVE_CMD = 0x31f
HDIO_DRIVE_CMD_AEB = 0x31e
HDIO_DRIVE_CMD_HDR_SIZE = 0x4
HDIO_DRIVE_HOB_HDR_SIZE = 0x8
HDIO_DRIVE_RESET = 0x31c
HDIO_DRIVE_TASK = 0x31e
HDIO_DRIVE_TASKFILE = 0x31d
HDIO_DRIVE_TASK_HDR_SIZE = 0x8
HDIO_GETGEO = 0x301
HDIO_GET_32BIT = 0x309
HDIO_GET_ACOUSTIC = 0x30f
HDIO_GET_ADDRESS = 0x310
HDIO_GET_BUSSTATE = 0x31a
HDIO_GET_DMA = 0x30b
HDIO_GET_IDENTITY = 0x30d
HDIO_GET_KEEPSETTINGS = 0x308
HDIO_GET_MULTCOUNT = 0x304
HDIO_GET_NICE = 0x30c
HDIO_GET_NOWERR = 0x30a
HDIO_GET_QDMA = 0x305
HDIO_GET_UNMASKINTR = 0x302
HDIO_GET_WCACHE = 0x30e
HDIO_OBSOLETE_IDENTITY = 0x307
HDIO_SCAN_HWIF = 0x328
HDIO_SET_32BIT = 0x324
HDIO_SET_ACOUSTIC = 0x32c
HDIO_SET_ADDRESS = 0x32f
HDIO_SET_BUSSTATE = 0x32d
HDIO_SET_DMA = 0x326
HDIO_SET_KEEPSETTINGS = 0x323
HDIO_SET_MULTCOUNT = 0x321
HDIO_SET_NICE = 0x329
HDIO_SET_NOWERR = 0x325
HDIO_SET_PIO_MODE = 0x327
HDIO_SET_QDMA = 0x32e
HDIO_SET_UNMASKINTR = 0x322
HDIO_SET_WCACHE = 0x32b
HDIO_SET_XFER = 0x306
HDIO_TRISTATE_HWIF = 0x31b
HDIO_UNREGISTER_HWIF = 0x32a
HOSTFS_SUPER_MAGIC = 0xc0ffee
HPFS_SUPER_MAGIC = 0xf995e849
HUGETLBFS_MAGIC = 0x958458f6
HUPCL = 0x4000
IBSHIFT = 0x10
ICANON = 0x100
ICMPV6_FILTER = 0x1
ICRNL = 0x100
IEXTEN = 0x400
IFA_F_DADFAILED = 0x8
IFA_F_DEPRECATED = 0x20
IFA_F_HOMEADDRESS = 0x10
IFA_F_MANAGETEMPADDR = 0x100
IFA_F_MCAUTOJOIN = 0x400
IFA_F_NODAD = 0x2
IFA_F_NOPREFIXROUTE = 0x200
IFA_F_OPTIMISTIC = 0x4
IFA_F_PERMANENT = 0x80
IFA_F_SECONDARY = 0x1
IFA_F_STABLE_PRIVACY = 0x800
IFA_F_TEMPORARY = 0x1
IFA_F_TENTATIVE = 0x40
IFA_MAX = 0xa
IFF_ALLMULTI = 0x200
IFF_ATTACH_QUEUE = 0x200
IFF_AUTOMEDIA = 0x4000
IFF_BROADCAST = 0x2
IFF_DEBUG = 0x4
IFF_DETACH_QUEUE = 0x400
IFF_DORMANT = 0x20000
IFF_DYNAMIC = 0x8000
IFF_ECHO = 0x40000
IFF_LOOPBACK = 0x8
IFF_LOWER_UP = 0x10000
IFF_MASTER = 0x400
IFF_MULTICAST = 0x1000
IFF_MULTI_QUEUE = 0x100
IFF_NAPI = 0x10
IFF_NAPI_FRAGS = 0x20
IFF_NOARP = 0x80
IFF_NOFILTER = 0x1000
IFF_NOTRAILERS = 0x20
IFF_NO_PI = 0x1000
IFF_ONE_QUEUE = 0x2000
IFF_PERSIST = 0x800
IFF_POINTOPOINT = 0x10
IFF_PORTSEL = 0x2000
IFF_PROMISC = 0x100
IFF_RUNNING = 0x40
IFF_SLAVE = 0x800
IFF_TAP = 0x2
IFF_TUN = 0x1
IFF_TUN_EXCL = 0x8000
IFF_UP = 0x1
IFF_VNET_HDR = 0x4000
IFF_VOLATILE = 0x70c5a
IFNAMSIZ = 0x10
IGNBRK = 0x1
IGNCR = 0x80
IGNPAR = 0x4
IMAXBEL = 0x2000
INLCR = 0x40
INPCK = 0x10
IN_ACCESS = 0x1
IN_ALL_EVENTS = 0xfff
IN_ATTRIB = 0x4
IN_CLASSA_HOST = 0xffffff
IN_CLASSA_MAX = 0x80
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 0x18
IN_CLASSB_HOST = 0xffff
IN_CLASSB_MAX = 0x10000
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 0x10
IN_CLASSC_HOST = 0xff
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 0x8
IN_CLOEXEC = 0x80000
IN_CLOSE = 0x18
IN_CLOSE_NOWRITE = 0x10
IN_CLOSE_WRITE = 0x8
IN_CREATE = 0x100
IN_DELETE = 0x200
IN_DELETE_SELF = 0x400
IN_DONT_FOLLOW = 0x2000000
IN_EXCL_UNLINK = 0x4000000
IN_IGNORED = 0x8000
IN_ISDIR = 0x40000000
IN_LOOPBACKNET = 0x7f
IN_MASK_ADD = 0x20000000
IN_MASK_CREATE = 0x10000000
IN_MODIFY = 0x2
IN_MOVE = 0xc0
IN_MOVED_FROM = 0x40
IN_MOVED_TO = 0x80
IN_MOVE_SELF = 0x800
IN_NONBLOCK = 0x800
IN_ONESHOT = 0x80000000
IN_ONLYDIR = 0x1000000
IN_OPEN = 0x20
IN_Q_OVERFLOW = 0x4000
IN_UNMOUNT = 0x2000
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
IPPROTO_AH = 0x33
IPPROTO_BEETPH = 0x5e
IPPROTO_COMP = 0x6c
IPPROTO_DCCP = 0x21
IPPROTO_DSTOPTS = 0x3c
IPPROTO_EGP = 0x8
IPPROTO_ENCAP = 0x62
IPPROTO_ESP = 0x32
IPPROTO_FRAGMENT = 0x2c
IPPROTO_GRE = 0x2f
IPPROTO_HOPOPTS = 0x0
IPPROTO_ICMP = 0x1
IPPROTO_ICMPV6 = 0x3a
IPPROTO_IDP = 0x16
IPPROTO_IGMP = 0x2
IPPROTO_IP = 0x0
IPPROTO_IPIP = 0x4
IPPROTO_IPV6 = 0x29
IPPROTO_MH = 0x87
IPPROTO_MPLS = 0x89
IPPROTO_MTP = 0x5c
IPPROTO_NONE = 0x3b
IPPROTO_PIM = 0x67
IPPROTO_PUP = 0xc
IPPROTO_RAW = 0xff
IPPROTO_ROUTING = 0x2b
IPPROTO_RSVP = 0x2e
IPPROTO_SCTP = 0x84
IPPROTO_TCP = 0x6
IPPROTO_TP = 0x1d
IPPROTO_UDP = 0x11
IPPROTO_UDPLITE = 0x88
IPV6_2292DSTOPTS = 0x4
IPV6_2292HOPLIMIT = 0x8
IPV6_2292HOPOPTS = 0x3
IPV6_2292PKTINFO = 0x2
IPV6_2292PKTOPTIONS = 0x6
IPV6_2292RTHDR = 0x5
IPV6_ADDRFORM = 0x1
IPV6_ADDR_PREFERENCES = 0x48
IPV6_ADD_MEMBERSHIP = 0x14
IPV6_AUTHHDR = 0xa
IPV6_AUTOFLOWLABEL = 0x46
IPV6_CHECKSUM = 0x7
IPV6_DONTFRAG = 0x3e
IPV6_DROP_MEMBERSHIP = 0x15
IPV6_DSTOPTS = 0x3b
IPV6_FREEBIND = 0x4e
IPV6_HDRINCL = 0x24
IPV6_HOPLIMIT = 0x34
IPV6_HOPOPTS = 0x36
IPV6_IPSEC_POLICY = 0x22
IPV6_JOIN_ANYCAST = 0x1b
IPV6_JOIN_GROUP = 0x14
IPV6_LEAVE_ANYCAST = 0x1c
IPV6_LEAVE_GROUP = 0x15
IPV6_MINHOPCOUNT = 0x49
IPV6_MTU = 0x18
IPV6_MTU_DISCOVER = 0x17
IPV6_MULTICAST_ALL = 0x1d
IPV6_MULTICAST_HOPS = 0x12
IPV6_MULTICAST_IF = 0x11
IPV6_MULTICAST_LOOP = 0x13
IPV6_NEXTHOP = 0x9
IPV6_ORIGDSTADDR = 0x4a
IPV6_PATHMTU = 0x3d
IPV6_PKTINFO = 0x32
IPV6_PMTUDISC_DO = 0x2
IPV6_PMTUDISC_DONT = 0x0
IPV6_PMTUDISC_INTERFACE = 0x4
IPV6_PMTUDISC_OMIT = 0x5
IPV6_PMTUDISC_PROBE = 0x3
IPV6_PMTUDISC_WANT = 0x1
IPV6_RECVDSTOPTS = 0x3a
IPV6_RECVERR = 0x19
IPV6_RECVFRAGSIZE = 0x4d
IPV6_RECVHOPLIMIT = 0x33
IPV6_RECVHOPOPTS = 0x35
IPV6_RECVORIGDSTADDR = 0x4a
IPV6_RECVPATHMTU = 0x3c
IPV6_RECVPKTINFO = 0x31
IPV6_RECVRTHDR = 0x38
IPV6_RECVTCLASS = 0x42
IPV6_ROUTER_ALERT = 0x16
IPV6_ROUTER_ALERT_ISOLATE = 0x1e
IPV6_RTHDR = 0x39
IPV6_RTHDRDSTOPTS = 0x37
IPV6_RTHDR_LOOSE = 0x0
IPV6_RTHDR_STRICT = 0x1
IPV6_RTHDR_TYPE_0 = 0x0
IPV6_RXDSTOPTS = 0x3b
IPV6_RXHOPOPTS = 0x36
IPV6_TCLASS = 0x43
IPV6_TRANSPARENT = 0x4b
IPV6_UNICAST_HOPS = 0x10
IPV6_UNICAST_IF = 0x4c
IPV6_V6ONLY = 0x1a
IPV6_XFRM_POLICY = 0x23
IP_ADD_MEMBERSHIP = 0x23
IP_ADD_SOURCE_MEMBERSHIP = 0x27
IP_BIND_ADDRESS_NO_PORT = 0x18
IP_BLOCK_SOURCE = 0x26
IP_CHECKSUM = 0x17
IP_DEFAULT_MULTICAST_LOOP = 0x1
IP_DEFAULT_MULTICAST_TTL = 0x1
IP_DF = 0x4000
IP_DROP_MEMBERSHIP = 0x24
IP_DROP_SOURCE_MEMBERSHIP = 0x28
IP_FREEBIND = 0xf
IP_HDRINCL = 0x3
IP_IPSEC_POLICY = 0x10
IP_MAXPACKET = 0xffff
IP_MAX_MEMBERSHIPS = 0x14
IP_MF = 0x2000
IP_MINTTL = 0x15
IP_MSFILTER = 0x29
IP_MSS = 0x240
IP_MTU = 0xe
IP_MTU_DISCOVER = 0xa
IP_MULTICAST_ALL = 0x31
IP_MULTICAST_IF = 0x20
IP_MULTICAST_LOOP = 0x22
IP_MULTICAST_TTL = 0x21
IP_NODEFRAG = 0x16
IP_OFFMASK = 0x1fff
IP_OPTIONS = 0x4
IP_ORIGDSTADDR = 0x14
IP_PASSSEC = 0x12
IP_PKTINFO = 0x8
IP_PKTOPTIONS = 0x9
IP_PMTUDISC = 0xa
IP_PMTUDISC_DO = 0x2
IP_PMTUDISC_DONT = 0x0
IP_PMTUDISC_INTERFACE = 0x4
IP_PMTUDISC_OMIT = 0x5
IP_PMTUDISC_PROBE = 0x3
IP_PMTUDISC_WANT = 0x1
IP_RECVERR = 0xb
IP_RECVFRAGSIZE = 0x19
IP_RECVOPTS = 0x6
IP_RECVORIGDSTADDR = 0x14
IP_RECVRETOPTS = 0x7
IP_RECVTOS = 0xd
IP_RECVTTL = 0xc
IP_RETOPTS = 0x7
IP_RF = 0x8000
IP_ROUTER_ALERT = 0x5
IP_TOS = 0x1
IP_TRANSPARENT = 0x13
IP_TTL = 0x2
IP_UNBLOCK_SOURCE = 0x25
IP_UNICAST_IF = 0x32
IP_XFRM_POLICY = 0x11
ISIG = 0x80
ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20
IUCLC = 0x1000
IUTF8 = 0x4000
IXANY = 0x800
IXOFF = 0x400
IXON = 0x200
JFFS2_SUPER_MAGIC = 0x72b6
KEXEC_ARCH_386 = 0x30000
KEXEC_ARCH_68K = 0x40000
KEXEC_ARCH_AARCH64 = 0xb70000
KEXEC_ARCH_ARM = 0x280000
KEXEC_ARCH_DEFAULT = 0x0
KEXEC_ARCH_IA_64 = 0x320000
KEXEC_ARCH_MASK = 0xffff0000
KEXEC_ARCH_MIPS = 0x80000
KEXEC_ARCH_MIPS_LE = 0xa0000
KEXEC_ARCH_PARISC = 0xf0000
KEXEC_ARCH_PPC = 0x140000
KEXEC_ARCH_PPC64 = 0x150000
KEXEC_ARCH_S390 = 0x160000
KEXEC_ARCH_SH = 0x2a0000
KEXEC_ARCH_X86_64 = 0x3e0000
KEXEC_FILE_NO_INITRAMFS = 0x4
KEXEC_FILE_ON_CRASH = 0x2
KEXEC_FILE_UNLOAD = 0x1
KEXEC_ON_CRASH = 0x1
KEXEC_PRESERVE_CONTEXT = 0x2
KEXEC_SEGMENT_MAX = 0x10
KEYCTL_ASSUME_AUTHORITY = 0x10
KEYCTL_CAPABILITIES = 0x1f
KEYCTL_CAPS0_BIG_KEY = 0x10
KEYCTL_CAPS0_CAPABILITIES = 0x1
KEYCTL_CAPS0_DIFFIE_HELLMAN = 0x4
KEYCTL_CAPS0_INVALIDATE = 0x20
KEYCTL_CAPS0_MOVE = 0x80
KEYCTL_CAPS0_PERSISTENT_KEYRINGS = 0x2
KEYCTL_CAPS0_PUBLIC_KEY = 0x8
KEYCTL_CAPS0_RESTRICT_KEYRING = 0x40
KEYCTL_CAPS1_NS_KEYRING_NAME = 0x1
KEYCTL_CAPS1_NS_KEY_TAG = 0x2
KEYCTL_CHOWN = 0x4
KEYCTL_CLEAR = 0x7
KEYCTL_DESCRIBE = 0x6
KEYCTL_DH_COMPUTE = 0x17
KEYCTL_GET_KEYRING_ID = 0x0
KEYCTL_GET_PERSISTENT = 0x16
KEYCTL_GET_SECURITY = 0x11
KEYCTL_INSTANTIATE = 0xc
KEYCTL_INSTANTIATE_IOV = 0x14
KEYCTL_INVALIDATE = 0x15
KEYCTL_JOIN_SESSION_KEYRING = 0x1
KEYCTL_LINK = 0x8
KEYCTL_MOVE = 0x1e
KEYCTL_MOVE_EXCL = 0x1
KEYCTL_NEGATE = 0xd
KEYCTL_PKEY_DECRYPT = 0x1a
KEYCTL_PKEY_ENCRYPT = 0x19
KEYCTL_PKEY_QUERY = 0x18
KEYCTL_PKEY_SIGN = 0x1b
KEYCTL_PKEY_VERIFY = 0x1c
KEYCTL_READ = 0xb
KEYCTL_REJECT = 0x13
KEYCTL_RESTRICT_KEYRING = 0x1d
KEYCTL_REVOKE = 0x3
KEYCTL_SEARCH = 0xa
KEYCTL_SESSION_TO_PARENT = 0x12
KEYCTL_SETPERM = 0x5
KEYCTL_SET_REQKEY_KEYRING = 0xe
KEYCTL_SET_TIMEOUT = 0xf
KEYCTL_SUPPORTS_DECRYPT = 0x2
KEYCTL_SUPPORTS_ENCRYPT = 0x1
KEYCTL_SUPPORTS_SIGN = 0x4
KEYCTL_SUPPORTS_VERIFY = 0x8
KEYCTL_UNLINK = 0x9
KEYCTL_UPDATE = 0x2
KEY_REQKEY_DEFL_DEFAULT = 0x0
KEY_REQKEY_DEFL_GROUP_KEYRING = 0x6
KEY_REQKEY_DEFL_NO_CHANGE = -0x1
KEY_REQKEY_DEFL_PROCESS_KEYRING = 0x2
KEY_REQKEY_DEFL_REQUESTOR_KEYRING = 0x7
KEY_REQKEY_DEFL_SESSION_KEYRING = 0x3
KEY_REQKEY_DEFL_THREAD_KEYRING = 0x1
KEY_REQKEY_DEFL_USER_KEYRING = 0x4
KEY_REQKEY_DEFL_USER_SESSION_KEYRING = 0x5
KEY_SPEC_GROUP_KEYRING = -0x6
KEY_SPEC_PROCESS_KEYRING = -0x2
KEY_SPEC_REQKEY_AUTH_KEY = -0x7
KEY_SPEC_REQUESTOR_KEYRING = -0x8
KEY_SPEC_SESSION_KEYRING = -0x3
KEY_SPEC_THREAD_KEYRING = -0x1
KEY_SPEC_USER_KEYRING = -0x4
KEY_SPEC_USER_SESSION_KEYRING = -0x5
LINUX_REBOOT_CMD_CAD_OFF = 0x0
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
LINUX_REBOOT_CMD_HALT = 0xcdef0123
LINUX_REBOOT_CMD_KEXEC = 0x45584543
LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
LINUX_REBOOT_CMD_RESTART = 0x1234567
LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
LINUX_REBOOT_MAGIC1 = 0xfee1dead
LINUX_REBOOT_MAGIC2 = 0x28121969
LOCK_EX = 0x2
LOCK_NB = 0x4
LOCK_SH = 0x1
LOCK_UN = 0x8
LOOP_CLR_FD = 0x4c01
LOOP_CTL_ADD = 0x4c80
LOOP_CTL_GET_FREE = 0x4c82
LOOP_CTL_REMOVE = 0x4c81
LOOP_GET_STATUS = 0x4c03
LOOP_GET_STATUS64 = 0x4c05
LOOP_SET_BLOCK_SIZE = 0x4c09
LOOP_SET_CAPACITY = 0x4c07
LOOP_SET_DIRECT_IO = 0x4c08
LOOP_SET_FD = 0x4c00
LOOP_SET_STATUS = 0x4c02
LOOP_SET_STATUS64 = 0x4c04
LO_KEY_SIZE = 0x20
LO_NAME_SIZE = 0x40
MADV_COLD = 0x14
MADV_DODUMP = 0x11
MADV_DOFORK = 0xb
MADV_DONTDUMP = 0x10
MADV_DONTFORK = 0xa
MADV_DONTNEED = 0x4
MADV_FREE = 0x8
MADV_HUGEPAGE = 0xe
MADV_HWPOISON = 0x64
MADV_KEEPONFORK = 0x13
MADV_MERGEABLE = 0xc
MADV_NOHUGEPAGE = 0xf
MADV_NORMAL = 0x0
MADV_PAGEOUT = 0x15
MADV_RANDOM = 0x1
MADV_REMOVE = 0x9
MADV_SEQUENTIAL = 0x2
MADV_UNMERGEABLE = 0xd
MADV_WILLNEED = 0x3
MADV_WIPEONFORK = 0x12
MAP_ANON = 0x20
MAP_ANONYMOUS = 0x20
MAP_DENYWRITE = 0x800
MAP_EXECUTABLE = 0x1000
MAP_FILE = 0x0
MAP_FIXED = 0x10
MAP_FIXED_NOREPLACE = 0x100000
MAP_GROWSDOWN = 0x100
MAP_HUGETLB = 0x40000
MAP_HUGE_MASK = 0x3f
MAP_HUGE_SHIFT = 0x1a
MAP_LOCKED = 0x80
MAP_NONBLOCK = 0x10000
MAP_NORESERVE = 0x40
MAP_POPULATE = 0x8000
MAP_PRIVATE = 0x2
MAP_SHARED = 0x1
MAP_SHARED_VALIDATE = 0x3
MAP_STACK = 0x20000
MAP_SYNC = 0x80000
MAP_TYPE = 0xf
MCAST_BLOCK_SOURCE = 0x2b
MCAST_EXCLUDE = 0x0
MCAST_INCLUDE = 0x1
MCAST_JOIN_GROUP = 0x2a
MCAST_JOIN_SOURCE_GROUP = 0x2e
MCAST_LEAVE_GROUP = 0x2d
MCAST_LEAVE_SOURCE_GROUP = 0x2f
MCAST_MSFILTER = 0x30
MCAST_UNBLOCK_SOURCE = 0x2c
MCL_CURRENT = 0x2000
MCL_FUTURE = 0x4000
MCL_ONFAULT = 0x8000
MFD_ALLOW_SEALING = 0x2
MFD_CLOEXEC = 0x1
MFD_HUGETLB = 0x4
MFD_HUGE_16GB = -0x78000000
MFD_HUGE_16MB = 0x60000000
MFD_HUGE_1GB = 0x78000000
MFD_HUGE_1MB = 0x50000000
MFD_HUGE_256MB = 0x70000000
MFD_HUGE_2GB = 0x7c000000
MFD_HUGE_2MB = 0x54000000
MFD_HUGE_32MB = 0x64000000
MFD_HUGE_512KB = 0x4c000000
MFD_HUGE_512MB = 0x74000000
MFD_HUGE_64KB = 0x40000000
MFD_HUGE_8MB = 0x5c000000
MFD_HUGE_MASK = 0x3f
MFD_HUGE_SHIFT = 0x1a
MINIX2_SUPER_MAGIC = 0x2468
MINIX2_SUPER_MAGIC2 = 0x2478
MINIX3_SUPER_MAGIC = 0x4d5a
MINIX_SUPER_MAGIC = 0x137f
MINIX_SUPER_MAGIC2 = 0x138f
MNT_DETACH = 0x2
MNT_EXPIRE = 0x4
MNT_FORCE = 0x1
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
MODULE_INIT_IGNORE_VERMAGIC = 0x2
MSDOS_SUPER_MAGIC = 0x4d44
MSG_BATCH = 0x40000
MSG_CMSG_CLOEXEC = 0x40000000
MSG_CONFIRM = 0x800
MSG_CTRUNC = 0x8
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x40
MSG_EOR = 0x80
MSG_ERRQUEUE = 0x2000
MSG_FASTOPEN = 0x20000000
MSG_FIN = 0x200
MSG_MORE = 0x8000
MSG_NOSIGNAL = 0x4000
MSG_OOB = 0x1
MSG_PEEK = 0x2
MSG_PROXY = 0x10
MSG_RST = 0x1000
MSG_SYN = 0x400
MSG_TRUNC = 0x20
MSG_TRYHARD = 0x4
MSG_WAITALL = 0x100
MSG_WAITFORONE = 0x10000
MSG_ZEROCOPY = 0x4000000
MS_ACTIVE = 0x40000000
MS_ASYNC = 0x1
MS_BIND = 0x1000
MS_BORN = 0x20000000
MS_DIRSYNC = 0x80
MS_INVALIDATE = 0x2
MS_I_VERSION = 0x800000
MS_KERNMOUNT = 0x400000
MS_LAZYTIME = 0x2000000
MS_MANDLOCK = 0x40
MS_MGC_MSK = 0xffff0000
MS_MGC_VAL = 0xc0ed0000
MS_MOVE = 0x2000
MS_NOATIME = 0x400
MS_NODEV = 0x4
MS_NODIRATIME = 0x800
MS_NOEXEC = 0x8
MS_NOREMOTELOCK = 0x8000000
MS_NOSEC = 0x10000000
MS_NOSUID = 0x2
MS_NOUSER = -0x80000000
MS_POSIXACL = 0x10000
MS_PRIVATE = 0x40000
MS_RDONLY = 0x1
MS_REC = 0x4000
MS_RELATIME = 0x200000
MS_REMOUNT = 0x20
MS_RMT_MASK = 0x2800051
MS_SHARED = 0x100000
MS_SILENT = 0x8000
MS_SLAVE = 0x80000
MS_STRICTATIME = 0x1000000
MS_SUBMOUNT = 0x4000000
MS_SYNC = 0x4
MS_SYNCHRONOUS = 0x10
MS_UNBINDABLE = 0x20000
MS_VERBOSE = 0x8000
MTD_INODE_FS_MAGIC = 0x11307854
NAME_MAX = 0xff
NCP_SUPER_MAGIC = 0x564c
NETLINK_ADD_MEMBERSHIP = 0x1
NETLINK_AUDIT = 0x9
NETLINK_BROADCAST_ERROR = 0x4
NETLINK_CAP_ACK = 0xa
NETLINK_CONNECTOR = 0xb
NETLINK_CRYPTO = 0x15
NETLINK_DNRTMSG = 0xe
NETLINK_DROP_MEMBERSHIP = 0x2
NETLINK_ECRYPTFS = 0x13
NETLINK_EXT_ACK = 0xb
NETLINK_FIB_LOOKUP = 0xa
NETLINK_FIREWALL = 0x3
NETLINK_GENERIC = 0x10
NETLINK_GET_STRICT_CHK = 0xc
NETLINK_INET_DIAG = 0x4
NETLINK_IP6_FW = 0xd
NETLINK_ISCSI = 0x8
NETLINK_KOBJECT_UEVENT = 0xf
NETLINK_LISTEN_ALL_NSID = 0x8
NETLINK_LIST_MEMBERSHIPS = 0x9
NETLINK_NETFILTER = 0xc
NETLINK_NFLOG = 0x5
NETLINK_NO_ENOBUFS = 0x5
NETLINK_PKTINFO = 0x3
NETLINK_RDMA = 0x14
NETLINK_ROUTE = 0x0
NETLINK_RX_RING = 0x6
NETLINK_SCSITRANSPORT = 0x12
NETLINK_SELINUX = 0x7
NETLINK_SMC = 0x16
NETLINK_SOCK_DIAG = 0x4
NETLINK_TX_RING = 0x7
NETLINK_UNUSED = 0x1
NETLINK_USERSOCK = 0x2
NETLINK_XFRM = 0x6
NETNSA_MAX = 0x5
NETNSA_NSID_NOT_ASSIGNED = -0x1
NFDBITS = 0x40
NFNETLINK_V0 = 0x0
NFNLGRP_ACCT_QUOTA = 0x8
NFNLGRP_CONNTRACK_DESTROY = 0x3
NFNLGRP_CONNTRACK_EXP_DESTROY = 0x6
NFNLGRP_CONNTRACK_EXP_NEW = 0x4
NFNLGRP_CONNTRACK_EXP_UPDATE = 0x5
NFNLGRP_CONNTRACK_NEW = 0x1
NFNLGRP_CONNTRACK_UPDATE = 0x2
NFNLGRP_MAX = 0x9
NFNLGRP_NFTABLES = 0x7
NFNLGRP_NFTRACE = 0x9
NFNLGRP_NONE = 0x0
NFNL_BATCH_MAX = 0x1
NFNL_MSG_BATCH_BEGIN = 0x10
NFNL_MSG_BATCH_END = 0x11
NFNL_NFA_NEST = 0x8000
NFNL_SUBSYS_ACCT = 0x7
NFNL_SUBSYS_COUNT = 0xc
NFNL_SUBSYS_CTHELPER = 0x9
NFNL_SUBSYS_CTNETLINK = 0x1
NFNL_SUBSYS_CTNETLINK_EXP = 0x2
NFNL_SUBSYS_CTNETLINK_TIMEOUT = 0x8
NFNL_SUBSYS_IPSET = 0x6
NFNL_SUBSYS_NFTABLES = 0xa
NFNL_SUBSYS_NFT_COMPAT = 0xb
NFNL_SUBSYS_NONE = 0x0
NFNL_SUBSYS_OSF = 0x5
NFNL_SUBSYS_QUEUE = 0x3
NFNL_SUBSYS_ULOG = 0x4
NFS_SUPER_MAGIC = 0x6969
NILFS_SUPER_MAGIC = 0x3434
NL0 = 0x0
NL1 = 0x100
NL2 = 0x200
NL3 = 0x300
NLA_ALIGNTO = 0x4
NLA_F_NESTED = 0x8000
NLA_F_NET_BYTEORDER = 0x4000
NLA_HDRLEN = 0x4
NLDLY = 0x300
NLMSG_ALIGNTO = 0x4
NLMSG_DONE = 0x3
NLMSG_ERROR = 0x2
NLMSG_HDRLEN = 0x10
NLMSG_MIN_TYPE = 0x10
NLMSG_NOOP = 0x1
NLMSG_OVERRUN = 0x4
NLM_F_ACK = 0x4
NLM_F_ACK_TLVS = 0x200
NLM_F_APPEND = 0x800
NLM_F_ATOMIC = 0x400
NLM_F_CAPPED = 0x100
NLM_F_CREATE = 0x400
NLM_F_DUMP = 0x300
NLM_F_DUMP_FILTERED = 0x20
NLM_F_DUMP_INTR = 0x10
NLM_F_ECHO = 0x8
NLM_F_EXCL = 0x200
NLM_F_MATCH = 0x200
NLM_F_MULTI = 0x2
NLM_F_NONREC = 0x100
NLM_F_REPLACE = 0x100
NLM_F_REQUEST = 0x1
NLM_F_ROOT = 0x100
NOFLSH = 0x80000000
NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8
OFDEL = 0x80
OFILL = 0x40
OLCUC = 0x4
ONLCR = 0x2
ONLRET = 0x20
ONOCR = 0x10
OPENPROM_SUPER_MAGIC = 0x9fa1
OPOST = 0x1
OVERLAYFS_SUPER_MAGIC = 0x794c7630
O_ACCMODE = 0x3
O_APPEND = 0x400
O_ASYNC = 0x2000
O_CLOEXEC = 0x80000
O_CREAT = 0x40
O_DIRECT = 0x20000
O_DIRECTORY = 0x4000
O_DSYNC = 0x1000
O_EXCL = 0x80
O_FSYNC = 0x101000
O_LARGEFILE = 0x0
O_NDELAY = 0x800
O_NOATIME = 0x40000
O_NOCTTY = 0x100
O_NOFOLLOW = 0x8000
O_NONBLOCK = 0x800
O_PATH = 0x200000
O_RDONLY = 0x0
O_RDWR = 0x2
O_RSYNC = 0x101000
O_SYNC = 0x101000
O_TMPFILE = 0x404000
O_TRUNC = 0x200
O_WRONLY = 0x1
PACKET_ADD_MEMBERSHIP = 0x1
PACKET_AUXDATA = 0x8
PACKET_BROADCAST = 0x1
PACKET_COPY_THRESH = 0x7
PACKET_DROP_MEMBERSHIP = 0x2
PACKET_FANOUT = 0x12
PACKET_FANOUT_CBPF = 0x6
PACKET_FANOUT_CPU = 0x2
PACKET_FANOUT_DATA = 0x16
PACKET_FANOUT_EBPF = 0x7
PACKET_FANOUT_FLAG_DEFRAG = 0x8000
PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
PACKET_FANOUT_FLAG_UNIQUEID = 0x2000
PACKET_FANOUT_HASH = 0x0
PACKET_FANOUT_LB = 0x1
PACKET_FANOUT_QM = 0x5
PACKET_FANOUT_RND = 0x4
PACKET_FANOUT_ROLLOVER = 0x3
PACKET_FASTROUTE = 0x6
PACKET_HDRLEN = 0xb
PACKET_HOST = 0x0
PACKET_IGNORE_OUTGOING = 0x17
PACKET_KERNEL = 0x7
PACKET_LOOPBACK = 0x5
PACKET_LOSS = 0xe
PACKET_MR_ALLMULTI = 0x2
PACKET_MR_MULTICAST = 0x0
PACKET_MR_PROMISC = 0x1
PACKET_MR_UNICAST = 0x3
PACKET_MULTICAST = 0x2
PACKET_ORIGDEV = 0x9
PACKET_OTHERHOST = 0x3
PACKET_OUTGOING = 0x4
PACKET_QDISC_BYPASS = 0x14
PACKET_RECV_OUTPUT = 0x3
PACKET_RESERVE = 0xc
PACKET_ROLLOVER_STATS = 0x15
PACKET_RX_RING = 0x5
PACKET_STATISTICS = 0x6
PACKET_TIMESTAMP = 0x11
PACKET_TX_HAS_OFF = 0x13
PACKET_TX_RING = 0xd
PACKET_TX_TIMESTAMP = 0x10
PACKET_USER = 0x6
PACKET_VERSION = 0xa
PACKET_VNET_HDR = 0xf
PARENB = 0x1000
PARITY_CRC16_PR0 = 0x2
PARITY_CRC16_PR0_CCITT = 0x4
PARITY_CRC16_PR1 = 0x3
PARITY_CRC16_PR1_CCITT = 0x5
PARITY_CRC32_PR0_CCITT = 0x6
PARITY_CRC32_PR1_CCITT = 0x7
PARITY_DEFAULT = 0x0
PARITY_NONE = 0x1
PARMRK = 0x8
PARODD = 0x2000
PENDIN = 0x20000000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40082407
PERF_EVENT_IOC_MODIFY_ATTRIBUTES = 0x8008240b
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_QUERY_BPF = 0xc008240a
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
PPC_CMM_MAGIC = 0xc7571590
PPPIOCATTACH = 0x8004743d
PPPIOCATTCHAN = 0x80047438
PPPIOCCONNECT = 0x8004743a
PPPIOCDETACH = 0x8004743c
PPPIOCDISCONN = 0x20007439
PPPIOCGASYNCMAP = 0x40047458
PPPIOCGCHAN = 0x40047437
PPPIOCGDEBUG = 0x40047441
PPPIOCGFLAGS = 0x4004745a
PPPIOCGIDLE = 0x4010743f
PPPIOCGIDLE32 = 0x4008743f
PPPIOCGIDLE64 = 0x4010743f
PPPIOCGL2TPSTATS = 0x40487436
PPPIOCGMRU = 0x40047453
PPPIOCGNPMODE = 0xc008744c
PPPIOCGRASYNCMAP = 0x40047455
PPPIOCGUNIT = 0x40047456
PPPIOCGXASYNCMAP = 0x40207450
PPPIOCNEWUNIT = 0xc004743e
PPPIOCSACTIVE = 0x80107446
PPPIOCSASYNCMAP = 0x80047457
PPPIOCSCOMPRESS = 0x8010744d
PPPIOCSDEBUG = 0x80047440
PPPIOCSFLAGS = 0x80047459
PPPIOCSMAXCID = 0x80047451
PPPIOCSMRRU = 0x8004743b
PPPIOCSMRU = 0x80047452
PPPIOCSNPMODE = 0x8008744b
PPPIOCSPASS = 0x80107447
PPPIOCSRASYNCMAP = 0x80047454
PPPIOCSXASYNCMAP = 0x8020744f
PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
PROC_SUPER_MAGIC = 0x9fa0
PROT_EXEC = 0x4
PROT_GROWSDOWN = 0x1000000
PROT_GROWSUP = 0x2000000
PROT_NONE = 0x0
PROT_READ = 0x1
PROT_SAO = 0x10
PROT_WRITE = 0x2
PR_CAPBSET_DROP = 0x18
PR_CAPBSET_READ = 0x17
PR_CAP_AMBIENT = 0x2f
PR_CAP_AMBIENT_CLEAR_ALL = 0x4
PR_CAP_AMBIENT_IS_SET = 0x1
PR_CAP_AMBIENT_LOWER = 0x3
PR_CAP_AMBIENT_RAISE = 0x2
PR_ENDIAN_BIG = 0x0
PR_ENDIAN_LITTLE = 0x1
PR_ENDIAN_PPC_LITTLE = 0x2
PR_FPEMU_NOPRINT = 0x1
PR_FPEMU_SIGFPE = 0x2
PR_FP_EXC_ASYNC = 0x2
PR_FP_EXC_DISABLED = 0x0
PR_FP_EXC_DIV = 0x10000
PR_FP_EXC_INV = 0x100000
PR_FP_EXC_NONRECOV = 0x1
PR_FP_EXC_OVF = 0x20000
PR_FP_EXC_PRECISE = 0x3
PR_FP_EXC_RES = 0x80000
PR_FP_EXC_SW_ENABLE = 0x80
PR_FP_EXC_UND = 0x40000
PR_FP_MODE_FR = 0x1
PR_FP_MODE_FRE = 0x2
PR_GET_CHILD_SUBREAPER = 0x25
PR_GET_DUMPABLE = 0x3
PR_GET_ENDIAN = 0x13
PR_GET_FPEMU = 0x9
PR_GET_FPEXC = 0xb
PR_GET_FP_MODE = 0x2e
PR_GET_KEEPCAPS = 0x7
PR_GET_NAME = 0x10
PR_GET_NO_NEW_PRIVS = 0x27
PR_GET_PDEATHSIG = 0x2
PR_GET_SECCOMP = 0x15
PR_GET_SECUREBITS = 0x1b
PR_GET_SPECULATION_CTRL = 0x34
PR_GET_TAGGED_ADDR_CTRL = 0x38
PR_GET_THP_DISABLE = 0x2a
PR_GET_TID_ADDRESS = 0x28
PR_GET_TIMERSLACK = 0x1e
PR_GET_TIMING = 0xd
PR_GET_TSC = 0x19
PR_GET_UNALIGN = 0x5
PR_MCE_KILL = 0x21
PR_MCE_KILL_CLEAR = 0x0
PR_MCE_KILL_DEFAULT = 0x2
PR_MCE_KILL_EARLY = 0x1
PR_MCE_KILL_GET = 0x22
PR_MCE_KILL_LATE = 0x0
PR_MCE_KILL_SET = 0x1
PR_MPX_DISABLE_MANAGEMENT = 0x2c
PR_MPX_ENABLE_MANAGEMENT = 0x2b
PR_PAC_APDAKEY = 0x4
PR_PAC_APDBKEY = 0x8
PR_PAC_APGAKEY = 0x10
PR_PAC_APIAKEY = 0x1
PR_PAC_APIBKEY = 0x2
PR_PAC_RESET_KEYS = 0x36
PR_SET_CHILD_SUBREAPER = 0x24
PR_SET_DUMPABLE = 0x4
PR_SET_ENDIAN = 0x14
PR_SET_FPEMU = 0xa
PR_SET_FPEXC = 0xc
PR_SET_FP_MODE = 0x2d
PR_SET_KEEPCAPS = 0x8
PR_SET_MM = 0x23
PR_SET_MM_ARG_END = 0x9
PR_SET_MM_ARG_START = 0x8
PR_SET_MM_AUXV = 0xc
PR_SET_MM_BRK = 0x7
PR_SET_MM_END_CODE = 0x2
PR_SET_MM_END_DATA = 0x4
PR_SET_MM_ENV_END = 0xb
PR_SET_MM_ENV_START = 0xa
PR_SET_MM_EXE_FILE = 0xd
PR_SET_MM_MAP = 0xe
PR_SET_MM_MAP_SIZE = 0xf
PR_SET_MM_START_BRK = 0x6
PR_SET_MM_START_CODE = 0x1
PR_SET_MM_START_DATA = 0x3
PR_SET_MM_START_STACK = 0x5
PR_SET_NAME = 0xf
PR_SET_NO_NEW_PRIVS = 0x26
PR_SET_PDEATHSIG = 0x1
PR_SET_PTRACER = 0x59616d61
PR_SET_PTRACER_ANY = 0xffffffffffffffff
PR_SET_SECCOMP = 0x16
PR_SET_SECUREBITS = 0x1c
PR_SET_SPECULATION_CTRL = 0x35
PR_SET_TAGGED_ADDR_CTRL = 0x37
PR_SET_THP_DISABLE = 0x29
PR_SET_TIMERSLACK = 0x1d
PR_SET_TIMING = 0xe
PR_SET_TSC = 0x1a
PR_SET_UNALIGN = 0x6
PR_SPEC_DISABLE = 0x4
PR_SPEC_DISABLE_NOEXEC = 0x10
PR_SPEC_ENABLE = 0x2
PR_SPEC_FORCE_DISABLE = 0x8
PR_SPEC_INDIRECT_BRANCH = 0x1
PR_SPEC_NOT_AFFECTED = 0x0
PR_SPEC_PRCTL = 0x1
PR_SPEC_STORE_BYPASS = 0x0
PR_SVE_GET_VL = 0x33
PR_SVE_SET_VL = 0x32
PR_SVE_SET_VL_ONEXEC = 0x40000
PR_SVE_VL_INHERIT = 0x20000
PR_SVE_VL_LEN_MASK = 0xffff
PR_TAGGED_ADDR_ENABLE = 0x1
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
PR_TASK_PERF_EVENTS_ENABLE = 0x20
PR_TIMING_STATISTICAL = 0x0
PR_TIMING_TIMESTAMP = 0x1
PR_TSC_ENABLE = 0x1
PR_TSC_SIGSEGV = 0x2
PR_UNALIGN_NOPRINT = 0x1
PR_UNALIGN_SIGBUS = 0x2
PSTOREFS_MAGIC = 0x6165676c
PTRACE_ATTACH = 0x10
PTRACE_CONT = 0x7
PTRACE_DETACH = 0x11
PTRACE_EVENTMSG_SYSCALL_ENTRY = 0x1
PTRACE_EVENTMSG_SYSCALL_EXIT = 0x2
PTRACE_EVENT_CLONE = 0x3
PTRACE_EVENT_EXEC = 0x4
PTRACE_EVENT_EXIT = 0x6
PTRACE_EVENT_FORK = 0x1
PTRACE_EVENT_SECCOMP = 0x7
PTRACE_EVENT_STOP = 0x80
PTRACE_EVENT_VFORK = 0x2
PTRACE_EVENT_VFORK_DONE = 0x5
PTRACE_GETEVENTMSG = 0x4201
PTRACE_GETEVRREGS = 0x14
PTRACE_GETFPREGS = 0xe
PTRACE_GETREGS = 0xc
PTRACE_GETREGS64 = 0x16
PTRACE_GETREGSET = 0x4204
PTRACE_GETSIGINFO = 0x4202
PTRACE_GETSIGMASK = 0x420a
PTRACE_GETVRREGS = 0x12
PTRACE_GETVSRREGS = 0x1b
PTRACE_GET_DEBUGREG = 0x19
PTRACE_GET_SYSCALL_INFO = 0x420e
PTRACE_INTERRUPT = 0x4207
PTRACE_KILL = 0x8
PTRACE_LISTEN = 0x4208
PTRACE_O_EXITKILL = 0x100000
PTRACE_O_MASK = 0x3000ff
PTRACE_O_SUSPEND_SECCOMP = 0x200000
PTRACE_O_TRACECLONE = 0x8
PTRACE_O_TRACEEXEC = 0x10
PTRACE_O_TRACEEXIT = 0x40
PTRACE_O_TRACEFORK = 0x2
PTRACE_O_TRACESECCOMP = 0x80
PTRACE_O_TRACESYSGOOD = 0x1
PTRACE_O_TRACEVFORK = 0x4
PTRACE_O_TRACEVFORKDONE = 0x20
PTRACE_PEEKDATA = 0x2
PTRACE_PEEKSIGINFO = 0x4209
PTRACE_PEEKSIGINFO_SHARED = 0x1
PTRACE_PEEKTEXT = 0x1
PTRACE_PEEKUSR = 0x3
PTRACE_POKEDATA = 0x5
PTRACE_POKETEXT = 0x4
PTRACE_POKEUSR = 0x6
PTRACE_SECCOMP_GET_FILTER = 0x420c
PTRACE_SECCOMP_GET_METADATA = 0x420d
PTRACE_SEIZE = 0x4206
PTRACE_SETEVRREGS = 0x15
PTRACE_SETFPREGS = 0xf
PTRACE_SETOPTIONS = 0x4200
PTRACE_SETREGS = 0xd
PTRACE_SETREGS64 = 0x17
PTRACE_SETREGSET = 0x4205
PTRACE_SETSIGINFO = 0x4203
PTRACE_SETSIGMASK = 0x420b
PTRACE_SETVRREGS = 0x13
PTRACE_SETVSRREGS = 0x1c
PTRACE_SET_DEBUGREG = 0x1a
PTRACE_SINGLEBLOCK = 0x100
PTRACE_SINGLESTEP = 0x9
PTRACE_SYSCALL = 0x18
PTRACE_SYSCALL_INFO_ENTRY = 0x1
PTRACE_SYSCALL_INFO_EXIT = 0x2
PTRACE_SYSCALL_INFO_NONE = 0x0
PTRACE_SYSCALL_INFO_SECCOMP = 0x3
PTRACE_SYSEMU = 0x1d
PTRACE_SYSEMU_SINGLESTEP = 0x1e
PTRACE_TRACEME = 0x0
PT_CCR = 0x26
PT_CTR = 0x23
PT_DAR = 0x29
PT_DSCR = 0x2c
PT_DSISR = 0x2a
PT_FPR0 = 0x30
PT_FPSCR = 0x50
PT_LNK = 0x24
PT_MSR = 0x21
PT_NIP = 0x20
PT_ORIG_R3 = 0x22
PT_R0 = 0x0
PT_R1 = 0x1
PT_R10 = 0xa
PT_R11 = 0xb
PT_R12 = 0xc
PT_R13 = 0xd
PT_R14 = 0xe
PT_R15 = 0xf
PT_R16 = 0x10
PT_R17 = 0x11
PT_R18 = 0x12
PT_R19 = 0x13
PT_R2 = 0x2
PT_R20 = 0x14
PT_R21 = 0x15
PT_R22 = 0x16
PT_R23 = 0x17
PT_R24 = 0x18
PT_R25 = 0x19
PT_R26 = 0x1a
PT_R27 = 0x1b
PT_R28 = 0x1c
PT_R29 = 0x1d
PT_R3 = 0x3
PT_R30 = 0x1e
PT_R31 = 0x1f
PT_R4 = 0x4
PT_R5 = 0x5
PT_R6 = 0x6
PT_R7 = 0x7
PT_R8 = 0x8
PT_R9 = 0x9
PT_REGS_COUNT = 0x2c
PT_RESULT = 0x2b
PT_SOFTE = 0x27
PT_TRAP = 0x28
PT_VR0 = 0x52
PT_VRSAVE = 0x94
PT_VSCR = 0x93
PT_VSR0 = 0x96
PT_VSR31 = 0xd4
PT_XER = 0x25
QNX4_SUPER_MAGIC = 0x2f
QNX6_SUPER_MAGIC = 0x68191122
RAMFS_MAGIC = 0x858458f6
RDTGROUP_SUPER_MAGIC = 0x7655821
REISERFS_SUPER_MAGIC = 0x52654973
RENAME_EXCHANGE = 0x2
RENAME_NOREPLACE = 0x1
RENAME_WHITEOUT = 0x4
RLIMIT_AS = 0x9
RLIMIT_CORE = 0x4
RLIMIT_CPU = 0x0
RLIMIT_DATA = 0x2
RLIMIT_FSIZE = 0x1
RLIMIT_LOCKS = 0xa
RLIMIT_MEMLOCK = 0x8
RLIMIT_MSGQUEUE = 0xc
RLIMIT_NICE = 0xd
RLIMIT_NOFILE = 0x7
RLIMIT_NPROC = 0x6
RLIMIT_RSS = 0x5
RLIMIT_RTPRIO = 0xe
RLIMIT_RTTIME = 0xf
RLIMIT_SIGPENDING = 0xb
RLIMIT_STACK = 0x3
RLIM_INFINITY = 0xffffffffffffffff
RNDADDENTROPY = 0x80085203
RNDADDTOENTCNT = 0x80045201
RNDCLEARPOOL = 0x20005206
RNDGETENTCNT = 0x40045200
RNDGETPOOL = 0x40085202
RNDRESEEDCRNG = 0x20005207
RNDZAPENTCNT = 0x20005204
RTAX_ADVMSS = 0x8
RTAX_CC_ALGO = 0x10
RTAX_CWND = 0x7
RTAX_FASTOPEN_NO_COOKIE = 0x11
RTAX_FEATURES = 0xc
RTAX_FEATURE_ALLFRAG = 0x8
RTAX_FEATURE_ECN = 0x1
RTAX_FEATURE_MASK = 0xf
RTAX_FEATURE_SACK = 0x2
RTAX_FEATURE_TIMESTAMP = 0x4
RTAX_HOPLIMIT = 0xa
RTAX_INITCWND = 0xb
RTAX_INITRWND = 0xe
RTAX_LOCK = 0x1
RTAX_MAX = 0x11
RTAX_MTU = 0x2
RTAX_QUICKACK = 0xf
RTAX_REORDERING = 0x9
RTAX_RTO_MIN = 0xd
RTAX_RTT = 0x4
RTAX_RTTVAR = 0x5
RTAX_SSTHRESH = 0x6
RTAX_UNSPEC = 0x0
RTAX_WINDOW = 0x3
RTA_ALIGNTO = 0x4
RTA_MAX = 0x1e
RTCF_DIRECTSRC = 0x4000000
RTCF_DOREDIRECT = 0x1000000
RTCF_LOG = 0x2000000
RTCF_MASQ = 0x400000
RTCF_NAT = 0x800000
RTCF_VALVE = 0x200000
RTC_AF = 0x20
RTC_AIE_OFF = 0x20007002
RTC_AIE_ON = 0x20007001
RTC_ALM_READ = 0x40247008
RTC_ALM_SET = 0x80247007
RTC_EPOCH_READ = 0x4008700d
RTC_EPOCH_SET = 0x8008700e
RTC_IRQF = 0x80
RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c
RTC_MAX_FREQ = 0x2000
RTC_PF = 0x40
RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011
RTC_PLL_SET = 0x80207012
RTC_RD_TIME = 0x40247009
RTC_SET_TIME = 0x8024700a
RTC_UF = 0x10
RTC_UIE_OFF = 0x20007004
RTC_UIE_ON = 0x20007003
RTC_VL_CLR = 0x20007014
RTC_VL_READ = 0x40047013
RTC_WIE_OFF = 0x20007010
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
RTF_ADDRCLASSMASK = 0xf8000000
RTF_ADDRCONF = 0x40000
RTF_ALLONLINK = 0x20000
RTF_BROADCAST = 0x10000000
RTF_CACHE = 0x1000000
RTF_DEFAULT = 0x10000
RTF_DYNAMIC = 0x10
RTF_FLOW = 0x2000000
RTF_GATEWAY = 0x2
RTF_HOST = 0x4
RTF_INTERFACE = 0x40000000
RTF_IRTT = 0x100
RTF_LINKRT = 0x100000
RTF_LOCAL = 0x80000000
RTF_MODIFIED = 0x20
RTF_MSS = 0x40
RTF_MTU = 0x40
RTF_MULTICAST = 0x20000000
RTF_NAT = 0x8000000
RTF_NOFORWARD = 0x1000
RTF_NONEXTHOP = 0x200000
RTF_NOPMTUDISC = 0x4000
RTF_POLICY = 0x4000000
RTF_REINSTATE = 0x8
RTF_REJECT = 0x200
RTF_STATIC = 0x400
RTF_THROW = 0x2000
RTF_UP = 0x1
RTF_WINDOW = 0x80
RTF_XRESOLVE = 0x800
RTM_BASE = 0x10
RTM_DELACTION = 0x31
RTM_DELADDR = 0x15
RTM_DELADDRLABEL = 0x49
RTM_DELCHAIN = 0x65
RTM_DELLINK = 0x11
RTM_DELLINKPROP = 0x6d
RTM_DELMDB = 0x55
RTM_DELNEIGH = 0x1d
RTM_DELNETCONF = 0x51
RTM_DELNEXTHOP = 0x69
RTM_DELNSID = 0x59
RTM_DELQDISC = 0x25
RTM_DELROUTE = 0x19
RTM_DELRULE = 0x21
RTM_DELTCLASS = 0x29
RTM_DELTFILTER = 0x2d
RTM_F_CLONED = 0x200
RTM_F_EQUALIZE = 0x400
RTM_F_FIB_MATCH = 0x2000
RTM_F_LOOKUP_TABLE = 0x1000
RTM_F_NOTIFY = 0x100
RTM_F_PREFIX = 0x800
RTM_GETACTION = 0x32
RTM_GETADDR = 0x16
RTM_GETADDRLABEL = 0x4a
RTM_GETANYCAST = 0x3e
RTM_GETCHAIN = 0x66
RTM_GETDCB = 0x4e
RTM_GETLINK = 0x12
RTM_GETLINKPROP = 0x6e
RTM_GETMDB = 0x56
RTM_GETMULTICAST = 0x3a
RTM_GETNEIGH = 0x1e
RTM_GETNEIGHTBL = 0x42
RTM_GETNETCONF = 0x52
RTM_GETNEXTHOP = 0x6a
RTM_GETNSID = 0x5a
RTM_GETQDISC = 0x26
RTM_GETROUTE = 0x1a
RTM_GETRULE = 0x22
RTM_GETSTATS = 0x5e
RTM_GETTCLASS = 0x2a
RTM_GETTFILTER = 0x2e
RTM_MAX = 0x6f
RTM_NEWACTION = 0x30
RTM_NEWADDR = 0x14
RTM_NEWADDRLABEL = 0x48
RTM_NEWCACHEREPORT = 0x60
RTM_NEWCHAIN = 0x64
RTM_NEWLINK = 0x10
RTM_NEWLINKPROP = 0x6c
RTM_NEWMDB = 0x54
RTM_NEWNDUSEROPT = 0x44
RTM_NEWNEIGH = 0x1c
RTM_NEWNEIGHTBL = 0x40
RTM_NEWNETCONF = 0x50
RTM_NEWNEXTHOP = 0x68
RTM_NEWNSID = 0x58
RTM_NEWPREFIX = 0x34
RTM_NEWQDISC = 0x24
RTM_NEWROUTE = 0x18
RTM_NEWRULE = 0x20
RTM_NEWSTATS = 0x5c
RTM_NEWTCLASS = 0x28
RTM_NEWTFILTER = 0x2c
RTM_NR_FAMILIES = 0x18
RTM_NR_MSGTYPES = 0x60
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_COMPARE_MASK = 0x19
RTNH_F_DEAD = 0x1
RTNH_F_LINKDOWN = 0x10
RTNH_F_OFFLOAD = 0x8
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTNH_F_UNRESOLVED = 0x20
RTN_MAX = 0xb
RTPROT_BABEL = 0x2a
RTPROT_BGP = 0xba
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_EIGRP = 0xc0
RTPROT_GATED = 0x8
RTPROT_ISIS = 0xbb
RTPROT_KERNEL = 0x2
RTPROT_MROUTED = 0x11
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_OSPF = 0xbc
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_RIP = 0xbd
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0x0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
RT_CLASS_DEFAULT = 0xfd
RT_CLASS_LOCAL = 0xff
RT_CLASS_MAIN = 0xfe
RT_CLASS_MAX = 0xff
RT_CLASS_UNSPEC = 0x0
RUSAGE_CHILDREN = -0x1
RUSAGE_SELF = 0x0
RUSAGE_THREAD = 0x1
RWF_APPEND = 0x10
RWF_DSYNC = 0x2
RWF_HIPRI = 0x1
RWF_NOWAIT = 0x8
RWF_SUPPORTED = 0x1f
RWF_SYNC = 0x4
RWF_WRITE_LIFE_NOT_SET = 0x0
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SECURITYFS_MAGIC = 0x73636673
SELINUX_MAGIC = 0xf97cff8c
SFD_CLOEXEC = 0x80000
SFD_NONBLOCK = 0x800
SHUT_RD = 0x0
SHUT_RDWR = 0x2
SHUT_WR = 0x1
SIOCADDDLCI = 0x8980
SIOCADDMULTI = 0x8931
SIOCADDRT = 0x890b
SIOCATMARK = 0x8905
SIOCBONDCHANGEACTIVE = 0x8995
SIOCBONDENSLAVE = 0x8990
SIOCBONDINFOQUERY = 0x8994
SIOCBONDRELEASE = 0x8991
SIOCBONDSETHWADDR = 0x8992
SIOCBONDSLAVEINFOQUERY = 0x8993
SIOCBRADDBR = 0x89a0
SIOCBRADDIF = 0x89a2
SIOCBRDELBR = 0x89a1
SIOCBRDELIF = 0x89a3
SIOCDARP = 0x8953
SIOCDELDLCI = 0x8981
SIOCDELMULTI = 0x8932
SIOCDELRT = 0x890c
SIOCDEVPRIVATE = 0x89f0
SIOCDIFADDR = 0x8936
SIOCDRARP = 0x8960
SIOCETHTOOL = 0x8946
SIOCGARP = 0x8954
SIOCGETLINKNAME = 0x89e0
SIOCGETNODEID = 0x89e1
SIOCGHWTSTAMP = 0x89b1
SIOCGIFADDR = 0x8915
SIOCGIFBR = 0x8940
SIOCGIFBRDADDR = 0x8919
SIOCGIFCONF = 0x8912
SIOCGIFCOUNT = 0x8938
SIOCGIFDSTADDR = 0x8917
SIOCGIFENCAP = 0x8925
SIOCGIFFLAGS = 0x8913
SIOCGIFHWADDR = 0x8927
SIOCGIFINDEX = 0x8933
SIOCGIFMAP = 0x8970
SIOCGIFMEM = 0x891f
SIOCGIFMETRIC = 0x891d
SIOCGIFMTU = 0x8921
SIOCGIFNAME = 0x8910
SIOCGIFNETMASK = 0x891b
SIOCGIFPFLAGS = 0x8935
SIOCGIFSLAVE = 0x8929
SIOCGIFTXQLEN = 0x8942
SIOCGIFVLAN = 0x8982
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
SIOCGPPPCSTATS = 0x89f2
SIOCGPPPSTATS = 0x89f0
SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
SIOCGSTAMPNS = 0x8907
SIOCGSTAMPNS_NEW = 0x40108907
SIOCGSTAMPNS_OLD = 0x8907
SIOCGSTAMP_NEW = 0x40108906
SIOCGSTAMP_OLD = 0x8906
SIOCINQ = 0x4004667f
SIOCOUTQ = 0x40047473
SIOCOUTQNSD = 0x894b
SIOCPROTOPRIVATE = 0x89e0
SIOCRTMSG = 0x890d
SIOCSARP = 0x8955
SIOCSHWTSTAMP = 0x89b0
SIOCSIFADDR = 0x8916
SIOCSIFBR = 0x8941
SIOCSIFBRDADDR = 0x891a
SIOCSIFDSTADDR = 0x8918
SIOCSIFENCAP = 0x8926
SIOCSIFFLAGS = 0x8914
SIOCSIFHWADDR = 0x8924
SIOCSIFHWBROADCAST = 0x8937
SIOCSIFLINK = 0x8911
SIOCSIFMAP = 0x8971
SIOCSIFMEM = 0x8920
SIOCSIFMETRIC = 0x891e
SIOCSIFMTU = 0x8922
SIOCSIFNAME = 0x8923
SIOCSIFNETMASK = 0x891c
SIOCSIFPFLAGS = 0x8934
SIOCSIFSLAVE = 0x8930
SIOCSIFTXQLEN = 0x8943
SIOCSIFVLAN = 0x8983
SIOCSMIIREG = 0x8949
SIOCSPGRP = 0x8902
SIOCSRARP = 0x8962
SIOCWANDEV = 0x894a
SMACK_MAGIC = 0x43415d53
SMART_AUTOSAVE = 0xd2
SMART_AUTO_OFFLINE = 0xdb
SMART_DISABLE = 0xd9
SMART_ENABLE = 0xd8
SMART_HCYL_PASS = 0xc2
SMART_IMMEDIATE_OFFLINE = 0xd4
SMART_LCYL_PASS = 0x4f
SMART_READ_LOG_SECTOR = 0xd5
SMART_READ_THRESHOLDS = 0xd1
SMART_READ_VALUES = 0xd0
SMART_SAVE = 0xd3
SMART_STATUS = 0xda
SMART_WRITE_LOG_SECTOR = 0xd6
SMART_WRITE_THRESHOLDS = 0xd7
SMB_SUPER_MAGIC = 0x517b
SOCKFS_MAGIC = 0x534f434b
SOCK_CLOEXEC = 0x80000
SOCK_DCCP = 0x6
SOCK_DGRAM = 0x2
SOCK_IOC_TYPE = 0x89
SOCK_NONBLOCK = 0x800
SOCK_PACKET = 0xa
SOCK_RAW = 0x3
SOCK_RDM = 0x4
SOCK_SEQPACKET = 0x5
SOCK_STREAM = 0x1
SOL_AAL = 0x109
SOL_ALG = 0x117
SOL_ATM = 0x108
SOL_CAIF = 0x116
SOL_CAN_BASE = 0x64
SOL_DCCP = 0x10d
SOL_DECNET = 0x105
SOL_ICMPV6 = 0x3a
SOL_IP = 0x0
SOL_IPV6 = 0x29
SOL_IRDA = 0x10a
SOL_IUCV = 0x115
SOL_KCM = 0x119
SOL_LLC = 0x10c
SOL_NETBEUI = 0x10b
SOL_NETLINK = 0x10e
SOL_NFC = 0x118
SOL_PACKET = 0x107
SOL_PNPIPE = 0x113
SOL_PPPOL2TP = 0x111
SOL_RAW = 0xff
SOL_RDS = 0x114
SOL_RXRPC = 0x110
SOL_SOCKET = 0x1
SOL_TCP = 0x6
SOL_TIPC = 0x10f
SOL_TLS = 0x11a
SOL_X25 = 0x106
SOL_XDP = 0x11b
SOMAXCONN = 0x1000
SO_ACCEPTCONN = 0x1e
SO_ATTACH_BPF = 0x32
SO_ATTACH_FILTER = 0x1a
SO_ATTACH_REUSEPORT_CBPF = 0x33
SO_ATTACH_REUSEPORT_EBPF = 0x34
SO_BINDTODEVICE = 0x19
SO_BINDTOIFINDEX = 0x3e
SO_BPF_EXTENSIONS = 0x30
SO_BROADCAST = 0x6
SO_BSDCOMPAT = 0xe
SO_BUSY_POLL = 0x2e
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DEBUG = 0x1
SO_DETACH_BPF = 0x1b
SO_DETACH_FILTER = 0x1b
SO_DETACH_REUSEPORT_BPF = 0x44
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_EE_CODE_TXTIME_INVALID_PARAM = 0x1
SO_EE_CODE_TXTIME_MISSED = 0x2
SO_EE_CODE_ZEROCOPY_COPIED = 0x1
SO_EE_ORIGIN_ICMP = 0x2
SO_EE_ORIGIN_ICMP6 = 0x3
SO_EE_ORIGIN_LOCAL = 0x1
SO_EE_ORIGIN_NONE = 0x0
SO_EE_ORIGIN_TIMESTAMPING = 0x4
SO_EE_ORIGIN_TXSTATUS = 0x4
SO_EE_ORIGIN_TXTIME = 0x6
SO_EE_ORIGIN_ZEROCOPY = 0x5
SO_ERROR = 0x4
SO_GET_FILTER = 0x1a
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
SO_MARK = 0x24
SO_MAX_PACING_RATE = 0x2f
SO_MEMINFO = 0x37
SO_NOFCS = 0x2b
SO_NO_CHECK = 0xb
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x14
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x15
SO_PEERGROUPS = 0x3b
SO_PEERNAME = 0x1c
SO_PEERSEC = 0x1f
SO_PRIORITY = 0xc
SO_PROTOCOL = 0x26
SO_RCVBUF = 0x8
SO_RCVBUFFORCE = 0x21
SO_RCVLOWAT = 0x10
SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12
SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28
SO_SECURITY_AUTHENTICATION = 0x16
SO_SECURITY_ENCRYPTION_NETWORK = 0x18
SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
SO_SELECT_ERR_QUEUE = 0x2d
SO_SNDBUF = 0x7
SO_SNDBUFFORCE = 0x20
SO_SNDLOWAT = 0x11
SO_SNDTIMEO = 0x13
SO_SNDTIMEO_NEW = 0x43
SO_SNDTIMEO_OLD = 0x13
SO_TIMESTAMP = 0x1d
SO_TIMESTAMPING = 0x25
SO_TIMESTAMPING_NEW = 0x41
SO_TIMESTAMPING_OLD = 0x25
SO_TIMESTAMPNS = 0x23
SO_TIMESTAMPNS_NEW = 0x40
SO_TIMESTAMPNS_OLD = 0x23
SO_TIMESTAMP_NEW = 0x3f
SO_TIMESTAMP_OLD = 0x1d
SO_TXTIME = 0x3d
SO_TYPE = 0x3
SO_VM_SOCKETS_BUFFER_MAX_SIZE = 0x2
SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
SO_VM_SOCKETS_BUFFER_SIZE = 0x0
SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
SO_VM_SOCKETS_TRUSTED = 0x5
SO_WIFI_STATUS = 0x29
SO_ZEROCOPY = 0x3c
SPLICE_F_GIFT = 0x8
SPLICE_F_MORE = 0x4
SPLICE_F_MOVE = 0x1
SPLICE_F_NONBLOCK = 0x2
SQUASHFS_MAGIC = 0x73717368
STACK_END_MAGIC = 0x57ac6e9d
STATX_ALL = 0xfff
STATX_ATIME = 0x20
STATX_ATTR_APPEND = 0x20
STATX_ATTR_AUTOMOUNT = 0x1000
STATX_ATTR_COMPRESSED = 0x4
STATX_ATTR_ENCRYPTED = 0x800
STATX_ATTR_IMMUTABLE = 0x10
STATX_ATTR_NODUMP = 0x40
STATX_ATTR_VERITY = 0x100000
STATX_BASIC_STATS = 0x7ff
STATX_BLOCKS = 0x400
STATX_BTIME = 0x800
STATX_CTIME = 0x80
STATX_GID = 0x10
STATX_INO = 0x100
STATX_MODE = 0x2
STATX_MTIME = 0x40
STATX_NLINK = 0x4
STATX_SIZE = 0x200
STATX_TYPE = 0x1
STATX_UID = 0x8
STATX__RESERVED = 0x80000000
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
SYNC_FILE_RANGE_WRITE = 0x2
SYNC_FILE_RANGE_WRITE_AND_WAIT = 0x7
SYSFS_MAGIC = 0x62656572
S_BLKSIZE = 0x200
S_IEXEC = 0x40
S_IFBLK = 0x6000
S_IFCHR = 0x2000
S_IFDIR = 0x4000
S_IFIFO = 0x1000
S_IFLNK = 0xa000
S_IFMT = 0xf000
S_IFREG = 0x8000
S_IFSOCK = 0xc000
S_IREAD = 0x100
S_IRGRP = 0x20
S_IROTH = 0x4
S_IRUSR = 0x100
S_IRWXG = 0x38
S_IRWXO = 0x7
S_IRWXU = 0x1c0
S_ISGID = 0x400
S_ISUID = 0x800
S_ISVTX = 0x200
S_IWGRP = 0x10
S_IWOTH = 0x2
S_IWRITE = 0x80
S_IWUSR = 0x80
S_IXGRP = 0x8
S_IXOTH = 0x1
S_IXUSR = 0x40
TAB0 = 0x0
TAB1 = 0x400
TAB2 = 0x800
TAB3 = 0xc00
TABDLY = 0xc00
TASKSTATS_CMD_ATTR_MAX = 0x4
TASKSTATS_CMD_MAX = 0x2
TASKSTATS_GENL_NAME = "TASKSTATS"
TASKSTATS_GENL_VERSION = 0x1
TASKSTATS_TYPE_MAX = 0x6
TASKSTATS_VERSION = 0x9
TCFLSH = 0x2000741f
TCGETA = 0x40147417
TCGETS = 0x402c7413
TCIFLUSH = 0x0
TCIOFF = 0x2
TCIOFLUSH = 0x2
TCION = 0x3
TCOFLUSH = 0x1
TCOOFF = 0x0
TCOON = 0x1
TCP_BPF_IW = 0x3e9
TCP_BPF_SNDCWND_CLAMP = 0x3ea
TCP_CC_INFO = 0x1a
TCP_CM_INQ = 0x24
TCP_CONGESTION = 0xd
TCP_COOKIE_IN_ALWAYS = 0x1
TCP_COOKIE_MAX = 0x10
TCP_COOKIE_MIN = 0x8
TCP_COOKIE_OUT_NEVER = 0x2
TCP_COOKIE_PAIR_SIZE = 0x20
TCP_COOKIE_TRANSACTIONS = 0xf
TCP_CORK = 0x3
TCP_DEFER_ACCEPT = 0x9
TCP_FASTOPEN = 0x17
TCP_FASTOPEN_CONNECT = 0x1e
TCP_FASTOPEN_KEY = 0x21
TCP_FASTOPEN_NO_COOKIE = 0x22
TCP_INFO = 0xb
TCP_INQ = 0x24
TCP_KEEPCNT = 0x6
TCP_KEEPIDLE = 0x4
TCP_KEEPINTVL = 0x5
TCP_LINGER2 = 0x8
TCP_MAXSEG = 0x2
TCP_MAXWIN = 0xffff
TCP_MAX_WINSHIFT = 0xe
TCP_MD5SIG = 0xe
TCP_MD5SIG_EXT = 0x20
TCP_MD5SIG_FLAG_PREFIX = 0x1
TCP_MD5SIG_MAXKEYLEN = 0x50
TCP_MSS = 0x200
TCP_MSS_DEFAULT = 0x218
TCP_MSS_DESIRED = 0x4c4
TCP_NODELAY = 0x1
TCP_NOTSENT_LOWAT = 0x19
TCP_QUEUE_SEQ = 0x15
TCP_QUICKACK = 0xc
TCP_REPAIR = 0x13
TCP_REPAIR_OFF = 0x0
TCP_REPAIR_OFF_NO_WP = -0x1
TCP_REPAIR_ON = 0x1
TCP_REPAIR_OPTIONS = 0x16
TCP_REPAIR_QUEUE = 0x14
TCP_REPAIR_WINDOW = 0x1d
TCP_SAVED_SYN = 0x1c
TCP_SAVE_SYN = 0x1b
TCP_SYNCNT = 0x7
TCP_S_DATA_IN = 0x4
TCP_S_DATA_OUT = 0x8
TCP_THIN_DUPACK = 0x11
TCP_THIN_LINEAR_TIMEOUTS = 0x10
TCP_TIMESTAMP = 0x18
TCP_TX_DELAY = 0x25
TCP_ULP = 0x1f
TCP_USER_TIMEOUT = 0x12
TCP_WINDOW_CLAMP = 0xa
TCP_ZEROCOPY_RECEIVE = 0x23
TCSAFLUSH = 0x2
TCSBRK = 0x2000741d
TCSBRKP = 0x5425
TCSETA = 0x80147418
TCSETAF = 0x8014741c
TCSETAW = 0x80147419
TCSETS = 0x802c7414
TCSETSF = 0x802c7416
TCSETSW = 0x802c7415
TCXONC = 0x2000741e
TIMER_ABSTIME = 0x1
TIOCCBRK = 0x5428
TIOCCONS = 0x541d
TIOCEXCL = 0x540c
TIOCGDEV = 0x40045432
TIOCGETC = 0x40067412
TIOCGETD = 0x5424
TIOCGETP = 0x40067408
TIOCGEXCL = 0x40045440
TIOCGICOUNT = 0x545d
TIOCGISO7816 = 0x40285442
TIOCGLCKTRMIOS = 0x5456
TIOCGLTC = 0x40067474
TIOCGPGRP = 0x40047477
TIOCGPKT = 0x40045438
TIOCGPTLCK = 0x40045439
TIOCGPTN = 0x40045430
TIOCGPTPEER = 0x20005441
TIOCGRS485 = 0x542e
TIOCGSERIAL = 0x541e
TIOCGSID = 0x5429
TIOCGSOFTCAR = 0x5419
TIOCGWINSZ = 0x40087468
TIOCINQ = 0x4004667f
TIOCLINUX = 0x541c
TIOCMBIC = 0x5417
TIOCMBIS = 0x5416
TIOCMGET = 0x5415
TIOCMIWAIT = 0x545c
TIOCMSET = 0x5418
TIOCM_CAR = 0x40
TIOCM_CD = 0x40
TIOCM_CTS = 0x20
TIOCM_DSR = 0x100
TIOCM_DTR = 0x2
TIOCM_LE = 0x1
TIOCM_LOOP = 0x8000
TIOCM_OUT1 = 0x2000
TIOCM_OUT2 = 0x4000
TIOCM_RI = 0x80
TIOCM_RNG = 0x80
TIOCM_RTS = 0x4
TIOCM_SR = 0x10
TIOCM_ST = 0x8
TIOCNOTTY = 0x5422
TIOCNXCL = 0x540d
TIOCOUTQ = 0x40047473
TIOCPKT = 0x5420
TIOCPKT_DATA = 0x0
TIOCPKT_DOSTOP = 0x20
TIOCPKT_FLUSHREAD = 0x1
TIOCPKT_FLUSHWRITE = 0x2
TIOCPKT_IOCTL = 0x40
TIOCPKT_NOSTOP = 0x10
TIOCPKT_START = 0x8
TIOCPKT_STOP = 0x4
TIOCSBRK = 0x5427
TIOCSCTTY = 0x540e
TIOCSERCONFIG = 0x5453
TIOCSERGETLSR = 0x5459
TIOCSERGETMULTI = 0x545a
TIOCSERGSTRUCT = 0x5458
TIOCSERGWILD = 0x5454
TIOCSERSETMULTI = 0x545b
TIOCSERSWILD = 0x5455
TIOCSER_TEMT = 0x1
TIOCSETC = 0x80067411
TIOCSETD = 0x5423
TIOCSETN = 0x8006740a
TIOCSETP = 0x80067409
TIOCSIG = 0x80045436
TIOCSISO7816 = 0xc0285443
TIOCSLCKTRMIOS = 0x5457
TIOCSLTC = 0x80067475
TIOCSPGRP = 0x80047476
TIOCSPTLCK = 0x80045431
TIOCSRS485 = 0x542f
TIOCSSERIAL = 0x541f
TIOCSSOFTCAR = 0x541a
TIOCSTART = 0x2000746e
TIOCSTI = 0x5412
TIOCSTOP = 0x2000746f
TIOCSWINSZ = 0x80087467
TIOCVHANGUP = 0x5437
TIPC_ADDR_ID = 0x3
TIPC_ADDR_MCAST = 0x1
TIPC_ADDR_NAME = 0x2
TIPC_ADDR_NAMESEQ = 0x1
TIPC_AEAD_ALG_NAME = 0x20
TIPC_AEAD_KEYLEN_MAX = 0x24
TIPC_AEAD_KEYLEN_MIN = 0x14
TIPC_AEAD_KEY_SIZE_MAX = 0x48
TIPC_CFG_SRV = 0x0
TIPC_CLUSTER_BITS = 0xc
TIPC_CLUSTER_MASK = 0xfff000
TIPC_CLUSTER_OFFSET = 0xc
TIPC_CLUSTER_SIZE = 0xfff
TIPC_CONN_SHUTDOWN = 0x5
TIPC_CONN_TIMEOUT = 0x82
TIPC_CRITICAL_IMPORTANCE = 0x3
TIPC_DESTNAME = 0x3
TIPC_DEST_DROPPABLE = 0x81
TIPC_ERRINFO = 0x1
TIPC_ERR_NO_NAME = 0x1
TIPC_ERR_NO_NODE = 0x3
TIPC_ERR_NO_PORT = 0x2
TIPC_ERR_OVERLOAD = 0x4
TIPC_GROUP_JOIN = 0x87
TIPC_GROUP_LEAVE = 0x88
TIPC_GROUP_LOOPBACK = 0x1
TIPC_GROUP_MEMBER_EVTS = 0x2
TIPC_HIGH_IMPORTANCE = 0x2
TIPC_IMPORTANCE = 0x7f
TIPC_LINK_STATE = 0x2
TIPC_LOW_IMPORTANCE = 0x0
TIPC_MAX_BEARER_NAME = 0x20
TIPC_MAX_IF_NAME = 0x10
TIPC_MAX_LINK_NAME = 0x44
TIPC_MAX_MEDIA_NAME = 0x10
TIPC_MAX_USER_MSG_SIZE = 0x101d0
TIPC_MCAST_BROADCAST = 0x85
TIPC_MCAST_REPLICAST = 0x86
TIPC_MEDIUM_IMPORTANCE = 0x1
TIPC_NODEID_LEN = 0x10
TIPC_NODELAY = 0x8a
TIPC_NODE_BITS = 0xc
TIPC_NODE_MASK = 0xfff
TIPC_NODE_OFFSET = 0x0
TIPC_NODE_RECVQ_DEPTH = 0x83
TIPC_NODE_SIZE = 0xfff
TIPC_NODE_STATE = 0x0
TIPC_OK = 0x0
TIPC_PUBLISHED = 0x1
TIPC_RESERVED_TYPES = 0x40
TIPC_RETDATA = 0x2
TIPC_SERVICE_ADDR = 0x2
TIPC_SERVICE_RANGE = 0x1
TIPC_SOCKET_ADDR = 0x3
TIPC_SOCK_RECVQ_DEPTH = 0x84
TIPC_SOCK_RECVQ_USED = 0x89
TIPC_SRC_DROPPABLE = 0x80
TIPC_SUBSCR_TIMEOUT = 0x3
TIPC_SUB_CANCEL = 0x4
TIPC_SUB_PORTS = 0x1
TIPC_SUB_SERVICE = 0x2
TIPC_TOP_SRV = 0x1
TIPC_WAIT_FOREVER = 0xffffffff
TIPC_WITHDRAWN = 0x2
TIPC_ZONE_BITS = 0x8
TIPC_ZONE_CLUSTER_MASK = 0xfffff000
TIPC_ZONE_MASK = 0xff000000
TIPC_ZONE_OFFSET = 0x18
TIPC_ZONE_SCOPE = 0x1
TIPC_ZONE_SIZE = 0xff
TMPFS_MAGIC = 0x1021994
TOSTOP = 0x400000
TPACKET_ALIGNMENT = 0x10
TPACKET_HDRLEN = 0x34
TP_STATUS_AVAILABLE = 0x0
TP_STATUS_BLK_TMO = 0x20
TP_STATUS_COPY = 0x2
TP_STATUS_CSUMNOTREADY = 0x8
TP_STATUS_CSUM_VALID = 0x80
TP_STATUS_KERNEL = 0x0
TP_STATUS_LOSING = 0x4
TP_STATUS_SENDING = 0x2
TP_STATUS_SEND_REQUEST = 0x1
TP_STATUS_TS_RAW_HARDWARE = 0x80000000
TP_STATUS_TS_SOFTWARE = 0x20000000
TP_STATUS_TS_SYS_HARDWARE = 0x40000000
TP_STATUS_USER = 0x1
TP_STATUS_VLAN_TPID_VALID = 0x40
TP_STATUS_VLAN_VALID = 0x10
TP_STATUS_WRONG_FORMAT = 0x4
TRACEFS_MAGIC = 0x74726163
TS_COMM_LEN = 0x20
TUNATTACHFILTER = 0x801054d5
TUNDETACHFILTER = 0x801054d6
TUNGETDEVNETNS = 0x200054e3
TUNGETFEATURES = 0x400454cf
TUNGETFILTER = 0x401054db
TUNGETIFF = 0x400454d2
TUNGETSNDBUF = 0x400454d3
TUNGETVNETBE = 0x400454df
TUNGETVNETHDRSZ = 0x400454d7
TUNGETVNETLE = 0x400454dd
TUNSETCARRIER = 0x800454e2
TUNSETDEBUG = 0x800454c9
TUNSETFILTEREBPF = 0x400454e1
TUNSETGROUP = 0x800454ce
TUNSETIFF = 0x800454ca
TUNSETIFINDEX = 0x800454da
TUNSETLINK = 0x800454cd
TUNSETNOCSUM = 0x800454c8
TUNSETOFFLOAD = 0x800454d0
TUNSETOWNER = 0x800454cc
TUNSETPERSIST = 0x800454cb
TUNSETQUEUE = 0x800454d9
TUNSETSNDBUF = 0x800454d4
TUNSETSTEERINGEBPF = 0x400454e0
TUNSETTXFILTER = 0x800454d1
TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc
UBI_IOCATT = 0x80186f40
UBI_IOCDET = 0x80046f41
UBI_IOCEBCH = 0x80044f02
UBI_IOCEBER = 0x80044f01
UBI_IOCEBISMAP = 0x40044f05
UBI_IOCEBMAP = 0x80084f03
UBI_IOCEBUNMAP = 0x80044f04
UBI_IOCMKVOL = 0x80986f00
UBI_IOCRMVOL = 0x80046f01
UBI_IOCRNVOL = 0x91106f03
UBI_IOCRPEB = 0x80046f04
UBI_IOCRSVOL = 0x800c6f02
UBI_IOCSETVOLPROP = 0x80104f06
UBI_IOCSPEB = 0x80046f05
UBI_IOCVOLCRBLK = 0x80804f07
UBI_IOCVOLRMBLK = 0x20004f08
UBI_IOCVOLUP = 0x80084f00
UDF_SUPER_MAGIC = 0x15013346
UMOUNT_NOFOLLOW = 0x8
USBDEVICE_SUPER_MAGIC = 0x9fa2
UTIME_NOW = 0x3fffffff
UTIME_OMIT = 0x3ffffffe
V9FS_MAGIC = 0x1021997
VDISCARD = 0x10
VEOF = 0x4
VEOL = 0x6
VEOL2 = 0x8
VERASE = 0x2
VINTR = 0x0
VKILL = 0x3
VLNEXT = 0xf
VMADDR_CID_ANY = 0xffffffff
VMADDR_CID_HOST = 0x2
VMADDR_CID_HYPERVISOR = 0x0
VMADDR_CID_RESERVED = 0x1
VMADDR_PORT_ANY = 0xffffffff
VMIN = 0x5
VM_SOCKETS_INVALID_VERSION = 0xffffffff
VQUIT = 0x1
VREPRINT = 0xb
VSTART = 0xd
VSTOP = 0xe
VSUSP = 0xc
VSWTC = 0x9
VT0 = 0x0
VT1 = 0x10000
VTDLY = 0x10000
VTIME = 0x7
VWERASE = 0xa
WALL = 0x40000000
WCLONE = 0x80000000
WCONTINUED = 0x8
WDIOC_GETBOOTSTATUS = 0x40045702
WDIOC_GETPRETIMEOUT = 0x40045709
WDIOC_GETSTATUS = 0x40045701
WDIOC_GETSUPPORT = 0x40285700
WDIOC_GETTEMP = 0x40045703
WDIOC_GETTIMELEFT = 0x4004570a
WDIOC_GETTIMEOUT = 0x40045707
WDIOC_KEEPALIVE = 0x40045705
WDIOC_SETOPTIONS = 0x40045704
WDIOC_SETPRETIMEOUT = 0xc0045708
WDIOC_SETTIMEOUT = 0xc0045706
WEXITED = 0x4
WIN_ACKMEDIACHANGE = 0xdb
WIN_CHECKPOWERMODE1 = 0xe5
WIN_CHECKPOWERMODE2 = 0x98
WIN_DEVICE_RESET = 0x8
WIN_DIAGNOSE = 0x90
WIN_DOORLOCK = 0xde
WIN_DOORUNLOCK = 0xdf
WIN_DOWNLOAD_MICROCODE = 0x92
WIN_FLUSH_CACHE = 0xe7
WIN_FLUSH_CACHE_EXT = 0xea
WIN_FORMAT = 0x50
WIN_GETMEDIASTATUS = 0xda
WIN_IDENTIFY = 0xec
WIN_IDENTIFY_DMA = 0xee
WIN_IDLEIMMEDIATE = 0xe1
WIN_INIT = 0x60
WIN_MEDIAEJECT = 0xed
WIN_MULTREAD = 0xc4
WIN_MULTREAD_EXT = 0x29
WIN_MULTWRITE = 0xc5
WIN_MULTWRITE_EXT = 0x39
WIN_NOP = 0x0
WIN_PACKETCMD = 0xa0
WIN_PIDENTIFY = 0xa1
WIN_POSTBOOT = 0xdc
WIN_PREBOOT = 0xdd
WIN_QUEUED_SERVICE = 0xa2
WIN_READ = 0x20
WIN_READDMA = 0xc8
WIN_READDMA_EXT = 0x25
WIN_READDMA_ONCE = 0xc9
WIN_READDMA_QUEUED = 0xc7
WIN_READDMA_QUEUED_EXT = 0x26
WIN_READ_BUFFER = 0xe4
WIN_READ_EXT = 0x24
WIN_READ_LONG = 0x22
WIN_READ_LONG_ONCE = 0x23
WIN_READ_NATIVE_MAX = 0xf8
WIN_READ_NATIVE_MAX_EXT = 0x27
WIN_READ_ONCE = 0x21
WIN_RECAL = 0x10
WIN_RESTORE = 0x10
WIN_SECURITY_DISABLE = 0xf6
WIN_SECURITY_ERASE_PREPARE = 0xf3
WIN_SECURITY_ERASE_UNIT = 0xf4
WIN_SECURITY_FREEZE_LOCK = 0xf5
WIN_SECURITY_SET_PASS = 0xf1
WIN_SECURITY_UNLOCK = 0xf2
WIN_SEEK = 0x70
WIN_SETFEATURES = 0xef
WIN_SETIDLE1 = 0xe3
WIN_SETIDLE2 = 0x97
WIN_SETMULT = 0xc6
WIN_SET_MAX = 0xf9
WIN_SET_MAX_EXT = 0x37
WIN_SLEEPNOW1 = 0xe6
WIN_SLEEPNOW2 = 0x99
WIN_SMART = 0xb0
WIN_SPECIFY = 0x91
WIN_SRST = 0x8
WIN_STANDBY = 0xe2
WIN_STANDBY2 = 0x96
WIN_STANDBYNOW1 = 0xe0
WIN_STANDBYNOW2 = 0x94
WIN_VERIFY = 0x40
WIN_VERIFY_EXT = 0x42
WIN_VERIFY_ONCE = 0x41
WIN_WRITE = 0x30
WIN_WRITEDMA = 0xca
WIN_WRITEDMA_EXT = 0x35
WIN_WRITEDMA_ONCE = 0xcb
WIN_WRITEDMA_QUEUED = 0xcc
WIN_WRITEDMA_QUEUED_EXT = 0x36
WIN_WRITE_BUFFER = 0xe8
WIN_WRITE_EXT = 0x34
WIN_WRITE_LONG = 0x32
WIN_WRITE_LONG_ONCE = 0x33
WIN_WRITE_ONCE = 0x31
WIN_WRITE_SAME = 0xe9
WIN_WRITE_VERIFY = 0x3c
WNOHANG = 0x1
WNOTHREAD = 0x20000000
WNOWAIT = 0x1000000
WORDSIZE = 0x40
WSTOPPED = 0x2
WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4000
XDP_COPY = 0x2
XDP_FLAGS_DRV_MODE = 0x4
XDP_FLAGS_HW_MODE = 0x8
XDP_FLAGS_MASK = 0xf
XDP_FLAGS_MODES = 0xe
XDP_FLAGS_SKB_MODE = 0x2
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
XDP_MMAP_OFFSETS = 0x1
XDP_OPTIONS = 0x8
XDP_OPTIONS_ZEROCOPY = 0x1
XDP_PACKET_HEADROOM = 0x100
XDP_PGOFF_RX_RING = 0x0
XDP_PGOFF_TX_RING = 0x80000000
XDP_RING_NEED_WAKEUP = 0x1
XDP_RX_RING = 0x2
XDP_SHARED_UMEM = 0x1
XDP_STATISTICS = 0x7
XDP_TX_RING = 0x3
XDP_UMEM_COMPLETION_RING = 0x6
XDP_UMEM_FILL_RING = 0x5
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
XDP_UMEM_REG = 0x4
XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
XDP_USE_NEED_WAKEUP = 0x8
XDP_ZEROCOPY = 0x4
XENFS_SUPER_MAGIC = 0xabba1974
XFS_SUPER_MAGIC = 0x58465342
XTABS = 0xc00
Z3FOLD_MAGIC = 0x33
ZSMALLOC_MAGIC = 0x58295829
)
// Errors
const (
E2BIG = syscall.Errno(0x7)
EACCES = syscall.Errno(0xd)
EADDRINUSE = syscall.Errno(0x62)
EADDRNOTAVAIL = syscall.Errno(0x63)
EADV = syscall.Errno(0x44)
EAFNOSUPPORT = syscall.Errno(0x61)
EAGAIN = syscall.Errno(0xb)
EALREADY = syscall.Errno(0x72)
EBADE = syscall.Errno(0x34)
EBADF = syscall.Errno(0x9)
EBADFD = syscall.Errno(0x4d)
EBADMSG = syscall.Errno(0x4a)
EBADR = syscall.Errno(0x35)
EBADRQC = syscall.Errno(0x38)
EBADSLT = syscall.Errno(0x39)
EBFONT = syscall.Errno(0x3b)
EBUSY = syscall.Errno(0x10)
ECANCELED = syscall.Errno(0x7d)
ECHILD = syscall.Errno(0xa)
ECHRNG = syscall.Errno(0x2c)
ECOMM = syscall.Errno(0x46)
ECONNABORTED = syscall.Errno(0x67)
ECONNREFUSED = syscall.Errno(0x6f)
ECONNRESET = syscall.Errno(0x68)
EDEADLK = syscall.Errno(0x23)
EDEADLOCK = syscall.Errno(0x3a)
EDESTADDRREQ = syscall.Errno(0x59)
EDOM = syscall.Errno(0x21)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EEXIST = syscall.Errno(0x11)
EFAULT = syscall.Errno(0xe)
EFBIG = syscall.Errno(0x1b)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
EIDRM = syscall.Errno(0x2b)
EILSEQ = syscall.Errno(0x54)
EINPROGRESS = syscall.Errno(0x73)
EINTR = syscall.Errno(0x4)
EINVAL = syscall.Errno(0x16)
EIO = syscall.Errno(0x5)
EISCONN = syscall.Errno(0x6a)
EISDIR = syscall.Errno(0x15)
EISNAM = syscall.Errno(0x78)
EKEYEXPIRED = syscall.Errno(0x7f)
EKEYREJECTED = syscall.Errno(0x81)
EKEYREVOKED = syscall.Errno(0x80)
EL2HLT = syscall.Errno(0x33)
EL2NSYNC = syscall.Errno(0x2d)
EL3HLT = syscall.Errno(0x2e)
EL3RST = syscall.Errno(0x2f)
ELIBACC = syscall.Errno(0x4f)
ELIBBAD = syscall.Errno(0x50)
ELIBEXEC = syscall.Errno(0x53)
ELIBMAX = syscall.Errno(0x52)
ELIBSCN = syscall.Errno(0x51)
ELNRNG = syscall.Errno(0x30)
ELOOP = syscall.Errno(0x28)
EMEDIUMTYPE = syscall.Errno(0x7c)
EMFILE = syscall.Errno(0x18)
EMLINK = syscall.Errno(0x1f)
EMSGSIZE = syscall.Errno(0x5a)
EMULTIHOP = syscall.Errno(0x48)
ENAMETOOLONG = syscall.Errno(0x24)
ENAVAIL = syscall.Errno(0x77)
ENETDOWN = syscall.Errno(0x64)
ENETRESET = syscall.Errno(0x66)
ENETUNREACH = syscall.Errno(0x65)
ENFILE = syscall.Errno(0x17)
ENOANO = syscall.Errno(0x37)
ENOBUFS = syscall.Errno(0x69)
ENOCSI = syscall.Errno(0x32)
ENODATA = syscall.Errno(0x3d)
ENODEV = syscall.Errno(0x13)
ENOENT = syscall.Errno(0x2)
ENOEXEC = syscall.Errno(0x8)
ENOKEY = syscall.Errno(0x7e)
ENOLCK = syscall.Errno(0x25)
ENOLINK = syscall.Errno(0x43)
ENOMEDIUM = syscall.Errno(0x7b)
ENOMEM = syscall.Errno(0xc)
ENOMSG = syscall.Errno(0x2a)
ENONET = syscall.Errno(0x40)
ENOPKG = syscall.Errno(0x41)
ENOPROTOOPT = syscall.Errno(0x5c)
ENOSPC = syscall.Errno(0x1c)
ENOSR = syscall.Errno(0x3f)
ENOSTR = syscall.Errno(0x3c)
ENOSYS = syscall.Errno(0x26)
ENOTBLK = syscall.Errno(0xf)
ENOTCONN = syscall.Errno(0x6b)
ENOTDIR = syscall.Errno(0x14)
ENOTEMPTY = syscall.Errno(0x27)
ENOTNAM = syscall.Errno(0x76)
ENOTRECOVERABLE = syscall.Errno(0x83)
ENOTSOCK = syscall.Errno(0x58)
ENOTSUP = syscall.Errno(0x5f)
ENOTTY = syscall.Errno(0x19)
ENOTUNIQ = syscall.Errno(0x4c)
ENXIO = syscall.Errno(0x6)
EOPNOTSUPP = syscall.Errno(0x5f)
EOVERFLOW = syscall.Errno(0x4b)
EOWNERDEAD = syscall.Errno(0x82)
EPERM = syscall.Errno(0x1)
EPFNOSUPPORT = syscall.Errno(0x60)
EPIPE = syscall.Errno(0x20)
EPROTO = syscall.Errno(0x47)
EPROTONOSUPPORT = syscall.Errno(0x5d)
EPROTOTYPE = syscall.Errno(0x5b)
ERANGE = syscall.Errno(0x22)
EREMCHG = syscall.Errno(0x4e)
EREMOTE = syscall.Errno(0x42)
EREMOTEIO = syscall.Errno(0x79)
ERESTART = syscall.Errno(0x55)
ERFKILL = syscall.Errno(0x84)
EROFS = syscall.Errno(0x1e)
ESHUTDOWN = syscall.Errno(0x6c)
ESOCKTNOSUPPORT = syscall.Errno(0x5e)
ESPIPE = syscall.Errno(0x1d)
ESRCH = syscall.Errno(0x3)
ESRMNT = syscall.Errno(0x45)
ESTALE = syscall.Errno(0x74)
ESTRPIPE = syscall.Errno(0x56)
ETIME = syscall.Errno(0x3e)
ETIMEDOUT = syscall.Errno(0x6e)
ETOOMANYREFS = syscall.Errno(0x6d)
ETXTBSY = syscall.Errno(0x1a)
EUCLEAN = syscall.Errno(0x75)
EUNATCH = syscall.Errno(0x31)
EUSERS = syscall.Errno(0x57)
EWOULDBLOCK = syscall.Errno(0xb)
EXDEV = syscall.Errno(0x12)
EXFULL = syscall.Errno(0x36)
)
// Signals
const (
SIGABRT = syscall.Signal(0x6)
SIGALRM = syscall.Signal(0xe)
SIGBUS = syscall.Signal(0x7)
SIGCHLD = syscall.Signal(0x11)
SIGCLD = syscall.Signal(0x11)
SIGCONT = syscall.Signal(0x12)
SIGFPE = syscall.Signal(0x8)
SIGHUP = syscall.Signal(0x1)
SIGILL = syscall.Signal(0x4)
SIGINT = syscall.Signal(0x2)
SIGIO = syscall.Signal(0x1d)
SIGIOT = syscall.Signal(0x6)
SIGKILL = syscall.Signal(0x9)
SIGPIPE = syscall.Signal(0xd)
SIGPOLL = syscall.Signal(0x1d)
SIGPROF = syscall.Signal(0x1b)
SIGPWR = syscall.Signal(0x1e)
SIGQUIT = syscall.Signal(0x3)
SIGSEGV = syscall.Signal(0xb)
SIGSTKFLT = syscall.Signal(0x10)
SIGSTOP = syscall.Signal(0x13)
SIGSYS = syscall.Signal(0x1f)
SIGTERM = syscall.Signal(0xf)
SIGTRAP = syscall.Signal(0x5)
SIGTSTP = syscall.Signal(0x14)
SIGTTIN = syscall.Signal(0x15)
SIGTTOU = syscall.Signal(0x16)
SIGURG = syscall.Signal(0x17)
SIGUSR1 = syscall.Signal(0xa)
SIGUSR2 = syscall.Signal(0xc)
SIGVTALRM = syscall.Signal(0x1a)
SIGWINCH = syscall.Signal(0x1c)
SIGXCPU = syscall.Signal(0x18)
SIGXFSZ = syscall.Signal(0x19)
)
// Error table
var errorList = [...]struct {
num syscall.Errno
name string
desc string
}{
{1, "EPERM", "operation not permitted"},
{2, "ENOENT", "no such file or directory"},
{3, "ESRCH", "no such process"},
{4, "EINTR", "interrupted system call"},
{5, "EIO", "input/output error"},
{6, "ENXIO", "no such device or address"},
{7, "E2BIG", "argument list too long"},
{8, "ENOEXEC", "exec format error"},
{9, "EBADF", "bad file descriptor"},
{10, "ECHILD", "no child processes"},
{11, "EAGAIN", "resource temporarily unavailable"},
{12, "ENOMEM", "cannot allocate memory"},
{13, "EACCES", "permission denied"},
{14, "EFAULT", "bad address"},
{15, "ENOTBLK", "block device required"},
{16, "EBUSY", "device or resource busy"},
{17, "EEXIST", "file exists"},
{18, "EXDEV", "invalid cross-device link"},
{19, "ENODEV", "no such device"},
{20, "ENOTDIR", "not a directory"},
{21, "EISDIR", "is a directory"},
{22, "EINVAL", "invalid argument"},
{23, "ENFILE", "too many open files in system"},
{24, "EMFILE", "too many open files"},
{25, "ENOTTY", "inappropriate ioctl for device"},
{26, "ETXTBSY", "text file busy"},
{27, "EFBIG", "file too large"},
{28, "ENOSPC", "no space left on device"},
{29, "ESPIPE", "illegal seek"},
{30, "EROFS", "read-only file system"},
{31, "EMLINK", "too many links"},
{32, "EPIPE", "broken pipe"},
{33, "EDOM", "numerical argument out of domain"},
{34, "ERANGE", "numerical result out of range"},
{35, "EDEADLK", "resource deadlock avoided"},
{36, "ENAMETOOLONG", "file name too long"},
{37, "ENOLCK", "no locks available"},
{38, "ENOSYS", "function not implemented"},
{39, "ENOTEMPTY", "directory not empty"},
{40, "ELOOP", "too many levels of symbolic links"},
{42, "ENOMSG", "no message of desired type"},
{43, "EIDRM", "identifier removed"},
{44, "ECHRNG", "channel number out of range"},
{45, "EL2NSYNC", "level 2 not synchronized"},
{46, "EL3HLT", "level 3 halted"},
{47, "EL3RST", "level 3 reset"},
{48, "ELNRNG", "link number out of range"},
{49, "EUNATCH", "protocol driver not attached"},
{50, "ENOCSI", "no CSI structure available"},
{51, "EL2HLT", "level 2 halted"},
{52, "EBADE", "invalid exchange"},
{53, "EBADR", "invalid request descriptor"},
{54, "EXFULL", "exchange full"},
{55, "ENOANO", "no anode"},
{56, "EBADRQC", "invalid request code"},
{57, "EBADSLT", "invalid slot"},
{58, "EDEADLOCK", "file locking deadlock error"},
{59, "EBFONT", "bad font file format"},
{60, "ENOSTR", "device not a stream"},
{61, "ENODATA", "no data available"},
{62, "ETIME", "timer expired"},
{63, "ENOSR", "out of streams resources"},
{64, "ENONET", "machine is not on the network"},
{65, "ENOPKG", "package not installed"},
{66, "EREMOTE", "object is remote"},
{67, "ENOLINK", "link has been severed"},
{68, "EADV", "advertise error"},
{69, "ESRMNT", "srmount error"},
{70, "ECOMM", "communication error on send"},
{71, "EPROTO", "protocol error"},
{72, "EMULTIHOP", "multihop attempted"},
{73, "EDOTDOT", "RFS specific error"},
{74, "EBADMSG", "bad message"},
{75, "EOVERFLOW", "value too large for defined data type"},
{76, "ENOTUNIQ", "name not unique on network"},
{77, "EBADFD", "file descriptor in bad state"},
{78, "EREMCHG", "remote address changed"},
{79, "ELIBACC", "can not access a needed shared library"},
{80, "ELIBBAD", "accessing a corrupted shared library"},
{81, "ELIBSCN", ".lib section in a.out corrupted"},
{82, "ELIBMAX", "attempting to link in too many shared libraries"},
{83, "ELIBEXEC", "cannot exec a shared library directly"},
{84, "EILSEQ", "invalid or incomplete multibyte or wide character"},
{85, "ERESTART", "interrupted system call should be restarted"},
{86, "ESTRPIPE", "streams pipe error"},
{87, "EUSERS", "too many users"},
{88, "ENOTSOCK", "socket operation on non-socket"},
{89, "EDESTADDRREQ", "destination address required"},
{90, "EMSGSIZE", "message too long"},
{91, "EPROTOTYPE", "protocol wrong type for socket"},
{92, "ENOPROTOOPT", "protocol not available"},
{93, "EPROTONOSUPPORT", "protocol not supported"},
{94, "ESOCKTNOSUPPORT", "socket type not supported"},
{95, "ENOTSUP", "operation not supported"},
{96, "EPFNOSUPPORT", "protocol family not supported"},
{97, "EAFNOSUPPORT", "address family not supported by protocol"},
{98, "EADDRINUSE", "address already in use"},
{99, "EADDRNOTAVAIL", "cannot assign requested address"},
{100, "ENETDOWN", "network is down"},
{101, "ENETUNREACH", "network is unreachable"},
{102, "ENETRESET", "network dropped connection on reset"},
{103, "ECONNABORTED", "software caused connection abort"},
{104, "ECONNRESET", "connection reset by peer"},
{105, "ENOBUFS", "no buffer space available"},
{106, "EISCONN", "transport endpoint is already connected"},
{107, "ENOTCONN", "transport endpoint is not connected"},
{108, "ESHUTDOWN", "cannot send after transport endpoint shutdown"},
{109, "ETOOMANYREFS", "too many references: cannot splice"},
{110, "ETIMEDOUT", "connection timed out"},
{111, "ECONNREFUSED", "connection refused"},
{112, "EHOSTDOWN", "host is down"},
{113, "EHOSTUNREACH", "no route to host"},
{114, "EALREADY", "operation already in progress"},
{115, "EINPROGRESS", "operation now in progress"},
{116, "ESTALE", "stale file handle"},
{117, "EUCLEAN", "structure needs cleaning"},
{118, "ENOTNAM", "not a XENIX named type file"},
{119, "ENAVAIL", "no XENIX semaphores available"},
{120, "EISNAM", "is a named type file"},
{121, "EREMOTEIO", "remote I/O error"},
{122, "EDQUOT", "disk quota exceeded"},
{123, "ENOMEDIUM", "no medium found"},
{124, "EMEDIUMTYPE", "wrong medium type"},
{125, "ECANCELED", "operation canceled"},
{126, "ENOKEY", "required key not available"},
{127, "EKEYEXPIRED", "key has expired"},
{128, "EKEYREVOKED", "key has been revoked"},
{129, "EKEYREJECTED", "key was rejected by service"},
{130, "EOWNERDEAD", "owner died"},
{131, "ENOTRECOVERABLE", "state not recoverable"},
{132, "ERFKILL", "operation not possible due to RF-kill"},
{133, "EHWPOISON", "memory page has hardware error"},
}
// Signal table
var signalList = [...]struct {
num syscall.Signal
name string
desc string
}{
{1, "SIGHUP", "hangup"},
{2, "SIGINT", "interrupt"},
{3, "SIGQUIT", "quit"},
{4, "SIGILL", "illegal instruction"},
{5, "SIGTRAP", "trace/breakpoint trap"},
{6, "SIGABRT", "aborted"},
{7, "SIGBUS", "bus error"},
{8, "SIGFPE", "floating point exception"},
{9, "SIGKILL", "killed"},
{10, "SIGUSR1", "user defined signal 1"},
{11, "SIGSEGV", "segmentation fault"},
{12, "SIGUSR2", "user defined signal 2"},
{13, "SIGPIPE", "broken pipe"},
{14, "SIGALRM", "alarm clock"},
{15, "SIGTERM", "terminated"},
{16, "SIGSTKFLT", "stack fault"},
{17, "SIGCHLD", "child exited"},
{18, "SIGCONT", "continued"},
{19, "SIGSTOP", "stopped (signal)"},
{20, "SIGTSTP", "stopped"},
{21, "SIGTTIN", "stopped (tty input)"},
{22, "SIGTTOU", "stopped (tty output)"},
{23, "SIGURG", "urgent I/O condition"},
{24, "SIGXCPU", "CPU time limit exceeded"},
{25, "SIGXFSZ", "file size limit exceeded"},
{26, "SIGVTALRM", "virtual timer expired"},
{27, "SIGPROF", "profiling timer expired"},
{28, "SIGWINCH", "window changed"},
{29, "SIGIO", "I/O possible"},
{30, "SIGPWR", "power failure"},
{31, "SIGSYS", "bad system call"},
}
| apache-2.0 |
ricepanda/rice-git2 | rice-middleware/web/src/main/webapp/rice-portal/css/portal.css | 14214 | /**
* Copyright 2005-2014 The Kuali Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ecl2.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
body
{
font-size: 71%;
margin: 0;
background-color: #a02919;
}
form { margin: 0; }
li, td, div, th, table, span, body {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
table
{
margin-top: 0px;
margin: 0px;
padding: 0px;
font-size: 100%;
}
a:link
{
text-decoration: underline;
color: #000000;
}
a:visited
{
text-decoration: underline;
color: #000000;
}
a:hover
{
color: #990000;
text-decoration: underline;
}
a:active
{
color: #333333;
text-decoration: underline;
}
.alignright
{
margin-top: 0;
text-align: right;
}
.small { font-size: .9em; }
#portchancont table
{
}
#portchancont td
{
padding-left: 12px;
}
#topcontrols
{
position: absolute;
top: 0;
right: 0;
text-align: right;
background-image: url("../images/topcontrolback.gif");
background-repeat: no-repeat;
height: 22px;
padding-left: 60px;
padding-right: 20px;
padding-top: 3px;
}
#topcontrols input.loginbox
{
border: 1px solid #666666;
height: 14px;
font-size: 80%;
background-color: #FBF8E0;
margin: 0;
padding: 0;
vertical-align: top;
}
#topcontrols input.loginbutton
{
border: none;
background-color: #FBF8E0;
margin: 0;
padding: 0;
vertical-align: middle;
}
#topcontrols a:link
{
color: #000000;
text-decoration: none;
}
#topcontrols a:visited
{
color: #000000;
text-decoration: none;
}
#topcontrols a:hover
{
color: #990000;
text-decoration: underline;
}
#topcontrols a:active
{
color: #333333;
text-decoration: underline;
}
#search
{
position: absolute;
top: 70px;
right: 0;
text-align: right;
background-image: url("../images/searchback.gif");
height: 38px;
background-repeat: no-repeat;
padding-right: 10px;
padding-left: 60px;
font-size: 10px;
color: #FFFFFF;
padding-top: 8px;
}
#search input
{
border: 1px solid #480000;
font-size: 10px;
background-color: #FFFFCC;
}
#search select
{
border: 1px solid #480000;
font-size: 10px;
background-color: #FFFFCC;
}
#search input.loginbox
{
border: 1px solid #666666;
font-size: 10px;
background-color: #FBF8E0;
margin: 0;
padding: 0;
vertical-align: top;
height: 16px;
}
#search input.go
{
font-size: 10px;
background-color: #BA3B25;
font-weight: bold;
color: #FFFFFF;
border-top: 1px solid #FF7979;
border-right: 2px solid #761818;
border-bottom: 2px solid #761818;
border-left: 1px solid #FF7979;
}
/*******************************************************************************
Positioning rules
*******************************************************************************/
#login-info
{
height: 12px;
position: absolute;
top: 87px;
right: 260px;
color: #990000;
}
#build
{
height: 12px;
position: absolute;
top: 47px;
right: 20px;
color: #999999;
}
#feedback
{
height: 12px;
position: absolute;
top: 10px;
right: 10px;
font-weight: bold;
color: #999999;
}
#header
{
height: 70px;
background-image: url("../images/headerback.gif");
color: #FFFFFF;
font-size: 1.5em;
}
#header span { display: none; }
#header h1.headerImage
{
background-image: url("../images/logo-krice.png");
margin: 0px;
padding: 0px;
height:70px;
width: 221px;
position: absolute;
left: 0px;
top: 0px;
}
div.header2
{
background-image: url("../images/head2-back.gif");
background-color: #F4D9D8;
background-repeat: repeat-x;
height: 38px;
}
div.header2-left
{
background-image: url("../images/header2-left.gif");
height: 38px;
background-repeat: no-repeat;
}
div.header2-left-focus
{
background-image: url("../images/header2-left-focus.gif");
height: 38px;
background-repeat: no-repeat;
}
div.breadcrumb
{
font-family: "Arial Narrow";
font-size: 16px;
position: absolute;
left: 182px;
top: 65px;
color: #000000;
font-weight: bold;
}
div.breadcrumb-focus
{
position: absolute;
left: 28px;
top: 84px;
color: #000000;
font-weight: bold;
}
div.tabposition
{
position: absolute;
top: 48px;
left: 210px;
width: 200px;
white-space: nowrap;
}
#tabs
{
float: left;
font-size: 93%;
line-height: normal;
white-space: nowrap;
width: 800px;
}
#tabs ul
{
margin: 0;
padding: 0px 0px 0;
list-style: none;
white-space: nowrap;
}
#tabs li.red
{
background: url("../images/left-red.gif") no-repeat left top;
margin: 0px 3px;
padding: 0px 0px 0px 9px;
float: left;
white-space: nowrap;
}
#tabs a.red
{
float: left;
display: block;
background: url("../images/right-red.gif") no-repeat right top;
padding: 5px 9px 4px 0px;
text-decoration: none;
font-weight: bold;
color: #FFFFFF;
}
#tabs li.green
{
background: url("../images/left-tan.gif") no-repeat left top;
margin: 0 3px;
padding: 0 0 0 9px;
float: left;
}
#tabs a.green
{
float: left;
display: block;
background: url("../images/right-tan.gif") no-repeat right top;
padding: 5px 9px 4px 0px;
text-decoration: none;
font-weight: bold;
color: #333333;
}
/* Commented Backslash Hack
hides rule from IE5-Mac \*/
#tabs a
{
float: none;
white-space: nowrap;
}
/* End IE5-Mac hack */
#tabs a:hover
{
color: #333333;
text-decoration: underline;
}
#tabs #current { background-image: url("../images/left_on.gif"); }
#tabs #current a
{
background-image: url("../images/right_on.gif");
color: #333;
padding-bottom: 5px;
}
#subtabs { background-color: #99FF99; }
h1, h2
{
margin: 0;
font-size: 100%;
}
.footerbevel
{
background-image: url(../images/bl-bevel-focus.gif);
height: 27px;
}
#footer-copyright
{
background-color: #a02919;
color: #fff;
bottom: 0px;
width: 100%;
text-align: center;
background-image: url("../images/os-guy.gif");
padding-top: 20px;
padding-bottom: 12px;
background-repeat: no-repeat;
background-position: right 5px;
height: 60px;
}
#footer-copyright a:link
{
color: #FFFFFF;
text-decoration: underline;
}
#footer-copyright a:visited
{
color: #FFFFFF;
text-decoration: underline;
}
#footer-copyright a:hover
{
color: #000000;
text-decoration: underline;
}
#footer-copyright a:active
{
color: #000000;
text-decoration: underline;
}
#footer-nav
{
background-image: url("../images/leftback.gif");
background-repeat: no-repeat;
height: 20px;
background-color: #FFFFFF;
}
#footer-nav-focus
{
background-image: url("../images/bl-bevel-focus.gif");
background-repeat: no-repeat;
height: 20px;
background-color: #FFFFFF;
background-position: left bottom;
}
#footer-nav a:link
{
color: #000000;
text-decoration: none;
}
#footer-nav a:visited
{
color: #000000;
text-decoration: none;
}
#footer-nav a:hover
{
color: #990000;
text-decoration: underline;
}
#footer-nav a:active
{
color: #333333;
text-decoration: underline;
}
#footer-nav-focus a:link
{
color: #000000;
text-decoration: none;
}
#footer-nav-focus a:visited
{
color: #000000;
text-decoration: none;
}
#footer-nav-focus a:hover
{
color: #990000;
text-decoration: underline;
}
#footer-nav-focus a:active
{
color: #333333;
text-decoration: underline;
}
div.leftswoop
{
background: url("../images/subnav-left.gif") no-repeat left top;
padding: 0 0 0 9px;
float: left;
position: relative;
left: 40%;
right: 60%;
bottom: 2px;
}
html>body div.leftswoop
{
background: url("../images/subnav-left.gif") no-repeat left top;
padding: 0 0 0 9px;
float: left;
position: relative;
left: 40%;
right: 60%;
bottom: 3px;
}
span.rightswoop
{
float: left;
display: block;
background: url("../images/subnav-right.gif") no-repeat right top;
padding: 5px 15px 4px 6px;
text-decoration: none;
font-weight: bold;
}
.centerfootnav { width: 300px; }
div#leftbox
{
left: 0px;
padding-top: 0px;
margin: 0;
width: 169px;
}
.leftback { background-image: url("../images/leftback.gif"); }
.leftback-focus { background-image: url("../images/leftback-focus.gif"); }
td.content { padding-bottom: 40px; }
#middlebox
{
margin: 0px 0px 0px 169px;
background-color: #FFFFFF;
}
div#rightbox
{
position: absolute;
right: 0px;
width: 30%;
background-color: #FFFFFF;
}
/** 'portlet' block **/
#portlets-left-column
{
margin: 0 0 0 12px;
padding: 0;
width: 49%;
float: left;
}
#portlets-right-column
{
margin: 0 12px 0 0;
padding: 0;
width: 50%;
float: right;
}
.portlet
{
margin: 20px 10px 0px;
padding: 0px;
border: 1px solid #999999;
}
.portlet-iframe
{
margin: 0px;
padding: 0px;
border: 1px solid #999999;
}
.portlet .header
{
padding-left: 0.25em;
background-color: #E5E5E5;
height: 22px;
background-image: url("../images/chanhead-back.gif");
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999999;
font-family: "Arial Narrow";
font-size: 14px;
color: #990000;
text-align: left;
}
.portlet .header h2
{
margin: 0px;
padding: 0px;
font-size: 100%;
float: left;
white-space: nowrap;
}
.portlet .header span
{
width: 16px;
height: 16px;
float: right;
}
.portlet-nav { float: left; }
#navcontainer
{
margin: 0px;
padding: 0px;
width: 169px;
}
#navcontainer ul
{
list-style-type: none;
margin: 0;
padding: 0;
}
#navcontainer li
{
list-style-type: none;
margin: 0;
padding: 0;
}
#navcontainer a
{
display: block;
padding: 4px 0px 4px 12px;
width: 169px;
border-bottom: 1px solid #333333;
background-image: url("../images/subnav-back.gif");
background-position: right;
text-decoration: none;
color: #FFFFFF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
html>body #navcontainer a
{
display: block;
padding: 4px 0px 4px 12px;
width: 157px;
border-bottom: 1px solid #333333;
background-image: url("../images/subnav-back.gif");
background-position: right;
text-decoration: none;
color: #FFFFFF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
#navcontainer a.current
{
display: block;
padding: 4px 0px 4px 12px;
width: 169px;
border-bottom: 1px solid #333333;
background-image: url("../images/subnav-back1.gif");
background-position: right;
text-decoration: none;
color: #000000;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
font-weight: bold;
}
html>body #navcontainer a.current
{
display: block;
padding: 4px 0px 4px 12px;
width: 157px;
border-bottom: 1px solid #333333;
background-image: url("../images/subnav-back1.gif");
background-position: right;
text-decoration: none;
color: #000000;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
font-weight: bold;
}
#navcontainer a:link, #navlist a:visited
{
color: #EEE;
text-decoration: none;
}
#navcontainer a:hover
{
background-image: url("../images/subnav-back1.gif");
color: #000000;
}
#misclinks
{
padding-top: 30px;
padding-left: 8px;
}
#misclinks li { list-style-image: url("../images/bullet.gif"); }
#misclinks a:link
{
color: #000000;
text-decoration: none;
}
#misclinks a:visited
{
color: #000000;
text-decoration: none;
}
#misclinks a:hover
{
color: #990000;
text-decoration: underline;
}
#misclinks a:active
{
color: #333333;
text-decoration: underline;
}
/** 'portlet' block: portlet mode and window state controls **/
div.portlet-head { height: 40px; }
div.portlet-title {
float: left;
padding: 3px;
}
h2.portlet-title
{
font-family: "Arial Narrow";
font-size: 16px;
margin-right: 10px;
margin-left: 10px;
margin-top: 20px;
margin-bottom: 10px;
color: #8D2C1B;
white-space: nowrap;
}
div.portlet-modify
{
float: right;
margin-right: 10px;
margin-left: 10px;
margin-top: 20px;
margin-bottom: 10px;
}
.dddlist
{
width: 68px;
font-size: 10px;
background-color: #e5e5e5;
height: 14px;
border: 1px solid #999999;
float: right;
}
.portlet .body { padding: 10px; }
.portlet .header span.min { background: url(../images/min.png) no-repeat; }
.portlet .header span.max { background: url(../images/max.png) no-repeat; }
.portlet .header span.norm { background: url(../images/norm.png) no-repeat; }
.portlet .header span.view { background: url(../images/view.png) no-repeat; }
.portlet .header span.edit { background: url(../images/edit.png) no-repeat; }
.portlet .header span.help { background: url(../images/help.png) no-repeat; }
.bord-lb {
border-bottom-width: 1px;
border-left-width: 1px;
border-bottom-style: solid;
border-left-style: solid;
border-bottom-color: #A8B2BC;
border-left-color: #A8B2BC;
}
.bord-rt {
border-top-width: 1px;
border-right-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-top-color: #A8B2BC;
border-right-color: #A8B2BC;
}
ul.chan {
padding-left: 15px;
padding-top: 10px;
padding-bottom: 10px;
}
ul {
margin: 0px;
padding: 0px;
}
#iframe_portlet_container_div {
background-color: #FFFFFF;
background-image: url('../images/leftback-focus.gif');
background-repeat: repeat-y;
/* padding left 15px simulates previous table layout spacing */
padding: 0px 0px 0px 15px;
}
div.blockOverlay{
background-color: black;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60) !important;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)" !important;
opacity:.60;
-moz-opacity:.60;
z-index: 10100 !important;
}
div.blockElement{
padding: 0;
margin: 0;
top: 40%;
left: 0;
background-color: white;
textAlign: center;
color: #000;
border: 3px solid #aaa;
cursor: wait;
z-index: 10101 !important;
}
div.blockPage{
padding: 0;
margin: 0;
width: 30%;
top: 40%;
left: 35%;
textAlign: center;
color: #000;
border: 3px solid #aaa;
background-color: white;
cursor: wait;
z-index: 10101 !important;
text-align: center;
}
.overlay-fixed{
opacity: 0.4 !important;
} | apache-2.0 |
adelez/grpc | test/core/end2end/fixtures/h2_fakesec.cc | 5455 | /*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "test/core/end2end/end2end_tests.h"
#include <stdio.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct fullstack_secure_fixture_data {
char* localaddr;
} fullstack_secure_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data* ffd =
static_cast<fullstack_secure_fixture_data*>(
gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
f.cq = grpc_completion_queue_create_for_next(nullptr);
f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
return f;
}
static void process_auth_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* md, size_t md_count,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args,
grpc_channel_credentials* creds) {
fullstack_secure_fixture_data* ffd =
static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client != nullptr);
grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* server_args,
grpc_server_credentials* server_creds) {
fullstack_secure_fixture_data* ffd =
static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
if (f->server) {
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
fullstack_secure_fixture_data* ffd =
static_cast<fullstack_secure_fixture_data*>(f->fixture_data);
gpr_free(ffd->localaddr);
gpr_free(ffd);
}
static void chttp2_init_client_fake_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
grpc_channel_credentials* fake_ts_creds =
grpc_fake_transport_security_credentials_create();
chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds);
}
static int fail_server_auth_check(grpc_channel_args* server_args) {
size_t i;
if (server_args == nullptr) return 0;
for (i = 0; i < server_args->num_args; i++) {
if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
0) {
return 1;
}
}
return 0;
}
static void chttp2_init_server_fake_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* server_args) {
grpc_server_credentials* fake_ts_creds =
grpc_fake_transport_security_server_credentials_create();
if (fail_server_auth_check(server_args)) {
grpc_auth_metadata_processor processor = {process_auth_failure, nullptr,
nullptr};
grpc_server_credentials_set_auth_metadata_processor(fake_ts_creds,
processor);
}
chttp2_init_server_secure_fullstack(f, server_args, fake_ts_creds);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
{"chttp2/fake_secure_fullstack",
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS |
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
chttp2_create_fixture_secure_fullstack,
chttp2_init_client_fake_secure_fullstack,
chttp2_init_server_fake_secure_fullstack,
chttp2_tear_down_secure_fullstack},
};
int main(int argc, char** argv) {
size_t i;
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(argc, argv, configs[i]);
}
grpc_shutdown();
return 0;
}
| apache-2.0 |
johnnyrich0617/Camel-Tut | chapter8/routingslip/src/test/java/camelinaction/RoutingSlipTest.java | 2525 | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package camelinaction;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* An example how to use Routing Slip EIP.
* <p/>
* This example uses a bean to compute the initial routing slip
* which is used directly on the RoutingSlip EIP
*
* @version $Revision$
*/
public class RoutingSlipTest extends CamelTestSupport {
@Test
public void testRoutingSlip() throws Exception {
// setup expectations that only A and C will receive the message
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:b").expectedMessageCount(0);
getMockEndpoint("mock:c").expectedMessageCount(1);
// send the incoming message
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
@Test
public void testRoutingSlipCool() throws Exception {
// setup expectations that all will receive the message
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:b").expectedMessageCount(1);
getMockEndpoint("mock:c").expectedMessageCount(1);
template.sendBody("direct:start", "We are Cool");
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
// compute the routing slip at runtime using a bean
// use the routing slip EIP
.routingSlip().method(ComputeSlip.class);
}
};
}
}
| apache-2.0 |
dalaro/incubator-tinkerpop | gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java | 11573 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tinkerpop.gremlin.process.util;
import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.structure.PropertyType;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
import org.junit.Test;
import org.mockito.Mockito;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class TraversalHelperTest {
@Test
public void shouldNotFindStepOfClassInTraversal() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertThat(TraversalHelper.hasStepOfClass(FilterStep.class, traversal), is(false));
}
@Test
public void shouldFindStepOfClassInTraversal() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new IdentityStep<>(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertThat(TraversalHelper.hasStepOfClass(IdentityStep.class, traversal), is(true));
}
@Test
public void shouldNotFindStepOfAssignableClassInTraversal() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertThat(TraversalHelper.hasStepOfAssignableClass(IdentityStep.class, traversal), is(false));
}
@Test
public void shouldFindStepOfAssignableClassInTraversal() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertThat(TraversalHelper.hasStepOfAssignableClass(FilterStep.class, traversal), is(true));
}
@Test
public void shouldGetTheStepIndex() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
final HasStep hasStep = new HasStep(traversal);
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, hasStep);
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertEquals(1, TraversalHelper.stepIndex(hasStep, traversal));
}
@Test
public void shouldNotFindTheStepIndex() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
final IdentityStep identityStep = new IdentityStep(traversal);
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new HasStep(traversal));
assertEquals(-1, TraversalHelper.stepIndex(identityStep, traversal));
}
@Test
public void shouldInsertBeforeStep() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
final HasStep hasStep = new HasStep(traversal);
final IdentityStep identityStep = new IdentityStep(traversal);
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, hasStep);
traversal.asAdmin().addStep(0, new HasStep(traversal));
TraversalHelper.insertBeforeStep(identityStep, hasStep, traversal);
assertEquals(traversal.asAdmin().getSteps().get(1), identityStep);
assertEquals(4, traversal.asAdmin().getSteps().size());
}
@Test
public void shouldInsertAfterStep() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
final HasStep hasStep = new HasStep(traversal);
final IdentityStep identityStep = new IdentityStep(traversal);
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, hasStep);
traversal.asAdmin().addStep(0, new HasStep(traversal));
TraversalHelper.insertAfterStep(identityStep, hasStep, traversal);
assertEquals(traversal.asAdmin().getSteps().get(2), identityStep);
assertEquals(4, traversal.asAdmin().getSteps().size());
}
@Test
public void shouldReplaceStep() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
final HasStep hasStep = new HasStep(traversal);
final IdentityStep identityStep = new IdentityStep(traversal);
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, hasStep);
traversal.asAdmin().addStep(0, new HasStep(traversal));
TraversalHelper.replaceStep(hasStep, identityStep, traversal);
assertEquals(traversal.asAdmin().getSteps().get(1), identityStep);
assertEquals(3, traversal.asAdmin().getSteps().size());
}
@Test
public void shouldChainTogetherStepsWithNextPreviousInALinkedListStructure() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(new IdentityStep(traversal));
traversal.asAdmin().addStep(new HasStep(traversal));
traversal.asAdmin().addStep(new LambdaFilterStep(traversal, traverser -> true));
validateToyTraversal(traversal);
}
@Test
public void shouldAddStepsCorrectly() {
Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new LambdaFilterStep(traversal, traverser -> true));
traversal.asAdmin().addStep(0, new HasStep(traversal));
traversal.asAdmin().addStep(0, new IdentityStep(traversal));
validateToyTraversal(traversal);
traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(0, new IdentityStep(traversal));
traversal.asAdmin().addStep(1, new HasStep(traversal));
traversal.asAdmin().addStep(2, new LambdaFilterStep(traversal, traverser -> true));
validateToyTraversal(traversal);
}
@Test
public void shouldRemoveStepsCorrectly() {
final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
traversal.asAdmin().addStep(new IdentityStep(traversal));
traversal.asAdmin().addStep(new HasStep(traversal));
traversal.asAdmin().addStep(new LambdaFilterStep(traversal, traverser -> true));
traversal.asAdmin().addStep(new PropertiesStep(traversal, PropertyType.VALUE, "marko"));
traversal.asAdmin().removeStep(3);
validateToyTraversal(traversal);
traversal.asAdmin().addStep(0, new PropertiesStep(traversal, PropertyType.PROPERTY, "marko"));
traversal.asAdmin().removeStep(0);
validateToyTraversal(traversal);
traversal.asAdmin().removeStep(1);
traversal.asAdmin().addStep(1, new HasStep(traversal));
validateToyTraversal(traversal);
}
private static void validateToyTraversal(final Traversal traversal) {
assertEquals(traversal.asAdmin().getSteps().size(), 3);
assertEquals(IdentityStep.class, traversal.asAdmin().getSteps().get(0).getClass());
assertEquals(HasStep.class, traversal.asAdmin().getSteps().get(1).getClass());
assertEquals(LambdaFilterStep.class, traversal.asAdmin().getSteps().get(2).getClass());
// IDENTITY STEP
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(0)).getPreviousStep().getClass());
assertEquals(HasStep.class, ((Step) traversal.asAdmin().getSteps().get(0)).getNextStep().getClass());
assertEquals(LambdaFilterStep.class, ((Step) traversal.asAdmin().getSteps().get(0)).getNextStep().getNextStep().getClass());
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(0)).getNextStep().getNextStep().getNextStep().getClass());
// HAS STEP
assertEquals(IdentityStep.class, ((Step) traversal.asAdmin().getSteps().get(1)).getPreviousStep().getClass());
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(1)).getPreviousStep().getPreviousStep().getClass());
assertEquals(LambdaFilterStep.class, ((Step) traversal.asAdmin().getSteps().get(1)).getNextStep().getClass());
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(1)).getNextStep().getNextStep().getClass());
// FILTER STEP
assertEquals(HasStep.class, ((Step) traversal.asAdmin().getSteps().get(2)).getPreviousStep().getClass());
assertEquals(IdentityStep.class, ((Step) traversal.asAdmin().getSteps().get(2)).getPreviousStep().getPreviousStep().getClass());
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(2)).getPreviousStep().getPreviousStep().getPreviousStep().getClass());
assertEquals(EmptyStep.class, ((Step) traversal.asAdmin().getSteps().get(2)).getNextStep().getClass());
assertEquals(3, traversal.asAdmin().getSteps().size());
}
@Test
public void shouldTruncateLongName() {
Step s = Mockito.mock(Step.class);
Mockito.when(s.toString()).thenReturn("0123456789");
assertEquals("0123...", TraversalHelper.getShortName(s, 7));
}
}
| apache-2.0 |
MartinHjelmare/home-assistant | homeassistant/components/rpi_pfio/binary_sensor.py | 2581 | """Support for binary sensor using the PiFace Digital I/O module on a RPi."""
import logging
import voluptuous as vol
from homeassistant.components.binary_sensor import (
PLATFORM_SCHEMA, BinarySensorDevice)
from homeassistant.components import rpi_pfio
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
CONF_INVERT_LOGIC = 'invert_logic'
CONF_PORTS = 'ports'
CONF_SETTLE_TIME = 'settle_time'
DEFAULT_INVERT_LOGIC = False
DEFAULT_SETTLE_TIME = 20
PORT_SCHEMA = vol.Schema({
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_SETTLE_TIME, default=DEFAULT_SETTLE_TIME):
cv.positive_int,
vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_PORTS, default={}): vol.Schema({
cv.positive_int: PORT_SCHEMA,
})
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the PiFace Digital Input devices."""
binary_sensors = []
ports = config.get(CONF_PORTS)
for port, port_entity in ports.items():
name = port_entity.get(CONF_NAME)
settle_time = port_entity[CONF_SETTLE_TIME] / 1000
invert_logic = port_entity[CONF_INVERT_LOGIC]
binary_sensors.append(RPiPFIOBinarySensor(
hass, port, name, settle_time, invert_logic))
add_entities(binary_sensors, True)
rpi_pfio.activate_listener(hass)
class RPiPFIOBinarySensor(BinarySensorDevice):
"""Represent a binary sensor that a PiFace Digital Input."""
def __init__(self, hass, port, name, settle_time, invert_logic):
"""Initialize the RPi binary sensor."""
self._port = port
self._name = name or DEVICE_DEFAULT_NAME
self._invert_logic = invert_logic
self._state = None
def read_pfio(port):
"""Read state from PFIO."""
self._state = rpi_pfio.read_input(self._port)
self.schedule_update_ha_state()
rpi_pfio.edge_detect(hass, self._port, read_pfio, settle_time)
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def name(self):
"""Return the name of the sensor."""
return self._name
@property
def is_on(self):
"""Return the state of the entity."""
return self._state != self._invert_logic
def update(self):
"""Update the PFIO state."""
self._state = rpi_pfio.read_input(self._port)
| apache-2.0 |
gingerwizard/elasticsearch | x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/apikey/RestCreateApiKeyAction.java | 2255 | /*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.security.rest.action.apikey;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.xpack.core.security.action.CreateApiKeyRequest;
import org.elasticsearch.xpack.core.security.action.CreateApiKeyRequestBuilder;
import java.io.IOException;
import java.util.List;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestRequest.Method.PUT;
/**
* Rest action to create an API key
*/
public final class RestCreateApiKeyAction extends ApiKeyBaseRestHandler {
/**
* @param settings the node's settings
* @param licenseState the license state that will be used to determine if
* security is licensed
*/
public RestCreateApiKeyAction(Settings settings, XPackLicenseState licenseState) {
super(settings, licenseState);
}
@Override
public List<Route> routes() {
return List.of(
new Route(POST, "/_security/api_key"),
new Route(PUT, "/_security/api_key"));
}
@Override
public String getName() {
return "xpack_security_create_api_key";
}
@Override
protected RestChannelConsumer innerPrepareRequest(final RestRequest request, final NodeClient client) throws IOException {
String refresh = request.param("refresh");
CreateApiKeyRequestBuilder builder = new CreateApiKeyRequestBuilder(client)
.source(request.requiredContent(), request.getXContentType())
.setRefreshPolicy((refresh != null) ?
WriteRequest.RefreshPolicy.parse(request.param("refresh")) : CreateApiKeyRequest.DEFAULT_REFRESH_POLICY);
return channel -> builder.execute(new RestToXContentListener<>(channel));
}
}
| apache-2.0 |
ClusterHQ/docker | docs/sources/reference/api/docker_remote_api_v1.10.md | 31646 | page_title: Remote API v1.10
page_description: API Documentation for Docker
page_keywords: API, Docker, rcli, REST, documentation
# Docker Remote API v1.10
## 1. Brief introduction
- The Remote API has replaced rcli
- The daemon listens on `unix:///var/run/docker.sock` but you can bind
Docker to another host/port or a Unix socket.
- The API tends to be REST, but for some complex commands, like `attach`
or `pull`, the HTTP connection is hijacked to transport `stdout, stdin`
and `stderr`
# 2. Endpoints
## 2.1 Containers
### List containers
`GET /containers/json`
List containers
**Example request**:
GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"Id": "8dfafdbc3a40",
"Image": "base:latest",
"Command": "echo 1",
"Created": 1367854155,
"Status": "Exit 0",
"Ports":[{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
"SizeRw":12288,
"SizeRootFs":0
},
{
"Id": "9cd87474be90",
"Image": "base:latest",
"Command": "echo 222222",
"Created": 1367854155,
"Status": "Exit 0",
"Ports":[],
"SizeRw":12288,
"SizeRootFs":0
},
{
"Id": "3176a2479c92",
"Image": "base:latest",
"Command": "echo 3333333333333333",
"Created": 1367854154,
"Status": "Exit 0",
"Ports":[],
"SizeRw":12288,
"SizeRootFs":0
},
{
"Id": "4cb07b47f9fb",
"Image": "base:latest",
"Command": "echo 444444444444444444444444444444444",
"Created": 1367854152,
"Status": "Exit 0",
"Ports":[],
"SizeRw":12288,
"SizeRootFs":0
}
]
Query Parameters:
- **all** – 1/True/true or 0/False/false, Show all containers.
Only running containers are shown by default (i.e., this defaults to false)
- **limit** – Show `limit` last created containers, include non-running ones.
- **since** – Show only containers created since Id, include non-running ones.
- **before** – Show only containers created before Id, include non-running ones.
- **size** – 1/True/true or 0/False/false, Show the containers sizes
Status Codes:
- **200** – no error
- **400** – bad parameter
- **500** – server error
### Create a container
`POST /containers/create`
Create a container
**Example request**:
POST /containers/create HTTP/1.1
Content-Type: application/json
{
"Hostname":"",
"User":"",
"Memory":0,
"MemorySwap":0,
"AttachStdin":false,
"AttachStdout":true,
"AttachStderr":true,
"PortSpecs":null,
"Tty":false,
"OpenStdin":false,
"StdinOnce":false,
"Env":null,
"Cmd":[
"date"
],
"Image":"base",
"Volumes":{
"/tmp": {}
},
"WorkingDir":"",
"NetworkDisabled": false,
"ExposedPorts":{
"22/tcp": {}
}
}
**Example response**:
HTTP/1.1 201 Created
Content-Type: application/json
{
"Id":"e90e34656806"
"Warnings":[]
}
Json Parameters:
- **config** – the container's configuration
Query Parameters:
- **name** – Assign the specified name to the container. Mus
match `/?[a-zA-Z0-9_-]+`.
Status Codes:
- **201** – no error
- **404** – no such container
- **406** – impossible to attach (container not running)
- **500** – server error
### Inspect a container
`GET /containers/(id)/json`
Return low-level information on the container `id`
**Example request**:
GET /containers/4fa6e0f0c678/json HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
"Created": "2013-05-07T14:51:42.041847+02:00",
"Path": "date",
"Args": [],
"Config": {
"Hostname": "4fa6e0f0c678",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"PortSpecs": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Image": "base",
"Volumes": {},
"WorkingDir":""
},
"State": {
"Running": false,
"Pid": 0,
"ExitCode": 0,
"StartedAt": "2013-05-07T14:51:42.087658+02:01360",
"Ghost": false
},
"Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"NetworkSettings": {
"IpAddress": "",
"IpPrefixLen": 0,
"Gateway": "",
"Bridge": "",
"PortMapping": null
},
"SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
"ResolvConfPath": "/etc/resolv.conf",
"Volumes": {},
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Privileged": false,
"PortBindings": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "49153"
}
]
},
"Links": null,
"PublishAllPorts": false
}
}
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### List processes running inside a container
`GET /containers/(id)/top`
List processes running inside the container `id`
**Example request**:
GET /containers/4fa6e0f0c678/top HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{
"Titles":[
"USER",
"PID",
"%CPU",
"%MEM",
"VSZ",
"RSS",
"TTY",
"STAT",
"START",
"TIME",
"COMMAND"
],
"Processes":[
["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
]
}
Query Parameters:
- **ps\_args** – ps arguments to use (e.g., aux)
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### Inspect changes on a container's filesystem
`GET /containers/(id)/changes`
Inspect changes on container `id` 's filesystem
**Example request**:
GET /containers/4fa6e0f0c678/changes HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"Path":"/dev",
"Kind":0
},
{
"Path":"/dev/kmsg",
"Kind":1
},
{
"Path":"/test",
"Kind":1
}
]
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### Export a container
`GET /containers/(id)/export`
Export the contents of container `id`
**Example request**:
GET /containers/4fa6e0f0c678/export HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/octet-stream
{{ TAR STREAM }}
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### Start a container
`POST /containers/(id)/start`
Start the container `id`
**Example request**:
POST /containers/(id)/start HTTP/1.1
Content-Type: application/json
{
"Binds":["/tmp:/tmp"],
"LxcConf":[{"Key":"lxc.utsname","Value":"docker"}],
"PortBindings":{ "22/tcp": [{ "HostPort": "11022" }] },
"PublishAllPorts":false,
"Privileged":false,
"Dns": ["8.8.8.8"],
"VolumesFrom": ["parent", "other:ro"]
}
**Example response**:
HTTP/1.1 204 No Content
Content-Type: text/plain
Json Parameters:
- **hostConfig** – the container's host configuration (optional)
Status Codes:
- **204** – no error
- **404** – no such container
- **500** – server error
### Stop a container
`POST /containers/(id)/stop`
Stop the container `id`
**Example request**:
POST /containers/e90e34656806/stop?t=5 HTTP/1.1
**Example response**:
HTTP/1.1 204 OK
Query Parameters:
- **t** – number of seconds to wait before killing the container
Status Codes:
- **204** – no error
- **404** – no such container
- **500** – server error
### Restart a container
`POST /containers/(id)/restart`
Restart the container `id`
**Example request**:
POST /containers/e90e34656806/restart?t=5 HTTP/1.1
**Example response**:
HTTP/1.1 204 No Content
Query Parameters:
- **t** – number of seconds to wait before killing the container
Status Codes:
- **204** – no error
- **404** – no such container
- **500** – server error
### Kill a container
`POST /containers/(id)/kill`
Kill the container `id`
**Example request**:
POST /containers/e90e34656806/kill HTTP/1.1
**Example response**:
HTTP/1.1 204 No Content
Query Parameters
- **signal** - Signal to send to the container: integer or string like "SIGINT".
When not set, SIGKILL is assumed and the call will wait for the container to exit.
Status Codes:
- **204** – no error
- **404** – no such container
- **500** – server error
### Attach to a container
`POST /containers/(id)/attach`
Attach to the container `id`
**Example request**:
POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream
{{ STREAM }}
Query Parameters:
- **logs** – 1/True/true or 0/False/false, return logs. Defaul
false
- **stream** – 1/True/true or 0/False/false, return stream.
Default false
- **stdin** – 1/True/true or 0/False/false, if stream=true, attach
to stdin. Default false
- **stdout** – 1/True/true or 0/False/false, if logs=true, return
stdout log, if stream=true, attach to stdout. Default false
- **stderr** – 1/True/true or 0/False/false, if logs=true, return
stderr log, if stream=true, attach to stderr. Default false
Status Codes:
- **200** – no error
- **400** – bad parameter
- **404** – no such container
- **500** – server error
**Stream details**:
When using the TTY setting is enabled in
[`POST /containers/create`
](../docker_remote_api_v1.9/#post--containers-create "POST /containers/create"),
the stream is the raw data from the process PTY and client's stdin.
When the TTY is disabled, then the stream is multiplexed to separate
stdout and stderr.
The format is a **Header** and a **Payload** (frame).
**HEADER**
The header will contain the information on which stream write the
stream (stdout or stderr). It also contain the size of the
associated frame encoded on the last 4 bytes (uint32).
It is encoded on the first 8 bytes like this:
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
`STREAM_TYPE` can be:
- 0: stdin (will be written on stdout)
- 1: stdout
- 2: stderr
`SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
the uint32 size encoded as big endian.
**PAYLOAD**
The payload is the raw stream.
**IMPLEMENTATION**
The simplest way to implement the Attach protocol is the following:
1. Read 8 bytes
2. chose stdout or stderr depending on the first byte
3. Extract the frame size from the last 4 byets
4. Read the extracted size and output it on the correct output
5. Goto 1)
### Wait a container
`POST /containers/(id)/wait`
Block until container `id` stops, then returns
the exit code
**Example request**:
POST /containers/16253994b7c4/wait HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"StatusCode":0}
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### Remove a container
`DELETE /containers/(id*)
: Remove the container `id` from the filesystem
**Example request**:
DELETE /containers/16253994b7c4?v=1 HTTP/1.1
**Example response**:
HTTP/1.1 204 No Content
Query Parameters:
- **v** – 1/True/true or 0/False/false, Remove the volumes
associated to the container. Default false
- **force** – 1/True/true or 0/False/false, Removes the container
even if it was running. Default false
Status Codes:
- **204** – no error
- **400** – bad parameter
- **404** – no such container
- **500** – server error
### Copy files or folders from a container
`POST /containers/(id)/copy`
Copy files or folders of container `id`
**Example request**:
POST /containers/4fa6e0f0c678/copy HTTP/1.1
Content-Type: application/json
{
"Resource":"test.txt"
}
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/octet-stream
{{ TAR STREAM }}
Status Codes:
- **200** – no error
- **404** – no such container
- **500** – server error
### 2.2 Images
### List Images
`GET /images/json`
**Example request**:
GET /images/json?all=0 HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]
### Create an image
`POST /images/create`
Create an image, either by pull it from the registry or by importing
i
**Example request**:
POST /images/create?fromImage=base HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"Pulling..."}
{"status":"Pulling", "progress":"1 B/ 100 B", "progressDetail":{"current":1, "total":100}}
{"error":"Invalid..."}
...
When using this endpoint to pull an image from the registry, the
`X-Registry-Auth` header can be used to include
a base64-encoded AuthConfig object.
Query Parameters:
- **fromImage** – name of the image to pull
- **fromSrc** – source to import, - means stdin
- **repo** – repository
- **tag** – tag
- **registry** – the registry to pull from
Request Headers:
- **X-Registry-Auth** – base64-encoded AuthConfig object
Status Codes:
- **200** – no error
- **500** – server error
### Insert a file in an image
`POST /images/(name)/insert`
Insert a file from `url` in the image
`name` at `path`
**Example request**:
POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"Inserting..."}
{"status":"Inserting", "progress":"1/? (n/a)", "progressDetail":{"current":1}}
{"error":"Invalid..."}
...
Query Parameters:
- **url** – The url from where the file is taken
- **path** – The path where the file is stored
Status Codes:
- **200** – no error
- **500** – server error
### Inspect an image
`GET /images/(name)/json`
Return low-level information on the image `name`
**Example request**:
GET /images/base/json HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"parent":"27cf784147099545",
"created":"2013-03-23T22:24:18.818426-07:00",
"container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
"container_config":
{
"Hostname":"",
"User":"",
"Memory":0,
"MemorySwap":0,
"AttachStdin":false,
"AttachStdout":false,
"AttachStderr":false,
"PortSpecs":null,
"Tty":true,
"OpenStdin":true,
"StdinOnce":false,
"Env":null,
"Cmd": ["/bin/bash"]
"Image":"base",
"Volumes":null,
"WorkingDir":""
},
"Size": 6824592
}
Status Codes:
- **200** – no error
- **404** – no such image
- **500** – server error
### Get the history of an image
`GET /images/(name)/history`
Return the history of the image `name`
**Example request**:
GET /images/base/history HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"Id":"b750fe79269d",
"Created":1364102658,
"CreatedBy":"/bin/bash"
},
{
"Id":"27cf78414709",
"Created":1364068391,
"CreatedBy":""
}
]
Status Codes:
- **200** – no error
- **404** – no such image
- **500** – server error
### Push an image on the registry
`POST /images/(name)/push`
Push the image `name` on the registry
**Example request**:
POST /images/test/push HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"Pushing..."}
{"status":"Pushing", "progress":"1/? (n/a)", "progressDetail":{"current":1}}}
{"error":"Invalid..."}
...
If you wish to push an image on to a private registry, that image must already have been tagged
into a repository which references that registry host name and port. This repository name should
then be used in the URL. This mirrors the flow of the CLI.
**Example request**:
POST /images/registry.acme.com:5000/test/push HTTP/1.1
Query Parameters:
- **tag** – the tag to associate with the image on the registry, optional
Request Headers:
- **X-Registry-Auth** – include a base64-encoded AuthConfig object.
Status Codes:
- **200** – no error
- **404** – no such image
- **500** – server error
### Tag an image into a repository
`POST /images/(name)/tag`
Tag the image `name` into a repository
**Example request**:
POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
**Example response**:
HTTP/1.1 201 OK
Query Parameters:
- **repo** – The repository to tag in
- **force** – 1/True/true or 0/False/false, default false
- **tag** - The new tag name
Status Codes:
- **201** – no error
- **400** – bad parameter
- **404** – no such image
- **409** – conflict
- **500** – server error
### Remove an image
`DELETE /images/(name*)
: Remove the image `name` from the filesystem
**Example request**:
DELETE /images/test HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-type: application/json
[
{"Untagged":"3e2f21a89f"},
{"Deleted":"3e2f21a89f"},
{"Deleted":"53b4f83ac9"}
]
Query Parameters:
- **force** – 1/True/true or 0/False/false, default false
- **noprune** – 1/True/true or 0/False/false, default false
Status Codes:
- **200** – no error
- **404** – no such image
- **409** – conflict
- **500** – server error
### Search images
`GET /images/search`
Search for an image on [Docker Hub](https://hub.docker.com).
> **Note**:
> The response keys have changed from API v1.6 to reflect the JSON
> sent by the registry server to the docker daemon's request.
**Example request**:
GET /images/search?term=sshd HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"description": "",
"is_official": false,
"is_trusted": false,
"name": "wma55/u1210sshd",
"star_count": 0
},
{
"description": "",
"is_official": false,
"is_trusted": false,
"name": "jdswinbank/sshd",
"star_count": 0
},
{
"description": "",
"is_official": false,
"is_trusted": false,
"name": "vgauthier/sshd",
"star_count": 0
}
...
]
Query Parameters:
- **term** – term to search
Status Codes:
- **200** – no error
- **500** – server error
### 2.3 Misc
### Build an image from Dockerfile via stdin
`POST /build`
Build an image from Dockerfile via stdin
**Example request**:
POST /build HTTP/1.1
{{ TAR STREAM }}
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"stream":"Step 1..."}
{"stream":"..."}
{"error":"Error...", "errorDetail":{"code": 123, "message": "Error..."}}
The stream must be a tar archive compressed with one of the
following algorithms: identity (no compression), gzip, bzip2, xz.
The archive must include a file called `Dockerfile`
at its root. It may include any number of other files,
which will be accessible in the build context (See the [*ADD build
command*](/reference/builder/#dockerbuilder)).
Query Parameters:
- **t** – repository name (and optionally a tag) to be applied to
the resulting image in case of success
- **q** – suppress verbose build output
- **nocache** – do not use the cache when building the image
- **rm** - remove intermediate containers after a successful build
Request Headers:
- **Content-type** – should be set to `"application/tar"`.
- **X-Registry-Config** – base64-encoded ConfigFile objec
Status Codes:
- **200** – no error
- **500** – server error
### Check auth configuration
`POST /auth`
Get the default username and email
**Example request**:
POST /auth HTTP/1.1
Content-Type: application/json
{
"username":"hannibal",
"password:"xxxx",
"email":"[email protected]",
"serveraddress":"https://index.docker.io/v1/"
}
**Example response**:
HTTP/1.1 200 OK
Content-Type: text/plain
Status Codes:
- **200** – no error
- **204** – no error
- **500** – server error
### Display system-wide information
`GET /info`
Display system-wide information
**Example request**:
GET /info HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{
"Containers":11,
"Images":16,
"Debug":false,
"NFd": 11,
"NGoroutines":21,
"MemoryLimit":true,
"SwapLimit":false,
"IPv4Forwarding":true
}
Status Codes:
- **200** – no error
- **500** – server error
### Show the docker version information
`GET /version`
Show the docker version information
**Example request**:
GET /version HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{
"Version":"0.2.2",
"GitCommit":"5a2a5cc+CHANGES",
"GoVersion":"go1.0.3"
}
Status Codes:
- **200** – no error
- **500** – server error
### Create a new image from a container's changes
`POST /commit`
Create a new image from a container's changes
**Example request**:
POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
Content-Type: application/json
{
"Hostname":"",
"User":"",
"Memory":0,
"MemorySwap":0,
"AttachStdin":false,
"AttachStdout":true,
"AttachStderr":true,
"PortSpecs":null,
"Tty":false,
"OpenStdin":false,
"StdinOnce":false,
"Env":null,
"Cmd":[
"date"
],
"Volumes":{
"/tmp": {}
},
"WorkingDir":"",
"NetworkDisabled": false,
"ExposedPorts":{
"22/tcp": {}
}
}
**Example response**:
HTTP/1.1 201 OK
Content-Type: application/vnd.docker.raw-stream
{"Id":"596069db4bf5"}
Json Parameters:
- **config** - the container's configuration
Query Parameters:
- **container** – source container
- **repo** – repository
- **tag** – tag
- **m** – commit message
- **author** – author (e.g., "John Hannibal Smith
<[[email protected]](mailto:hannibal%40a-team.com)>")
Status Codes:
- **201** – no error
- **404** – no such container
- **500** – server error
### Monitor Docker's events
`GET /events`
Get events from docker, either in real time via streaming, or via
polling (using since).
Docker containers will report the following events:
create, destroy, die, export, kill, pause, restart, start, stop, unpause
and Docker images will report:
untag, delete
**Example request**:
GET /events?since=1374067924
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"create","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
{"status":"start","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
{"status":"stop","id":"dfdf82bd3881","from":"base:latest","time":1374067966}
{"status":"destroy","id":"dfdf82bd3881","from":"base:latest","time":1374067970}
Query Parameters:
- **since** – timestamp used for polling
Status Codes:
- **200** – no error
- **500** – server error
### Get a tarball containing all images and tags in a repository
`GET /images/(name)/get`
Get a tarball containing all images and metadata for the repository
specified by `name`.
See the [image tarball format](#image-tarball-format) for more details.
**Example request**
GET /images/ubuntu/get
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/x-tar
Binary data stream
Status Codes:
- **200** – no error
- **500** – server error
### Load a tarball with a set of images and tags into docker
`POST /images/load`
Load a set of images and tags into the docker repository.
See the [image tarball format](#image-tarball-format) for more details.
**Example request**
POST /images/load
Tarball in body
**Example response**:
HTTP/1.1 200 OK
Status Codes:
- **200** – no error
- **500** – server error
### Image tarball format
An image tarball contains one directory per image layer (named using its long ID),
each containing three files:
1. `VERSION`: currently `1.0` - the file format version
2. `json`: detailed layer information, similar to `docker inspect layer_id`
3. `layer.tar`: A tarfile containing the filesystem changes in this layer
The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
for storing attribute changes and deletions.
If the tarball defines a repository, there will also be a `repositories` file at
the root that contains a list of repository and tag names mapped to layer IDs.
```
{"hello-world":
{"latest":"565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
}
```
# 3. Going further
## 3.1 Inside `docker run`
Here are the steps of `docker run` :
- Create the container
- If the status code is 404, it means the image doesn't exist:
- Try to pull it
- Then retry to create the container
- Start the container
- If you are not in detached mode:
- Attach to the container, using logs=1 (to have stdout and
stderr from the container's start) and stream=1
- If in detached mode or only stdin is attached:
- Display the container's id
## 3.2 Hijacking
In this version of the API, /attach, uses hijacking to transport stdin,
stdout and stderr on the same socket. This might change in the future.
## 3.3 CORS Requests
To enable cross origin requests to the remote api add the flag
"--api-enable-cors" when running docker in daemon mode.
$ docker -d -H="192.168.1.9:2375" --api-enable-cors
| apache-2.0 |
abovelabs/aws-ios-sdk | src/include/EC2/EC2TagDescriptionUnmarshaller.h | 1317 | /*
* Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "EC2TagDescription.h"
#import "EC2ResponseUnmarshaller.h"
#import "../AmazonValueUnmarshaller.h"
#import "../AmazonBoolValueUnmarshaller.h"
/**
* Tag Description Unmarshaller
*/
@interface EC2TagDescriptionUnmarshaller:EC2ResponseUnmarshaller {
EC2TagDescription *response;
}
@property (nonatomic, readonly) EC2TagDescription *response;
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict;
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;
@end
| apache-2.0 |
psoreide/bnd | docs/releases/4.2.0/heads/bundle_nativecode.html | 9014 | <!DOCTYPE html>
<html lang="en" ng-app="jpm">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/releases/4.2.0/css/style.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="/js/releases.js"></script>
<!-- Begin Jekyll SEO tag v2.5.0 -->
<title>Bundle-NativeCode ::= nativecode ( ‘,’ nativecode )* ( ‘,’ optional ) ?</title>
<meta name="generator" content="Jekyll v3.7.4" />
<meta property="og:title" content="Bundle-NativeCode ::= nativecode ( ‘,’ nativecode )* ( ‘,’ optional ) ?" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="/* * Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ’,’ optional) ? * nativecode ::= path ( ';' path )* // See 1.4.2 ( ';' parameter )+ * optional ::= ’*’ */ public void verifyNative() { String nc = get(Constants.BUNDLE_NATIVECODE); doNative(nc); }" />
<meta property="og:description" content="/* * Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ’,’ optional) ? * nativecode ::= path ( ';' path )* // See 1.4.2 ( ';' parameter )+ * optional ::= ’*’ */ public void verifyNative() { String nc = get(Constants.BUNDLE_NATIVECODE); doNative(nc); }" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2019-10-12T19:48:23-04:00" />
<script type="application/ld+json">
{"headline":"Bundle-NativeCode ::= nativecode ( ‘,’ nativecode )* ( ‘,’ optional ) ?","dateModified":"2019-10-12T19:48:23-04:00","datePublished":"2019-10-12T19:48:23-04:00","@type":"BlogPosting","mainEntityOfPage":{"@type":"WebPage","@id":"/releases/4.2.0/heads/bundle_nativecode.html"},"url":"/releases/4.2.0/heads/bundle_nativecode.html","description":"/* * Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ’,’ optional) ? * nativecode ::= path ( ';' path )* // See 1.4.2 ( ';' parameter )+ * optional ::= ’*’ */ public void verifyNative() { String nc = get(Constants.BUNDLE_NATIVECODE); doNative(nc); }","@context":"http://schema.org"}</script>
<!-- End Jekyll SEO tag -->
</head>
<body>
<ul class="container12 menu-bar">
<li span=11><a class=menu-link href="/releases/4.2.0/"><img
class=menu-logo src='/releases/4.2.0/img/bnd-80x40-white.png'></a>
<a href="/releases/4.2.0/chapters/110-introduction.html">Intro
</a><a href="/releases/4.2.0/chapters/800-headers.html">Headers
</a><a href="/releases/4.2.0/chapters/825-instructions-ref.html">Instructions
</a><a href="/releases/4.2.0/chapters/855-macros-ref.html">Macros
</a><a href="/releases/4.2.0/chapters/400-commands.html">Commands
</a><div class="releases"><button class="dropbtn">4.2.0</button><div class="dropdown-content"></div></div>
<li class=menu-link span=1>
<a href="https://github.com/bndtools/bnd" target="_"><img
style="position:absolute;top:0;right:0;margin:0;padding:0;z-index:100"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
</ul>
<ul class=container12>
<li span=3>
<div>
<ul class="side-nav">
<li><a href="/releases/4.2.0/chapters/110-introduction.html">Introduction</a>
<li><a href="/releases/4.2.0/chapters/120-install.html">How to install bnd</a>
<li><a href="/releases/4.2.0/chapters/123-tour-workspace.html">Guided Tour</a>
<li><a href="/releases/4.2.0/chapters/125-tour-features.html">Guided Tour Workspace & Projects</a>
<li><a href="/releases/4.2.0/chapters/130-concepts.html">Concepts</a>
<li><a href="/releases/4.2.0/chapters/140-best-practices.html">Best practices</a>
<li><a href="/releases/4.2.0/chapters/150-build.html">Build</a>
<li><a href="/releases/4.2.0/chapters/160-jars.html">Generating JARs</a>
<li><a href="/releases/4.2.0/chapters/170-versioning.html">Versioning</a>
<li><a href="/releases/4.2.0/chapters/180-baselining.html">Baselining</a>
<li><a href="/releases/4.2.0/chapters/200-components.html">Service Components</a>
<li><a href="/releases/4.2.0/chapters/210-metatype.html">Metatype</a>
<li><a href="/releases/4.2.0/chapters/220-contracts.html">Contracts</a>
<li><a href="/releases/4.2.0/chapters/230-manifest-annotations.html">Manifest Annotations</a>
<li><a href="/releases/4.2.0/chapters/250-resolving.html">Resolving Dependencies</a>
<li><a href="/releases/4.2.0/chapters/300-launching.html">Launching</a>
<li><a href="/releases/4.2.0/chapters/305-Junit-Testing-OSGi.html">Plain JUnit Testing with OSGi (PRELIMENARY)</a>
<li><a href="/releases/4.2.0/chapters/310-testing.html">Testing</a>
<li><a href="/releases/4.2.0/chapters/320-packaging.html">Packaging Applications</a>
<li><a href="/releases/4.2.0/chapters/390-wrapping.html">Wrapping Libraries to OSGi Bundles</a>
<li><a href="/releases/4.2.0/chapters/400-commands.html">Commands</a>
<li><a href="/releases/4.2.0/chapters/600-developer.html">For Developers</a>
<li><a href="/releases/4.2.0/chapters/700-tools.html">Tools bound to bnd</a>
<li><a href="/releases/4.2.0/chapters/800-headers.html">Headers</a>
<li><a href="/releases/4.2.0/chapters/820-instructions.html">Instruction Reference</a>
<li><a href="/releases/4.2.0/chapters/825-instructions-ref.html">Instruction Index</a>
<li><a href="/releases/4.2.0/chapters/850-macros.html">Macro Reference</a>
<li><a href="/releases/4.2.0/chapters/855-macros-ref.html">Macro Index</a>
<li><a href="/releases/4.2.0/chapters/870-plugins.html">Plugins</a>
<li><a href="/releases/4.2.0/chapters/880-settings.html">Settings</a>
<li><a href="/releases/4.2.0/chapters/900-errors.html">Errors</a>
<li><a href="/releases/4.2.0/chapters/910-warnings.html">Warnings</a>
<li><a href="/releases/4.2.0/chapters/920-faq.html">Frequently Asked Questions</a>
</ul>
</div>
<li span=9>
<div class=notes-margin>
<h1> Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ',' optional ) ?</h1>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/*
* Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ’,’ optional) ?
* nativecode ::= path ( ';' path )* // See 1.4.2 ( ';' parameter )+
* optional ::= ’*’
*/
public void verifyNative() {
String nc = get(Constants.BUNDLE_NATIVECODE);
doNative(nc);
}
public void doNative(String nc) {
if (nc != null) {
QuotedTokenizer qt = new QuotedTokenizer(nc, ",;=", false);
char del;
do {
do {
String name = qt.nextToken();
if (name == null) {
error("Can not parse name from bundle native code header: " + nc);
return;
}
del = qt.getSeparator();
if (del == ';') {
if (dot != null && !dot.exists(name)) {
error("Native library not found in JAR: " + name);
}
} else {
String value = null;
if (del == '=')
value = qt.nextToken();
String key = name.toLowerCase();
if (key.equals("osname")) {
// ...
} else if (key.equals("osversion")) {
// verify version range
verify(value, VERSIONRANGE);
} else if (key.equals("language")) {
verify(value, ISO639);
} else if (key.equals("processor")) {
// verify(value, PROCESSORS);
} else if (key.equals("selection-filter")) {
// verify syntax filter
verifyFilter(value);
} else if (name.equals("*") && value == null) {
// Wildcard must be at end.
if (qt.nextToken() != null)
error("Bundle-Native code header may only END in wildcard: nc");
} else {
warning("Unknown attribute in native code: " + name + "=" + value);
}
del = qt.getSeparator();
}
} while (del == ';');
} while (del == ',');
}
}
public boolean verifyFilter(String value) {
String s = validateFilter(value);
if (s == null)
return true;
error(s);
return false;
}
public static String validateFilter(String value) {
try {
verifyFilter(value, 0);
return null;
}
catch (Exception e) {
return "Not a valid filter: " + value + e.getMessage();
}
}
</code></pre></div></div>
</div>
</ul>
<nav class=next-prev>
<a href='/releases/4.2.0/heads/bundle_name.html'></a> <a href='/releases/4.2.0/heads/bundle_requiredexecutionenvironment.html'></a>
</nav>
<footer class="container12" style="border-top: 1px solid black;padding:10px 0">
<ul span=12 row>
<li span=12>
<ul>
<li><a href="/releases/4.2.0/">GitHub</a>
</ul>
</ul>
</footer>
</body>
</html>
| apache-2.0 |
howard5888/wine | wine-1.7.7/include/xmldomdid.h | 7535 | /*
* Copyright (C) 2005 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __XMLDOMDID_H__
#define __XMLDOMDID_H__
#define DISPID_DOM_BASE 1
#define DISPID_DOM_COLLECTION_BASE 1000000
#define DISPID_DOM_COLLECTION_MAX 2999999
#define DISPID_DOM_NODE 1
#define DISPID_DOM_NODE_NODENAME 2
#define DISPID_DOM_NODE_NODEVALUE 3
#define DISPID_DOM_NODE_NODETYPE 4
#define DISPID_DOM_NODE_NODETYPEENUM 5
#define DISPID_DOM_NODE_PARENTNODE 6
#define DISPID_DOM_NODE_CHILDNODES 7
#define DISPID_DOM_NODE_FIRSTCHILD 8
#define DISPID_DOM_NODE_LASTCHILD 9
#define DISPID_DOM_NODE_PREVIOUSSIBLING 10
#define DISPID_DOM_NODE_NEXTSIBLING 11
#define DISPID_DOM_NODE_ATTRIBUTES 12
#define DISPID_DOM_NODE_INSERTBEFORE 13
#define DISPID_DOM_NODE_REPLACECHILD 14
#define DISPID_DOM_NODE_REMOVECHILD 15
#define DISPID_DOM_NODE_APPENDCHILD 16
#define DISPID_DOM_NODE_HASCHILDNODES 17
#define DISPID_DOM_NODE_OWNERDOC 18
#define DISPID_DOM_NODE_CLONENODE 19
#define DISPID_XMLDOM_NODE 20
#define DISPID_XMLDOM_NODE_STRINGTYPE 21
#define DISPID_XMLDOM_NODE_SPECIFIED 22
#define DISPID_XMLDOM_NODE_DEFINITION 23
#define DISPID_XMLDOM_NODE_TEXT 24
#define DISPID_XMLDOM_NODE_NODETYPEDVALUE 25
#define DISPID_XMLDOM_NODE_DATATYPE 26
#define DISPID_XMLDOM_NODE_XML 27
#define DISPID_XMLDOM_NODE_TRANSFORMNODE 28
#define DISPID_XMLDOM_NODE_SELECTNODES 29
#define DISPID_XMLDOM_NODE_SELECTSINGLENODE 30
#define DISPID_XMLDOM_NODE_PARSED 31
#define DISPID_XMLDOM_NODE_NAMESPACE 32
#define DISPID_XMLDOM_NODE_PREFIX 33
#define DISPID_XMLDOM_NODE_BASENAME 34
#define DISPID_XMLDOM_NODE_TRANSFORMNODETOOBJECT 35
#define DISPID_XMLDOM_NODE__TOP 36
#define DISPID_DOM_DOCUMENT 37
#define DISPID_DOM_DOCUMENT_DOCTYPE 38
#define DISPID_DOM_DOCUMENT_IMPLEMENTATION 39
#define DISPID_DOM_DOCUMENT_DOCUMENTELEMENT 40
#define DISPID_DOM_DOCUMENT_CREATEELEMENT 41
#define DISPID_DOM_DOCUMENT_CREATEDOCUMENTFRAGMENT 42
#define DISPID_DOM_DOCUMENT_CREATETEXTNODE 43
#define DISPID_DOM_DOCUMENT_CREATECOMMENT 44
#define DISPID_DOM_DOCUMENT_CREATECDATASECTION 45
#define DISPID_DOM_DOCUMENT_CREATEPROCESSINGINSTRUCTION 46
#define DISPID_DOM_DOCUMENT_CREATEATTRIBUTE 47
#define DISPID_DOM_DOCUMENT_CREATEENTITY 48
#define DISPID_DOM_DOCUMENT_CREATEENTITYREFERENCE 49
#define DISPID_DOM_DOCUMENT_GETELEMENTSBYTAGNAME 50
#define DISPID_DOM_DOCUMENT_TOP 51
#define DISPID_XMLDOM_DOCUMENT 52
#define DISPID_XMLDOM_DOCUMENT_DOCUMENTNODE 53
#define DISPID_XMLDOM_DOCUMENT_CREATENODE 54
#define DISPID_XMLDOM_DOCUMENT_CREATENODEEX 55
#define DISPID_XMLDOM_DOCUMENT_NODEFROMID 56
#define DISPID_XMLDOM_DOCUMENT_DOCUMENTNAMESPACES 57
#define DISPID_XMLDOM_DOCUMENT_LOAD 58
#define DISPID_XMLDOM_DOCUMENT_PARSEERROR 59
#define DISPID_XMLDOM_DOCUMENT_URL 60
#define DISPID_XMLDOM_DOCUMENT_ASYNC 61
#define DISPID_XMLDOM_DOCUMENT_ABORT 62
#define DISPID_XMLDOM_DOCUMENT_LOADXML 63
#define DISPID_XMLDOM_DOCUMENT_SAVE 64
#define DISPID_XMLDOM_DOCUMENT_VALIDATE 65
#define DISPID_XMLDOM_DOCUMENT_RESOLVENAMESPACE 66
#define DISPID_XMLDOM_DOCUMENT_PRESERVEWHITESPACE 67
#define DISPID_XMLDOM_DOCUMENT_ONREADYSTATECHANGE 68
#define DISPID_XMLDOM_DOCUMENT_ONDATAAVAILABLE 69
#define DISPID_XMLDOM_DOCUMENT_ONTRANSFORMNODE 70
#define DISPID_XMLDOM_DOCUMENT__TOP 71
#define DISPID_DOM_NODELIST 72
#define DISPID_DOM_NODELIST_ITEM 73
#define DISPID_DOM_NODELIST_LENGTH 74
#define DISPID_XMLDOM_NODELIST 75
#define DISPID_XMLDOM_NODELIST_NEXTNODE 76
#define DISPID_XMLDOM_NODELIST_RESET 77
#define DISPID_XMLDOM_NODELIST_NEWENUM 78
#define DISPID_XMLDOM_NODELIST__TOP 79
#define DISPID_DOM_NAMEDNODEMAP 80
#define DISPID_DOM_NAMEDNODEMAP_GETNAMEDITEM 81
#define DISPID_DOM_NAMEDNODEMAP_SETNAMEDITEM 82
#define DISPID_DOM_NAMEDNODEMAP_REMOVENAMEDITEM 83
#define DISPID_XMLDOM_NAMEDNODEMAP 84
#define DISPID_XMLDOM_NAMEDNODEMAP_GETQUALIFIEDITEM 85
#define DISPID_XMLDOM_NAMEDNODEMAP_REMOVEQUALIFIEDITEM 86
#define DISPID_XMLDOM_NAMEDNODEMAP_NEXTNODE 87
#define DISPID_XMLDOM_NAMEDNODEMAP_RESET 88
#define DISPID_XMLDOM_NAMEDNODEMAP_NEWENUM 89
#define DISPID_XMLDOM_NAMEDNODEMAP__TOP 90
#define DISPID_DOM_W3CWRAPPERS 91
#define DISPID_DOM_DOCUMENTFRAGMENT 92
#define DISPID_DOM_DOCUMENTFRAGMENT__TOP 93
#define DISPID_DOM_ELEMENT 94
#define DISPID_DOM_ELEMENT_GETTAGNAME 95
#define DISPID_DOM_ELEMENT_GETATTRIBUTES 96
#define DISPID_DOM_ELEMENT_GETATTRIBUTE 97
#define DISPID_DOM_ELEMENT_SETATTRIBUTE 98
#define DISPID_DOM_ELEMENT_REMOVEATTRIBUTE 99
#define DISPID_DOM_ELEMENT_GETATTRIBUTENODE 100
#define DISPID_DOM_ELEMENT_SETATTRIBUTENODE 101
#define DISPID_DOM_ELEMENT_REMOVEATTRIBUTENODE 102
#define DISPID_DOM_ELEMENT_GETELEMENTSBYTAGNAME 103
#define DISPID_DOM_ELEMENT_NORMALIZE 104
#define DISPID_DOM_ELEMENT__TOP 105
#define DISPID_DOM_DATA 106
#define DISPID_DOM_DATA_DATA 107
#define DISPID_DOM_DATA_LENGTH 108
#define DISPID_DOM_DATA_SUBSTRING 109
#define DISPID_DOM_DATA_APPEND 110
#define DISPID_DOM_DATA_INSERT 111
#define DISPID_DOM_DATA_DELETE 112
#define DISPID_DOM_DATA_REPLACE 113
#define DISPID_DOM_DATA__TOP 114
#define DISPID_DOM_ATTRIBUTE 115
#define DISPID_DOM_ATTRIBUTE_GETNAME 116
#define DISPID_DOM_ATTRIBUTE_SPECIFIED 117
#define DISPID_DOM_ATTRIBUTE_VALUE 118
#define DISPID_DOM_ATTRIBUTE__TOP 119
#define DISPID_DOM_TEXT 120
#define DISPID_DOM_TEXT_SPLITTEXT 121
#define DISPID_DOM_TEXT_JOINTEXT 122
#define DISPID_DOM_TEXT__TOP 123
#define DISPID_DOM_PI 124
#define DISPID_DOM_PI_TARGET 125
#define DISPID_DOM_PI_DATA 126
#define DISPID_DOM_PI__TOP 127
#define DISPID_DOM_DOCUMENTTYPE 128
#define DISPID_DOM_DOCUMENTTYPE_NAME 129
#define DISPID_DOM_DOCUMENTTYPE_ENTITIES 130
#define DISPID_DOM_DOCUMENTTYPE_NOTATIONS 131
#define DISPID_DOM_DOCUMENTTYPE__TOP 132
#define DISPID_DOM_NOTATION 133
#define DISPID_DOM_NOTATION_PUBLICID 134
#define DISPID_DOM_NOTATION_SYSTEMID 135
#define DISPID_DOM_NOTATION__TOP 136
#define DISPID_DOM_ENTITY 137
#define DISPID_DOM_ENTITY_PUBLICID 138
#define DISPID_DOM_ENTITY_SYSTEMID 139
#define DISPID_DOM_ENTITY_NOTATIONNAME 140
#define DISPID_DOM_ENTITY__TOP 141
#define DISPID_DOM_IMPLEMENTATION 142
#define DISPID_DOM_IMPLEMENTATION_HASFEATURE 143
#define DISPID_DOM_IMPLEMENTATION__TOP 144
#define DISPID_DOM_ERROR 0x000000b0
#define DISPID_DOM_ERROR_ERRORCODE 0x000000b1
#define DISPID_DOM_ERROR_URL 0x000000b2
#define DISPID_DOM_ERROR_REASON 0x000000b3
#define DISPID_DOM_ERROR_SRCTEXT 0x000000b4
#define DISPID_DOM_ERROR_LINE 0x000000b5
#define DISPID_DOM_ERROR_LINEPOS 0x000000b6
#define DISPID_DOM_ERROR_FILEPOS 0x000000b7
#define DISPID_DOM_ERROR__TOP 0x000000b8
#define DISPID_XMLDOMEVENT 197
#define DISPID_XMLDOMEVENT_ONREADYSTATECHANGE DISPID_READYSTATECHANGE
#define DISPID_XMLDOMEVENT_ONDATAAVAILABLE 198
#define DISPID_XMLDOMEVENT__TOP 199
#endif /* __XMLDOMDID_H__ */
| apache-2.0 |
TakayukiSakai/tensorflow | tensorflow/g3doc/api_docs/python/functions_and_classes/shard3/tf.contrib.framework.add_model_variable.md | 170 | ### `tf.contrib.framework.add_model_variable(var)` {#add_model_variable}
Adds a variable to the MODEL_VARIABLES collection.
##### Args:
* <b>`var`</b>: a variable.
| apache-2.0 |
npuichigo/ttsflow | third_party/protobuf/src/google/protobuf/descriptor.pb.cc | 644516 | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/descriptor.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include <google/protobuf/descriptor.pb.h>
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
namespace google {
namespace protobuf {
class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> {
} _FileDescriptorSet_default_instance_;
class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> {
} _FileDescriptorProto_default_instance_;
class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> {
} _DescriptorProto_ExtensionRange_default_instance_;
class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> {
} _DescriptorProto_ReservedRange_default_instance_;
class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> {
} _DescriptorProto_default_instance_;
class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> {
} _FieldDescriptorProto_default_instance_;
class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> {
} _OneofDescriptorProto_default_instance_;
class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> {
} _EnumDescriptorProto_default_instance_;
class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> {
} _EnumValueDescriptorProto_default_instance_;
class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> {
} _ServiceDescriptorProto_default_instance_;
class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> {
} _MethodDescriptorProto_default_instance_;
class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> {
} _FileOptions_default_instance_;
class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> {
} _MessageOptions_default_instance_;
class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> {
} _FieldOptions_default_instance_;
class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> {
} _OneofOptions_default_instance_;
class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> {
} _EnumOptions_default_instance_;
class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> {
} _EnumValueOptions_default_instance_;
class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> {
} _ServiceOptions_default_instance_;
class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> {
} _MethodOptions_default_instance_;
class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> {
} _UninterpretedOption_NamePart_default_instance_;
class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> {
} _UninterpretedOption_default_instance_;
class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> {
} _SourceCodeInfo_Location_default_instance_;
class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> {
} _SourceCodeInfo_default_instance_;
class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> {
} _GeneratedCodeInfo_Annotation_default_instance_;
class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> {
} _GeneratedCodeInfo_default_instance_;
namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto {
namespace {
::google::protobuf::Metadata file_level_metadata[25];
const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6];
} // namespace
PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField
const TableStruct::entries[] = {
{0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},
};
PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField
const TableStruct::aux[] = {
::google::protobuf::internal::AuxillaryParseTableField(),
};
PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const
TableStruct::schema[] = {
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
{ NULL, NULL, 0, -1, -1, false },
};
const ::google::protobuf::uint32 TableStruct::offsets[] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_),
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_),
0,
1,
~0u,
~0u,
~0u,
~0u,
~0u,
~0u,
~0u,
3,
4,
2,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_),
0,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_),
0,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_),
0,
~0u,
~0u,
~0u,
~0u,
~0u,
~0u,
1,
~0u,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_),
0,
6,
8,
9,
2,
1,
3,
7,
4,
5,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_),
0,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_),
0,
~0u,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_),
0,
2,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_),
0,
~0u,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_),
0,
1,
2,
3,
4,
5,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_class_prefix_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_),
0,
1,
7,
8,
9,
15,
2,
10,
11,
12,
13,
14,
3,
4,
5,
6,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_),
0,
1,
2,
3,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_),
0,
1,
5,
2,
3,
4,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_),
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_),
0,
1,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_),
0,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_),
0,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, idempotency_level_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_),
0,
1,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_),
0,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_),
~0u,
0,
3,
4,
5,
1,
2,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_),
~0u,
~0u,
0,
1,
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_),
~0u,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_),
~0u,
0,
1,
2,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_),
~0u,
};
static const ::google::protobuf::internal::MigrationSchema schemas[] = {
{ 0, 6, sizeof(FileDescriptorSet)},
{ 7, 24, sizeof(FileDescriptorProto)},
{ 36, 43, sizeof(DescriptorProto_ExtensionRange)},
{ 45, 52, sizeof(DescriptorProto_ReservedRange)},
{ 54, 69, sizeof(DescriptorProto)},
{ 79, 94, sizeof(FieldDescriptorProto)},
{ 104, 111, sizeof(OneofDescriptorProto)},
{ 113, 121, sizeof(EnumDescriptorProto)},
{ 124, 132, sizeof(EnumValueDescriptorProto)},
{ 135, 143, sizeof(ServiceDescriptorProto)},
{ 146, 157, sizeof(MethodDescriptorProto)},
{ 163, 185, sizeof(FileOptions)},
{ 202, 212, sizeof(MessageOptions)},
{ 217, 229, sizeof(FieldOptions)},
{ 236, 242, sizeof(OneofOptions)},
{ 243, 251, sizeof(EnumOptions)},
{ 254, 261, sizeof(EnumValueOptions)},
{ 263, 270, sizeof(ServiceOptions)},
{ 272, 280, sizeof(MethodOptions)},
{ 283, 290, sizeof(UninterpretedOption_NamePart)},
{ 292, 304, sizeof(UninterpretedOption)},
{ 311, 321, sizeof(SourceCodeInfo_Location)},
{ 326, 332, sizeof(SourceCodeInfo)},
{ 333, 342, sizeof(GeneratedCodeInfo_Annotation)},
{ 346, 352, sizeof(GeneratedCodeInfo)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_),
};
namespace {
void protobuf_AssignDescriptors() {
AddDescriptors();
::google::protobuf::MessageFactory* factory = NULL;
AssignDescriptors(
"google/protobuf/descriptor.proto", schemas, file_default_instances, TableStruct::offsets, factory,
file_level_metadata, file_level_enum_descriptors, NULL);
}
void protobuf_AssignDescriptorsOnce() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 25);
}
} // namespace
void TableStruct::Shutdown() {
_FileDescriptorSet_default_instance_.Shutdown();
delete file_level_metadata[0].reflection;
_FileDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[1].reflection;
_DescriptorProto_ExtensionRange_default_instance_.Shutdown();
delete file_level_metadata[2].reflection;
_DescriptorProto_ReservedRange_default_instance_.Shutdown();
delete file_level_metadata[3].reflection;
_DescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[4].reflection;
_FieldDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[5].reflection;
_OneofDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[6].reflection;
_EnumDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[7].reflection;
_EnumValueDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[8].reflection;
_ServiceDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[9].reflection;
_MethodDescriptorProto_default_instance_.Shutdown();
delete file_level_metadata[10].reflection;
_FileOptions_default_instance_.Shutdown();
delete file_level_metadata[11].reflection;
_MessageOptions_default_instance_.Shutdown();
delete file_level_metadata[12].reflection;
_FieldOptions_default_instance_.Shutdown();
delete file_level_metadata[13].reflection;
_OneofOptions_default_instance_.Shutdown();
delete file_level_metadata[14].reflection;
_EnumOptions_default_instance_.Shutdown();
delete file_level_metadata[15].reflection;
_EnumValueOptions_default_instance_.Shutdown();
delete file_level_metadata[16].reflection;
_ServiceOptions_default_instance_.Shutdown();
delete file_level_metadata[17].reflection;
_MethodOptions_default_instance_.Shutdown();
delete file_level_metadata[18].reflection;
_UninterpretedOption_NamePart_default_instance_.Shutdown();
delete file_level_metadata[19].reflection;
_UninterpretedOption_default_instance_.Shutdown();
delete file_level_metadata[20].reflection;
_SourceCodeInfo_Location_default_instance_.Shutdown();
delete file_level_metadata[21].reflection;
_SourceCodeInfo_default_instance_.Shutdown();
delete file_level_metadata[22].reflection;
_GeneratedCodeInfo_Annotation_default_instance_.Shutdown();
delete file_level_metadata[23].reflection;
_GeneratedCodeInfo_default_instance_.Shutdown();
delete file_level_metadata[24].reflection;
}
void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
::google::protobuf::internal::InitProtobufDefaults();
_FileDescriptorSet_default_instance_.DefaultConstruct();
_FileDescriptorProto_default_instance_.DefaultConstruct();
_DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct();
_DescriptorProto_ReservedRange_default_instance_.DefaultConstruct();
_DescriptorProto_default_instance_.DefaultConstruct();
_FieldDescriptorProto_default_instance_.DefaultConstruct();
_OneofDescriptorProto_default_instance_.DefaultConstruct();
_EnumDescriptorProto_default_instance_.DefaultConstruct();
_EnumValueDescriptorProto_default_instance_.DefaultConstruct();
_ServiceDescriptorProto_default_instance_.DefaultConstruct();
_MethodDescriptorProto_default_instance_.DefaultConstruct();
_FileOptions_default_instance_.DefaultConstruct();
_MessageOptions_default_instance_.DefaultConstruct();
_FieldOptions_default_instance_.DefaultConstruct();
_OneofOptions_default_instance_.DefaultConstruct();
_EnumOptions_default_instance_.DefaultConstruct();
_EnumValueOptions_default_instance_.DefaultConstruct();
_ServiceOptions_default_instance_.DefaultConstruct();
_MethodOptions_default_instance_.DefaultConstruct();
_UninterpretedOption_NamePart_default_instance_.DefaultConstruct();
_UninterpretedOption_default_instance_.DefaultConstruct();
_SourceCodeInfo_Location_default_instance_.DefaultConstruct();
_SourceCodeInfo_default_instance_.DefaultConstruct();
_GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct();
_GeneratedCodeInfo_default_instance_.DefaultConstruct();
_FileDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>(
::google::protobuf::FileOptions::internal_default_instance());
_FileDescriptorProto_default_instance_.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(
::google::protobuf::SourceCodeInfo::internal_default_instance());
_DescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>(
::google::protobuf::MessageOptions::internal_default_instance());
_FieldDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>(
::google::protobuf::FieldOptions::internal_default_instance());
_OneofDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>(
::google::protobuf::OneofOptions::internal_default_instance());
_EnumDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>(
::google::protobuf::EnumOptions::internal_default_instance());
_EnumValueDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>(
::google::protobuf::EnumValueOptions::internal_default_instance());
_ServiceDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>(
::google::protobuf::ServiceOptions::internal_default_instance());
_MethodDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>(
::google::protobuf::MethodOptions::internal_default_instance());
}
void InitDefaults() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] = {
"\n google/protobuf/descriptor.proto\022\017goog"
"le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file"
"\030\001 \003(\0132$.google.protobuf.FileDescriptorP"
"roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001"
"(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022"
"\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen"
"dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog"
"le.protobuf.DescriptorProto\0227\n\tenum_type"
"\030\005 \003(\0132$.google.protobuf.EnumDescriptorP"
"roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf."
"ServiceDescriptorProto\0228\n\textension\030\007 \003("
"\0132%.google.protobuf.FieldDescriptorProto"
"\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File"
"Options\0229\n\020source_code_info\030\t \001(\0132\037.goog"
"le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001"
"(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005"
"field\030\002 \003(\0132%.google.protobuf.FieldDescr"
"iptorProto\0228\n\textension\030\006 \003(\0132%.google.p"
"rotobuf.FieldDescriptorProto\0225\n\013nested_t"
"ype\030\003 \003(\0132 .google.protobuf.DescriptorPr"
"oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf"
".EnumDescriptorProto\022H\n\017extension_range\030"
"\005 \003(\0132/.google.protobuf.DescriptorProto."
"ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo"
"gle.protobuf.OneofDescriptorProto\0220\n\007opt"
"ions\030\007 \001(\0132\037.google.protobuf.MessageOpti"
"ons\022F\n\016reserved_range\030\t \003(\0132..google.pro"
"tobuf.DescriptorProto.ReservedRange\022\025\n\rr"
"eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005"
"start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang"
"e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD"
"escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003"
" \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi"
"eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*"
".google.protobuf.FieldDescriptorProto.Ty"
"pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022"
"\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t "
"\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132"
"\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022"
"\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE"
"_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020"
"\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n"
"\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR"
"OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022"
"\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_"
"SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI"
"NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE"
"L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE"
"L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004"
"name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro"
"tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro"
"to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google"
".protobuf.EnumValueDescriptorProto\022-\n\007op"
"tions\030\003 \001(\0132\034.google.protobuf.EnumOption"
"s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 "
"\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g"
"oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv"
"iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth"
"od\030\002 \003(\0132&.google.protobuf.MethodDescrip"
"torProto\0220\n\007options\030\003 \001(\0132\037.google.proto"
"buf.ServiceOptions\"\301\001\n\025MethodDescriptorP"
"roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023"
"\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g"
"oogle.protobuf.MethodOptions\022\037\n\020client_s"
"treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin"
"g\030\006 \001(\010:\005false\"\264\005\n\013FileOptions\022\024\n\014java_p"
"ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001"
"(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)"
"\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030"
"\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false"
"\022F\n\014optimize_for\030\t \001(\0162).google.protobuf"
".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p"
"ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001("
"\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:"
"\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal"
"se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab"
"le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre"
"fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s"
"wift_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( "
"\001(\t\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo"
"gle.protobuf.UninterpretedOption\":\n\014Opti"
"mizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LI"
"TE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016Messag"
"eOptions\022&\n\027message_set_wire_format\030\001 \001("
"\010:\005false\022.\n\037no_standard_descriptor_acces"
"sor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005fa"
"lse\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_"
"option\030\347\007 \003(\0132$.google.protobuf.Uninterp"
"retedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014F"
"ieldOptions\022:\n\005ctype\030\001 \001(\0162#.google.prot"
"obuf.FieldOptions.CType:\006STRING\022\016\n\006packe"
"d\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google.protobu"
"f.FieldOptions.JSType:\tJS_NORMAL\022\023\n\004lazy"
"\030\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false"
"\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_o"
"ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr"
"etedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020"
"\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORM"
"AL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020"
"\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpr"
"eted_option\030\347\007 \003(\0132$.google.protobuf.Uni"
"nterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOpti"
"ons\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003"
" \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003"
"(\0132$.google.protobuf.UninterpretedOption"
"*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n"
"\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterprete"
"d_option\030\347\007 \003(\0132$.google.protobuf.Uninte"
"rpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptio"
"ns\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninter"
"preted_option\030\347\007 \003(\0132$.google.protobuf.U"
"ninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethod"
"Options\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021id"
"empotency_level\030\" \001(\0162/.google.protobuf."
"MethodOptions.IdempotencyLevel:\023IDEMPOTE"
"NCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003"
"(\0132$.google.protobuf.UninterpretedOption"
"\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKN"
"OWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT"
"\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n"
"\004name\030\002 \003(\0132-.google.protobuf.Uninterpre"
"tedOption.NamePart\022\030\n\020identifier_value\030\003"
" \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022nega"
"tive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001"
"(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_va"
"lue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t"
"\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInf"
"o\022:\n\010location\030\001 \003(\0132(.google.protobuf.So"
"urceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pa"
"th\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leadin"
"g_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 "
"\001(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\247"
"\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\013"
"2-.google.protobuf.GeneratedCodeInfo.Ann"
"otation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022"
"\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e"
"nd\030\004 \001(\005B\214\001\n\023com.google.protobufB\020Descri"
"ptorProtosH\001Z>github.com/golang/protobuf"
"/protoc-gen-go/descriptor;descriptor\242\002\003G"
"PB\252\002\032Google.Protobuf.Reflection"
};
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
descriptor, 5591);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/descriptor.proto", &protobuf_RegisterTypes);
::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
void AddDescriptors() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer {
StaticDescriptorInitializer() {
AddDescriptors();
}
} static_descriptor_initializer;
} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto
const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[0];
}
bool FieldDescriptorProto_Type_IsValid(int value) {
switch (value) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32;
const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64;
const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN;
const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX;
const int FieldDescriptorProto::Type_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[1];
}
bool FieldDescriptorProto_Label_IsValid(int value) {
switch (value) {
case 1:
case 2:
case 3:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL;
const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED;
const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED;
const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN;
const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX;
const int FieldDescriptorProto::Label_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[2];
}
bool FileOptions_OptimizeMode_IsValid(int value) {
switch (value) {
case 1:
case 2:
case 3:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const FileOptions_OptimizeMode FileOptions::SPEED;
const FileOptions_OptimizeMode FileOptions::CODE_SIZE;
const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME;
const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN;
const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX;
const int FileOptions::OptimizeMode_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[3];
}
bool FieldOptions_CType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const FieldOptions_CType FieldOptions::STRING;
const FieldOptions_CType FieldOptions::CORD;
const FieldOptions_CType FieldOptions::STRING_PIECE;
const FieldOptions_CType FieldOptions::CType_MIN;
const FieldOptions_CType FieldOptions::CType_MAX;
const int FieldOptions::CType_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[4];
}
bool FieldOptions_JSType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const FieldOptions_JSType FieldOptions::JS_NORMAL;
const FieldOptions_JSType FieldOptions::JS_STRING;
const FieldOptions_JSType FieldOptions::JS_NUMBER;
const FieldOptions_JSType FieldOptions::JSType_MIN;
const FieldOptions_JSType FieldOptions::JSType_MAX;
const int FieldOptions::JSType_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[5];
}
bool MethodOptions_IdempotencyLevel_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENCY_UNKNOWN;
const MethodOptions_IdempotencyLevel MethodOptions::NO_SIDE_EFFECTS;
const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENT;
const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MIN;
const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MAX;
const int MethodOptions::IdempotencyLevel_ARRAYSIZE;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FileDescriptorSet::kFileFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FileDescriptorSet::FileDescriptorSet()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet)
}
FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
file_(from.file_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet)
}
void FileDescriptorSet::SharedCtor() {
_cached_size_ = 0;
}
FileDescriptorSet::~FileDescriptorSet() {
// @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorSet)
SharedDtor();
}
void FileDescriptorSet::SharedDtor() {
}
void FileDescriptorSet::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FileDescriptorSet& FileDescriptorSet::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const {
FileDescriptorSet* n = new FileDescriptorSet;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void FileDescriptorSet::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet)
file_.Clear();
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool FileDescriptorSet::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.FileDescriptorProto file = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_file()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FileDescriptorSet)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FileDescriptorSet)
return false;
#undef DO_
}
void FileDescriptorSet::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FileDescriptorSet)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.FileDescriptorProto file = 1;
for (unsigned int i = 0, n = this->file_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->file(i), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorSet)
}
::google::protobuf::uint8* FileDescriptorSet::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.FileDescriptorProto file = 1;
for (unsigned int i = 0, n = this->file_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
1, this->file(i), deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorSet)
return target;
}
size_t FileDescriptorSet::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.FileDescriptorProto file = 1;
{
unsigned int count = this->file_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->file(i));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet)
GOOGLE_DCHECK_NE(&from, this);
const FileDescriptorSet* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileDescriptorSet)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet)
MergeFrom(*source);
}
}
void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
file_.MergeFrom(from.file_);
}
void FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileDescriptorSet)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FileDescriptorSet::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->file())) return false;
return true;
}
void FileDescriptorSet::Swap(FileDescriptorSet* other) {
if (other == this) return;
InternalSwap(other);
}
void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
file_.InternalSwap(&other->file_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FileDescriptorSet
// repeated .google.protobuf.FileDescriptorProto file = 1;
int FileDescriptorSet::file_size() const {
return file_.size();
}
void FileDescriptorSet::clear_file() {
file_.Clear();
}
const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file)
return file_.Get(index);
}
::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file)
return file_.Mutable(index);
}
::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file)
return file_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
FileDescriptorSet::mutable_file() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file)
return &file_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
FileDescriptorSet::file() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file)
return file_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FileDescriptorProto::kNameFieldNumber;
const int FileDescriptorProto::kPackageFieldNumber;
const int FileDescriptorProto::kDependencyFieldNumber;
const int FileDescriptorProto::kPublicDependencyFieldNumber;
const int FileDescriptorProto::kWeakDependencyFieldNumber;
const int FileDescriptorProto::kMessageTypeFieldNumber;
const int FileDescriptorProto::kEnumTypeFieldNumber;
const int FileDescriptorProto::kServiceFieldNumber;
const int FileDescriptorProto::kExtensionFieldNumber;
const int FileDescriptorProto::kOptionsFieldNumber;
const int FileDescriptorProto::kSourceCodeInfoFieldNumber;
const int FileDescriptorProto::kSyntaxFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FileDescriptorProto::FileDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto)
}
FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
dependency_(from.dependency_),
message_type_(from.message_type_),
enum_type_(from.enum_type_),
service_(from.service_),
extension_(from.extension_),
public_dependency_(from.public_dependency_),
weak_dependency_(from.weak_dependency_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_package()) {
package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_);
}
syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_syntax()) {
syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::FileOptions(*from.options_);
} else {
options_ = NULL;
}
if (from.has_source_code_info()) {
source_code_info_ = new ::google::protobuf::SourceCodeInfo(*from.source_code_info_);
} else {
source_code_info_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto)
}
void FileDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&options_, 0, reinterpret_cast<char*>(&source_code_info_) -
reinterpret_cast<char*>(&options_) + sizeof(source_code_info_));
}
FileDescriptorProto::~FileDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorProto)
SharedDtor();
}
void FileDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
if (this != internal_default_instance()) {
delete source_code_info_;
}
}
void FileDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FileDescriptorProto& FileDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const {
FileDescriptorProto* n = new FileDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void FileDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto)
dependency_.Clear();
message_type_.Clear();
enum_type_.Clear();
service_.Clear();
extension_.Clear();
public_dependency_.Clear();
weak_dependency_.Clear();
if (_has_bits_[0 / 32] & 31u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_package()) {
GOOGLE_DCHECK(!package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*package_.UnsafeRawStringPointer())->clear();
}
if (has_syntax()) {
GOOGLE_DCHECK(!syntax_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*syntax_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::FileOptions::Clear();
}
if (has_source_code_info()) {
GOOGLE_DCHECK(source_code_info_ != NULL);
source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool FileDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// optional string package = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->package().data(), this->package().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileDescriptorProto.package");
} else {
goto handle_unusual;
}
break;
}
// repeated string dependency = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_dependency()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(this->dependency_size() - 1).data(),
this->dependency(this->dependency_size() - 1).length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileDescriptorProto.dependency");
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_message_type()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(42u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_enum_type()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_service()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_extension()));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FileOptions options = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(74u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_source_code_info()));
} else {
goto handle_unusual;
}
break;
}
// repeated int32 public_dependency = 10;
case 10: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(80u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 80u, input, this->mutable_public_dependency())));
} else if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(82u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_public_dependency())));
} else {
goto handle_unusual;
}
break;
}
// repeated int32 weak_dependency = 11;
case 11: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(88u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 88u, input, this->mutable_weak_dependency())));
} else if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(90u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_weak_dependency())));
} else {
goto handle_unusual;
}
break;
}
// optional string syntax = 12;
case 12: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(98u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_syntax()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->syntax().data(), this->syntax().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileDescriptorProto.syntax");
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FileDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FileDescriptorProto)
return false;
#undef DO_
}
void FileDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FileDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// optional string package = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->package().data(), this->package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.package");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->package(), output);
}
// repeated string dependency = 3;
for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.dependency");
::google::protobuf::internal::WireFormatLite::WriteString(
3, this->dependency(i), output);
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, this->message_type(i), output);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5, this->enum_type(i), output);
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
for (unsigned int i = 0, n = this->service_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
6, this->service(i), output);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
7, this->extension(i), output);
}
// optional .google.protobuf.FileOptions options = 8;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, *this->options_, output);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
9, *this->source_code_info_, output);
}
// repeated int32 public_dependency = 10;
for (int i = 0, n = this->public_dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
10, this->public_dependency(i), output);
}
// repeated int32 weak_dependency = 11;
for (int i = 0, n = this->weak_dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
11, this->weak_dependency(i), output);
}
// optional string syntax = 12;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->syntax().data(), this->syntax().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.syntax");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
12, this->syntax(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorProto)
}
::google::protobuf::uint8* FileDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// optional string package = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->package().data(), this->package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.package");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->package(), target);
}
// repeated string dependency = 3;
for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.dependency");
target = ::google::protobuf::internal::WireFormatLite::
WriteStringToArray(3, this->dependency(i), target);
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
4, this->message_type(i), deterministic, target);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
5, this->enum_type(i), deterministic, target);
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
for (unsigned int i = 0, n = this->service_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
6, this->service(i), deterministic, target);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
7, this->extension(i), deterministic, target);
}
// optional .google.protobuf.FileOptions options = 8;
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
8, *this->options_, deterministic, target);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (cached_has_bits & 0x00000010u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
9, *this->source_code_info_, deterministic, target);
}
// repeated int32 public_dependency = 10;
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(10, this->public_dependency_, target);
// repeated int32 weak_dependency = 11;
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(11, this->weak_dependency_, target);
// optional string syntax = 12;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->syntax().data(), this->syntax().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.syntax");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
12, this->syntax(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorProto)
return target;
}
size_t FileDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated string dependency = 3;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->dependency_size());
for (int i = 0, n = this->dependency_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->dependency(i));
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
{
unsigned int count = this->message_type_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->message_type(i));
}
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
{
unsigned int count = this->enum_type_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->enum_type(i));
}
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
{
unsigned int count = this->service_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->service(i));
}
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
{
unsigned int count = this->extension_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->extension(i));
}
}
// repeated int32 public_dependency = 10;
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->public_dependency_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->public_dependency_size());
total_size += data_size;
}
// repeated int32 weak_dependency = 11;
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->weak_dependency_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->weak_dependency_size());
total_size += data_size;
}
if (_has_bits_[0 / 32] & 31u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional string package = 2;
if (has_package()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->package());
}
// optional string syntax = 12;
if (has_syntax()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->syntax());
}
// optional .google.protobuf.FileOptions options = 8;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
if (has_source_code_info()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->source_code_info_);
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const FileDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto)
MergeFrom(*source);
}
}
void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
dependency_.MergeFrom(from.dependency_);
message_type_.MergeFrom(from.message_type_);
enum_type_.MergeFrom(from.enum_type_);
service_.MergeFrom(from.service_);
extension_.MergeFrom(from.extension_);
public_dependency_.MergeFrom(from.public_dependency_);
weak_dependency_.MergeFrom(from.weak_dependency_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 31u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
set_has_package();
package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_);
}
if (cached_has_bits & 0x00000004u) {
set_has_syntax();
syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);
}
if (cached_has_bits & 0x00000008u) {
mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options());
}
if (cached_has_bits & 0x00000010u) {
mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info());
}
}
}
void FileDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FileDescriptorProto::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->message_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->service())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void FileDescriptorProto::Swap(FileDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
dependency_.InternalSwap(&other->dependency_);
message_type_.InternalSwap(&other->message_type_);
enum_type_.InternalSwap(&other->enum_type_);
service_.InternalSwap(&other->service_);
extension_.InternalSwap(&other->extension_);
public_dependency_.InternalSwap(&other->public_dependency_);
weak_dependency_.InternalSwap(&other->weak_dependency_);
name_.Swap(&other->name_);
package_.Swap(&other->package_);
syntax_.Swap(&other->syntax_);
std::swap(options_, other->options_);
std::swap(source_code_info_, other->source_code_info_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FileDescriptorProto
// optional string name = 1;
bool FileDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void FileDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void FileDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void FileDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& FileDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)
return name_.GetNoArena();
}
void FileDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)
}
#if LANG_CXX11
void FileDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name)
}
#endif
void FileDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name)
}
void FileDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name)
}
::std::string* FileDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name)
}
// optional string package = 2;
bool FileDescriptorProto::has_package() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void FileDescriptorProto::set_has_package() {
_has_bits_[0] |= 0x00000002u;
}
void FileDescriptorProto::clear_has_package() {
_has_bits_[0] &= ~0x00000002u;
}
void FileDescriptorProto::clear_package() {
package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_package();
}
const ::std::string& FileDescriptorProto::package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)
return package_.GetNoArena();
}
void FileDescriptorProto::set_package(const ::std::string& value) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)
}
#if LANG_CXX11
void FileDescriptorProto::set_package(::std::string&& value) {
set_has_package();
package_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package)
}
#endif
void FileDescriptorProto::set_package(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package)
}
void FileDescriptorProto::set_package(const char* value, size_t size) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package)
}
::std::string* FileDescriptorProto::mutable_package() {
set_has_package();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package)
return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileDescriptorProto::release_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package)
clear_has_package();
return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileDescriptorProto::set_allocated_package(::std::string* package) {
if (package != NULL) {
set_has_package();
} else {
clear_has_package();
}
package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package)
}
// repeated string dependency = 3;
int FileDescriptorProto::dependency_size() const {
return dependency_.size();
}
void FileDescriptorProto::clear_dependency() {
dependency_.Clear();
}
const ::std::string& FileDescriptorProto::dependency(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency)
return dependency_.Get(index);
}
::std::string* FileDescriptorProto::mutable_dependency(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency)
return dependency_.Mutable(index);
}
void FileDescriptorProto::set_dependency(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
dependency_.Mutable(index)->assign(value);
}
#if LANG_CXX11
void FileDescriptorProto::set_dependency(int index, ::std::string&& value) {
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
dependency_.Mutable(index)->assign(std::move(value));
}
#endif
void FileDescriptorProto::set_dependency(int index, const char* value) {
GOOGLE_DCHECK(value != NULL);
dependency_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)
}
void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) {
dependency_.Mutable(index)->assign(
reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency)
}
::std::string* FileDescriptorProto::add_dependency() {
// @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency)
return dependency_.Add();
}
void FileDescriptorProto::add_dependency(const ::std::string& value) {
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
}
#if LANG_CXX11
void FileDescriptorProto::add_dependency(::std::string&& value) {
dependency_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
}
#endif
void FileDescriptorProto::add_dependency(const char* value) {
GOOGLE_DCHECK(value != NULL);
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)
}
void FileDescriptorProto::add_dependency(const char* value, size_t size) {
dependency_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency)
}
const ::google::protobuf::RepeatedPtrField< ::std::string>&
FileDescriptorProto::dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency)
return dependency_;
}
::google::protobuf::RepeatedPtrField< ::std::string>*
FileDescriptorProto::mutable_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency)
return &dependency_;
}
// repeated int32 public_dependency = 10;
int FileDescriptorProto::public_dependency_size() const {
return public_dependency_.size();
}
void FileDescriptorProto::clear_public_dependency() {
public_dependency_.Clear();
}
::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency)
return public_dependency_.Get(index);
}
void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) {
public_dependency_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency)
}
void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) {
public_dependency_.Add(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency)
}
const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
FileDescriptorProto::public_dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency)
return public_dependency_;
}
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
FileDescriptorProto::mutable_public_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency)
return &public_dependency_;
}
// repeated int32 weak_dependency = 11;
int FileDescriptorProto::weak_dependency_size() const {
return weak_dependency_.size();
}
void FileDescriptorProto::clear_weak_dependency() {
weak_dependency_.Clear();
}
::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency)
return weak_dependency_.Get(index);
}
void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) {
weak_dependency_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency)
}
void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) {
weak_dependency_.Add(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency)
}
const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
FileDescriptorProto::weak_dependency() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency)
return weak_dependency_;
}
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
FileDescriptorProto::mutable_weak_dependency() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency)
return &weak_dependency_;
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
int FileDescriptorProto::message_type_size() const {
return message_type_.size();
}
void FileDescriptorProto::clear_message_type() {
message_type_.Clear();
}
const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type)
return message_type_.Get(index);
}
::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type)
return message_type_.Mutable(index);
}
::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type)
return message_type_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
FileDescriptorProto::mutable_message_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type)
return &message_type_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
FileDescriptorProto::message_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type)
return message_type_;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
int FileDescriptorProto::enum_type_size() const {
return enum_type_.size();
}
void FileDescriptorProto::clear_enum_type() {
enum_type_.Clear();
}
const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type)
return enum_type_.Get(index);
}
::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type)
return enum_type_.Mutable(index);
}
::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type)
return enum_type_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
FileDescriptorProto::mutable_enum_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type)
return &enum_type_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
FileDescriptorProto::enum_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type)
return enum_type_;
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
int FileDescriptorProto::service_size() const {
return service_.size();
}
void FileDescriptorProto::clear_service() {
service_.Clear();
}
const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service)
return service_.Get(index);
}
::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service)
return service_.Mutable(index);
}
::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service)
return service_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*
FileDescriptorProto::mutable_service() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service)
return &service_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&
FileDescriptorProto::service() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service)
return service_;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
int FileDescriptorProto::extension_size() const {
return extension_.size();
}
void FileDescriptorProto::clear_extension() {
extension_.Clear();
}
const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension)
return extension_.Get(index);
}
::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension)
return extension_.Mutable(index);
}
::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() {
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension)
return extension_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
FileDescriptorProto::mutable_extension() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension)
return &extension_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
FileDescriptorProto::extension() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension)
return extension_;
}
// optional .google.protobuf.FileOptions options = 8;
bool FileDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void FileDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000008u;
}
void FileDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000008u;
}
void FileDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();
clear_has_options();
}
const ::google::protobuf::FileOptions& FileDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::FileOptions::internal_default_instance();
}
::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::FileOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options)
return options_;
}
::google::protobuf::FileOptions* FileDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options)
clear_has_options();
::google::protobuf::FileOptions* temp = options_;
options_ = NULL;
return temp;
}
void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options)
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
bool FileDescriptorProto::has_source_code_info() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void FileDescriptorProto::set_has_source_code_info() {
_has_bits_[0] |= 0x00000010u;
}
void FileDescriptorProto::clear_has_source_code_info() {
_has_bits_[0] &= ~0x00000010u;
}
void FileDescriptorProto::clear_source_code_info() {
if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
clear_has_source_code_info();
}
const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info)
return source_code_info_ != NULL ? *source_code_info_
: *::google::protobuf::SourceCodeInfo::internal_default_instance();
}
::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() {
set_has_source_code_info();
if (source_code_info_ == NULL) {
source_code_info_ = new ::google::protobuf::SourceCodeInfo;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info)
return source_code_info_;
}
::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info)
clear_has_source_code_info();
::google::protobuf::SourceCodeInfo* temp = source_code_info_;
source_code_info_ = NULL;
return temp;
}
void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) {
delete source_code_info_;
source_code_info_ = source_code_info;
if (source_code_info) {
set_has_source_code_info();
} else {
clear_has_source_code_info();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info)
}
// optional string syntax = 12;
bool FileDescriptorProto::has_syntax() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void FileDescriptorProto::set_has_syntax() {
_has_bits_[0] |= 0x00000004u;
}
void FileDescriptorProto::clear_has_syntax() {
_has_bits_[0] &= ~0x00000004u;
}
void FileDescriptorProto::clear_syntax() {
syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_syntax();
}
const ::std::string& FileDescriptorProto::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)
return syntax_.GetNoArena();
}
void FileDescriptorProto::set_syntax(const ::std::string& value) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)
}
#if LANG_CXX11
void FileDescriptorProto::set_syntax(::std::string&& value) {
set_has_syntax();
syntax_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax)
}
#endif
void FileDescriptorProto::set_syntax(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax)
}
void FileDescriptorProto::set_syntax(const char* value, size_t size) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax)
}
::std::string* FileDescriptorProto::mutable_syntax() {
set_has_syntax();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax)
return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileDescriptorProto::release_syntax() {
// @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax)
clear_has_syntax();
return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) {
if (syntax != NULL) {
set_has_syntax();
} else {
clear_has_syntax();
}
syntax_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DescriptorProto_ExtensionRange::kStartFieldNumber;
const int DescriptorProto_ExtensionRange::kEndFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&start_, &from.start_,
reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
void DescriptorProto_ExtensionRange::SharedCtor() {
_cached_size_ = 0;
::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
}
DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ExtensionRange)
SharedDtor();
}
void DescriptorProto_ExtensionRange::SharedDtor() {
}
void DescriptorProto_ExtensionRange::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const {
DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void DescriptorProto_ExtensionRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)
if (_has_bits_[0 / 32] & 3u) {
::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional int32 start = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
set_has_start();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &start_)));
} else {
goto handle_unusual;
}
break;
}
// optional int32 end = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &end_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto.ExtensionRange)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto.ExtensionRange)
return false;
#undef DO_
}
void DescriptorProto_ExtensionRange::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto.ExtensionRange)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ExtensionRange)
}
::google::protobuf::uint8* DescriptorProto_ExtensionRange::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ExtensionRange)
return target;
}
size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 3u) {
// optional int32 start = 1;
if (has_start()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->start());
}
// optional int32 end = 2;
if (has_end()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->end());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto_ExtensionRange* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto.ExtensionRange)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange)
MergeFrom(*source);
}
}
void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
start_ = from.start_;
}
if (cached_has_bits & 0x00000002u) {
end_ = from.end_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRange& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool DescriptorProto_ExtensionRange::IsInitialized() const {
return true;
}
void DescriptorProto_ExtensionRange::Swap(DescriptorProto_ExtensionRange* other) {
if (other == this) return;
InternalSwap(other);
}
void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) {
std::swap(start_, other->start_);
std::swap(end_, other->end_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// DescriptorProto_ExtensionRange
// optional int32 start = 1;
bool DescriptorProto_ExtensionRange::has_start() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void DescriptorProto_ExtensionRange::set_has_start() {
_has_bits_[0] |= 0x00000001u;
}
void DescriptorProto_ExtensionRange::clear_has_start() {
_has_bits_[0] &= ~0x00000001u;
}
void DescriptorProto_ExtensionRange::clear_start() {
start_ = 0;
clear_has_start();
}
::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)
return start_;
}
void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) {
set_has_start();
start_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)
}
// optional int32 end = 2;
bool DescriptorProto_ExtensionRange::has_end() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void DescriptorProto_ExtensionRange::set_has_end() {
_has_bits_[0] |= 0x00000002u;
}
void DescriptorProto_ExtensionRange::clear_has_end() {
_has_bits_[0] &= ~0x00000002u;
}
void DescriptorProto_ExtensionRange::clear_end() {
end_ = 0;
clear_has_end();
}
::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)
return end_;
}
void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) {
set_has_end();
end_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DescriptorProto_ReservedRange::kStartFieldNumber;
const int DescriptorProto_ReservedRange::kEndFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange)
}
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&start_, &from.start_,
reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
void DescriptorProto_ReservedRange::SharedCtor() {
_cached_size_ = 0;
::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
}
DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ReservedRange)
SharedDtor();
}
void DescriptorProto_ReservedRange::SharedDtor() {
}
void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const {
DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void DescriptorProto_ReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)
if (_has_bits_[0 / 32] & 3u) {
::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&start_) + sizeof(end_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional int32 start = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
set_has_start();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &start_)));
} else {
goto handle_unusual;
}
break;
}
// optional int32 end = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &end_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto.ReservedRange)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto.ReservedRange)
return false;
#undef DO_
}
void DescriptorProto_ReservedRange::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto.ReservedRange)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ReservedRange)
}
::google::protobuf::uint8* DescriptorProto_ReservedRange::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional int32 start = 1;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target);
}
// optional int32 end = 2;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ReservedRange)
return target;
}
size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 3u) {
// optional int32 start = 1;
if (has_start()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->start());
}
// optional int32 end = 2;
if (has_end()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->end());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto_ReservedRange* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto.ReservedRange)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange)
MergeFrom(*source);
}
}
void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
start_ = from.start_;
}
if (cached_has_bits & 0x00000002u) {
end_ = from.end_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void DescriptorProto_ReservedRange::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto.ReservedRange)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool DescriptorProto_ReservedRange::IsInitialized() const {
return true;
}
void DescriptorProto_ReservedRange::Swap(DescriptorProto_ReservedRange* other) {
if (other == this) return;
InternalSwap(other);
}
void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) {
std::swap(start_, other->start_);
std::swap(end_, other->end_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// DescriptorProto_ReservedRange
// optional int32 start = 1;
bool DescriptorProto_ReservedRange::has_start() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void DescriptorProto_ReservedRange::set_has_start() {
_has_bits_[0] |= 0x00000001u;
}
void DescriptorProto_ReservedRange::clear_has_start() {
_has_bits_[0] &= ~0x00000001u;
}
void DescriptorProto_ReservedRange::clear_start() {
start_ = 0;
clear_has_start();
}
::google::protobuf::int32 DescriptorProto_ReservedRange::start() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)
return start_;
}
void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) {
set_has_start();
start_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)
}
// optional int32 end = 2;
bool DescriptorProto_ReservedRange::has_end() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void DescriptorProto_ReservedRange::set_has_end() {
_has_bits_[0] |= 0x00000002u;
}
void DescriptorProto_ReservedRange::clear_has_end() {
_has_bits_[0] &= ~0x00000002u;
}
void DescriptorProto_ReservedRange::clear_end() {
end_ = 0;
clear_has_end();
}
::google::protobuf::int32 DescriptorProto_ReservedRange::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)
return end_;
}
void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) {
set_has_end();
end_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DescriptorProto::kNameFieldNumber;
const int DescriptorProto::kFieldFieldNumber;
const int DescriptorProto::kExtensionFieldNumber;
const int DescriptorProto::kNestedTypeFieldNumber;
const int DescriptorProto::kEnumTypeFieldNumber;
const int DescriptorProto::kExtensionRangeFieldNumber;
const int DescriptorProto::kOneofDeclFieldNumber;
const int DescriptorProto::kOptionsFieldNumber;
const int DescriptorProto::kReservedRangeFieldNumber;
const int DescriptorProto::kReservedNameFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
DescriptorProto::DescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto)
}
DescriptorProto::DescriptorProto(const DescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
field_(from.field_),
nested_type_(from.nested_type_),
enum_type_(from.enum_type_),
extension_range_(from.extension_range_),
extension_(from.extension_),
oneof_decl_(from.oneof_decl_),
reserved_range_(from.reserved_range_),
reserved_name_(from.reserved_name_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::MessageOptions(*from.options_);
} else {
options_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto)
}
void DescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
options_ = NULL;
}
DescriptorProto::~DescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto)
SharedDtor();
}
void DescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void DescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const DescriptorProto& DescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {
DescriptorProto* n = new DescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void DescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto)
field_.Clear();
nested_type_.Clear();
enum_type_.Clear();
extension_range_.Clear();
extension_.Clear();
oneof_decl_.Clear();
reserved_range_.Clear();
reserved_name_.Clear();
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::MessageOptions::Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool DescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.DescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_field()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_nested_type()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_enum_type()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(42u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_extension_range()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_extension()));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.MessageOptions options = 7;
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_oneof_decl()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(74u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_reserved_range()));
} else {
goto handle_unusual;
}
break;
}
// repeated string reserved_name = 10;
case 10: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(82u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_reserved_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(this->reserved_name_size() - 1).data(),
this->reserved_name(this->reserved_name_size() - 1).length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.DescriptorProto.reserved_name");
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto)
return false;
#undef DO_
}
void DescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
for (unsigned int i = 0, n = this->field_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->field(i), output);
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, this->nested_type(i), output);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, this->enum_type(i), output);
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5, this->extension_range(i), output);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
6, this->extension(i), output);
}
// optional .google.protobuf.MessageOptions options = 7;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
7, *this->options_, output);
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, this->oneof_decl(i), output);
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
9, this->reserved_range(i), output);
}
// repeated string reserved_name = 10;
for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.reserved_name");
::google::protobuf::internal::WireFormatLite::WriteString(
10, this->reserved_name(i), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto)
}
::google::protobuf::uint8* DescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
for (unsigned int i = 0, n = this->field_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
2, this->field(i), deterministic, target);
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
3, this->nested_type(i), deterministic, target);
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
4, this->enum_type(i), deterministic, target);
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
5, this->extension_range(i), deterministic, target);
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
6, this->extension(i), deterministic, target);
}
// optional .google.protobuf.MessageOptions options = 7;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
7, *this->options_, deterministic, target);
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
8, this->oneof_decl(i), deterministic, target);
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
9, this->reserved_range(i), deterministic, target);
}
// repeated string reserved_name = 10;
for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.reserved_name");
target = ::google::protobuf::internal::WireFormatLite::
WriteStringToArray(10, this->reserved_name(i), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto)
return target;
}
size_t DescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
{
unsigned int count = this->field_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->field(i));
}
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
{
unsigned int count = this->nested_type_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->nested_type(i));
}
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
{
unsigned int count = this->enum_type_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->enum_type(i));
}
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
{
unsigned int count = this->extension_range_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->extension_range(i));
}
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
{
unsigned int count = this->extension_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->extension(i));
}
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
{
unsigned int count = this->oneof_decl_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->oneof_decl(i));
}
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
{
unsigned int count = this->reserved_range_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->reserved_range(i));
}
}
// repeated string reserved_name = 10;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->reserved_name_size());
for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->reserved_name(i));
}
if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional .google.protobuf.MessageOptions options = 7;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto)
MergeFrom(*source);
}
}
void DescriptorProto::MergeFrom(const DescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
field_.MergeFrom(from.field_);
nested_type_.MergeFrom(from.nested_type_);
enum_type_.MergeFrom(from.enum_type_);
extension_range_.MergeFrom(from.extension_range_);
extension_.MergeFrom(from.extension_);
oneof_decl_.MergeFrom(from.oneof_decl_);
reserved_range_.MergeFrom(from.reserved_range_);
reserved_name_.MergeFrom(from.reserved_name_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options());
}
}
}
void DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void DescriptorProto::CopyFrom(const DescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool DescriptorProto::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->oneof_decl())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void DescriptorProto::Swap(DescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void DescriptorProto::InternalSwap(DescriptorProto* other) {
field_.InternalSwap(&other->field_);
nested_type_.InternalSwap(&other->nested_type_);
enum_type_.InternalSwap(&other->enum_type_);
extension_range_.InternalSwap(&other->extension_range_);
extension_.InternalSwap(&other->extension_);
oneof_decl_.InternalSwap(&other->oneof_decl_);
reserved_range_.InternalSwap(&other->reserved_range_);
reserved_name_.InternalSwap(&other->reserved_name_);
name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata DescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// DescriptorProto
// optional string name = 1;
bool DescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void DescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void DescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void DescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& DescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)
return name_.GetNoArena();
}
void DescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)
}
#if LANG_CXX11
void DescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name)
}
#endif
void DescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name)
}
void DescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name)
}
::std::string* DescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* DescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void DescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name)
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
int DescriptorProto::field_size() const {
return field_.size();
}
void DescriptorProto::clear_field() {
field_.Clear();
}
const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field)
return field_.Get(index);
}
::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field)
return field_.Mutable(index);
}
::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field)
return field_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
DescriptorProto::mutable_field() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field)
return &field_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
DescriptorProto::field() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field)
return field_;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
int DescriptorProto::extension_size() const {
return extension_.size();
}
void DescriptorProto::clear_extension() {
extension_.Clear();
}
const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension)
return extension_.Get(index);
}
::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension)
return extension_.Mutable(index);
}
::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension)
return extension_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*
DescriptorProto::mutable_extension() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension)
return &extension_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
DescriptorProto::extension() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension)
return extension_;
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
int DescriptorProto::nested_type_size() const {
return nested_type_.size();
}
void DescriptorProto::clear_nested_type() {
nested_type_.Clear();
}
const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type)
return nested_type_.Get(index);
}
::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type)
return nested_type_.Mutable(index);
}
::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type)
return nested_type_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*
DescriptorProto::mutable_nested_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type)
return &nested_type_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&
DescriptorProto::nested_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type)
return nested_type_;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
int DescriptorProto::enum_type_size() const {
return enum_type_.size();
}
void DescriptorProto::clear_enum_type() {
enum_type_.Clear();
}
const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type)
return enum_type_.Get(index);
}
::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type)
return enum_type_.Mutable(index);
}
::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type)
return enum_type_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*
DescriptorProto::mutable_enum_type() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type)
return &enum_type_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&
DescriptorProto::enum_type() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type)
return enum_type_;
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
int DescriptorProto::extension_range_size() const {
return extension_range_.size();
}
void DescriptorProto::clear_extension_range() {
extension_range_.Clear();
}
const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range)
return extension_range_.Get(index);
}
::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range)
return extension_range_.Mutable(index);
}
::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range)
return extension_range_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*
DescriptorProto::mutable_extension_range() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range)
return &extension_range_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&
DescriptorProto::extension_range() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range)
return extension_range_;
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
int DescriptorProto::oneof_decl_size() const {
return oneof_decl_.size();
}
void DescriptorProto::clear_oneof_decl() {
oneof_decl_.Clear();
}
const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl)
return oneof_decl_.Get(index);
}
::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl)
return oneof_decl_.Mutable(index);
}
::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl)
return oneof_decl_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*
DescriptorProto::mutable_oneof_decl() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl)
return &oneof_decl_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&
DescriptorProto::oneof_decl() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl)
return oneof_decl_;
}
// optional .google.protobuf.MessageOptions options = 7;
bool DescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void DescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000002u;
}
void DescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000002u;
}
void DescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();
clear_has_options();
}
const ::google::protobuf::MessageOptions& DescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::MessageOptions::internal_default_instance();
}
::google::protobuf::MessageOptions* DescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::MessageOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options)
return options_;
}
::google::protobuf::MessageOptions* DescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options)
clear_has_options();
::google::protobuf::MessageOptions* temp = options_;
options_ = NULL;
return temp;
}
void DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options)
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
int DescriptorProto::reserved_range_size() const {
return reserved_range_.size();
}
void DescriptorProto::clear_reserved_range() {
reserved_range_.Clear();
}
const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range)
return reserved_range_.Get(index);
}
::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range)
return reserved_range_.Mutable(index);
}
::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() {
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range)
return reserved_range_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*
DescriptorProto::mutable_reserved_range() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range)
return &reserved_range_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&
DescriptorProto::reserved_range() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range)
return reserved_range_;
}
// repeated string reserved_name = 10;
int DescriptorProto::reserved_name_size() const {
return reserved_name_.size();
}
void DescriptorProto::clear_reserved_name() {
reserved_name_.Clear();
}
const ::std::string& DescriptorProto::reserved_name(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name)
return reserved_name_.Get(index);
}
::std::string* DescriptorProto::mutable_reserved_name(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name)
return reserved_name_.Mutable(index);
}
void DescriptorProto::set_reserved_name(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
reserved_name_.Mutable(index)->assign(value);
}
#if LANG_CXX11
void DescriptorProto::set_reserved_name(int index, ::std::string&& value) {
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
reserved_name_.Mutable(index)->assign(std::move(value));
}
#endif
void DescriptorProto::set_reserved_name(int index, const char* value) {
GOOGLE_DCHECK(value != NULL);
reserved_name_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)
}
void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) {
reserved_name_.Mutable(index)->assign(
reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name)
}
::std::string* DescriptorProto::add_reserved_name() {
// @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name)
return reserved_name_.Add();
}
void DescriptorProto::add_reserved_name(const ::std::string& value) {
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
}
#if LANG_CXX11
void DescriptorProto::add_reserved_name(::std::string&& value) {
reserved_name_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
}
#endif
void DescriptorProto::add_reserved_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)
}
void DescriptorProto::add_reserved_name(const char* value, size_t size) {
reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name)
}
const ::google::protobuf::RepeatedPtrField< ::std::string>&
DescriptorProto::reserved_name() const {
// @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name)
return reserved_name_;
}
::google::protobuf::RepeatedPtrField< ::std::string>*
DescriptorProto::mutable_reserved_name() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name)
return &reserved_name_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FieldDescriptorProto::kNameFieldNumber;
const int FieldDescriptorProto::kNumberFieldNumber;
const int FieldDescriptorProto::kLabelFieldNumber;
const int FieldDescriptorProto::kTypeFieldNumber;
const int FieldDescriptorProto::kTypeNameFieldNumber;
const int FieldDescriptorProto::kExtendeeFieldNumber;
const int FieldDescriptorProto::kDefaultValueFieldNumber;
const int FieldDescriptorProto::kOneofIndexFieldNumber;
const int FieldDescriptorProto::kJsonNameFieldNumber;
const int FieldDescriptorProto::kOptionsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FieldDescriptorProto::FieldDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto)
}
FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_extendee()) {
extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_);
}
type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_type_name()) {
type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_);
}
default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_default_value()) {
default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);
}
json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_json_name()) {
json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::FieldOptions(*from.options_);
} else {
options_ = NULL;
}
::memcpy(&number_, &from.number_,
reinterpret_cast<char*>(&type_) -
reinterpret_cast<char*>(&number_) + sizeof(type_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto)
}
void FieldDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&options_, 0, reinterpret_cast<char*>(&oneof_index_) -
reinterpret_cast<char*>(&options_) + sizeof(oneof_index_));
label_ = 1;
type_ = 1;
}
FieldDescriptorProto::~FieldDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.FieldDescriptorProto)
SharedDtor();
}
void FieldDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
type_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void FieldDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FieldDescriptorProto& FieldDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const {
FieldDescriptorProto* n = new FieldDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void FieldDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto)
if (_has_bits_[0 / 32] & 63u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_extendee()) {
GOOGLE_DCHECK(!extendee_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*extendee_.UnsafeRawStringPointer())->clear();
}
if (has_type_name()) {
GOOGLE_DCHECK(!type_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*type_name_.UnsafeRawStringPointer())->clear();
}
if (has_default_value()) {
GOOGLE_DCHECK(!default_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*default_value_.UnsafeRawStringPointer())->clear();
}
if (has_json_name()) {
GOOGLE_DCHECK(!json_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*json_name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::FieldOptions::Clear();
}
}
if (_has_bits_[0 / 32] & 192u) {
::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) -
reinterpret_cast<char*>(&number_) + sizeof(oneof_index_));
}
if (_has_bits_[8 / 32] & 768u) {
label_ = 1;
type_ = 1;
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool FieldDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FieldDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// optional string extendee = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_extendee()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->extendee().data(), this->extendee().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FieldDescriptorProto.extendee");
} else {
goto handle_unusual;
}
break;
}
// optional int32 number = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u)) {
set_has_number();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &number_)));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(32u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::FieldDescriptorProto_Label_IsValid(value)) {
set_label(static_cast< ::google::protobuf::FieldDescriptorProto_Label >(value));
} else {
mutable_unknown_fields()->AddVarint(4, value);
}
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::FieldDescriptorProto_Type_IsValid(value)) {
set_type(static_cast< ::google::protobuf::FieldDescriptorProto_Type >(value));
} else {
mutable_unknown_fields()->AddVarint(5, value);
}
} else {
goto handle_unusual;
}
break;
}
// optional string type_name = 6;
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_type_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->type_name().data(), this->type_name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FieldDescriptorProto.type_name");
} else {
goto handle_unusual;
}
break;
}
// optional string default_value = 7;
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_default_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->default_value().data(), this->default_value().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FieldDescriptorProto.default_value");
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FieldOptions options = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
// optional int32 oneof_index = 9;
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(72u)) {
set_has_oneof_index();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &oneof_index_)));
} else {
goto handle_unusual;
}
break;
}
// optional string json_name = 10;
case 10: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(82u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_json_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->json_name().data(), this->json_name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FieldDescriptorProto.json_name");
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FieldDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FieldDescriptorProto)
return false;
#undef DO_
}
void FieldDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// optional string extendee = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->extendee().data(), this->extendee().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.extendee");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->extendee(), output);
}
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output);
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (cached_has_bits & 0x00000100u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
4, this->label(), output);
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (cached_has_bits & 0x00000200u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
5, this->type(), output);
}
// optional string type_name = 6;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->type_name().data(), this->type_name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.type_name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
6, this->type_name(), output);
}
// optional string default_value = 7;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->default_value().data(), this->default_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.default_value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
7, this->default_value(), output);
}
// optional .google.protobuf.FieldOptions options = 8;
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, *this->options_, output);
}
// optional int32 oneof_index = 9;
if (cached_has_bits & 0x00000080u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(9, this->oneof_index(), output);
}
// optional string json_name = 10;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->json_name().data(), this->json_name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.json_name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
10, this->json_name(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FieldDescriptorProto)
}
::google::protobuf::uint8* FieldDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// optional string extendee = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->extendee().data(), this->extendee().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.extendee");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->extendee(), target);
}
// optional int32 number = 3;
if (cached_has_bits & 0x00000040u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target);
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (cached_has_bits & 0x00000100u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
4, this->label(), target);
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (cached_has_bits & 0x00000200u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
5, this->type(), target);
}
// optional string type_name = 6;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->type_name().data(), this->type_name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.type_name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
6, this->type_name(), target);
}
// optional string default_value = 7;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->default_value().data(), this->default_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.default_value");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
7, this->default_value(), target);
}
// optional .google.protobuf.FieldOptions options = 8;
if (cached_has_bits & 0x00000020u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
8, *this->options_, deterministic, target);
}
// optional int32 oneof_index = 9;
if (cached_has_bits & 0x00000080u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(9, this->oneof_index(), target);
}
// optional string json_name = 10;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->json_name().data(), this->json_name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.json_name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
10, this->json_name(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldDescriptorProto)
return target;
}
size_t FieldDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 255u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional string extendee = 2;
if (has_extendee()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->extendee());
}
// optional string type_name = 6;
if (has_type_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->type_name());
}
// optional string default_value = 7;
if (has_default_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->default_value());
}
// optional string json_name = 10;
if (has_json_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->json_name());
}
// optional .google.protobuf.FieldOptions options = 8;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
// optional int32 number = 3;
if (has_number()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->number());
}
// optional int32 oneof_index = 9;
if (has_oneof_index()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->oneof_index());
}
}
if (_has_bits_[8 / 32] & 768u) {
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
if (has_label()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->label());
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
if (has_type()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const FieldDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FieldDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto)
MergeFrom(*source);
}
}
void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 255u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
set_has_extendee();
extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_);
}
if (cached_has_bits & 0x00000004u) {
set_has_type_name();
type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_);
}
if (cached_has_bits & 0x00000008u) {
set_has_default_value();
default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);
}
if (cached_has_bits & 0x00000010u) {
set_has_json_name();
json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);
}
if (cached_has_bits & 0x00000020u) {
mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options());
}
if (cached_has_bits & 0x00000040u) {
number_ = from.number_;
}
if (cached_has_bits & 0x00000080u) {
oneof_index_ = from.oneof_index_;
}
_has_bits_[0] |= cached_has_bits;
}
if (cached_has_bits & 768u) {
if (cached_has_bits & 0x00000100u) {
label_ = from.label_;
}
if (cached_has_bits & 0x00000200u) {
type_ = from.type_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void FieldDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FieldDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FieldDescriptorProto::IsInitialized() const {
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void FieldDescriptorProto::Swap(FieldDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
name_.Swap(&other->name_);
extendee_.Swap(&other->extendee_);
type_name_.Swap(&other->type_name_);
default_value_.Swap(&other->default_value_);
json_name_.Swap(&other->json_name_);
std::swap(options_, other->options_);
std::swap(number_, other->number_);
std::swap(oneof_index_, other->oneof_index_);
std::swap(label_, other->label_);
std::swap(type_, other->type_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FieldDescriptorProto
// optional string name = 1;
bool FieldDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void FieldDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void FieldDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void FieldDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& FieldDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)
return name_.GetNoArena();
}
void FieldDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)
}
#if LANG_CXX11
void FieldDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name)
}
#endif
void FieldDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name)
}
void FieldDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name)
}
::std::string* FieldDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FieldDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FieldDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name)
}
// optional int32 number = 3;
bool FieldDescriptorProto::has_number() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
void FieldDescriptorProto::set_has_number() {
_has_bits_[0] |= 0x00000040u;
}
void FieldDescriptorProto::clear_has_number() {
_has_bits_[0] &= ~0x00000040u;
}
void FieldDescriptorProto::clear_number() {
number_ = 0;
clear_has_number();
}
::google::protobuf::int32 FieldDescriptorProto::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number)
return number_;
}
void FieldDescriptorProto::set_number(::google::protobuf::int32 value) {
set_has_number();
number_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number)
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
bool FieldDescriptorProto::has_label() const {
return (_has_bits_[0] & 0x00000100u) != 0;
}
void FieldDescriptorProto::set_has_label() {
_has_bits_[0] |= 0x00000100u;
}
void FieldDescriptorProto::clear_has_label() {
_has_bits_[0] &= ~0x00000100u;
}
void FieldDescriptorProto::clear_label() {
label_ = 1;
clear_has_label();
}
::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label)
return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_);
}
void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) {
assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value));
set_has_label();
label_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label)
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
bool FieldDescriptorProto::has_type() const {
return (_has_bits_[0] & 0x00000200u) != 0;
}
void FieldDescriptorProto::set_has_type() {
_has_bits_[0] |= 0x00000200u;
}
void FieldDescriptorProto::clear_has_type() {
_has_bits_[0] &= ~0x00000200u;
}
void FieldDescriptorProto::clear_type() {
type_ = 1;
clear_has_type();
}
::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type)
return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_);
}
void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) {
assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value));
set_has_type();
type_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type)
}
// optional string type_name = 6;
bool FieldDescriptorProto::has_type_name() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void FieldDescriptorProto::set_has_type_name() {
_has_bits_[0] |= 0x00000004u;
}
void FieldDescriptorProto::clear_has_type_name() {
_has_bits_[0] &= ~0x00000004u;
}
void FieldDescriptorProto::clear_type_name() {
type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_type_name();
}
const ::std::string& FieldDescriptorProto::type_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)
return type_name_.GetNoArena();
}
void FieldDescriptorProto::set_type_name(const ::std::string& value) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)
}
#if LANG_CXX11
void FieldDescriptorProto::set_type_name(::std::string&& value) {
set_has_type_name();
type_name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name)
}
#endif
void FieldDescriptorProto::set_type_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name)
}
void FieldDescriptorProto::set_type_name(const char* value, size_t size) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name)
}
::std::string* FieldDescriptorProto::mutable_type_name() {
set_has_type_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name)
return type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FieldDescriptorProto::release_type_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name)
clear_has_type_name();
return type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) {
if (type_name != NULL) {
set_has_type_name();
} else {
clear_has_type_name();
}
type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name)
}
// optional string extendee = 2;
bool FieldDescriptorProto::has_extendee() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void FieldDescriptorProto::set_has_extendee() {
_has_bits_[0] |= 0x00000002u;
}
void FieldDescriptorProto::clear_has_extendee() {
_has_bits_[0] &= ~0x00000002u;
}
void FieldDescriptorProto::clear_extendee() {
extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_extendee();
}
const ::std::string& FieldDescriptorProto::extendee() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)
return extendee_.GetNoArena();
}
void FieldDescriptorProto::set_extendee(const ::std::string& value) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)
}
#if LANG_CXX11
void FieldDescriptorProto::set_extendee(::std::string&& value) {
set_has_extendee();
extendee_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee)
}
#endif
void FieldDescriptorProto::set_extendee(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee)
}
void FieldDescriptorProto::set_extendee(const char* value, size_t size) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee)
}
::std::string* FieldDescriptorProto::mutable_extendee() {
set_has_extendee();
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee)
return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FieldDescriptorProto::release_extendee() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee)
clear_has_extendee();
return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) {
if (extendee != NULL) {
set_has_extendee();
} else {
clear_has_extendee();
}
extendee_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee)
}
// optional string default_value = 7;
bool FieldDescriptorProto::has_default_value() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void FieldDescriptorProto::set_has_default_value() {
_has_bits_[0] |= 0x00000008u;
}
void FieldDescriptorProto::clear_has_default_value() {
_has_bits_[0] &= ~0x00000008u;
}
void FieldDescriptorProto::clear_default_value() {
default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_default_value();
}
const ::std::string& FieldDescriptorProto::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)
return default_value_.GetNoArena();
}
void FieldDescriptorProto::set_default_value(const ::std::string& value) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)
}
#if LANG_CXX11
void FieldDescriptorProto::set_default_value(::std::string&& value) {
set_has_default_value();
default_value_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value)
}
#endif
void FieldDescriptorProto::set_default_value(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value)
}
void FieldDescriptorProto::set_default_value(const char* value, size_t size) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value)
}
::std::string* FieldDescriptorProto::mutable_default_value() {
set_has_default_value();
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value)
return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FieldDescriptorProto::release_default_value() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value)
clear_has_default_value();
return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) {
if (default_value != NULL) {
set_has_default_value();
} else {
clear_has_default_value();
}
default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value)
}
// optional int32 oneof_index = 9;
bool FieldDescriptorProto::has_oneof_index() const {
return (_has_bits_[0] & 0x00000080u) != 0;
}
void FieldDescriptorProto::set_has_oneof_index() {
_has_bits_[0] |= 0x00000080u;
}
void FieldDescriptorProto::clear_has_oneof_index() {
_has_bits_[0] &= ~0x00000080u;
}
void FieldDescriptorProto::clear_oneof_index() {
oneof_index_ = 0;
clear_has_oneof_index();
}
::google::protobuf::int32 FieldDescriptorProto::oneof_index() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index)
return oneof_index_;
}
void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) {
set_has_oneof_index();
oneof_index_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index)
}
// optional string json_name = 10;
bool FieldDescriptorProto::has_json_name() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void FieldDescriptorProto::set_has_json_name() {
_has_bits_[0] |= 0x00000010u;
}
void FieldDescriptorProto::clear_has_json_name() {
_has_bits_[0] &= ~0x00000010u;
}
void FieldDescriptorProto::clear_json_name() {
json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_json_name();
}
const ::std::string& FieldDescriptorProto::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)
return json_name_.GetNoArena();
}
void FieldDescriptorProto::set_json_name(const ::std::string& value) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)
}
#if LANG_CXX11
void FieldDescriptorProto::set_json_name(::std::string&& value) {
set_has_json_name();
json_name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name)
}
#endif
void FieldDescriptorProto::set_json_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name)
}
void FieldDescriptorProto::set_json_name(const char* value, size_t size) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name)
}
::std::string* FieldDescriptorProto::mutable_json_name() {
set_has_json_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name)
return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FieldDescriptorProto::release_json_name() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name)
clear_has_json_name();
return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) {
if (json_name != NULL) {
set_has_json_name();
} else {
clear_has_json_name();
}
json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name)
}
// optional .google.protobuf.FieldOptions options = 8;
bool FieldDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
void FieldDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000020u;
}
void FieldDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000020u;
}
void FieldDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();
clear_has_options();
}
const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::FieldOptions::internal_default_instance();
}
::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::FieldOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options)
return options_;
}
::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options)
clear_has_options();
::google::protobuf::FieldOptions* temp = options_;
options_ = NULL;
return temp;
}
void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int OneofDescriptorProto::kNameFieldNumber;
const int OneofDescriptorProto::kOptionsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
OneofDescriptorProto::OneofDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto)
}
OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::OneofOptions(*from.options_);
} else {
options_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto)
}
void OneofDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
options_ = NULL;
}
OneofDescriptorProto::~OneofDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.OneofDescriptorProto)
SharedDtor();
}
void OneofDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void OneofDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const OneofDescriptorProto& OneofDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const {
OneofDescriptorProto* n = new OneofDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void OneofDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto)
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::OneofOptions::Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool OneofDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.OneofDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.OneofOptions options = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.OneofDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.OneofDescriptorProto)
return false;
#undef DO_
}
void OneofDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.OneofDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.OneofDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// optional .google.protobuf.OneofOptions options = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, *this->options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.OneofDescriptorProto)
}
::google::protobuf::uint8* OneofDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.OneofDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// optional .google.protobuf.OneofOptions options = 2;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
2, *this->options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofDescriptorProto)
return target;
}
size_t OneofDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional .google.protobuf.OneofOptions options = 2;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const OneofDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.OneofDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto)
MergeFrom(*source);
}
}
void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options());
}
}
}
void OneofDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.OneofDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool OneofDescriptorProto::IsInitialized() const {
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void OneofDescriptorProto::Swap(OneofDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// OneofDescriptorProto
// optional string name = 1;
bool OneofDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void OneofDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void OneofDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void OneofDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& OneofDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)
return name_.GetNoArena();
}
void OneofDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)
}
#if LANG_CXX11
void OneofDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name)
}
#endif
void OneofDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name)
}
void OneofDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name)
}
::std::string* OneofDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* OneofDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void OneofDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name)
}
// optional .google.protobuf.OneofOptions options = 2;
bool OneofDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void OneofDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000002u;
}
void OneofDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000002u;
}
void OneofDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear();
clear_has_options();
}
const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::OneofOptions::internal_default_instance();
}
::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::OneofOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options)
return options_;
}
::google::protobuf::OneofOptions* OneofDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options)
clear_has_options();
::google::protobuf::OneofOptions* temp = options_;
options_ = NULL;
return temp;
}
void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int EnumDescriptorProto::kNameFieldNumber;
const int EnumDescriptorProto::kValueFieldNumber;
const int EnumDescriptorProto::kOptionsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
EnumDescriptorProto::EnumDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto)
}
EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
value_(from.value_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::EnumOptions(*from.options_);
} else {
options_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto)
}
void EnumDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
options_ = NULL;
}
EnumDescriptorProto::~EnumDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto)
SharedDtor();
}
void EnumDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void EnumDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const EnumDescriptorProto& EnumDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const {
EnumDescriptorProto* n = new EnumDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void EnumDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto)
value_.Clear();
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::EnumOptions::Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool EnumDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.EnumDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_value()));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.EnumOptions options = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.EnumDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.EnumDescriptorProto)
return false;
#undef DO_
}
void EnumDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.EnumDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
for (unsigned int i = 0, n = this->value_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->value(i), output);
}
// optional .google.protobuf.EnumOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, *this->options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.EnumDescriptorProto)
}
::google::protobuf::uint8* EnumDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
for (unsigned int i = 0, n = this->value_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
2, this->value(i), deterministic, target);
}
// optional .google.protobuf.EnumOptions options = 3;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
3, *this->options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto)
return target;
}
size_t EnumDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
{
unsigned int count = this->value_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->value(i));
}
}
if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional .google.protobuf.EnumOptions options = 3;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const EnumDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto)
MergeFrom(*source);
}
}
void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
value_.MergeFrom(from.value_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options());
}
}
}
void EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool EnumDescriptorProto::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->value())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void EnumDescriptorProto::Swap(EnumDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
value_.InternalSwap(&other->value_);
name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// EnumDescriptorProto
// optional string name = 1;
bool EnumDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void EnumDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void EnumDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void EnumDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& EnumDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)
return name_.GetNoArena();
}
void EnumDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)
}
#if LANG_CXX11
void EnumDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name)
}
#endif
void EnumDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name)
}
void EnumDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name)
}
::std::string* EnumDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* EnumDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void EnumDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name)
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
int EnumDescriptorProto::value_size() const {
return value_.size();
}
void EnumDescriptorProto::clear_value() {
value_.Clear();
}
const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value)
return value_.Get(index);
}
::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value)
return value_.Mutable(index);
}
::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() {
// @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value)
return value_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*
EnumDescriptorProto::mutable_value() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value)
return &value_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&
EnumDescriptorProto::value() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value)
return value_;
}
// optional .google.protobuf.EnumOptions options = 3;
bool EnumDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void EnumDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000002u;
}
void EnumDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000002u;
}
void EnumDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();
clear_has_options();
}
const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::EnumOptions::internal_default_instance();
}
::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::EnumOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options)
return options_;
}
::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options)
clear_has_options();
::google::protobuf::EnumOptions* temp = options_;
options_ = NULL;
return temp;
}
void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int EnumValueDescriptorProto::kNameFieldNumber;
const int EnumValueDescriptorProto::kNumberFieldNumber;
const int EnumValueDescriptorProto::kOptionsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
EnumValueDescriptorProto::EnumValueDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto)
}
EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::EnumValueOptions(*from.options_);
} else {
options_ = NULL;
}
number_ = from.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto)
}
void EnumValueDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&options_, 0, reinterpret_cast<char*>(&number_) -
reinterpret_cast<char*>(&options_) + sizeof(number_));
}
EnumValueDescriptorProto::~EnumValueDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumValueDescriptorProto)
SharedDtor();
}
void EnumValueDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void EnumValueDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const {
EnumValueDescriptorProto* n = new EnumValueDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void EnumValueDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto)
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::EnumValueOptions::Clear();
}
}
number_ = 0;
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool EnumValueDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.EnumValueDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// optional int32 number = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_number();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &number_)));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.EnumValueOptions options = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.EnumValueDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.EnumValueDescriptorProto)
return false;
#undef DO_
}
void EnumValueDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.EnumValueDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumValueDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output);
}
// optional .google.protobuf.EnumValueOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, *this->options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueDescriptorProto)
}
::google::protobuf::uint8* EnumValueDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumValueDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// optional int32 number = 2;
if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target);
}
// optional .google.protobuf.EnumValueOptions options = 3;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
3, *this->options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueDescriptorProto)
return target;
}
size_t EnumValueDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 7u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional .google.protobuf.EnumValueOptions options = 3;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
// optional int32 number = 2;
if (has_number()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->number());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const EnumValueDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumValueDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto)
MergeFrom(*source);
}
}
void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 7u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options());
}
if (cached_has_bits & 0x00000004u) {
number_ = from.number_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void EnumValueDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumValueDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool EnumValueDescriptorProto::IsInitialized() const {
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(number_, other->number_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// EnumValueDescriptorProto
// optional string name = 1;
bool EnumValueDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void EnumValueDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void EnumValueDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void EnumValueDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& EnumValueDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)
return name_.GetNoArena();
}
void EnumValueDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)
}
#if LANG_CXX11
void EnumValueDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name)
}
#endif
void EnumValueDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name)
}
void EnumValueDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name)
}
::std::string* EnumValueDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* EnumValueDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void EnumValueDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name)
}
// optional int32 number = 2;
bool EnumValueDescriptorProto::has_number() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void EnumValueDescriptorProto::set_has_number() {
_has_bits_[0] |= 0x00000004u;
}
void EnumValueDescriptorProto::clear_has_number() {
_has_bits_[0] &= ~0x00000004u;
}
void EnumValueDescriptorProto::clear_number() {
number_ = 0;
clear_has_number();
}
::google::protobuf::int32 EnumValueDescriptorProto::number() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number)
return number_;
}
void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) {
set_has_number();
number_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number)
}
// optional .google.protobuf.EnumValueOptions options = 3;
bool EnumValueDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void EnumValueDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000002u;
}
void EnumValueDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000002u;
}
void EnumValueDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();
clear_has_options();
}
const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::EnumValueOptions::internal_default_instance();
}
::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::EnumValueOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options)
return options_;
}
::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options)
clear_has_options();
::google::protobuf::EnumValueOptions* temp = options_;
options_ = NULL;
return temp;
}
void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int ServiceDescriptorProto::kNameFieldNumber;
const int ServiceDescriptorProto::kMethodFieldNumber;
const int ServiceDescriptorProto::kOptionsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
ServiceDescriptorProto::ServiceDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto)
}
ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
method_(from.method_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::ServiceOptions(*from.options_);
} else {
options_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto)
}
void ServiceDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
options_ = NULL;
}
ServiceDescriptorProto::~ServiceDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.ServiceDescriptorProto)
SharedDtor();
}
void ServiceDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void ServiceDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const {
ServiceDescriptorProto* n = new ServiceDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void ServiceDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto)
method_.Clear();
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::ServiceOptions::Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool ServiceDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.ServiceDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_method()));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.ServiceOptions options = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.ServiceDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.ServiceDescriptorProto)
return false;
#undef DO_
}
void ServiceDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.ServiceDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.ServiceDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
for (unsigned int i = 0, n = this->method_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->method(i), output);
}
// optional .google.protobuf.ServiceOptions options = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, *this->options_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.ServiceDescriptorProto)
}
::google::protobuf::uint8* ServiceDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.ServiceDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
for (unsigned int i = 0, n = this->method_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
2, this->method(i), deterministic, target);
}
// optional .google.protobuf.ServiceOptions options = 3;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
3, *this->options_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceDescriptorProto)
return target;
}
size_t ServiceDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
{
unsigned int count = this->method_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->method(i));
}
}
if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional .google.protobuf.ServiceOptions options = 3;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const ServiceDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ServiceDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto)
MergeFrom(*source);
}
}
void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
method_.MergeFrom(from.method_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options());
}
}
}
void ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ServiceDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ServiceDescriptorProto::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->method())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
method_.InternalSwap(&other->method_);
name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// ServiceDescriptorProto
// optional string name = 1;
bool ServiceDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void ServiceDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void ServiceDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void ServiceDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& ServiceDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)
return name_.GetNoArena();
}
void ServiceDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)
}
#if LANG_CXX11
void ServiceDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name)
}
#endif
void ServiceDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name)
}
void ServiceDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name)
}
::std::string* ServiceDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* ServiceDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void ServiceDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name)
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
int ServiceDescriptorProto::method_size() const {
return method_.size();
}
void ServiceDescriptorProto::clear_method() {
method_.Clear();
}
const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method)
return method_.Get(index);
}
::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method)
return method_.Mutable(index);
}
::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() {
// @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method)
return method_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*
ServiceDescriptorProto::mutable_method() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method)
return &method_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&
ServiceDescriptorProto::method() const {
// @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method)
return method_;
}
// optional .google.protobuf.ServiceOptions options = 3;
bool ServiceDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void ServiceDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000002u;
}
void ServiceDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000002u;
}
void ServiceDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();
clear_has_options();
}
const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::ServiceOptions::internal_default_instance();
}
::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::ServiceOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options)
return options_;
}
::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options)
clear_has_options();
::google::protobuf::ServiceOptions* temp = options_;
options_ = NULL;
return temp;
}
void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MethodDescriptorProto::kNameFieldNumber;
const int MethodDescriptorProto::kInputTypeFieldNumber;
const int MethodDescriptorProto::kOutputTypeFieldNumber;
const int MethodDescriptorProto::kOptionsFieldNumber;
const int MethodDescriptorProto::kClientStreamingFieldNumber;
const int MethodDescriptorProto::kServerStreamingFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
MethodDescriptorProto::MethodDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto)
}
MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name()) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_input_type()) {
input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_);
}
output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_output_type()) {
output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_);
}
if (from.has_options()) {
options_ = new ::google::protobuf::MethodOptions(*from.options_);
} else {
options_ = NULL;
}
::memcpy(&client_streaming_, &from.client_streaming_,
reinterpret_cast<char*>(&server_streaming_) -
reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto)
}
void MethodDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&options_, 0, reinterpret_cast<char*>(&server_streaming_) -
reinterpret_cast<char*>(&options_) + sizeof(server_streaming_));
}
MethodDescriptorProto::~MethodDescriptorProto() {
// @@protoc_insertion_point(destructor:google.protobuf.MethodDescriptorProto)
SharedDtor();
}
void MethodDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) {
delete options_;
}
}
void MethodDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const MethodDescriptorProto& MethodDescriptorProto::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const {
MethodDescriptorProto* n = new MethodDescriptorProto;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void MethodDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)
if (_has_bits_[0 / 32] & 15u) {
if (has_name()) {
GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_.UnsafeRawStringPointer())->clear();
}
if (has_input_type()) {
GOOGLE_DCHECK(!input_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*input_type_.UnsafeRawStringPointer())->clear();
}
if (has_output_type()) {
GOOGLE_DCHECK(!output_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*output_type_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
GOOGLE_DCHECK(options_ != NULL);
options_->::google::protobuf::MethodOptions::Clear();
}
}
if (_has_bits_[0 / 32] & 48u) {
::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) -
reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool MethodDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.MethodDescriptorProto.name");
} else {
goto handle_unusual;
}
break;
}
// optional string input_type = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_input_type()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->input_type().data(), this->input_type().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.MethodDescriptorProto.input_type");
} else {
goto handle_unusual;
}
break;
}
// optional string output_type = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_output_type()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->output_type().data(), this->output_type().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.MethodDescriptorProto.output_type");
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.MethodOptions options = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
break;
}
// optional bool client_streaming = 5 [default = false];
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u)) {
set_has_client_streaming();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &client_streaming_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool server_streaming = 6 [default = false];
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(48u)) {
set_has_server_streaming();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &server_streaming_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.MethodDescriptorProto)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.MethodDescriptorProto)
return false;
#undef DO_
}
void MethodDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.MethodDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name(), output);
}
// optional string input_type = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->input_type().data(), this->input_type().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.input_type");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->input_type(), output);
}
// optional string output_type = 3;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->output_type().data(), this->output_type().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.output_type");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
3, this->output_type(), output);
}
// optional .google.protobuf.MethodOptions options = 4;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, *this->options_, output);
}
// optional bool client_streaming = 5 [default = false];
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormatLite::WriteBool(5, this->client_streaming(), output);
}
// optional bool server_streaming = 6 [default = false];
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormatLite::WriteBool(6, this->server_streaming(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.MethodDescriptorProto)
}
::google::protobuf::uint8* MethodDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name(), target);
}
// optional string input_type = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->input_type().data(), this->input_type().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.input_type");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->input_type(), target);
}
// optional string output_type = 3;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->output_type().data(), this->output_type().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.output_type");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
3, this->output_type(), target);
}
// optional .google.protobuf.MethodOptions options = 4;
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
4, *this->options_, deterministic, target);
}
// optional bool client_streaming = 5 [default = false];
if (cached_has_bits & 0x00000010u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->client_streaming(), target);
}
// optional bool server_streaming = 6 [default = false];
if (cached_has_bits & 0x00000020u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->server_streaming(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodDescriptorProto)
return target;
}
size_t MethodDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (_has_bits_[0 / 32] & 63u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
// optional string input_type = 2;
if (has_input_type()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->input_type());
}
// optional string output_type = 3;
if (has_output_type()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->output_type());
}
// optional .google.protobuf.MethodOptions options = 4;
if (has_options()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*this->options_);
}
// optional bool client_streaming = 5 [default = false];
if (has_client_streaming()) {
total_size += 1 + 1;
}
// optional bool server_streaming = 6 [default = false];
if (has_server_streaming()) {
total_size += 1 + 1;
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
const MethodDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MethodDescriptorProto)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto)
MergeFrom(*source);
}
}
void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 63u) {
if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
if (cached_has_bits & 0x00000002u) {
set_has_input_type();
input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_);
}
if (cached_has_bits & 0x00000004u) {
set_has_output_type();
output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_);
}
if (cached_has_bits & 0x00000008u) {
mutable_options()->::google::protobuf::MethodOptions::MergeFrom(from.options());
}
if (cached_has_bits & 0x00000010u) {
client_streaming_ = from.client_streaming_;
}
if (cached_has_bits & 0x00000020u) {
server_streaming_ = from.server_streaming_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MethodDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool MethodDescriptorProto::IsInitialized() const {
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
return true;
}
void MethodDescriptorProto::Swap(MethodDescriptorProto* other) {
if (other == this) return;
InternalSwap(other);
}
void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
name_.Swap(&other->name_);
input_type_.Swap(&other->input_type_);
output_type_.Swap(&other->output_type_);
std::swap(options_, other->options_);
std::swap(client_streaming_, other->client_streaming_);
std::swap(server_streaming_, other->server_streaming_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// MethodDescriptorProto
// optional string name = 1;
bool MethodDescriptorProto::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void MethodDescriptorProto::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
void MethodDescriptorProto::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
void MethodDescriptorProto::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
}
const ::std::string& MethodDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)
return name_.GetNoArena();
}
void MethodDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)
}
#if LANG_CXX11
void MethodDescriptorProto::set_name(::std::string&& value) {
set_has_name();
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name)
}
#endif
void MethodDescriptorProto::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name)
}
void MethodDescriptorProto::set_name(const char* value, size_t size) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name)
}
::std::string* MethodDescriptorProto::mutable_name() {
set_has_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* MethodDescriptorProto::release_name() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name)
clear_has_name();
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void MethodDescriptorProto::set_allocated_name(::std::string* name) {
if (name != NULL) {
set_has_name();
} else {
clear_has_name();
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name)
}
// optional string input_type = 2;
bool MethodDescriptorProto::has_input_type() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void MethodDescriptorProto::set_has_input_type() {
_has_bits_[0] |= 0x00000002u;
}
void MethodDescriptorProto::clear_has_input_type() {
_has_bits_[0] &= ~0x00000002u;
}
void MethodDescriptorProto::clear_input_type() {
input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_input_type();
}
const ::std::string& MethodDescriptorProto::input_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)
return input_type_.GetNoArena();
}
void MethodDescriptorProto::set_input_type(const ::std::string& value) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)
}
#if LANG_CXX11
void MethodDescriptorProto::set_input_type(::std::string&& value) {
set_has_input_type();
input_type_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type)
}
#endif
void MethodDescriptorProto::set_input_type(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type)
}
void MethodDescriptorProto::set_input_type(const char* value, size_t size) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type)
}
::std::string* MethodDescriptorProto::mutable_input_type() {
set_has_input_type();
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type)
return input_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* MethodDescriptorProto::release_input_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type)
clear_has_input_type();
return input_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) {
if (input_type != NULL) {
set_has_input_type();
} else {
clear_has_input_type();
}
input_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type)
}
// optional string output_type = 3;
bool MethodDescriptorProto::has_output_type() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void MethodDescriptorProto::set_has_output_type() {
_has_bits_[0] |= 0x00000004u;
}
void MethodDescriptorProto::clear_has_output_type() {
_has_bits_[0] &= ~0x00000004u;
}
void MethodDescriptorProto::clear_output_type() {
output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_output_type();
}
const ::std::string& MethodDescriptorProto::output_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)
return output_type_.GetNoArena();
}
void MethodDescriptorProto::set_output_type(const ::std::string& value) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)
}
#if LANG_CXX11
void MethodDescriptorProto::set_output_type(::std::string&& value) {
set_has_output_type();
output_type_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type)
}
#endif
void MethodDescriptorProto::set_output_type(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type)
}
void MethodDescriptorProto::set_output_type(const char* value, size_t size) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type)
}
::std::string* MethodDescriptorProto::mutable_output_type() {
set_has_output_type();
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type)
return output_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* MethodDescriptorProto::release_output_type() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type)
clear_has_output_type();
return output_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) {
if (output_type != NULL) {
set_has_output_type();
} else {
clear_has_output_type();
}
output_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type)
}
// optional .google.protobuf.MethodOptions options = 4;
bool MethodDescriptorProto::has_options() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void MethodDescriptorProto::set_has_options() {
_has_bits_[0] |= 0x00000008u;
}
void MethodDescriptorProto::clear_has_options() {
_has_bits_[0] &= ~0x00000008u;
}
void MethodDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear();
clear_has_options();
}
const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options)
return options_ != NULL ? *options_
: *::google::protobuf::MethodOptions::internal_default_instance();
}
::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() {
set_has_options();
if (options_ == NULL) {
options_ = new ::google::protobuf::MethodOptions;
}
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options)
return options_;
}
::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() {
// @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options)
clear_has_options();
::google::protobuf::MethodOptions* temp = options_;
options_ = NULL;
return temp;
}
void MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) {
delete options_;
options_ = options;
if (options) {
set_has_options();
} else {
clear_has_options();
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options)
}
// optional bool client_streaming = 5 [default = false];
bool MethodDescriptorProto::has_client_streaming() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void MethodDescriptorProto::set_has_client_streaming() {
_has_bits_[0] |= 0x00000010u;
}
void MethodDescriptorProto::clear_has_client_streaming() {
_has_bits_[0] &= ~0x00000010u;
}
void MethodDescriptorProto::clear_client_streaming() {
client_streaming_ = false;
clear_has_client_streaming();
}
bool MethodDescriptorProto::client_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming)
return client_streaming_;
}
void MethodDescriptorProto::set_client_streaming(bool value) {
set_has_client_streaming();
client_streaming_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming)
}
// optional bool server_streaming = 6 [default = false];
bool MethodDescriptorProto::has_server_streaming() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
void MethodDescriptorProto::set_has_server_streaming() {
_has_bits_[0] |= 0x00000020u;
}
void MethodDescriptorProto::clear_has_server_streaming() {
_has_bits_[0] &= ~0x00000020u;
}
void MethodDescriptorProto::clear_server_streaming() {
server_streaming_ = false;
clear_has_server_streaming();
}
bool MethodDescriptorProto::server_streaming() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming)
return server_streaming_;
}
void MethodDescriptorProto::set_server_streaming(bool value) {
set_has_server_streaming();
server_streaming_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FileOptions::kJavaPackageFieldNumber;
const int FileOptions::kJavaOuterClassnameFieldNumber;
const int FileOptions::kJavaMultipleFilesFieldNumber;
const int FileOptions::kJavaGenerateEqualsAndHashFieldNumber;
const int FileOptions::kJavaStringCheckUtf8FieldNumber;
const int FileOptions::kOptimizeForFieldNumber;
const int FileOptions::kGoPackageFieldNumber;
const int FileOptions::kCcGenericServicesFieldNumber;
const int FileOptions::kJavaGenericServicesFieldNumber;
const int FileOptions::kPyGenericServicesFieldNumber;
const int FileOptions::kDeprecatedFieldNumber;
const int FileOptions::kCcEnableArenasFieldNumber;
const int FileOptions::kObjcClassPrefixFieldNumber;
const int FileOptions::kCsharpNamespaceFieldNumber;
const int FileOptions::kSwiftPrefixFieldNumber;
const int FileOptions::kPhpClassPrefixFieldNumber;
const int FileOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FileOptions::FileOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileOptions)
}
FileOptions::FileOptions(const FileOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_java_package()) {
java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_);
}
java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_java_outer_classname()) {
java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_);
}
go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_go_package()) {
go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);
}
objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_objc_class_prefix()) {
objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);
}
csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_csharp_namespace()) {
csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);
}
swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_swift_prefix()) {
swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_);
}
php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_php_class_prefix()) {
php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_);
}
::memcpy(&java_multiple_files_, &from.java_multiple_files_,
reinterpret_cast<char*>(&optimize_for_) -
reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)
}
void FileOptions::SharedCtor() {
_cached_size_ = 0;
java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) -
reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_));
optimize_for_ = 1;
}
FileOptions::~FileOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.FileOptions)
SharedDtor();
}
void FileOptions::SharedDtor() {
java_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
java_outer_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
php_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FileOptions& FileOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {
FileOptions* n = new FileOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void FileOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
if (_has_bits_[0 / 32] & 127u) {
if (has_java_package()) {
GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*java_package_.UnsafeRawStringPointer())->clear();
}
if (has_java_outer_classname()) {
GOOGLE_DCHECK(!java_outer_classname_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*java_outer_classname_.UnsafeRawStringPointer())->clear();
}
if (has_go_package()) {
GOOGLE_DCHECK(!go_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*go_package_.UnsafeRawStringPointer())->clear();
}
if (has_objc_class_prefix()) {
GOOGLE_DCHECK(!objc_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*objc_class_prefix_.UnsafeRawStringPointer())->clear();
}
if (has_csharp_namespace()) {
GOOGLE_DCHECK(!csharp_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*csharp_namespace_.UnsafeRawStringPointer())->clear();
}
if (has_swift_prefix()) {
GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*swift_prefix_.UnsafeRawStringPointer())->clear();
}
if (has_php_class_prefix()) {
GOOGLE_DCHECK(!php_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*php_class_prefix_.UnsafeRawStringPointer())->clear();
}
}
java_multiple_files_ = false;
if (_has_bits_[8 / 32] & 65280u) {
::memset(&java_generate_equals_and_hash_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) -
reinterpret_cast<char*>(&java_generate_equals_and_hash_) + sizeof(cc_enable_arenas_));
optimize_for_ = 1;
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool FileOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string java_package = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_java_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_package().data(), this->java_package().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.java_package");
} else {
goto handle_unusual;
}
break;
}
// optional string java_outer_classname = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_java_outer_classname()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_outer_classname().data(), this->java_outer_classname().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.java_outer_classname");
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
case 9: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(72u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::FileOptions_OptimizeMode_IsValid(value)) {
set_optimize_for(static_cast< ::google::protobuf::FileOptions_OptimizeMode >(value));
} else {
mutable_unknown_fields()->AddVarint(9, value);
}
} else {
goto handle_unusual;
}
break;
}
// optional bool java_multiple_files = 10 [default = false];
case 10: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(80u)) {
set_has_java_multiple_files();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &java_multiple_files_)));
} else {
goto handle_unusual;
}
break;
}
// optional string go_package = 11;
case 11: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(90u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_go_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->go_package().data(), this->go_package().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.go_package");
} else {
goto handle_unusual;
}
break;
}
// optional bool cc_generic_services = 16 [default = false];
case 16: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(128u)) {
set_has_cc_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &cc_generic_services_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool java_generic_services = 17 [default = false];
case 17: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(136u)) {
set_has_java_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &java_generic_services_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool py_generic_services = 18 [default = false];
case 18: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(144u)) {
set_has_py_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &py_generic_services_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
case 20: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(160u)) {
set_has_java_generate_equals_and_hash();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &java_generate_equals_and_hash_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool deprecated = 23 [default = false];
case 23: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(184u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool java_string_check_utf8 = 27 [default = false];
case 27: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(216u)) {
set_has_java_string_check_utf8();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &java_string_check_utf8_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool cc_enable_arenas = 31 [default = false];
case 31: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(248u)) {
set_has_cc_enable_arenas();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &cc_enable_arenas_)));
} else {
goto handle_unusual;
}
break;
}
// optional string objc_class_prefix = 36;
case 36: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(290u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_objc_class_prefix()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->objc_class_prefix().data(), this->objc_class_prefix().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.objc_class_prefix");
} else {
goto handle_unusual;
}
break;
}
// optional string csharp_namespace = 37;
case 37: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(298u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_csharp_namespace()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->csharp_namespace().data(), this->csharp_namespace().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.csharp_namespace");
} else {
goto handle_unusual;
}
break;
}
// optional string swift_prefix = 39;
case 39: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(314u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_swift_prefix()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->swift_prefix().data(), this->swift_prefix().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.swift_prefix");
} else {
goto handle_unusual;
}
break;
}
// optional string php_class_prefix = 40;
case 40: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(322u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_php_class_prefix()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->php_class_prefix().data(), this->php_class_prefix().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.FileOptions.php_class_prefix");
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FileOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FileOptions)
return false;
#undef DO_
}
void FileOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FileOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string java_package = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_package().data(), this->java_package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_package");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->java_package(), output);
}
// optional string java_outer_classname = 8;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_outer_classname().data(), this->java_outer_classname().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_outer_classname");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
8, this->java_outer_classname(), output);
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00008000u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
9, this->optimize_for(), output);
}
// optional bool java_multiple_files = 10 [default = false];
if (cached_has_bits & 0x00000080u) {
::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output);
}
// optional string go_package = 11;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->go_package().data(), this->go_package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.go_package");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
11, this->go_package(), output);
}
// optional bool cc_generic_services = 16 [default = false];
if (cached_has_bits & 0x00000400u) {
::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output);
}
// optional bool java_generic_services = 17 [default = false];
if (cached_has_bits & 0x00000800u) {
::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output);
}
// optional bool py_generic_services = 18 [default = false];
if (cached_has_bits & 0x00001000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output);
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
if (cached_has_bits & 0x00000100u) {
::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output);
}
// optional bool deprecated = 23 [default = false];
if (cached_has_bits & 0x00002000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output);
}
// optional bool java_string_check_utf8 = 27 [default = false];
if (cached_has_bits & 0x00000200u) {
::google::protobuf::internal::WireFormatLite::WriteBool(27, this->java_string_check_utf8(), output);
}
// optional bool cc_enable_arenas = 31 [default = false];
if (cached_has_bits & 0x00004000u) {
::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output);
}
// optional string objc_class_prefix = 36;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->objc_class_prefix().data(), this->objc_class_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.objc_class_prefix");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
36, this->objc_class_prefix(), output);
}
// optional string csharp_namespace = 37;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->csharp_namespace().data(), this->csharp_namespace().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.csharp_namespace");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
37, this->csharp_namespace(), output);
}
// optional string swift_prefix = 39;
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->swift_prefix().data(), this->swift_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.swift_prefix");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
39, this->swift_prefix(), output);
}
// optional string php_class_prefix = 40;
if (cached_has_bits & 0x00000040u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->php_class_prefix().data(), this->php_class_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.php_class_prefix");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
40, this->php_class_prefix(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FileOptions)
}
::google::protobuf::uint8* FileOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional string java_package = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_package().data(), this->java_package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_package");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->java_package(), target);
}
// optional string java_outer_classname = 8;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->java_outer_classname().data(), this->java_outer_classname().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_outer_classname");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
8, this->java_outer_classname(), target);
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (cached_has_bits & 0x00008000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
9, this->optimize_for(), target);
}
// optional bool java_multiple_files = 10 [default = false];
if (cached_has_bits & 0x00000080u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target);
}
// optional string go_package = 11;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->go_package().data(), this->go_package().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.go_package");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
11, this->go_package(), target);
}
// optional bool cc_generic_services = 16 [default = false];
if (cached_has_bits & 0x00000400u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target);
}
// optional bool java_generic_services = 17 [default = false];
if (cached_has_bits & 0x00000800u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target);
}
// optional bool py_generic_services = 18 [default = false];
if (cached_has_bits & 0x00001000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target);
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
if (cached_has_bits & 0x00000100u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target);
}
// optional bool deprecated = 23 [default = false];
if (cached_has_bits & 0x00002000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target);
}
// optional bool java_string_check_utf8 = 27 [default = false];
if (cached_has_bits & 0x00000200u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(27, this->java_string_check_utf8(), target);
}
// optional bool cc_enable_arenas = 31 [default = false];
if (cached_has_bits & 0x00004000u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target);
}
// optional string objc_class_prefix = 36;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->objc_class_prefix().data(), this->objc_class_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.objc_class_prefix");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
36, this->objc_class_prefix(), target);
}
// optional string csharp_namespace = 37;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->csharp_namespace().data(), this->csharp_namespace().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.csharp_namespace");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
37, this->csharp_namespace(), target);
}
// optional string swift_prefix = 39;
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->swift_prefix().data(), this->swift_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.swift_prefix");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
39, this->swift_prefix(), target);
}
// optional string php_class_prefix = 40;
if (cached_has_bits & 0x00000040u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->php_class_prefix().data(), this->php_class_prefix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.php_class_prefix");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
40, this->php_class_prefix(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileOptions)
return target;
}
size_t FileOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
if (_has_bits_[0 / 32] & 255u) {
// optional string java_package = 1;
if (has_java_package()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->java_package());
}
// optional string java_outer_classname = 8;
if (has_java_outer_classname()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->java_outer_classname());
}
// optional string go_package = 11;
if (has_go_package()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->go_package());
}
// optional string objc_class_prefix = 36;
if (has_objc_class_prefix()) {
total_size += 2 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->objc_class_prefix());
}
// optional string csharp_namespace = 37;
if (has_csharp_namespace()) {
total_size += 2 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->csharp_namespace());
}
// optional string swift_prefix = 39;
if (has_swift_prefix()) {
total_size += 2 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->swift_prefix());
}
// optional string php_class_prefix = 40;
if (has_php_class_prefix()) {
total_size += 2 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->php_class_prefix());
}
// optional bool java_multiple_files = 10 [default = false];
if (has_java_multiple_files()) {
total_size += 1 + 1;
}
}
if (_has_bits_[8 / 32] & 65280u) {
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
if (has_java_generate_equals_and_hash()) {
total_size += 2 + 1;
}
// optional bool java_string_check_utf8 = 27 [default = false];
if (has_java_string_check_utf8()) {
total_size += 2 + 1;
}
// optional bool cc_generic_services = 16 [default = false];
if (has_cc_generic_services()) {
total_size += 2 + 1;
}
// optional bool java_generic_services = 17 [default = false];
if (has_java_generic_services()) {
total_size += 2 + 1;
}
// optional bool py_generic_services = 18 [default = false];
if (has_py_generic_services()) {
total_size += 2 + 1;
}
// optional bool deprecated = 23 [default = false];
if (has_deprecated()) {
total_size += 2 + 1;
}
// optional bool cc_enable_arenas = 31 [default = false];
if (has_cc_enable_arenas()) {
total_size += 2 + 1;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (has_optimize_for()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void FileOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions)
GOOGLE_DCHECK_NE(&from, this);
const FileOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions)
MergeFrom(*source);
}
}
void FileOptions::MergeFrom(const FileOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 255u) {
if (cached_has_bits & 0x00000001u) {
set_has_java_package();
java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_);
}
if (cached_has_bits & 0x00000002u) {
set_has_java_outer_classname();
java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_);
}
if (cached_has_bits & 0x00000004u) {
set_has_go_package();
go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);
}
if (cached_has_bits & 0x00000008u) {
set_has_objc_class_prefix();
objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);
}
if (cached_has_bits & 0x00000010u) {
set_has_csharp_namespace();
csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);
}
if (cached_has_bits & 0x00000020u) {
set_has_swift_prefix();
swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_);
}
if (cached_has_bits & 0x00000040u) {
set_has_php_class_prefix();
php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_);
}
if (cached_has_bits & 0x00000080u) {
java_multiple_files_ = from.java_multiple_files_;
}
_has_bits_[0] |= cached_has_bits;
}
if (cached_has_bits & 65280u) {
if (cached_has_bits & 0x00000100u) {
java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_;
}
if (cached_has_bits & 0x00000200u) {
java_string_check_utf8_ = from.java_string_check_utf8_;
}
if (cached_has_bits & 0x00000400u) {
cc_generic_services_ = from.cc_generic_services_;
}
if (cached_has_bits & 0x00000800u) {
java_generic_services_ = from.java_generic_services_;
}
if (cached_has_bits & 0x00001000u) {
py_generic_services_ = from.py_generic_services_;
}
if (cached_has_bits & 0x00002000u) {
deprecated_ = from.deprecated_;
}
if (cached_has_bits & 0x00004000u) {
cc_enable_arenas_ = from.cc_enable_arenas_;
}
if (cached_has_bits & 0x00008000u) {
optimize_for_ = from.optimize_for_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void FileOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FileOptions::CopyFrom(const FileOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FileOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void FileOptions::Swap(FileOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void FileOptions::InternalSwap(FileOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
java_package_.Swap(&other->java_package_);
java_outer_classname_.Swap(&other->java_outer_classname_);
go_package_.Swap(&other->go_package_);
objc_class_prefix_.Swap(&other->objc_class_prefix_);
csharp_namespace_.Swap(&other->csharp_namespace_);
swift_prefix_.Swap(&other->swift_prefix_);
php_class_prefix_.Swap(&other->php_class_prefix_);
std::swap(java_multiple_files_, other->java_multiple_files_);
std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_);
std::swap(java_string_check_utf8_, other->java_string_check_utf8_);
std::swap(cc_generic_services_, other->cc_generic_services_);
std::swap(java_generic_services_, other->java_generic_services_);
std::swap(py_generic_services_, other->py_generic_services_);
std::swap(deprecated_, other->deprecated_);
std::swap(cc_enable_arenas_, other->cc_enable_arenas_);
std::swap(optimize_for_, other->optimize_for_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata FileOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FileOptions
// optional string java_package = 1;
bool FileOptions::has_java_package() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void FileOptions::set_has_java_package() {
_has_bits_[0] |= 0x00000001u;
}
void FileOptions::clear_has_java_package() {
_has_bits_[0] &= ~0x00000001u;
}
void FileOptions::clear_java_package() {
java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_java_package();
}
const ::std::string& FileOptions::java_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)
return java_package_.GetNoArena();
}
void FileOptions::set_java_package(const ::std::string& value) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)
}
#if LANG_CXX11
void FileOptions::set_java_package(::std::string&& value) {
set_has_java_package();
java_package_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package)
}
#endif
void FileOptions::set_java_package(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package)
}
void FileOptions::set_java_package(const char* value, size_t size) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package)
}
::std::string* FileOptions::mutable_java_package() {
set_has_java_package();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package)
return java_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_java_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package)
clear_has_java_package();
return java_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_java_package(::std::string* java_package) {
if (java_package != NULL) {
set_has_java_package();
} else {
clear_has_java_package();
}
java_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package)
}
// optional string java_outer_classname = 8;
bool FileOptions::has_java_outer_classname() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void FileOptions::set_has_java_outer_classname() {
_has_bits_[0] |= 0x00000002u;
}
void FileOptions::clear_has_java_outer_classname() {
_has_bits_[0] &= ~0x00000002u;
}
void FileOptions::clear_java_outer_classname() {
java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_java_outer_classname();
}
const ::std::string& FileOptions::java_outer_classname() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)
return java_outer_classname_.GetNoArena();
}
void FileOptions::set_java_outer_classname(const ::std::string& value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)
}
#if LANG_CXX11
void FileOptions::set_java_outer_classname(::std::string&& value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname)
}
#endif
void FileOptions::set_java_outer_classname(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname)
}
void FileOptions::set_java_outer_classname(const char* value, size_t size) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname)
}
::std::string* FileOptions::mutable_java_outer_classname() {
set_has_java_outer_classname();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname)
return java_outer_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_java_outer_classname() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname)
clear_has_java_outer_classname();
return java_outer_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) {
if (java_outer_classname != NULL) {
set_has_java_outer_classname();
} else {
clear_has_java_outer_classname();
}
java_outer_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname)
}
// optional bool java_multiple_files = 10 [default = false];
bool FileOptions::has_java_multiple_files() const {
return (_has_bits_[0] & 0x00000080u) != 0;
}
void FileOptions::set_has_java_multiple_files() {
_has_bits_[0] |= 0x00000080u;
}
void FileOptions::clear_has_java_multiple_files() {
_has_bits_[0] &= ~0x00000080u;
}
void FileOptions::clear_java_multiple_files() {
java_multiple_files_ = false;
clear_has_java_multiple_files();
}
bool FileOptions::java_multiple_files() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files)
return java_multiple_files_;
}
void FileOptions::set_java_multiple_files(bool value) {
set_has_java_multiple_files();
java_multiple_files_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files)
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
bool FileOptions::has_java_generate_equals_and_hash() const {
return (_has_bits_[0] & 0x00000100u) != 0;
}
void FileOptions::set_has_java_generate_equals_and_hash() {
_has_bits_[0] |= 0x00000100u;
}
void FileOptions::clear_has_java_generate_equals_and_hash() {
_has_bits_[0] &= ~0x00000100u;
}
void FileOptions::clear_java_generate_equals_and_hash() {
java_generate_equals_and_hash_ = false;
clear_has_java_generate_equals_and_hash();
}
bool FileOptions::java_generate_equals_and_hash() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash)
return java_generate_equals_and_hash_;
}
void FileOptions::set_java_generate_equals_and_hash(bool value) {
set_has_java_generate_equals_and_hash();
java_generate_equals_and_hash_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash)
}
// optional bool java_string_check_utf8 = 27 [default = false];
bool FileOptions::has_java_string_check_utf8() const {
return (_has_bits_[0] & 0x00000200u) != 0;
}
void FileOptions::set_has_java_string_check_utf8() {
_has_bits_[0] |= 0x00000200u;
}
void FileOptions::clear_has_java_string_check_utf8() {
_has_bits_[0] &= ~0x00000200u;
}
void FileOptions::clear_java_string_check_utf8() {
java_string_check_utf8_ = false;
clear_has_java_string_check_utf8();
}
bool FileOptions::java_string_check_utf8() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8)
return java_string_check_utf8_;
}
void FileOptions::set_java_string_check_utf8(bool value) {
set_has_java_string_check_utf8();
java_string_check_utf8_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8)
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
bool FileOptions::has_optimize_for() const {
return (_has_bits_[0] & 0x00008000u) != 0;
}
void FileOptions::set_has_optimize_for() {
_has_bits_[0] |= 0x00008000u;
}
void FileOptions::clear_has_optimize_for() {
_has_bits_[0] &= ~0x00008000u;
}
void FileOptions::clear_optimize_for() {
optimize_for_ = 1;
clear_has_optimize_for();
}
::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for)
return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_);
}
void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) {
assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value));
set_has_optimize_for();
optimize_for_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for)
}
// optional string go_package = 11;
bool FileOptions::has_go_package() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void FileOptions::set_has_go_package() {
_has_bits_[0] |= 0x00000004u;
}
void FileOptions::clear_has_go_package() {
_has_bits_[0] &= ~0x00000004u;
}
void FileOptions::clear_go_package() {
go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_go_package();
}
const ::std::string& FileOptions::go_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)
return go_package_.GetNoArena();
}
void FileOptions::set_go_package(const ::std::string& value) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)
}
#if LANG_CXX11
void FileOptions::set_go_package(::std::string&& value) {
set_has_go_package();
go_package_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package)
}
#endif
void FileOptions::set_go_package(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package)
}
void FileOptions::set_go_package(const char* value, size_t size) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package)
}
::std::string* FileOptions::mutable_go_package() {
set_has_go_package();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package)
return go_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_go_package() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package)
clear_has_go_package();
return go_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_go_package(::std::string* go_package) {
if (go_package != NULL) {
set_has_go_package();
} else {
clear_has_go_package();
}
go_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package)
}
// optional bool cc_generic_services = 16 [default = false];
bool FileOptions::has_cc_generic_services() const {
return (_has_bits_[0] & 0x00000400u) != 0;
}
void FileOptions::set_has_cc_generic_services() {
_has_bits_[0] |= 0x00000400u;
}
void FileOptions::clear_has_cc_generic_services() {
_has_bits_[0] &= ~0x00000400u;
}
void FileOptions::clear_cc_generic_services() {
cc_generic_services_ = false;
clear_has_cc_generic_services();
}
bool FileOptions::cc_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services)
return cc_generic_services_;
}
void FileOptions::set_cc_generic_services(bool value) {
set_has_cc_generic_services();
cc_generic_services_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services)
}
// optional bool java_generic_services = 17 [default = false];
bool FileOptions::has_java_generic_services() const {
return (_has_bits_[0] & 0x00000800u) != 0;
}
void FileOptions::set_has_java_generic_services() {
_has_bits_[0] |= 0x00000800u;
}
void FileOptions::clear_has_java_generic_services() {
_has_bits_[0] &= ~0x00000800u;
}
void FileOptions::clear_java_generic_services() {
java_generic_services_ = false;
clear_has_java_generic_services();
}
bool FileOptions::java_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services)
return java_generic_services_;
}
void FileOptions::set_java_generic_services(bool value) {
set_has_java_generic_services();
java_generic_services_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services)
}
// optional bool py_generic_services = 18 [default = false];
bool FileOptions::has_py_generic_services() const {
return (_has_bits_[0] & 0x00001000u) != 0;
}
void FileOptions::set_has_py_generic_services() {
_has_bits_[0] |= 0x00001000u;
}
void FileOptions::clear_has_py_generic_services() {
_has_bits_[0] &= ~0x00001000u;
}
void FileOptions::clear_py_generic_services() {
py_generic_services_ = false;
clear_has_py_generic_services();
}
bool FileOptions::py_generic_services() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services)
return py_generic_services_;
}
void FileOptions::set_py_generic_services(bool value) {
set_has_py_generic_services();
py_generic_services_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services)
}
// optional bool deprecated = 23 [default = false];
bool FileOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00002000u) != 0;
}
void FileOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00002000u;
}
void FileOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00002000u;
}
void FileOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool FileOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated)
return deprecated_;
}
void FileOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated)
}
// optional bool cc_enable_arenas = 31 [default = false];
bool FileOptions::has_cc_enable_arenas() const {
return (_has_bits_[0] & 0x00004000u) != 0;
}
void FileOptions::set_has_cc_enable_arenas() {
_has_bits_[0] |= 0x00004000u;
}
void FileOptions::clear_has_cc_enable_arenas() {
_has_bits_[0] &= ~0x00004000u;
}
void FileOptions::clear_cc_enable_arenas() {
cc_enable_arenas_ = false;
clear_has_cc_enable_arenas();
}
bool FileOptions::cc_enable_arenas() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas)
return cc_enable_arenas_;
}
void FileOptions::set_cc_enable_arenas(bool value) {
set_has_cc_enable_arenas();
cc_enable_arenas_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas)
}
// optional string objc_class_prefix = 36;
bool FileOptions::has_objc_class_prefix() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void FileOptions::set_has_objc_class_prefix() {
_has_bits_[0] |= 0x00000008u;
}
void FileOptions::clear_has_objc_class_prefix() {
_has_bits_[0] &= ~0x00000008u;
}
void FileOptions::clear_objc_class_prefix() {
objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_objc_class_prefix();
}
const ::std::string& FileOptions::objc_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)
return objc_class_prefix_.GetNoArena();
}
void FileOptions::set_objc_class_prefix(const ::std::string& value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)
}
#if LANG_CXX11
void FileOptions::set_objc_class_prefix(::std::string&& value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix)
}
#endif
void FileOptions::set_objc_class_prefix(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix)
}
void FileOptions::set_objc_class_prefix(const char* value, size_t size) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix)
}
::std::string* FileOptions::mutable_objc_class_prefix() {
set_has_objc_class_prefix();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix)
return objc_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_objc_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix)
clear_has_objc_class_prefix();
return objc_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) {
if (objc_class_prefix != NULL) {
set_has_objc_class_prefix();
} else {
clear_has_objc_class_prefix();
}
objc_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix)
}
// optional string csharp_namespace = 37;
bool FileOptions::has_csharp_namespace() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void FileOptions::set_has_csharp_namespace() {
_has_bits_[0] |= 0x00000010u;
}
void FileOptions::clear_has_csharp_namespace() {
_has_bits_[0] &= ~0x00000010u;
}
void FileOptions::clear_csharp_namespace() {
csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_csharp_namespace();
}
const ::std::string& FileOptions::csharp_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)
return csharp_namespace_.GetNoArena();
}
void FileOptions::set_csharp_namespace(const ::std::string& value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)
}
#if LANG_CXX11
void FileOptions::set_csharp_namespace(::std::string&& value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace)
}
#endif
void FileOptions::set_csharp_namespace(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace)
}
void FileOptions::set_csharp_namespace(const char* value, size_t size) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace)
}
::std::string* FileOptions::mutable_csharp_namespace() {
set_has_csharp_namespace();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace)
return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_csharp_namespace() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace)
clear_has_csharp_namespace();
return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) {
if (csharp_namespace != NULL) {
set_has_csharp_namespace();
} else {
clear_has_csharp_namespace();
}
csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)
}
// optional string swift_prefix = 39;
bool FileOptions::has_swift_prefix() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
void FileOptions::set_has_swift_prefix() {
_has_bits_[0] |= 0x00000020u;
}
void FileOptions::clear_has_swift_prefix() {
_has_bits_[0] &= ~0x00000020u;
}
void FileOptions::clear_swift_prefix() {
swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_swift_prefix();
}
const ::std::string& FileOptions::swift_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix)
return swift_prefix_.GetNoArena();
}
void FileOptions::set_swift_prefix(const ::std::string& value) {
set_has_swift_prefix();
swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix)
}
#if LANG_CXX11
void FileOptions::set_swift_prefix(::std::string&& value) {
set_has_swift_prefix();
swift_prefix_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix)
}
#endif
void FileOptions::set_swift_prefix(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_swift_prefix();
swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix)
}
void FileOptions::set_swift_prefix(const char* value, size_t size) {
set_has_swift_prefix();
swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix)
}
::std::string* FileOptions::mutable_swift_prefix() {
set_has_swift_prefix();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix)
return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_swift_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix)
clear_has_swift_prefix();
return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) {
if (swift_prefix != NULL) {
set_has_swift_prefix();
} else {
clear_has_swift_prefix();
}
swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix)
}
// optional string php_class_prefix = 40;
bool FileOptions::has_php_class_prefix() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
void FileOptions::set_has_php_class_prefix() {
_has_bits_[0] |= 0x00000040u;
}
void FileOptions::clear_has_php_class_prefix() {
_has_bits_[0] &= ~0x00000040u;
}
void FileOptions::clear_php_class_prefix() {
php_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_php_class_prefix();
}
const ::std::string& FileOptions::php_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix)
return php_class_prefix_.GetNoArena();
}
void FileOptions::set_php_class_prefix(const ::std::string& value) {
set_has_php_class_prefix();
php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix)
}
#if LANG_CXX11
void FileOptions::set_php_class_prefix(::std::string&& value) {
set_has_php_class_prefix();
php_class_prefix_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_class_prefix)
}
#endif
void FileOptions::set_php_class_prefix(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_php_class_prefix();
php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_class_prefix)
}
void FileOptions::set_php_class_prefix(const char* value, size_t size) {
set_has_php_class_prefix();
php_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix)
}
::std::string* FileOptions::mutable_php_class_prefix() {
set_has_php_class_prefix();
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix)
return php_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* FileOptions::release_php_class_prefix() {
// @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix)
clear_has_php_class_prefix();
return php_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix) {
if (php_class_prefix != NULL) {
set_has_php_class_prefix();
} else {
clear_has_php_class_prefix();
}
php_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_class_prefix);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int FileOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void FileOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
FileOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
FileOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MessageOptions::kMessageSetWireFormatFieldNumber;
const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber;
const int MessageOptions::kDeprecatedFieldNumber;
const int MessageOptions::kMapEntryFieldNumber;
const int MessageOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
MessageOptions::MessageOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MessageOptions)
}
MessageOptions::MessageOptions(const MessageOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&message_set_wire_format_, &from.message_set_wire_format_,
reinterpret_cast<char*>(&map_entry_) -
reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions)
}
void MessageOptions::SharedCtor() {
_cached_size_ = 0;
::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) -
reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_));
}
MessageOptions::~MessageOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.MessageOptions)
SharedDtor();
}
void MessageOptions::SharedDtor() {
}
void MessageOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MessageOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const MessageOptions& MessageOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {
MessageOptions* n = new MessageOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void MessageOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
if (_has_bits_[0 / 32] & 15u) {
::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) -
reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool MessageOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool message_set_wire_format = 1 [default = false];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
set_has_message_set_wire_format();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &message_set_wire_format_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_no_standard_descriptor_accessor();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &no_standard_descriptor_accessor_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool map_entry = 7;
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(56u)) {
set_has_map_entry();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &map_entry_)));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.MessageOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.MessageOptions)
return false;
#undef DO_
}
void MessageOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.MessageOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool message_set_wire_format = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->message_set_wire_format(), output);
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->no_standard_descriptor_accessor(), output);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);
}
// optional bool map_entry = 7;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteBool(7, this->map_entry(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.MessageOptions)
}
::google::protobuf::uint8* MessageOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool message_set_wire_format = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->message_set_wire_format(), target);
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->no_standard_descriptor_accessor(), target);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);
}
// optional bool map_entry = 7;
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->map_entry(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MessageOptions)
return target;
}
size_t MessageOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
if (_has_bits_[0 / 32] & 15u) {
// optional bool message_set_wire_format = 1 [default = false];
if (has_message_set_wire_format()) {
total_size += 1 + 1;
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
if (has_no_standard_descriptor_accessor()) {
total_size += 1 + 1;
}
// optional bool deprecated = 3 [default = false];
if (has_deprecated()) {
total_size += 1 + 1;
}
// optional bool map_entry = 7;
if (has_map_entry()) {
total_size += 1 + 1;
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions)
GOOGLE_DCHECK_NE(&from, this);
const MessageOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MessageOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions)
MergeFrom(*source);
}
}
void MessageOptions::MergeFrom(const MessageOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 15u) {
if (cached_has_bits & 0x00000001u) {
message_set_wire_format_ = from.message_set_wire_format_;
}
if (cached_has_bits & 0x00000002u) {
no_standard_descriptor_accessor_ = from.no_standard_descriptor_accessor_;
}
if (cached_has_bits & 0x00000004u) {
deprecated_ = from.deprecated_;
}
if (cached_has_bits & 0x00000008u) {
map_entry_ = from.map_entry_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void MessageOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MessageOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void MessageOptions::CopyFrom(const MessageOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool MessageOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void MessageOptions::Swap(MessageOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void MessageOptions::InternalSwap(MessageOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(message_set_wire_format_, other->message_set_wire_format_);
std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_);
std::swap(deprecated_, other->deprecated_);
std::swap(map_entry_, other->map_entry_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata MessageOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// MessageOptions
// optional bool message_set_wire_format = 1 [default = false];
bool MessageOptions::has_message_set_wire_format() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void MessageOptions::set_has_message_set_wire_format() {
_has_bits_[0] |= 0x00000001u;
}
void MessageOptions::clear_has_message_set_wire_format() {
_has_bits_[0] &= ~0x00000001u;
}
void MessageOptions::clear_message_set_wire_format() {
message_set_wire_format_ = false;
clear_has_message_set_wire_format();
}
bool MessageOptions::message_set_wire_format() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format)
return message_set_wire_format_;
}
void MessageOptions::set_message_set_wire_format(bool value) {
set_has_message_set_wire_format();
message_set_wire_format_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format)
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
bool MessageOptions::has_no_standard_descriptor_accessor() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void MessageOptions::set_has_no_standard_descriptor_accessor() {
_has_bits_[0] |= 0x00000002u;
}
void MessageOptions::clear_has_no_standard_descriptor_accessor() {
_has_bits_[0] &= ~0x00000002u;
}
void MessageOptions::clear_no_standard_descriptor_accessor() {
no_standard_descriptor_accessor_ = false;
clear_has_no_standard_descriptor_accessor();
}
bool MessageOptions::no_standard_descriptor_accessor() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor)
return no_standard_descriptor_accessor_;
}
void MessageOptions::set_no_standard_descriptor_accessor(bool value) {
set_has_no_standard_descriptor_accessor();
no_standard_descriptor_accessor_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor)
}
// optional bool deprecated = 3 [default = false];
bool MessageOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void MessageOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000004u;
}
void MessageOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000004u;
}
void MessageOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool MessageOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated)
return deprecated_;
}
void MessageOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated)
}
// optional bool map_entry = 7;
bool MessageOptions::has_map_entry() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void MessageOptions::set_has_map_entry() {
_has_bits_[0] |= 0x00000008u;
}
void MessageOptions::clear_has_map_entry() {
_has_bits_[0] &= ~0x00000008u;
}
void MessageOptions::clear_map_entry() {
map_entry_ = false;
clear_has_map_entry();
}
bool MessageOptions::map_entry() const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry)
return map_entry_;
}
void MessageOptions::set_map_entry(bool value) {
set_has_map_entry();
map_entry_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int MessageOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void MessageOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
MessageOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
MessageOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FieldOptions::kCtypeFieldNumber;
const int FieldOptions::kPackedFieldNumber;
const int FieldOptions::kJstypeFieldNumber;
const int FieldOptions::kLazyFieldNumber;
const int FieldOptions::kDeprecatedFieldNumber;
const int FieldOptions::kWeakFieldNumber;
const int FieldOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FieldOptions::FieldOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FieldOptions)
}
FieldOptions::FieldOptions(const FieldOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&ctype_, &from.ctype_,
reinterpret_cast<char*>(&jstype_) -
reinterpret_cast<char*>(&ctype_) + sizeof(jstype_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)
}
void FieldOptions::SharedCtor() {
_cached_size_ = 0;
::memset(&ctype_, 0, reinterpret_cast<char*>(&jstype_) -
reinterpret_cast<char*>(&ctype_) + sizeof(jstype_));
}
FieldOptions::~FieldOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.FieldOptions)
SharedDtor();
}
void FieldOptions::SharedDtor() {
}
void FieldOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FieldOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FieldOptions& FieldOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {
FieldOptions* n = new FieldOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void FieldOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
if (_has_bits_[0 / 32] & 63u) {
::memset(&ctype_, 0, reinterpret_cast<char*>(&jstype_) -
reinterpret_cast<char*>(&ctype_) + sizeof(jstype_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool FieldOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::FieldOptions_CType_IsValid(value)) {
set_ctype(static_cast< ::google::protobuf::FieldOptions_CType >(value));
} else {
mutable_unknown_fields()->AddVarint(1, value);
}
} else {
goto handle_unusual;
}
break;
}
// optional bool packed = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_packed();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &packed_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool lazy = 5 [default = false];
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u)) {
set_has_lazy();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &lazy_)));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(48u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::FieldOptions_JSType_IsValid(value)) {
set_jstype(static_cast< ::google::protobuf::FieldOptions_JSType >(value));
} else {
mutable_unknown_fields()->AddVarint(6, value);
}
} else {
goto handle_unusual;
}
break;
}
// optional bool weak = 10 [default = false];
case 10: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(80u)) {
set_has_weak();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &weak_)));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FieldOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FieldOptions)
return false;
#undef DO_
}
void FieldOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
1, this->ctype(), output);
}
// optional bool packed = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->packed(), output);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);
}
// optional bool lazy = 5 [default = false];
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteBool(5, this->lazy(), output);
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
6, this->jstype(), output);
}
// optional bool weak = 10 [default = false];
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormatLite::WriteBool(10, this->weak(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FieldOptions)
}
::google::protobuf::uint8* FieldOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
1, this->ctype(), target);
}
// optional bool packed = 2;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->packed(), target);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);
}
// optional bool lazy = 5 [default = false];
if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->lazy(), target);
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (cached_has_bits & 0x00000020u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
6, this->jstype(), target);
}
// optional bool weak = 10 [default = false];
if (cached_has_bits & 0x00000010u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->weak(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldOptions)
return target;
}
size_t FieldOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
if (_has_bits_[0 / 32] & 63u) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (has_ctype()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype());
}
// optional bool packed = 2;
if (has_packed()) {
total_size += 1 + 1;
}
// optional bool lazy = 5 [default = false];
if (has_lazy()) {
total_size += 1 + 1;
}
// optional bool deprecated = 3 [default = false];
if (has_deprecated()) {
total_size += 1 + 1;
}
// optional bool weak = 10 [default = false];
if (has_weak()) {
total_size += 1 + 1;
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (has_jstype()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->jstype());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions)
GOOGLE_DCHECK_NE(&from, this);
const FieldOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FieldOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions)
MergeFrom(*source);
}
}
void FieldOptions::MergeFrom(const FieldOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 63u) {
if (cached_has_bits & 0x00000001u) {
ctype_ = from.ctype_;
}
if (cached_has_bits & 0x00000002u) {
packed_ = from.packed_;
}
if (cached_has_bits & 0x00000004u) {
lazy_ = from.lazy_;
}
if (cached_has_bits & 0x00000008u) {
deprecated_ = from.deprecated_;
}
if (cached_has_bits & 0x00000010u) {
weak_ = from.weak_;
}
if (cached_has_bits & 0x00000020u) {
jstype_ = from.jstype_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void FieldOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FieldOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FieldOptions::CopyFrom(const FieldOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FieldOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void FieldOptions::Swap(FieldOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void FieldOptions::InternalSwap(FieldOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(ctype_, other->ctype_);
std::swap(packed_, other->packed_);
std::swap(lazy_, other->lazy_);
std::swap(deprecated_, other->deprecated_);
std::swap(weak_, other->weak_);
std::swap(jstype_, other->jstype_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata FieldOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FieldOptions
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
bool FieldOptions::has_ctype() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void FieldOptions::set_has_ctype() {
_has_bits_[0] |= 0x00000001u;
}
void FieldOptions::clear_has_ctype() {
_has_bits_[0] &= ~0x00000001u;
}
void FieldOptions::clear_ctype() {
ctype_ = 0;
clear_has_ctype();
}
::google::protobuf::FieldOptions_CType FieldOptions::ctype() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype)
return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_);
}
void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) {
assert(::google::protobuf::FieldOptions_CType_IsValid(value));
set_has_ctype();
ctype_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype)
}
// optional bool packed = 2;
bool FieldOptions::has_packed() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void FieldOptions::set_has_packed() {
_has_bits_[0] |= 0x00000002u;
}
void FieldOptions::clear_has_packed() {
_has_bits_[0] &= ~0x00000002u;
}
void FieldOptions::clear_packed() {
packed_ = false;
clear_has_packed();
}
bool FieldOptions::packed() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed)
return packed_;
}
void FieldOptions::set_packed(bool value) {
set_has_packed();
packed_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed)
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
bool FieldOptions::has_jstype() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
void FieldOptions::set_has_jstype() {
_has_bits_[0] |= 0x00000020u;
}
void FieldOptions::clear_has_jstype() {
_has_bits_[0] &= ~0x00000020u;
}
void FieldOptions::clear_jstype() {
jstype_ = 0;
clear_has_jstype();
}
::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype)
return static_cast< ::google::protobuf::FieldOptions_JSType >(jstype_);
}
void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) {
assert(::google::protobuf::FieldOptions_JSType_IsValid(value));
set_has_jstype();
jstype_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype)
}
// optional bool lazy = 5 [default = false];
bool FieldOptions::has_lazy() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void FieldOptions::set_has_lazy() {
_has_bits_[0] |= 0x00000004u;
}
void FieldOptions::clear_has_lazy() {
_has_bits_[0] &= ~0x00000004u;
}
void FieldOptions::clear_lazy() {
lazy_ = false;
clear_has_lazy();
}
bool FieldOptions::lazy() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy)
return lazy_;
}
void FieldOptions::set_lazy(bool value) {
set_has_lazy();
lazy_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy)
}
// optional bool deprecated = 3 [default = false];
bool FieldOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void FieldOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000008u;
}
void FieldOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000008u;
}
void FieldOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool FieldOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated)
return deprecated_;
}
void FieldOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated)
}
// optional bool weak = 10 [default = false];
bool FieldOptions::has_weak() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void FieldOptions::set_has_weak() {
_has_bits_[0] |= 0x00000010u;
}
void FieldOptions::clear_has_weak() {
_has_bits_[0] &= ~0x00000010u;
}
void FieldOptions::clear_weak() {
weak_ = false;
clear_has_weak();
}
bool FieldOptions::weak() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak)
return weak_;
}
void FieldOptions::set_weak(bool value) {
set_has_weak();
weak_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int FieldOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void FieldOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
FieldOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
FieldOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int OneofOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
OneofOptions::OneofOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.OneofOptions)
}
OneofOptions::OneofOptions(const OneofOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions)
}
void OneofOptions::SharedCtor() {
_cached_size_ = 0;
}
OneofOptions::~OneofOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.OneofOptions)
SharedDtor();
}
void OneofOptions::SharedDtor() {
}
void OneofOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* OneofOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const OneofOptions& OneofOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const {
OneofOptions* n = new OneofOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void OneofOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool OneofOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.OneofOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.OneofOptions)
return false;
#undef DO_
}
void OneofOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.OneofOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.OneofOptions)
}
::google::protobuf::uint8* OneofOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofOptions)
return target;
}
size_t OneofOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions)
GOOGLE_DCHECK_NE(&from, this);
const OneofOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.OneofOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions)
MergeFrom(*source);
}
}
void OneofOptions::MergeFrom(const OneofOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
}
void OneofOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.OneofOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void OneofOptions::CopyFrom(const OneofOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool OneofOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void OneofOptions::Swap(OneofOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void OneofOptions::InternalSwap(OneofOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata OneofOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// OneofOptions
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int OneofOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void OneofOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
OneofOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
OneofOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int EnumOptions::kAllowAliasFieldNumber;
const int EnumOptions::kDeprecatedFieldNumber;
const int EnumOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
EnumOptions::EnumOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumOptions)
}
EnumOptions::EnumOptions(const EnumOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&allow_alias_, &from.allow_alias_,
reinterpret_cast<char*>(&deprecated_) -
reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions)
}
void EnumOptions::SharedCtor() {
_cached_size_ = 0;
::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) -
reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_));
}
EnumOptions::~EnumOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumOptions)
SharedDtor();
}
void EnumOptions::SharedDtor() {
}
void EnumOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const EnumOptions& EnumOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {
EnumOptions* n = new EnumOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void EnumOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
if (_has_bits_[0 / 32] & 3u) {
::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) -
reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool EnumOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool allow_alias = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_allow_alias();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &allow_alias_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.EnumOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.EnumOptions)
return false;
#undef DO_
}
void EnumOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.EnumOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool allow_alias = 2;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->allow_alias(), output);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.EnumOptions)
}
::google::protobuf::uint8* EnumOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool allow_alias = 2;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->allow_alias(), target);
}
// optional bool deprecated = 3 [default = false];
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumOptions)
return target;
}
size_t EnumOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
if (_has_bits_[0 / 32] & 3u) {
// optional bool allow_alias = 2;
if (has_allow_alias()) {
total_size += 1 + 1;
}
// optional bool deprecated = 3 [default = false];
if (has_deprecated()) {
total_size += 1 + 1;
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions)
GOOGLE_DCHECK_NE(&from, this);
const EnumOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions)
MergeFrom(*source);
}
}
void EnumOptions::MergeFrom(const EnumOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
allow_alias_ = from.allow_alias_;
}
if (cached_has_bits & 0x00000002u) {
deprecated_ = from.deprecated_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void EnumOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void EnumOptions::CopyFrom(const EnumOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool EnumOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void EnumOptions::Swap(EnumOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void EnumOptions::InternalSwap(EnumOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(allow_alias_, other->allow_alias_);
std::swap(deprecated_, other->deprecated_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata EnumOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// EnumOptions
// optional bool allow_alias = 2;
bool EnumOptions::has_allow_alias() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void EnumOptions::set_has_allow_alias() {
_has_bits_[0] |= 0x00000001u;
}
void EnumOptions::clear_has_allow_alias() {
_has_bits_[0] &= ~0x00000001u;
}
void EnumOptions::clear_allow_alias() {
allow_alias_ = false;
clear_has_allow_alias();
}
bool EnumOptions::allow_alias() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias)
return allow_alias_;
}
void EnumOptions::set_allow_alias(bool value) {
set_has_allow_alias();
allow_alias_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias)
}
// optional bool deprecated = 3 [default = false];
bool EnumOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void EnumOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000002u;
}
void EnumOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000002u;
}
void EnumOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool EnumOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated)
return deprecated_;
}
void EnumOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int EnumOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void EnumOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
EnumOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
EnumOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int EnumValueOptions::kDeprecatedFieldNumber;
const int EnumValueOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
EnumValueOptions::EnumValueOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions)
}
EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
deprecated_ = from.deprecated_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions)
}
void EnumValueOptions::SharedCtor() {
_cached_size_ = 0;
deprecated_ = false;
}
EnumValueOptions::~EnumValueOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.EnumValueOptions)
SharedDtor();
}
void EnumValueOptions::SharedDtor() {
}
void EnumValueOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const EnumValueOptions& EnumValueOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const {
EnumValueOptions* n = new EnumValueOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void EnumValueOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
deprecated_ = false;
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool EnumValueOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 1 [default = false];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.EnumValueOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.EnumValueOptions)
return false;
#undef DO_
}
void EnumValueOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.EnumValueOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->deprecated(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueOptions)
}
::google::protobuf::uint8* EnumValueOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 1 [default = false];
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueOptions)
return target;
}
size_t EnumValueOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
// optional bool deprecated = 1 [default = false];
if (has_deprecated()) {
total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions)
GOOGLE_DCHECK_NE(&from, this);
const EnumValueOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumValueOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions)
MergeFrom(*source);
}
}
void EnumValueOptions::MergeFrom(const EnumValueOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
if (from.has_deprecated()) {
set_deprecated(from.deprecated());
}
}
void EnumValueOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumValueOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void EnumValueOptions::CopyFrom(const EnumValueOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool EnumValueOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void EnumValueOptions::Swap(EnumValueOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(deprecated_, other->deprecated_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata EnumValueOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// EnumValueOptions
// optional bool deprecated = 1 [default = false];
bool EnumValueOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void EnumValueOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000001u;
}
void EnumValueOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000001u;
}
void EnumValueOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool EnumValueOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated)
return deprecated_;
}
void EnumValueOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int EnumValueOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void EnumValueOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
EnumValueOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
EnumValueOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int ServiceOptions::kDeprecatedFieldNumber;
const int ServiceOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
ServiceOptions::ServiceOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions)
}
ServiceOptions::ServiceOptions(const ServiceOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
deprecated_ = from.deprecated_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions)
}
void ServiceOptions::SharedCtor() {
_cached_size_ = 0;
deprecated_ = false;
}
ServiceOptions::~ServiceOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.ServiceOptions)
SharedDtor();
}
void ServiceOptions::SharedDtor() {
}
void ServiceOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* ServiceOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const ServiceOptions& ServiceOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const {
ServiceOptions* n = new ServiceOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void ServiceOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
deprecated_ = false;
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool ServiceOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(264u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.ServiceOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.ServiceOptions)
return false;
#undef DO_
}
void ServiceOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.ServiceOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.ServiceOptions)
}
::google::protobuf::uint8* ServiceOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceOptions)
return target;
}
size_t ServiceOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
// optional bool deprecated = 33 [default = false];
if (has_deprecated()) {
total_size += 2 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions)
GOOGLE_DCHECK_NE(&from, this);
const ServiceOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ServiceOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions)
MergeFrom(*source);
}
}
void ServiceOptions::MergeFrom(const ServiceOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
if (from.has_deprecated()) {
set_deprecated(from.deprecated());
}
}
void ServiceOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ServiceOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ServiceOptions::CopyFrom(const ServiceOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ServiceOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void ServiceOptions::Swap(ServiceOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void ServiceOptions::InternalSwap(ServiceOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(deprecated_, other->deprecated_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata ServiceOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// ServiceOptions
// optional bool deprecated = 33 [default = false];
bool ServiceOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void ServiceOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000001u;
}
void ServiceOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000001u;
}
void ServiceOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool ServiceOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated)
return deprecated_;
}
void ServiceOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int ServiceOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void ServiceOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
ServiceOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
ServiceOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MethodOptions::kDeprecatedFieldNumber;
const int MethodOptions::kIdempotencyLevelFieldNumber;
const int MethodOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
MethodOptions::MethodOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MethodOptions)
}
MethodOptions::MethodOptions(const MethodOptions& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
uninterpreted_option_(from.uninterpreted_option_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
::memcpy(&deprecated_, &from.deprecated_,
reinterpret_cast<char*>(&idempotency_level_) -
reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions)
}
void MethodOptions::SharedCtor() {
_cached_size_ = 0;
::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) -
reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
}
MethodOptions::~MethodOptions() {
// @@protoc_insertion_point(destructor:google.protobuf.MethodOptions)
SharedDtor();
}
void MethodOptions::SharedDtor() {
}
void MethodOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MethodOptions::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const MethodOptions& MethodOptions::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const {
MethodOptions* n = new MethodOptions;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void MethodOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions)
_extensions_.Clear();
uninterpreted_option_.Clear();
if (_has_bits_[0 / 32] & 3u) {
::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) -
reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool MethodOptions::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 33 [default = false];
case 33: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(264u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &deprecated_)));
} else {
goto handle_unusual;
}
break;
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
case 34: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(272u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)) {
set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value));
} else {
mutable_unknown_fields()->AddVarint(34, value);
}
} else {
goto handle_unusual;
}
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(7994u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
if ((8000u <= tag)) {
DO_(_extensions_.ParseField(tag, input, internal_default_instance(),
mutable_unknown_fields()));
continue;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.MethodOptions)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.MethodOptions)
return false;
#undef DO_
}
void MethodOptions::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.MethodOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output);
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
34, this->idempotency_level(), output);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
999, this->uninterpreted_option(i), output);
}
// Extension range [1000, 536870912)
_extensions_.SerializeWithCachedSizes(
1000, 536870912, output);
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.MethodOptions)
}
::google::protobuf::uint8* MethodOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bool deprecated = 33 [default = false];
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target);
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
34, this->idempotency_level(), target);
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
999, this->uninterpreted_option(i), deterministic, target);
}
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodOptions)
return target;
}
size_t MethodOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
total_size += 2UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
}
if (_has_bits_[0 / 32] & 3u) {
// optional bool deprecated = 33 [default = false];
if (has_deprecated()) {
total_size += 2 + 1;
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
if (has_idempotency_level()) {
total_size += 2 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->idempotency_level());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions)
GOOGLE_DCHECK_NE(&from, this);
const MethodOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MethodOptions)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions)
MergeFrom(*source);
}
}
void MethodOptions::MergeFrom(const MethodOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions)
GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
deprecated_ = from.deprecated_;
}
if (cached_has_bits & 0x00000002u) {
idempotency_level_ = from.idempotency_level_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void MethodOptions::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MethodOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void MethodOptions::CopyFrom(const MethodOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool MethodOptions::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
void MethodOptions::Swap(MethodOptions* other) {
if (other == this) return;
InternalSwap(other);
}
void MethodOptions::InternalSwap(MethodOptions* other) {
uninterpreted_option_.InternalSwap(&other->uninterpreted_option_);
std::swap(deprecated_, other->deprecated_);
std::swap(idempotency_level_, other->idempotency_level_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
_extensions_.Swap(&other->_extensions_);
}
::google::protobuf::Metadata MethodOptions::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// MethodOptions
// optional bool deprecated = 33 [default = false];
bool MethodOptions::has_deprecated() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void MethodOptions::set_has_deprecated() {
_has_bits_[0] |= 0x00000001u;
}
void MethodOptions::clear_has_deprecated() {
_has_bits_[0] &= ~0x00000001u;
}
void MethodOptions::clear_deprecated() {
deprecated_ = false;
clear_has_deprecated();
}
bool MethodOptions::deprecated() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated)
return deprecated_;
}
void MethodOptions::set_deprecated(bool value) {
set_has_deprecated();
deprecated_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)
}
// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
bool MethodOptions::has_idempotency_level() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void MethodOptions::set_has_idempotency_level() {
_has_bits_[0] |= 0x00000002u;
}
void MethodOptions::clear_has_idempotency_level() {
_has_bits_[0] &= ~0x00000002u;
}
void MethodOptions::clear_idempotency_level() {
idempotency_level_ = 0;
clear_has_idempotency_level();
}
::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level)
return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_);
}
void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) {
assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value));
set_has_idempotency_level();
idempotency_level_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level)
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int MethodOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
}
void MethodOptions::clear_uninterpreted_option() {
uninterpreted_option_.Clear();
}
const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option)
return uninterpreted_option_.Get(index);
}
::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option)
return uninterpreted_option_.Mutable(index);
}
::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() {
// @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option)
return uninterpreted_option_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
MethodOptions::mutable_uninterpreted_option() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option)
return &uninterpreted_option_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
MethodOptions::uninterpreted_option() const {
// @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option)
return uninterpreted_option_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UninterpretedOption_NamePart::kNamePartFieldNumber;
const int UninterpretedOption_NamePart::kIsExtensionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UninterpretedOption_NamePart::UninterpretedOption_NamePart()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart)
}
UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_name_part()) {
name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_);
}
is_extension_ = from.is_extension_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart)
}
void UninterpretedOption_NamePart::SharedCtor() {
_cached_size_ = 0;
name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
is_extension_ = false;
}
UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
// @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption.NamePart)
SharedDtor();
}
void UninterpretedOption_NamePart::SharedDtor() {
name_part_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption_NamePart::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const {
UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void UninterpretedOption_NamePart::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart)
if (has_name_part()) {
GOOGLE_DCHECK(!name_part_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*name_part_.UnsafeRawStringPointer())->clear();
}
is_extension_ = false;
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required string name_part = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name_part()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name_part().data(), this->name_part().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.UninterpretedOption.NamePart.name_part");
} else {
goto handle_unusual;
}
break;
}
// required bool is_extension = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
set_has_is_extension();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &is_extension_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.UninterpretedOption.NamePart)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.UninterpretedOption.NamePart)
return false;
#undef DO_
}
void UninterpretedOption_NamePart::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UninterpretedOption.NamePart)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required string name_part = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name_part().data(), this->name_part().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.NamePart.name_part");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->name_part(), output);
}
// required bool is_extension = 2;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->is_extension(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption.NamePart)
}
::google::protobuf::uint8* UninterpretedOption_NamePart::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required string name_part = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name_part().data(), this->name_part().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.NamePart.name_part");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->name_part(), target);
}
// required bool is_extension = 2;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->is_extension(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption.NamePart)
return target;
}
size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:google.protobuf.UninterpretedOption.NamePart)
size_t total_size = 0;
if (has_name_part()) {
// required string name_part = 1;
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name_part());
}
if (has_is_extension()) {
// required bool is_extension = 2;
total_size += 1 + 1;
}
return total_size;
}
size_t UninterpretedOption_NamePart::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present.
// required string name_part = 1;
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name_part());
// required bool is_extension = 2;
total_size += 1 + 1;
} else {
total_size += RequiredFieldsByteSizeFallback();
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
GOOGLE_DCHECK_NE(&from, this);
const UninterpretedOption_NamePart* source =
::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UninterpretedOption.NamePart)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart)
MergeFrom(*source);
}
}
void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_name_part();
name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_);
}
if (cached_has_bits & 0x00000002u) {
is_extension_ = from.is_extension_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UninterpretedOption.NamePart)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool UninterpretedOption_NamePart::IsInitialized() const {
if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
return true;
}
void UninterpretedOption_NamePart::Swap(UninterpretedOption_NamePart* other) {
if (other == this) return;
InternalSwap(other);
}
void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* other) {
name_part_.Swap(&other->name_part_);
std::swap(is_extension_, other->is_extension_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// UninterpretedOption_NamePart
// required string name_part = 1;
bool UninterpretedOption_NamePart::has_name_part() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void UninterpretedOption_NamePart::set_has_name_part() {
_has_bits_[0] |= 0x00000001u;
}
void UninterpretedOption_NamePart::clear_has_name_part() {
_has_bits_[0] &= ~0x00000001u;
}
void UninterpretedOption_NamePart::clear_name_part() {
name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name_part();
}
const ::std::string& UninterpretedOption_NamePart::name_part() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)
return name_part_.GetNoArena();
}
void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {
set_has_name_part();
name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
}
#if LANG_CXX11
void UninterpretedOption_NamePart::set_name_part(::std::string&& value) {
set_has_name_part();
name_part_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part)
}
#endif
void UninterpretedOption_NamePart::set_name_part(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name_part();
name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part)
}
void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) {
set_has_name_part();
name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part)
}
::std::string* UninterpretedOption_NamePart::mutable_name_part() {
set_has_name_part();
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part)
return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* UninterpretedOption_NamePart::release_name_part() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)
clear_has_name_part();
return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) {
if (name_part != NULL) {
set_has_name_part();
} else {
clear_has_name_part();
}
name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)
}
// required bool is_extension = 2;
bool UninterpretedOption_NamePart::has_is_extension() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void UninterpretedOption_NamePart::set_has_is_extension() {
_has_bits_[0] |= 0x00000002u;
}
void UninterpretedOption_NamePart::clear_has_is_extension() {
_has_bits_[0] &= ~0x00000002u;
}
void UninterpretedOption_NamePart::clear_is_extension() {
is_extension_ = false;
clear_has_is_extension();
}
bool UninterpretedOption_NamePart::is_extension() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)
return is_extension_;
}
void UninterpretedOption_NamePart::set_is_extension(bool value) {
set_has_is_extension();
is_extension_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UninterpretedOption::kNameFieldNumber;
const int UninterpretedOption::kIdentifierValueFieldNumber;
const int UninterpretedOption::kPositiveIntValueFieldNumber;
const int UninterpretedOption::kNegativeIntValueFieldNumber;
const int UninterpretedOption::kDoubleValueFieldNumber;
const int UninterpretedOption::kStringValueFieldNumber;
const int UninterpretedOption::kAggregateValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UninterpretedOption::UninterpretedOption()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption)
}
UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
name_(from.name_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_identifier_value()) {
identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_);
}
string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_string_value()) {
string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);
}
aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_aggregate_value()) {
aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);
}
::memcpy(&positive_int_value_, &from.positive_int_value_,
reinterpret_cast<char*>(&double_value_) -
reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption)
}
void UninterpretedOption::SharedCtor() {
_cached_size_ = 0;
identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) -
reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_));
}
UninterpretedOption::~UninterpretedOption() {
// @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption)
SharedDtor();
}
void UninterpretedOption::SharedDtor() {
identifier_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
aggregate_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const UninterpretedOption& UninterpretedOption::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const {
UninterpretedOption* n = new UninterpretedOption;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void UninterpretedOption::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)
name_.Clear();
if (_has_bits_[0 / 32] & 7u) {
if (has_identifier_value()) {
GOOGLE_DCHECK(!identifier_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*identifier_value_.UnsafeRawStringPointer())->clear();
}
if (has_string_value()) {
GOOGLE_DCHECK(!string_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*string_value_.UnsafeRawStringPointer())->clear();
}
if (has_aggregate_value()) {
GOOGLE_DCHECK(!aggregate_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*aggregate_value_.UnsafeRawStringPointer())->clear();
}
}
if (_has_bits_[0 / 32] & 56u) {
::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) -
reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool UninterpretedOption::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_name()));
} else {
goto handle_unusual;
}
break;
}
// optional string identifier_value = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_identifier_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->identifier_value().data(), this->identifier_value().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.UninterpretedOption.identifier_value");
} else {
goto handle_unusual;
}
break;
}
// optional uint64 positive_int_value = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(32u)) {
set_has_positive_int_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
input, &positive_int_value_)));
} else {
goto handle_unusual;
}
break;
}
// optional int64 negative_int_value = 5;
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u)) {
set_has_negative_int_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
input, &negative_int_value_)));
} else {
goto handle_unusual;
}
break;
}
// optional double double_value = 6;
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(49u)) {
set_has_double_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
input, &double_value_)));
} else {
goto handle_unusual;
}
break;
}
// optional bytes string_value = 7;
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_string_value()));
} else {
goto handle_unusual;
}
break;
}
// optional string aggregate_value = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_aggregate_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->aggregate_value().data(), this->aggregate_value().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.UninterpretedOption.aggregate_value");
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.UninterpretedOption)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.UninterpretedOption)
return false;
#undef DO_
}
void UninterpretedOption::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UninterpretedOption)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
for (unsigned int i = 0, n = this->name_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->name(i), output);
}
cached_has_bits = _has_bits_[0];
// optional string identifier_value = 3;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->identifier_value().data(), this->identifier_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.identifier_value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
3, this->identifier_value(), output);
}
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->positive_int_value(), output);
}
// optional int64 negative_int_value = 5;
if (cached_has_bits & 0x00000010u) {
::google::protobuf::internal::WireFormatLite::WriteInt64(5, this->negative_int_value(), output);
}
// optional double double_value = 6;
if (cached_has_bits & 0x00000020u) {
::google::protobuf::internal::WireFormatLite::WriteDouble(6, this->double_value(), output);
}
// optional bytes string_value = 7;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
7, this->string_value(), output);
}
// optional string aggregate_value = 8;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->aggregate_value().data(), this->aggregate_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.aggregate_value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
8, this->aggregate_value(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption)
}
::google::protobuf::uint8* UninterpretedOption::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
for (unsigned int i = 0, n = this->name_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
2, this->name(i), deterministic, target);
}
cached_has_bits = _has_bits_[0];
// optional string identifier_value = 3;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->identifier_value().data(), this->identifier_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.identifier_value");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
3, this->identifier_value(), target);
}
// optional uint64 positive_int_value = 4;
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->positive_int_value(), target);
}
// optional int64 negative_int_value = 5;
if (cached_has_bits & 0x00000010u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(5, this->negative_int_value(), target);
}
// optional double double_value = 6;
if (cached_has_bits & 0x00000020u) {
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(6, this->double_value(), target);
}
// optional bytes string_value = 7;
if (cached_has_bits & 0x00000002u) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
7, this->string_value(), target);
}
// optional string aggregate_value = 8;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->aggregate_value().data(), this->aggregate_value().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.aggregate_value");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
8, this->aggregate_value(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption)
return target;
}
size_t UninterpretedOption::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
{
unsigned int count = this->name_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->name(i));
}
}
if (_has_bits_[0 / 32] & 63u) {
// optional string identifier_value = 3;
if (has_identifier_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->identifier_value());
}
// optional bytes string_value = 7;
if (has_string_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
this->string_value());
}
// optional string aggregate_value = 8;
if (has_aggregate_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->aggregate_value());
}
// optional uint64 positive_int_value = 4;
if (has_positive_int_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
this->positive_int_value());
}
// optional int64 negative_int_value = 5;
if (has_negative_int_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int64Size(
this->negative_int_value());
}
// optional double double_value = 6;
if (has_double_value()) {
total_size += 1 + 8;
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption)
GOOGLE_DCHECK_NE(&from, this);
const UninterpretedOption* source =
::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UninterpretedOption)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption)
MergeFrom(*source);
}
}
void UninterpretedOption::MergeFrom(const UninterpretedOption& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
name_.MergeFrom(from.name_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 63u) {
if (cached_has_bits & 0x00000001u) {
set_has_identifier_value();
identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_);
}
if (cached_has_bits & 0x00000002u) {
set_has_string_value();
string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);
}
if (cached_has_bits & 0x00000004u) {
set_has_aggregate_value();
aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);
}
if (cached_has_bits & 0x00000008u) {
positive_int_value_ = from.positive_int_value_;
}
if (cached_has_bits & 0x00000010u) {
negative_int_value_ = from.negative_int_value_;
}
if (cached_has_bits & 0x00000020u) {
double_value_ = from.double_value_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void UninterpretedOption::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UninterpretedOption)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void UninterpretedOption::CopyFrom(const UninterpretedOption& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool UninterpretedOption::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->name())) return false;
return true;
}
void UninterpretedOption::Swap(UninterpretedOption* other) {
if (other == this) return;
InternalSwap(other);
}
void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
name_.InternalSwap(&other->name_);
identifier_value_.Swap(&other->identifier_value_);
string_value_.Swap(&other->string_value_);
aggregate_value_.Swap(&other->aggregate_value_);
std::swap(positive_int_value_, other->positive_int_value_);
std::swap(negative_int_value_, other->negative_int_value_);
std::swap(double_value_, other->double_value_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata UninterpretedOption::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// UninterpretedOption
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
int UninterpretedOption::name_size() const {
return name_.size();
}
void UninterpretedOption::clear_name() {
name_.Clear();
}
const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name)
return name_.Get(index);
}
::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name)
return name_.Mutable(index);
}
::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() {
// @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name)
return name_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*
UninterpretedOption::mutable_name() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name)
return &name_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&
UninterpretedOption::name() const {
// @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name)
return name_;
}
// optional string identifier_value = 3;
bool UninterpretedOption::has_identifier_value() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void UninterpretedOption::set_has_identifier_value() {
_has_bits_[0] |= 0x00000001u;
}
void UninterpretedOption::clear_has_identifier_value() {
_has_bits_[0] &= ~0x00000001u;
}
void UninterpretedOption::clear_identifier_value() {
identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_identifier_value();
}
const ::std::string& UninterpretedOption::identifier_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)
return identifier_value_.GetNoArena();
}
void UninterpretedOption::set_identifier_value(const ::std::string& value) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)
}
#if LANG_CXX11
void UninterpretedOption::set_identifier_value(::std::string&& value) {
set_has_identifier_value();
identifier_value_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value)
}
#endif
void UninterpretedOption::set_identifier_value(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value)
}
void UninterpretedOption::set_identifier_value(const char* value, size_t size) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value)
}
::std::string* UninterpretedOption::mutable_identifier_value() {
set_has_identifier_value();
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value)
return identifier_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* UninterpretedOption::release_identifier_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value)
clear_has_identifier_value();
return identifier_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) {
if (identifier_value != NULL) {
set_has_identifier_value();
} else {
clear_has_identifier_value();
}
identifier_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value)
}
// optional uint64 positive_int_value = 4;
bool UninterpretedOption::has_positive_int_value() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
void UninterpretedOption::set_has_positive_int_value() {
_has_bits_[0] |= 0x00000008u;
}
void UninterpretedOption::clear_has_positive_int_value() {
_has_bits_[0] &= ~0x00000008u;
}
void UninterpretedOption::clear_positive_int_value() {
positive_int_value_ = GOOGLE_ULONGLONG(0);
clear_has_positive_int_value();
}
::google::protobuf::uint64 UninterpretedOption::positive_int_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value)
return positive_int_value_;
}
void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) {
set_has_positive_int_value();
positive_int_value_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value)
}
// optional int64 negative_int_value = 5;
bool UninterpretedOption::has_negative_int_value() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
void UninterpretedOption::set_has_negative_int_value() {
_has_bits_[0] |= 0x00000010u;
}
void UninterpretedOption::clear_has_negative_int_value() {
_has_bits_[0] &= ~0x00000010u;
}
void UninterpretedOption::clear_negative_int_value() {
negative_int_value_ = GOOGLE_LONGLONG(0);
clear_has_negative_int_value();
}
::google::protobuf::int64 UninterpretedOption::negative_int_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value)
return negative_int_value_;
}
void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) {
set_has_negative_int_value();
negative_int_value_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value)
}
// optional double double_value = 6;
bool UninterpretedOption::has_double_value() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
void UninterpretedOption::set_has_double_value() {
_has_bits_[0] |= 0x00000020u;
}
void UninterpretedOption::clear_has_double_value() {
_has_bits_[0] &= ~0x00000020u;
}
void UninterpretedOption::clear_double_value() {
double_value_ = 0;
clear_has_double_value();
}
double UninterpretedOption::double_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value)
return double_value_;
}
void UninterpretedOption::set_double_value(double value) {
set_has_double_value();
double_value_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value)
}
// optional bytes string_value = 7;
bool UninterpretedOption::has_string_value() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void UninterpretedOption::set_has_string_value() {
_has_bits_[0] |= 0x00000002u;
}
void UninterpretedOption::clear_has_string_value() {
_has_bits_[0] &= ~0x00000002u;
}
void UninterpretedOption::clear_string_value() {
string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_string_value();
}
const ::std::string& UninterpretedOption::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)
return string_value_.GetNoArena();
}
void UninterpretedOption::set_string_value(const ::std::string& value) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)
}
#if LANG_CXX11
void UninterpretedOption::set_string_value(::std::string&& value) {
set_has_string_value();
string_value_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value)
}
#endif
void UninterpretedOption::set_string_value(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value)
}
void UninterpretedOption::set_string_value(const void* value, size_t size) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value)
}
::std::string* UninterpretedOption::mutable_string_value() {
set_has_string_value();
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value)
return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* UninterpretedOption::release_string_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value)
clear_has_string_value();
return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption::set_allocated_string_value(::std::string* string_value) {
if (string_value != NULL) {
set_has_string_value();
} else {
clear_has_string_value();
}
string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value)
}
// optional string aggregate_value = 8;
bool UninterpretedOption::has_aggregate_value() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void UninterpretedOption::set_has_aggregate_value() {
_has_bits_[0] |= 0x00000004u;
}
void UninterpretedOption::clear_has_aggregate_value() {
_has_bits_[0] &= ~0x00000004u;
}
void UninterpretedOption::clear_aggregate_value() {
aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_aggregate_value();
}
const ::std::string& UninterpretedOption::aggregate_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)
return aggregate_value_.GetNoArena();
}
void UninterpretedOption::set_aggregate_value(const ::std::string& value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)
}
#if LANG_CXX11
void UninterpretedOption::set_aggregate_value(::std::string&& value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value)
}
#endif
void UninterpretedOption::set_aggregate_value(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value)
}
void UninterpretedOption::set_aggregate_value(const char* value, size_t size) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value)
}
::std::string* UninterpretedOption::mutable_aggregate_value() {
set_has_aggregate_value();
// @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value)
return aggregate_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* UninterpretedOption::release_aggregate_value() {
// @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value)
clear_has_aggregate_value();
return aggregate_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) {
if (aggregate_value != NULL) {
set_has_aggregate_value();
} else {
clear_has_aggregate_value();
}
aggregate_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int SourceCodeInfo_Location::kPathFieldNumber;
const int SourceCodeInfo_Location::kSpanFieldNumber;
const int SourceCodeInfo_Location::kLeadingCommentsFieldNumber;
const int SourceCodeInfo_Location::kTrailingCommentsFieldNumber;
const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
SourceCodeInfo_Location::SourceCodeInfo_Location()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location)
}
SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
path_(from.path_),
span_(from.span_),
leading_detached_comments_(from.leading_detached_comments_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_leading_comments()) {
leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_);
}
trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_trailing_comments()) {
trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_);
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
}
void SourceCodeInfo_Location::SharedCtor() {
_cached_size_ = 0;
leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
SourceCodeInfo_Location::~SourceCodeInfo_Location() {
// @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo.Location)
SharedDtor();
}
void SourceCodeInfo_Location::SharedDtor() {
leading_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
trailing_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void SourceCodeInfo_Location::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const {
SourceCodeInfo_Location* n = new SourceCodeInfo_Location;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void SourceCodeInfo_Location::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location)
path_.Clear();
span_.Clear();
leading_detached_comments_.Clear();
if (_has_bits_[0 / 32] & 3u) {
if (has_leading_comments()) {
GOOGLE_DCHECK(!leading_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*leading_comments_.UnsafeRawStringPointer())->clear();
}
if (has_trailing_comments()) {
GOOGLE_DCHECK(!trailing_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*trailing_comments_.UnsafeRawStringPointer())->clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool SourceCodeInfo_Location::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated int32 path = 1 [packed = true];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_path())));
} else if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 10u, input, this->mutable_path())));
} else {
goto handle_unusual;
}
break;
}
// repeated int32 span = 2 [packed = true];
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_span())));
} else if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 18u, input, this->mutable_span())));
} else {
goto handle_unusual;
}
break;
}
// optional string leading_comments = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_leading_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_comments().data(), this->leading_comments().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.SourceCodeInfo.Location.leading_comments");
} else {
goto handle_unusual;
}
break;
}
// optional string trailing_comments = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_trailing_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->trailing_comments().data(), this->trailing_comments().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.SourceCodeInfo.Location.trailing_comments");
} else {
goto handle_unusual;
}
break;
}
// repeated string leading_detached_comments = 6;
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_leading_detached_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(this->leading_detached_comments_size() - 1).data(),
this->leading_detached_comments(this->leading_detached_comments_size() - 1).length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo.Location)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo.Location)
return false;
#undef DO_
}
void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo.Location)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_path_cached_byte_size_);
}
for (int i = 0, n = this->path_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->path(i), output);
}
// repeated int32 span = 2 [packed = true];
if (this->span_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_span_cached_byte_size_);
}
for (int i = 0, n = this->span_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->span(i), output);
}
cached_has_bits = _has_bits_[0];
// optional string leading_comments = 3;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_comments().data(), this->leading_comments().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_comments");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
3, this->leading_comments(), output);
}
// optional string trailing_comments = 4;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->trailing_comments().data(), this->trailing_comments().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.trailing_comments");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
4, this->trailing_comments(), output);
}
// repeated string leading_detached_comments = 6;
for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
::google::protobuf::internal::WireFormatLite::WriteString(
6, this->leading_detached_comments(i), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo.Location)
}
::google::protobuf::uint8* SourceCodeInfo_Location::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
1,
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_path_cached_byte_size_, target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path_, target);
}
// repeated int32 span = 2 [packed = true];
if (this->span_size() > 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
2,
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_span_cached_byte_size_, target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->span_, target);
}
cached_has_bits = _has_bits_[0];
// optional string leading_comments = 3;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_comments().data(), this->leading_comments().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_comments");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
3, this->leading_comments(), target);
}
// optional string trailing_comments = 4;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->trailing_comments().data(), this->trailing_comments().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.trailing_comments");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
4, this->trailing_comments(), target);
}
// repeated string leading_detached_comments = 6;
for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
target = ::google::protobuf::internal::WireFormatLite::
WriteStringToArray(6, this->leading_detached_comments(i), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo.Location)
return target;
}
size_t SourceCodeInfo_Location::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated int32 path = 1 [packed = true];
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->path_);
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_path_cached_byte_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
total_size += data_size;
}
// repeated int32 span = 2 [packed = true];
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->span_);
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_span_cached_byte_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
total_size += data_size;
}
// repeated string leading_detached_comments = 6;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size());
for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->leading_detached_comments(i));
}
if (_has_bits_[0 / 32] & 3u) {
// optional string leading_comments = 3;
if (has_leading_comments()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->leading_comments());
}
// optional string trailing_comments = 4;
if (has_trailing_comments()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->trailing_comments());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location)
GOOGLE_DCHECK_NE(&from, this);
const SourceCodeInfo_Location* source =
::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo.Location)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location)
MergeFrom(*source);
}
}
void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
path_.MergeFrom(from.path_);
span_.MergeFrom(from.span_);
leading_detached_comments_.MergeFrom(from.leading_detached_comments_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
set_has_leading_comments();
leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_);
}
if (cached_has_bits & 0x00000002u) {
set_has_trailing_comments();
trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_);
}
}
}
void SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo.Location)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool SourceCodeInfo_Location::IsInitialized() const {
return true;
}
void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) {
if (other == this) return;
InternalSwap(other);
}
void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
path_.InternalSwap(&other->path_);
span_.InternalSwap(&other->span_);
leading_detached_comments_.InternalSwap(&other->leading_detached_comments_);
leading_comments_.Swap(&other->leading_comments_);
trailing_comments_.Swap(&other->trailing_comments_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// SourceCodeInfo_Location
// repeated int32 path = 1 [packed = true];
int SourceCodeInfo_Location::path_size() const {
return path_.size();
}
void SourceCodeInfo_Location::clear_path() {
path_.Clear();
}
::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path)
return path_.Get(index);
}
void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) {
path_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path)
}
void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) {
path_.Add(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path)
}
const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
SourceCodeInfo_Location::path() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path)
return path_;
}
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
SourceCodeInfo_Location::mutable_path() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path)
return &path_;
}
// repeated int32 span = 2 [packed = true];
int SourceCodeInfo_Location::span_size() const {
return span_.size();
}
void SourceCodeInfo_Location::clear_span() {
span_.Clear();
}
::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span)
return span_.Get(index);
}
void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) {
span_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span)
}
void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) {
span_.Add(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span)
}
const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
SourceCodeInfo_Location::span() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span)
return span_;
}
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
SourceCodeInfo_Location::mutable_span() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span)
return &span_;
}
// optional string leading_comments = 3;
bool SourceCodeInfo_Location::has_leading_comments() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void SourceCodeInfo_Location::set_has_leading_comments() {
_has_bits_[0] |= 0x00000001u;
}
void SourceCodeInfo_Location::clear_has_leading_comments() {
_has_bits_[0] &= ~0x00000001u;
}
void SourceCodeInfo_Location::clear_leading_comments() {
leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_leading_comments();
}
const ::std::string& SourceCodeInfo_Location::leading_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)
return leading_comments_.GetNoArena();
}
void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
#if LANG_CXX11
void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) {
set_has_leading_comments();
leading_comments_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
#endif
void SourceCodeInfo_Location::set_leading_comments(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
::std::string* SourceCodeInfo_Location::mutable_leading_comments() {
set_has_leading_comments();
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments)
return leading_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* SourceCodeInfo_Location::release_leading_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments)
clear_has_leading_comments();
return leading_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) {
if (leading_comments != NULL) {
set_has_leading_comments();
} else {
clear_has_leading_comments();
}
leading_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
// optional string trailing_comments = 4;
bool SourceCodeInfo_Location::has_trailing_comments() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void SourceCodeInfo_Location::set_has_trailing_comments() {
_has_bits_[0] |= 0x00000002u;
}
void SourceCodeInfo_Location::clear_has_trailing_comments() {
_has_bits_[0] &= ~0x00000002u;
}
void SourceCodeInfo_Location::clear_trailing_comments() {
trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_trailing_comments();
}
const ::std::string& SourceCodeInfo_Location::trailing_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)
return trailing_comments_.GetNoArena();
}
void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
#if LANG_CXX11
void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
#endif
void SourceCodeInfo_Location::set_trailing_comments(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
::std::string* SourceCodeInfo_Location::mutable_trailing_comments() {
set_has_trailing_comments();
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments)
return trailing_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* SourceCodeInfo_Location::release_trailing_comments() {
// @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments)
clear_has_trailing_comments();
return trailing_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) {
if (trailing_comments != NULL) {
set_has_trailing_comments();
} else {
clear_has_trailing_comments();
}
trailing_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
// repeated string leading_detached_comments = 6;
int SourceCodeInfo_Location::leading_detached_comments_size() const {
return leading_detached_comments_.size();
}
void SourceCodeInfo_Location::clear_leading_detached_comments() {
leading_detached_comments_.Clear();
}
const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return leading_detached_comments_.Get(index);
}
::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return leading_detached_comments_.Mutable(index);
}
void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
leading_detached_comments_.Mutable(index)->assign(value);
}
#if LANG_CXX11
void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) {
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
leading_detached_comments_.Mutable(index)->assign(std::move(value));
}
#endif
void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {
GOOGLE_DCHECK(value != NULL);
leading_detached_comments_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) {
leading_detached_comments_.Mutable(index)->assign(
reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
::std::string* SourceCodeInfo_Location::add_leading_detached_comments() {
// @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return leading_detached_comments_.Add();
}
void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) {
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
#if LANG_CXX11
void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) {
leading_detached_comments_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
#endif
void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {
GOOGLE_DCHECK(value != NULL);
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) {
leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
const ::google::protobuf::RepeatedPtrField< ::std::string>&
SourceCodeInfo_Location::leading_detached_comments() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return leading_detached_comments_;
}
::google::protobuf::RepeatedPtrField< ::std::string>*
SourceCodeInfo_Location::mutable_leading_detached_comments() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
return &leading_detached_comments_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int SourceCodeInfo::kLocationFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
SourceCodeInfo::SourceCodeInfo()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo)
}
SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
location_(from.location_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo)
}
void SourceCodeInfo::SharedCtor() {
_cached_size_ = 0;
}
SourceCodeInfo::~SourceCodeInfo() {
// @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo)
SharedDtor();
}
void SourceCodeInfo::SharedDtor() {
}
void SourceCodeInfo::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const SourceCodeInfo& SourceCodeInfo::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const {
SourceCodeInfo* n = new SourceCodeInfo;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void SourceCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)
location_.Clear();
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool SourceCodeInfo::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_location()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo)
return false;
#undef DO_
}
void SourceCodeInfo::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->location(i), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo)
}
::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
1, this->location(i), deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo)
return target;
}
size_t SourceCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
{
unsigned int count = this->location_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->location(i));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo)
GOOGLE_DCHECK_NE(&from, this);
const SourceCodeInfo* source =
::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo)
MergeFrom(*source);
}
}
void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
location_.MergeFrom(from.location_);
}
void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool SourceCodeInfo::IsInitialized() const {
return true;
}
void SourceCodeInfo::Swap(SourceCodeInfo* other) {
if (other == this) return;
InternalSwap(other);
}
void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
location_.InternalSwap(&other->location_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// SourceCodeInfo
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
int SourceCodeInfo::location_size() const {
return location_.size();
}
void SourceCodeInfo::clear_location() {
location_.Clear();
}
const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location)
return location_.Get(index);
}
::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location)
return location_.Mutable(index);
}
::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() {
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location)
return location_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*
SourceCodeInfo::mutable_location() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location)
return &location_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&
SourceCodeInfo::location() const {
// @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location)
return location_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int GeneratedCodeInfo_Annotation::kPathFieldNumber;
const int GeneratedCodeInfo_Annotation::kSourceFileFieldNumber;
const int GeneratedCodeInfo_Annotation::kBeginFieldNumber;
const int GeneratedCodeInfo_Annotation::kEndFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
path_(from.path_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_source_file()) {
source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_);
}
::memcpy(&begin_, &from.begin_,
reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&begin_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
void GeneratedCodeInfo_Annotation::SharedCtor() {
_cached_size_ = 0;
source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&begin_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&begin_) + sizeof(end_));
}
GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {
// @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo.Annotation)
SharedDtor();
}
void GeneratedCodeInfo_Annotation::SharedDtor() {
source_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const {
GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void GeneratedCodeInfo_Annotation::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)
path_.Clear();
if (has_source_file()) {
GOOGLE_DCHECK(!source_file_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*source_file_.UnsafeRawStringPointer())->clear();
}
if (_has_bits_[0 / 32] & 6u) {
::memset(&begin_, 0, reinterpret_cast<char*>(&end_) -
reinterpret_cast<char*>(&begin_) + sizeof(end_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated int32 path = 1 [packed = true];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_path())));
} else if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 10u, input, this->mutable_path())));
} else {
goto handle_unusual;
}
break;
}
// optional string source_file = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_source_file()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->source_file().data(), this->source_file().length(),
::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.GeneratedCodeInfo.Annotation.source_file");
} else {
goto handle_unusual;
}
break;
}
// optional int32 begin = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u)) {
set_has_begin();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &begin_)));
} else {
goto handle_unusual;
}
break;
}
// optional int32 end = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(32u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &end_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.GeneratedCodeInfo.Annotation)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.GeneratedCodeInfo.Annotation)
return false;
#undef DO_
}
void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.GeneratedCodeInfo.Annotation)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_path_cached_byte_size_);
}
for (int i = 0, n = this->path_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->path(i), output);
}
cached_has_bits = _has_bits_[0];
// optional string source_file = 2;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->source_file().data(), this->source_file().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.GeneratedCodeInfo.Annotation.source_file");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->source_file(), output);
}
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->begin(), output);
}
// optional int32 end = 4;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->end(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo.Annotation)
}
::google::protobuf::uint8* GeneratedCodeInfo_Annotation::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
1,
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_path_cached_byte_size_, target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path_, target);
}
cached_has_bits = _has_bits_[0];
// optional string source_file = 2;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->source_file().data(), this->source_file().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.GeneratedCodeInfo.Annotation.source_file");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->source_file(), target);
}
// optional int32 begin = 3;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->begin(), target);
}
// optional int32 end = 4;
if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->end(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo.Annotation)
return target;
}
size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated int32 path = 1 [packed = true];
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->path_);
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_path_cached_byte_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
total_size += data_size;
}
if (_has_bits_[0 / 32] & 7u) {
// optional string source_file = 2;
if (has_source_file()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->source_file());
}
// optional int32 begin = 3;
if (has_begin()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->begin());
}
// optional int32 end = 4;
if (has_end()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->end());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
GOOGLE_DCHECK_NE(&from, this);
const GeneratedCodeInfo_Annotation* source =
::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.GeneratedCodeInfo.Annotation)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation)
MergeFrom(*source);
}
}
void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
path_.MergeFrom(from.path_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 7u) {
if (cached_has_bits & 0x00000001u) {
set_has_source_file();
source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_);
}
if (cached_has_bits & 0x00000002u) {
begin_ = from.begin_;
}
if (cached_has_bits & 0x00000004u) {
end_ = from.end_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void GeneratedCodeInfo_Annotation::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool GeneratedCodeInfo_Annotation::IsInitialized() const {
return true;
}
void GeneratedCodeInfo_Annotation::Swap(GeneratedCodeInfo_Annotation* other) {
if (other == this) return;
InternalSwap(other);
}
void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* other) {
path_.InternalSwap(&other->path_);
source_file_.Swap(&other->source_file_);
std::swap(begin_, other->begin_);
std::swap(end_, other->end_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// GeneratedCodeInfo_Annotation
// repeated int32 path = 1 [packed = true];
int GeneratedCodeInfo_Annotation::path_size() const {
return path_.size();
}
void GeneratedCodeInfo_Annotation::clear_path() {
path_.Clear();
}
::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)
return path_.Get(index);
}
void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) {
path_.Set(index, value);
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)
}
void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) {
path_.Add(value);
// @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)
}
const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
GeneratedCodeInfo_Annotation::path() const {
// @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
return path_;
}
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
GeneratedCodeInfo_Annotation::mutable_path() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
return &path_;
}
// optional string source_file = 2;
bool GeneratedCodeInfo_Annotation::has_source_file() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
void GeneratedCodeInfo_Annotation::set_has_source_file() {
_has_bits_[0] |= 0x00000001u;
}
void GeneratedCodeInfo_Annotation::clear_has_source_file() {
_has_bits_[0] &= ~0x00000001u;
}
void GeneratedCodeInfo_Annotation::clear_source_file() {
source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_source_file();
}
const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
return source_file_.GetNoArena();
}
void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {
set_has_source_file();
source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
#if LANG_CXX11
void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) {
set_has_source_file();
source_file_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
#endif
void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_source_file();
source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) {
set_has_source_file();
source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() {
set_has_source_file();
// @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
::std::string* GeneratedCodeInfo_Annotation::release_source_file() {
// @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
clear_has_source_file();
return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) {
if (source_file != NULL) {
set_has_source_file();
} else {
clear_has_source_file();
}
source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
// optional int32 begin = 3;
bool GeneratedCodeInfo_Annotation::has_begin() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
void GeneratedCodeInfo_Annotation::set_has_begin() {
_has_bits_[0] |= 0x00000002u;
}
void GeneratedCodeInfo_Annotation::clear_has_begin() {
_has_bits_[0] &= ~0x00000002u;
}
void GeneratedCodeInfo_Annotation::clear_begin() {
begin_ = 0;
clear_has_begin();
}
::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)
return begin_;
}
void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) {
set_has_begin();
begin_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)
}
// optional int32 end = 4;
bool GeneratedCodeInfo_Annotation::has_end() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
void GeneratedCodeInfo_Annotation::set_has_end() {
_has_bits_[0] |= 0x00000004u;
}
void GeneratedCodeInfo_Annotation::clear_has_end() {
_has_bits_[0] &= ~0x00000004u;
}
void GeneratedCodeInfo_Annotation::clear_end() {
end_ = 0;
clear_has_end();
}
::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)
return end_;
}
void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) {
set_has_end();
end_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int GeneratedCodeInfo::kAnnotationFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
GeneratedCodeInfo::GeneratedCodeInfo()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
}
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo)
}
GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
annotation_(from.annotation_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo)
}
void GeneratedCodeInfo::SharedCtor() {
_cached_size_ = 0;
}
GeneratedCodeInfo::~GeneratedCodeInfo() {
// @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo)
SharedDtor();
}
void GeneratedCodeInfo::SharedDtor() {
}
void GeneratedCodeInfo::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const {
GeneratedCodeInfo* n = new GeneratedCodeInfo;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void GeneratedCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo)
annotation_.Clear();
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool GeneratedCodeInfo::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_annotation()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.GeneratedCodeInfo)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.GeneratedCodeInfo)
return false;
#undef DO_
}
void GeneratedCodeInfo::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.GeneratedCodeInfo)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->annotation(i), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo)
}
::google::protobuf::uint8* GeneratedCodeInfo::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
1, this->annotation(i), deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo)
return target;
}
size_t GeneratedCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
{
unsigned int count = this->annotation_size();
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->annotation(i));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo)
GOOGLE_DCHECK_NE(&from, this);
const GeneratedCodeInfo* source =
::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.GeneratedCodeInfo)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo)
MergeFrom(*source);
}
}
void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
annotation_.MergeFrom(from.annotation_);
}
void GeneratedCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.GeneratedCodeInfo)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool GeneratedCodeInfo::IsInitialized() const {
return true;
}
void GeneratedCodeInfo::Swap(GeneratedCodeInfo* other) {
if (other == this) return;
InternalSwap(other);
}
void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
annotation_.InternalSwap(&other->annotation_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const {
protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// GeneratedCodeInfo
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
int GeneratedCodeInfo::annotation_size() const {
return annotation_.size();
}
void GeneratedCodeInfo::clear_annotation() {
annotation_.Clear();
}
const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation)
return annotation_.Get(index);
}
::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) {
// @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation)
return annotation_.Mutable(index);
}
::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() {
// @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation)
return annotation_.Add();
}
::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*
GeneratedCodeInfo::mutable_annotation() {
// @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation)
return &annotation_;
}
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&
GeneratedCodeInfo::annotation() const {
// @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation)
return annotation_;
}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
| apache-2.0 |
bclozel/spring-boot | spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/convert/ConversionServiceParameterValueMapperTests.java | 4112 | /*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.endpoint.invoke.convert;
import java.time.OffsetDateTime;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.actuate.endpoint.invoke.OperationParameter;
import org.springframework.boot.actuate.endpoint.invoke.ParameterMappingException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.format.support.DefaultFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link ConversionServiceParameterValueMapper}.
*
* @author Phillip Webb
*/
public class ConversionServiceParameterValueMapperTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void mapParameterShouldDelegateToConversionService() {
DefaultFormattingConversionService conversionService = spy(
new DefaultFormattingConversionService());
ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper(
conversionService);
Object mapped = mapper
.mapParameterValue(new TestOperationParameter(Integer.class), "123");
assertThat(mapped).isEqualTo(123);
verify(conversionService).convert("123", Integer.class);
}
@Test
public void mapParameterWhenConversionServiceFailsShouldThrowParameterMappingException() {
ConversionService conversionService = mock(ConversionService.class);
RuntimeException error = new RuntimeException();
given(conversionService.convert(any(), any())).willThrow(error);
ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper(
conversionService);
try {
mapper.mapParameterValue(new TestOperationParameter(Integer.class), "123");
fail("Did not throw");
}
catch (ParameterMappingException ex) {
assertThat(ex.getValue()).isEqualTo("123");
assertThat(ex.getParameter().getType()).isEqualTo(Integer.class);
assertThat(ex.getCause()).isEqualTo(error);
}
}
@Test
public void createShouldRegisterIsoOffsetDateTimeConverter() {
ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper();
Object mapped = mapper.mapParameterValue(
new TestOperationParameter(OffsetDateTime.class),
"2011-12-03T10:15:30+01:00");
assertThat(mapped).isNotNull();
}
@Test
public void createWithConversionServiceShouldNotRegisterIsoOffsetDateTimeConverter() {
ConversionService conversionService = new DefaultConversionService();
ConversionServiceParameterValueMapper mapper = new ConversionServiceParameterValueMapper(
conversionService);
this.thrown.expect(ParameterMappingException.class);
mapper.mapParameterValue(new TestOperationParameter(OffsetDateTime.class),
"2011-12-03T10:15:30+01:00");
}
private static class TestOperationParameter implements OperationParameter {
private final Class<?> type;
TestOperationParameter(Class<?> type) {
this.type = type;
}
@Override
public String getName() {
return "test";
}
@Override
public Class<?> getType() {
return this.type;
}
@Override
public boolean isMandatory() {
return false;
}
}
}
| apache-2.0 |
ctiller/grpc | src/core/lib/iomgr/internal_errqueue.cc | 1686 | /*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/internal_errqueue.h"
#include <grpc/impl/codegen/log.h>
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET_TCP
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
namespace grpc_core {
static bool errqueue_supported = false;
bool kernel_supports_errqueue() { return errqueue_supported; }
void grpc_errqueue_init() {
/* Both-compile time and run-time linux kernel versions should be at least 4.0.0
*/
#ifdef GRPC_LINUX_ERRQUEUE
struct utsname buffer;
if (uname(&buffer) != 0) {
gpr_log(GPR_ERROR, "uname: %s", strerror(errno));
return;
}
char* release = buffer.release;
if (release == nullptr) {
return;
}
if (strtol(release, nullptr, 10) >= 4) {
errqueue_supported = true;
} else {
gpr_log(GPR_DEBUG, "ERRQUEUE support not enabled");
}
#endif /* GRPC_LINUX_ERRQUEUE */
}
} /* namespace grpc_core */
#else
namespace grpc_core {
void grpc_errqueue_init() {}
} /* namespace grpc_core */
#endif /* GRPC_POSIX_SOCKET_TCP */
| apache-2.0 |
lavjain/incubator-hawq | pxf/pxf-hbase/src/main/java/org/apache/hawq/pxf/plugins/hbase/HBaseFilterBuilder.java | 13894 | package org.apache.hawq.pxf.plugins.hbase;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.hawq.pxf.api.FilterParser;
import org.apache.hawq.pxf.api.io.DataType;
import org.apache.hawq.pxf.plugins.hbase.utilities.HBaseColumnDescriptor;
import org.apache.hawq.pxf.plugins.hbase.utilities.HBaseDoubleComparator;
import org.apache.hawq.pxf.plugins.hbase.utilities.HBaseFloatComparator;
import org.apache.hawq.pxf.plugins.hbase.utilities.HBaseIntegerComparator;
import org.apache.hawq.pxf.plugins.hbase.utilities.HBaseTupleDescription;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.hawq.pxf.api.io.DataType.TEXT;
/**
* This is the implementation of {@code FilterParser.FilterBuilder} for HBase.
* <p>
* The class uses the filter parser code to build a filter object,
* either simple (single {@link Filter} class) or a compound ({@link FilterList})
* for {@link HBaseAccessor} to use for its scan.
* <p>
* This is done before the scan starts. It is not a scan time operation.
* <p>
* HBase row key column is a special case.
* If the user defined row key column as TEXT and used {@code <,>,<=,>=,=} operators
* the startkey ({@code >/>=}) and the endkey ({@code </<=}) are stored in addition to
* the created filter.
* This is an addition on top of regular filters and does not replace
* any logic in HBase filter objects.
*/
public class HBaseFilterBuilder implements FilterParser.FilterBuilder {
private Map<FilterParser.Operation, CompareFilter.CompareOp> operatorsMap;
private Map<FilterParser.LogicalOperation, FilterList.Operator> logicalOperatorsMap;
private byte[] startKey;
private byte[] endKey;
private HBaseTupleDescription tupleDescription;
private static final String NOT_OP = "l2";
public HBaseFilterBuilder(HBaseTupleDescription tupleDescription) {
initOperatorsMap();
initLogicalOperatorsMap();
startKey = HConstants.EMPTY_START_ROW;
endKey = HConstants.EMPTY_END_ROW;
this.tupleDescription = tupleDescription;
}
private boolean filterNotOpPresent(String filterString) {
if (filterString.contains(NOT_OP)) {
String regex = ".*[o\\d|l\\d]l2.*";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(filterString);
return m.matches();
} else {
return false;
}
}
/**
* Translates a filterString into a HBase {@link Filter} object.
*
* @param filterString filter string
* @return filter object
* @throws Exception if parsing failed
*/
public Filter getFilterObject(String filterString) throws Exception {
if (filterString == null)
return null;
// First check for NOT, HBase does not support this
if (filterNotOpPresent(filterString))
return null;
FilterParser parser = new FilterParser(this);
Object result = parser.parse(filterString.getBytes(FilterParser.DEFAULT_CHARSET));
if (!(result instanceof Filter)) {
throw new Exception("String " + filterString + " couldn't be resolved to any supported filter");
}
return (Filter) result;
}
/**
* Returns the startKey for scanning the HBase table.
* If the user specified a {@code > / >=} operation
* on a textual row key column, this value will be returned.
* Otherwise, the start of table.
*
* @return start key for scanning HBase table
*/
public byte[] startKey() {
return startKey;
}
/**
* Returns the endKey for scanning the HBase table.
* If the user specified a {@code < / <=} operation
* on a textual row key column, this value will be returned.
* Otherwise, the end of table.
*
* @return end key for scanning HBase table
*/
public byte[] endKey() {
return endKey;
}
/**
* Builds a filter from the input operands and operation.
* Two kinds of operations are handled:
* <ol>
* <li>Simple operation between {@code FilterParser.Constant} and {@code FilterParser.ColumnIndex}.
* Supported operations are {@code <, >, <=, <=, >=, =, !=}. </li>
* <li>Compound operations between {@link Filter} objects.
* The only supported operation is {@code AND}. </li>
* </ol>
* <p>
* This function is called by {@link FilterParser},
* each time the parser comes across an operator.
*/
@Override
public Object build(FilterParser.Operation opId,
Object leftOperand,
Object rightOperand) throws Exception {
// Assume column is on the left
return handleSimpleOperations(opId,
(FilterParser.ColumnIndex) leftOperand,
(FilterParser.Constant) rightOperand);
}
@Override
public Object build(FilterParser.Operation operation, Object operand) throws Exception {
return handleSimpleOperations(operation, (FilterParser.ColumnIndex) operand);
}
@Override
public Object build(FilterParser.LogicalOperation opId, Object leftOperand, Object rightOperand) {
return handleCompoundOperations(opId, (Filter) leftOperand, (Filter) rightOperand);
}
@Override
public Object build(FilterParser.LogicalOperation opId, Object leftOperand) {
return null;
}
/**
* Initializes the {@link #operatorsMap} with appropriate values.
*/
private void initOperatorsMap() {
operatorsMap = new EnumMap<FilterParser.Operation, CompareFilter.CompareOp>(FilterParser.Operation.class);
operatorsMap.put(FilterParser.Operation.HDOP_LT, CompareFilter.CompareOp.LESS); // "<"
operatorsMap.put(FilterParser.Operation.HDOP_GT, CompareFilter.CompareOp.GREATER); // ">"
operatorsMap.put(FilterParser.Operation.HDOP_LE, CompareFilter.CompareOp.LESS_OR_EQUAL); // "<="
operatorsMap.put(FilterParser.Operation.HDOP_GE, CompareFilter.CompareOp.GREATER_OR_EQUAL); // ">="
operatorsMap.put(FilterParser.Operation.HDOP_EQ, CompareFilter.CompareOp.EQUAL); // "="
operatorsMap.put(FilterParser.Operation.HDOP_NE, CompareFilter.CompareOp.NOT_EQUAL); // "!="
}
private void initLogicalOperatorsMap() {
logicalOperatorsMap = new EnumMap<>(FilterParser.LogicalOperation.class);
logicalOperatorsMap.put(FilterParser.LogicalOperation.HDOP_AND, FilterList.Operator.MUST_PASS_ALL);
logicalOperatorsMap.put(FilterParser.LogicalOperation.HDOP_OR, FilterList.Operator.MUST_PASS_ONE);
}
private Object handleSimpleOperations(FilterParser.Operation opId,
FilterParser.ColumnIndex column) throws Exception {
HBaseColumnDescriptor hbaseColumn = tupleDescription.getColumn(column.index());
CompareFilter.CompareOp compareOperation;
ByteArrayComparable comparator;
switch (opId) {
case HDOP_IS_NULL:
compareOperation = CompareFilter.CompareOp.EQUAL;
comparator = new NullComparator();
break;
case HDOP_IS_NOT_NULL:
compareOperation = CompareFilter.CompareOp.NOT_EQUAL;
comparator = new NullComparator();
break;
default:
throw new Exception("unsupported unary operation for filtering " + opId);
}
return new SingleColumnValueFilter(hbaseColumn.columnFamilyBytes(),
hbaseColumn.qualifierBytes(),
compareOperation,
comparator);
}
/**
* Handles simple column-operator-constant expressions.
* Creates a special filter in the case the column is the row key column.
*/
private Filter handleSimpleOperations(FilterParser.Operation opId,
FilterParser.ColumnIndex column,
FilterParser.Constant constant) throws Exception {
HBaseColumnDescriptor hbaseColumn = tupleDescription.getColumn(column.index());
ByteArrayComparable comparator = getComparator(hbaseColumn.columnTypeCode(),
constant.constant());
if(operatorsMap.get(opId) == null){
//HBase does not support HDOP_LIKE, use 'NOT NULL' comparator
return new SingleColumnValueFilter(hbaseColumn.columnFamilyBytes(),
hbaseColumn.qualifierBytes(),
CompareFilter.CompareOp.NOT_EQUAL,
new NullComparator());
}
/**
* If row key is of type TEXT, allow filter in start/stop row key API in
* HBaseAccessor/Scan object.
*/
if (textualRowKey(hbaseColumn)) {
storeStartEndKeys(opId, constant.constant());
}
if (hbaseColumn.isKeyColumn()) {
return new RowFilter(operatorsMap.get(opId), comparator);
}
return new SingleColumnValueFilter(hbaseColumn.columnFamilyBytes(),
hbaseColumn.qualifierBytes(),
operatorsMap.get(opId),
comparator);
}
/**
* Resolves the column's type to a comparator class to be used.
* Currently, supported types are TEXT and INTEGER types.
*/
private ByteArrayComparable getComparator(int type, Object data) throws Exception {
ByteArrayComparable result;
switch (DataType.get(type)) {
case TEXT:
result = new BinaryComparator(Bytes.toBytes((String) data));
break;
case SMALLINT:
case INTEGER:
result = new HBaseIntegerComparator(((Integer) data).longValue());
break;
case BIGINT:
if (data instanceof Long) {
result = new HBaseIntegerComparator((Long) data);
} else if (data instanceof Integer) {
result = new HBaseIntegerComparator(((Integer) data).longValue());
} else {
result = null;
}
break;
case FLOAT8:
result = new HBaseDoubleComparator((double) data);
break;
case REAL:
if (data instanceof Double) {
result = new HBaseDoubleComparator((double) data);
} else if (data instanceof Float) {
result = new HBaseFloatComparator((float) data);
} else {
result = null;
}
break;
default:
throw new Exception("unsupported column type for filtering " + type);
}
return result;
}
/**
* Handles operation between already calculated expressions.
* Currently only {@code AND}, in the future {@code OR} can be added.
* <p>
* Four cases here:
* <ol>
* <li>Both are simple filters.</li>
* <li>Left is a FilterList and right is a filter.</li>
* <li>Left is a filter and right is a FilterList.</li>
* <li>Both are FilterLists.</li>
* </ol>
* <p>
* Currently, 1, 2 can occur, since no parenthesis are used.
*/
private Filter handleCompoundOperations(FilterParser.LogicalOperation opId, Filter left, Filter right) {
return new FilterList(logicalOperatorsMap.get(opId), new Filter[] {left, right});
}
/**
* Returns true if column is of type TEXT and is a row key column.
*/
private boolean textualRowKey(HBaseColumnDescriptor column) {
return column.isKeyColumn() &&
column.columnTypeCode() == TEXT.getOID();
}
/**
* Sets startKey/endKey and their inclusiveness
* according to the operation op.
* <p>
* TODO allow only one assignment to start/end key.
* Currently, multiple calls to this function might change
* previous assignments.
*/
private void storeStartEndKeys(FilterParser.Operation op, Object data) {
String key = (String) data;
// Adding a zero byte to endkey, makes it inclusive
// Adding a zero byte to startkey, makes it exclusive
byte[] zeroByte = new byte[1];
zeroByte[0] = 0;
switch (op) {
case HDOP_LT:
endKey = Bytes.toBytes(key);
break;
case HDOP_GT:
startKey = Bytes.add(Bytes.toBytes(key), zeroByte);
break;
case HDOP_LE:
endKey = Bytes.add(Bytes.toBytes(key), zeroByte);
break;
case HDOP_GE:
startKey = Bytes.toBytes(key);
break;
case HDOP_EQ:
startKey = Bytes.toBytes(key);
endKey = Bytes.add(Bytes.toBytes(key), zeroByte);
break;
}
}
}
| apache-2.0 |
vakninr/spring-boot | spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorFactory.java | 3398 | /*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.health;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Factory to create a {@link CompositeReactiveHealthIndicator}.
*
* @author Stephane Nicoll
* @since 2.0.0
*/
public class CompositeReactiveHealthIndicatorFactory {
private final Function<String, String> healthIndicatorNameFactory;
public CompositeReactiveHealthIndicatorFactory(
Function<String, String> healthIndicatorNameFactory) {
this.healthIndicatorNameFactory = healthIndicatorNameFactory;
}
public CompositeReactiveHealthIndicatorFactory() {
this(new HealthIndicatorNameFactory());
}
/**
* Create a {@link CompositeReactiveHealthIndicator} based on the specified health
* indicators. Each {@link HealthIndicator} are wrapped to a
* {@link HealthIndicatorReactiveAdapter}. If two instances share the same name, the
* reactive variant takes precedence.
* @param healthAggregator the {@link HealthAggregator}
* @param reactiveHealthIndicators the {@link ReactiveHealthIndicator} instances
* mapped by name
* @param healthIndicators the {@link HealthIndicator} instances mapped by name if
* any.
* @return a {@link ReactiveHealthIndicator} that delegates to the specified
* {@code reactiveHealthIndicators}.
*/
public CompositeReactiveHealthIndicator createReactiveHealthIndicator(
HealthAggregator healthAggregator,
Map<String, ReactiveHealthIndicator> reactiveHealthIndicators,
Map<String, HealthIndicator> healthIndicators) {
Assert.notNull(healthAggregator, "HealthAggregator must not be null");
Assert.notNull(reactiveHealthIndicators,
"ReactiveHealthIndicators must not be null");
CompositeReactiveHealthIndicator healthIndicator = new CompositeReactiveHealthIndicator(
healthAggregator);
merge(reactiveHealthIndicators, healthIndicators)
.forEach((beanName, indicator) -> {
String name = this.healthIndicatorNameFactory.apply(beanName);
healthIndicator.addHealthIndicator(name, indicator);
});
return healthIndicator;
}
private Map<String, ReactiveHealthIndicator> merge(
Map<String, ReactiveHealthIndicator> reactiveHealthIndicators,
Map<String, HealthIndicator> healthIndicators) {
if (ObjectUtils.isEmpty(healthIndicators)) {
return reactiveHealthIndicators;
}
Map<String, ReactiveHealthIndicator> allIndicators = new LinkedHashMap<>(
reactiveHealthIndicators);
healthIndicators.forEach((beanName, indicator) -> {
String name = this.healthIndicatorNameFactory.apply(beanName);
allIndicators.computeIfAbsent(name,
(n) -> new HealthIndicatorReactiveAdapter(indicator));
});
return allIndicators;
}
}
| apache-2.0 |
medicayun/medicayundicom | dcm4jboss-all/tags/DCM4JBOSS_2_4_2/dcm4jboss-hl7/src/java/org/dcm4chex/archive/hl7/HL7Exception.java | 1468 | /******************************************
* *
* dcm4che: A OpenSource DICOM Toolkit *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
******************************************/
package org.dcm4chex.archive.hl7;
/**
* @author [email protected]
* @version $Revision: 1357 $ $Date: 2004-12-30 08:55:56 +0800 (周四, 30 12月 2004) $
* @since 27.10.2004
*
*/
public abstract class HL7Exception extends Exception {
public HL7Exception(String message) {
super(message);
}
public HL7Exception(String message, Throwable cause) {
super(message, cause);
}
public abstract String getAcknowledgementCode();
public static class AE extends HL7Exception {
public AE(String message) {
super(message);
}
public AE(String message, Throwable cause) {
super(message, cause);
}
public String getAcknowledgementCode() {
return "AE";
}
}
public static class AR extends HL7Exception {
public AR(String message) {
super(message);
}
public AR(String message, Throwable cause) {
super(message, cause);
}
public String getAcknowledgementCode() {
return "AR";
}
}
}
| apache-2.0 |
aliosmanyuksel/show-java | app/src/main/java/org/jf/dexlib2/dexbacked/instruction/DexBackedInstruction22c.java | 2854 | /*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jf.dexlib2.dexbacked.instruction;
import javax.annotation.Nonnull;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.dexbacked.reference.DexBackedReference;
import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
import org.jf.dexlib2.iface.reference.Reference;
import org.jf.util.NibbleUtils;
public class DexBackedInstruction22c extends DexBackedInstruction implements Instruction22c {
public DexBackedInstruction22c(@Nonnull DexBackedDexFile dexFile,
@Nonnull Opcode opcode,
int instructionStart) {
super(dexFile, opcode, instructionStart);
}
@Override
public int getRegisterA() {
return NibbleUtils.extractLowUnsignedNibble(dexFile.readByte(instructionStart + 1));
}
@Override
public int getRegisterB() {
return NibbleUtils.extractHighUnsignedNibble(dexFile.readByte(instructionStart + 1));
}
@Nonnull
@Override
public Reference getReference() {
return DexBackedReference.makeReference(dexFile, opcode.referenceType, dexFile.readUshort(instructionStart + 2));
}
@Override
public int getReferenceType() {
return opcode.referenceType;
}
}
| apache-2.0 |
Subsets and Splits