repo_name
stringlengths
4
116
path
stringlengths
3
942
size
stringlengths
1
7
content
stringlengths
3
1.05M
license
stringclasses
15 values
ybznek/openscap
src/OVAL/probes/unix/process.c
11795
/** * @file process.c * @brief process probe * @author "Steve Grubb" <[email protected]> * * 2010/06/13 [email protected] * This probe is able to process an process_object as defined in OVAL 5.4 and 5.5. * */ /* * Copyright 2009-2010 Red Hat Inc., Durham, North Carolina. * All Rights Reserved. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Authors: * Steve Grubb <[email protected]> */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <string.h> #include <stdio.h> #include <errno.h> #ifdef HAVE_STDIO_EXT_H # include <stdio_ext.h> #endif #include <dirent.h> #include <sys/stat.h> #include <fcntl.h> #include <sched.h> #include <time.h> #ifdef HAVE_PROC_DEVNAME_H #include <proc/devname.h> #else #include "process58-devname.h" #endif #include "seap.h" #include "probe-api.h" #include "probe/entcmp.h" #include "alloc.h" #include "common/debug_priv.h" oval_schema_version_t over; /* Convenience structure for the results being reported */ struct result_info { const char *command; const char *exec_time; unsigned pid; unsigned ppid; long priority; int ruid; const char *scheduling_class; const char *start_time; const char *tty; int user_id; }; static void report_finding(struct result_info *res, probe_ctx *ctx) { SEXP_t *item; SEXP_t *se_ruid; if (oval_schema_version_cmp(over, OVAL_SCHEMA_VERSION(5.8)) < 0) { se_ruid = NULL; } else { se_ruid = SEXP_number_newu_64(res->ruid); } item = probe_item_create(OVAL_UNIX_PROCESS, NULL, "command", OVAL_DATATYPE_STRING, res->command, "exec_time", OVAL_DATATYPE_STRING, res->exec_time, "pid", OVAL_DATATYPE_INTEGER, (int64_t)res->pid, "ppid", OVAL_DATATYPE_INTEGER, (int64_t)res->ppid, "priority", OVAL_DATATYPE_INTEGER, (int64_t)res->priority, "ruid", OVAL_DATATYPE_SEXP, se_ruid, "scheduling_class", OVAL_DATATYPE_STRING, res->scheduling_class, "start_time", OVAL_DATATYPE_STRING, res->start_time, "tty", OVAL_DATATYPE_STRING, res->tty, "user_id", OVAL_DATATYPE_INTEGER, (int64_t)res->user_id, NULL); probe_item_collect(ctx, item); } #if defined(__linux__) unsigned long ticks, boot; static void get_boot_time(void) { char buf[100]; FILE *sf; int line; boot = 0; sf = fopen("/proc/stat", "rt"); if (sf == NULL) return; line = 0; __fsetlocking(sf, FSETLOCKING_BYCALLER); while (fgets(buf, sizeof(buf), sf)) { if (line == 0) { line++; continue; } if (memcmp(buf, "btime", 5) == 0) { sscanf(buf, "btime %lu", &boot); break; } } fclose(sf); } static int get_uids(int pid, struct result_info *r) { char buf[100]; FILE *sf; r->ruid = -1; r->user_id = -1; snprintf(buf, sizeof(buf), "/proc/%d/status", pid); sf = fopen(buf, "rt"); if (sf) { int line = 0; __fsetlocking(sf, FSETLOCKING_BYCALLER); while (fgets(buf, sizeof(buf), sf)) { if (line == 0) { line++; continue; } if (memcmp(buf, "Uid:", 4) == 0) { sscanf(buf, "Uid: %d %d", &r->ruid, &r->user_id); break; } } fclose(sf); } return 0; } static char *convert_time(unsigned long long t, char *tbuf, int tb_size) { unsigned d,h,m,s; s = t%60; t /= 60; m = t%60; t /=60; h = t%24; t /= 24; d = t; if (d) snprintf(tbuf, tb_size, "%u-%02u:%02u:%02u", d, h, m, s); else snprintf(tbuf, tb_size, "%02u:%02u:%02u", h, m, s); return tbuf; } static int read_process(SEXP_t *cmd_ent, probe_ctx *ctx) { int err = 1; DIR *d; struct dirent *ent; d = opendir("/proc"); if (d == NULL) return err; // Get the time tick hertz ticks = (unsigned long)sysconf(_SC_CLK_TCK); get_boot_time(); // Scan the directories while (( ent = readdir(d) )) { int fd, len; char buf[256]; char *tmp, cmd[16], state, tty_dev[128]; int pid, ppid, pgrp, session, tty_nr, tpgid; unsigned flags, sched_policy; unsigned long minflt, cminflt, majflt, cmajflt, uutime, ustime; long cutime, cstime, priority, cnice, nthreads, itrealvalue; unsigned long long start; SEXP_t *cmd_sexp; // Skip non-process dir entries if(*ent->d_name<'0' || *ent->d_name>'9') continue; errno = 0; pid = strtol(ent->d_name, NULL, 10); if (errno || pid == 2) // skip err & kthreads continue; // Parse up the stat file for the proc snprintf(buf, 32, "/proc/%d/stat", pid); fd = open(buf, O_RDONLY, 0); if (fd < 0) continue; len = read(fd, buf, sizeof buf - 1); close(fd); if (len < 40) continue; buf[len] = 0; tmp = strrchr(buf, ')'); if (tmp) *tmp = 0; else continue; memset(cmd, 0, sizeof(cmd)); sscanf(buf, "%d (%15c", &ppid, cmd); sscanf(tmp+2, "%c %d %d %d %d %d " "%u %lu %lu %lu %lu " "%lu %lu %lu %ld %ld " "%ld %ld %ld %llu", &state, &ppid, &pgrp, &session, &tty_nr, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &uutime, &ustime, &cutime, &cstime, &priority, &cnice, &nthreads, &itrealvalue, &start ); // Skip kthreads if (ppid == 2) continue; err = 0; // If we get this far, no permission problems dI("Have command: %s", cmd); cmd_sexp = SEXP_string_newf("%s", cmd); if (probe_entobj_cmp(cmd_ent, cmd_sexp) == OVAL_RESULT_TRUE) { struct result_info r; unsigned long t = uutime/ticks + ustime/ticks; char tbuf[32], sbuf[32]; int tday,tyear; time_t s_time; struct tm *proc, *now; const char *fmt; // Now get scheduler policy sched_policy = sched_getscheduler(pid); switch (sched_policy) { case SCHED_OTHER: r.scheduling_class = "TS"; break; case SCHED_BATCH: r.scheduling_class = "B"; break; #ifdef SCHED_IDLE case SCHED_IDLE: r.scheduling_class = "#5"; break; #endif case SCHED_FIFO: r.scheduling_class = "FF"; break; case SCHED_RR: r.scheduling_class = "RR"; break; default: r.scheduling_class = "?"; break; } // Calculate the start time s_time = time(NULL); now = localtime(&s_time); tyear = now->tm_year; tday = now->tm_yday; s_time = boot + (start / ticks); proc = localtime(&s_time); // Select format based on how long we've been running // // FROM THE SPEC: // "This is the time of day the process started formatted in HH:MM:SS if // the same day the process started or formatted as MMM_DD (Ex.: Feb_5) // if process started the previous day or further in the past." // if (tday != proc->tm_yday || tyear != proc->tm_year) fmt = "%b_%d"; else fmt = "%H:%M:%S"; strftime(sbuf, sizeof(sbuf), fmt, proc); r.command = cmd; r.exec_time = convert_time(t, tbuf, sizeof(tbuf)); r.pid = pid; r.ppid = ppid; r.priority = priority; r.start_time = sbuf; dev_to_tty(tty_dev, sizeof(tty_dev), (dev_t) tty_nr, pid, ABBREV_DEV); r.tty = tty_dev; get_uids(pid, &r); report_finding(&r, ctx); } SEXP_free(cmd_sexp); } closedir(d); return err; } int probe_main(probe_ctx *ctx, void *arg) { SEXP_t *ent; ent = probe_obj_getent(probe_ctx_getobject(ctx), "command", 1); if (ent == NULL) { return PROBE_ENOVAL; } if (read_process(ent, ctx)) { SEXP_free(ent); return PROBE_EACCESS; } SEXP_free(ent); return 0; } #elif defined (__SVR4) && defined (__sun) #include <procfs.h> #include <unistd.h> static char *convert_time(time_t t, char *tbuf, int tb_size) { unsigned d,h,m,s; s = t%60; t /= 60; m = t%60; t /=60; h = t%24; t /= 24; d = t; if (d) snprintf(tbuf, tb_size, "%u-%02u:%02u:%02u", d, h, m, s); else snprintf(tbuf, tb_size, "%02u:%02u:%02u", h, m, s); return tbuf; } static int read_process(SEXP_t *cmd_ent, probe_ctx *ctx) { int err = 1; DIR *d; struct dirent *ent; d = opendir("/proc"); if (d == NULL) return err; psinfo_t *psinfo; // Scan the directories while (( ent = readdir(d) )) { int fd, len; char buf[336]; int pid; unsigned sched_policy; SEXP_t *cmd_sexp; // Skip non-process dir entries if(*ent->d_name<'0' || *ent->d_name>'9') continue; errno = 0; pid = strtol(ent->d_name, NULL, 10); if (errno || pid == 2) // skip err & kthreads continue; // Parse up the stat file for the proc snprintf(buf, 32, "/proc/%d/psinfo", pid); fd = open(buf, O_RDONLY, 0); if (fd < 0) continue; len = read(fd, buf, sizeof buf); close(fd); if (len < 336) continue; // The psinfo file contains a psinfo struct; this typecast gets us the struct directly psinfo = (psinfo_t *) buf; err = 0; // If we get this far, no permission problems dI("Have command: %s", psinfo->pr_fname); cmd_sexp = SEXP_string_newf("%s", psinfo->pr_fname); if (probe_entobj_cmp(cmd_ent, cmd_sexp) == OVAL_RESULT_TRUE) { struct result_info r; char tbuf[32], sbuf[32]; int tday,tyear; time_t s_time; struct tm *proc, *now; const char *fmt; int fixfmt_year; r.scheduling_class = malloc(PRCLSZ); strncpy(r.scheduling_class, (psinfo->pr_lwp).pr_clname, sizeof(r.scheduling_class)); // Get the start time s_time = time(NULL); now = localtime(&s_time); tyear = now->tm_year; tday = now->tm_yday; // Get current time s_time = psinfo->pr_start.tv_sec; proc = localtime(&s_time); // Select format based on how long we've been running // // FROM THE SPEC: // "This is the time of day the process started formatted in HH:MM:SS if // the same day the process started or formatted as MMM_DD (Ex.: Feb_5) // if process started the previous day or further in the past." // if (tday != proc->tm_yday || tyear != proc->tm_year) fmt = "%b_%d"; else fmt = "%H:%M:%S"; strftime(sbuf, sizeof(sbuf), fmt, proc); r.command = psinfo->pr_fname; r.exec_time = convert_time(psinfo->pr_time.tv_sec, tbuf, sizeof(tbuf)); r.pid = psinfo->pr_pid; r.ppid = psinfo->pr_ppid; r.priority = (psinfo->pr_lwp).pr_pri; r.ruid = psinfo->pr_uid; r.start_time = sbuf; r.tty = oscap_sprintf("%s", psinfo->pr_ttydev); r.user_id = psinfo->pr_euid; report_finding(&r, ctx); } SEXP_free(cmd_sexp); } closedir(d); return err; } int probe_main(probe_ctx *ctx, void *arg) { SEXP_t *obj, *ent; obj = probe_ctx_getobject(ctx); over = probe_obj_get_platform_schema_version(obj); ent = probe_obj_getent(obj, "command", 1); if (ent == NULL) { return PROBE_ENOVAL; } if (read_process(ent, ctx)) { SEXP_free(ent); return PROBE_EACCESS; } SEXP_free(ent); return 0; } #else int probe_main(probe_ctx *ctx, void *arg) { SEXP_t *item_sexp; item_sexp = probe_item_creat ("process_item", NULL, NULL); probe_item_setstatus (item_sexp, SYSCHAR_STATUS_NOT_COLLECTED); probe_item_collect(ctx, item_sexp); return 0; } #endif /* __linux */
lgpl-2.1
spsoft/spnetkit
spnetkit/spnkprefork.cpp
6852
/* * Copyright 2011 Stephen Liu * For license terms, see the file COPYING along with this library. */ #include <vector> #include <unistd.h> #include <errno.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #include "spnkprefork.hpp" #include "spnklog.hpp" #include "spnkstr.hpp" #include "spnksocket.hpp" typedef struct tagSP_NKPreforkManagerImpl { SP_NKPreforkManager::Handler_t mHandler; void * mArgs; int mMaxProcs; int mCheckInterval; std::vector< pid_t > mPidList; } SP_NKPreforkManagerImpl_t; SP_NKPreforkManager :: SP_NKPreforkManager( Handler_t handler, void * args, int maxProcs, int checkInterval ) { mImpl = new SP_NKPreforkManagerImpl_t; mImpl->mHandler = handler; mImpl->mArgs = args; mImpl->mMaxProcs = maxProcs; mImpl->mCheckInterval = checkInterval; if( mImpl->mCheckInterval <= 0 ) checkInterval = 1; } SP_NKPreforkManager :: ~SP_NKPreforkManager() { delete mImpl; mImpl = NULL; } int SP_NKPreforkManager :: run() { pid_t pid = fork(); if( 0 == pid ) { runForever(); return 0; } else if( pid > 0 ) { SP_NKLog::log( LOG_DEBUG, "fork proc master %d", pid ); } else { SP_NKLog::log( LOG_ERR, "fork fail, errno %d, %s", errno, strerror( errno ) ); } return pid > 0 ? 0 : -1; } void SP_NKPreforkManager :: termHandler( int sig ) { kill( 0, SIGTERM ); exit( 0 ); } void SP_NKPreforkManager :: runForever() { signal( SIGCHLD, SIG_IGN ); signal( SIGTERM, termHandler ); for( int i = 0; i < mImpl->mMaxProcs; i++ ) { pid_t pid = fork(); if( 0 == pid ) { mImpl->mHandler( i, mImpl->mArgs ); exit( 0 ); } else if( pid > 0 ) { SP_NKLog::log( LOG_DEBUG, "fork proc#%d %d", i, pid ); mImpl->mPidList.push_back( pid ); } else { SP_NKLog::log( LOG_ERR, "fork fail, errno %d, %s", errno, strerror( errno ) ); exit( -1 ); } } for( ; ; ) { sleep( mImpl->mCheckInterval ); for( int i = 0; i < (int)mImpl->mPidList.size(); i++ ) { pid_t pid = mImpl->mPidList[i]; if( 0 != kill( pid, 0 ) ) { SP_NKLog::log( LOG_ERR, "proc#%d %d is not exists", i, pid ); pid = fork(); if( 0 == pid ) { mImpl->mHandler( i, mImpl->mArgs ); exit( 0 ); } else if( pid > 0 ) { SP_NKLog::log( LOG_DEBUG, "fork proc#%d %d to replace %d", i, pid, mImpl->mPidList[i] ); mImpl->mPidList[i] = pid; } else { SP_NKLog::log( LOG_ERR, "fork fail, errno %d, %s", errno, strerror( errno ) ); // leave pid for next check } } } } } void SP_NKPreforkManager :: shutdown() { kill( 0, SIGTERM ); } //=========================================================================== typedef struct tagSP_NKPreforkServerImpl { char mBindIP[ 64 ]; int mPort; SP_NKPreforkServer::OnRequest_t mOnRequest; void * mProcArgs; int mMaxProcs; int mCheckInterval; int mListenFD; int mMaxRequestsPerChild; SP_NKPreforkServer::BeforeChildRun_t mBeforeChildRun; SP_NKPreforkServer::AfterChildRun_t mAfterChildRun; } SP_NKPreforkServerImpl_t; SP_NKPreforkServer :: SP_NKPreforkServer( const char * bindIP, int port, OnRequest_t onRequest, void * procArgs ) { mImpl = (SP_NKPreforkServerImpl_t*)calloc( sizeof( SP_NKPreforkServerImpl_t ), 1 ); SP_NKStr::strlcpy( mImpl->mBindIP, bindIP, sizeof( mImpl->mBindIP ) ); mImpl->mPort = port; mImpl->mOnRequest = onRequest; mImpl->mProcArgs = procArgs; mImpl->mMaxProcs = 8; mImpl->mCheckInterval = 1; mImpl->mMaxRequestsPerChild = 10000; mImpl->mListenFD = -1; } SP_NKPreforkServer :: ~SP_NKPreforkServer() { if( mImpl->mListenFD >= 0 ) close( mImpl->mListenFD ); free( mImpl ); mImpl = NULL; } void SP_NKPreforkServer :: setBeforeChildRun( BeforeChildRun_t beforeChildRun ) { mImpl->mBeforeChildRun = beforeChildRun; } void SP_NKPreforkServer :: setAfterChildRun( AfterChildRun_t afterChildRun ) { mImpl->mAfterChildRun = afterChildRun; } void SP_NKPreforkServer :: setPreforkArgs( int maxProcs, int checkInterval, int maxRequestsPerChild ) { mImpl->mMaxProcs = maxProcs; mImpl->mCheckInterval = checkInterval; mImpl->mMaxRequestsPerChild = maxRequestsPerChild; } int SP_NKPreforkServer :: run() { pid_t pid = fork(); if( 0 == pid ) { runForever(); return 0; } else if( pid > 0 ) { SP_NKLog::log( LOG_DEBUG, "fork proc master %d", pid ); } else { SP_NKLog::log( LOG_ERR, "fork fail, errno %d, %s", errno, strerror( errno ) ); } return pid > 0 ? 0 : -1; } void SP_NKPreforkServer :: runForever() { #ifdef SIGPIPE /* Don't die with SIGPIPE on remote read shutdown. That's dumb. */ signal( SIGPIPE, SIG_IGN ); #endif int ret = 0; int listenFD = -1; ret = SP_NKSocket::tcpListen( mImpl->mBindIP, mImpl->mPort, &listenFD, 1 ); if( 0 == ret ) { mImpl->mListenFD = listenFD; SP_NKPreforkManager manager( serverHandler, mImpl, mImpl->mMaxProcs, mImpl->mCheckInterval ); manager.runForever(); } else { SP_NKLog::log( LOG_ERR, "list fail, errno %d, %s", errno, strerror( errno ) ); } } void SP_NKPreforkServer :: serverHandler( int index, void * args ) { SP_NKPreforkServerImpl_t * impl = (SP_NKPreforkServerImpl_t*)args; if( NULL != impl->mBeforeChildRun ) { impl->mBeforeChildRun( impl->mProcArgs ); } int factor = impl->mMaxRequestsPerChild / 10; factor = factor <= 0 ? 1 : factor; int maxRequestsPerChild = impl->mMaxRequestsPerChild + factor * index; for( int i= 0; i < maxRequestsPerChild; i++ ) { struct sockaddr_in addr; socklen_t socklen = sizeof( addr ); int fd = accept( impl->mListenFD, (struct sockaddr*)&addr, &socklen ); if( fd >= 0 ) { impl->mOnRequest( fd, impl->mProcArgs ); close( fd ); } else { SP_NKLog::log( LOG_ERR, "accept fail, errno %d, %s", errno, strerror( errno ) ); } } if( NULL != impl->mAfterChildRun ) { impl->mAfterChildRun( impl->mProcArgs ); } } void SP_NKPreforkServer :: shutdown() { kill( 0, SIGTERM ); } //=========================================================================== int SP_NKPreforkServer :: initDaemon( const char * workdir ) { pid_t pid; if ( (pid = fork()) < 0) return (-1); else if (pid) _exit(0); /* parent terminates */ /* child 1 continues... */ if (setsid() < 0) /* become session leader */ return (-1); assert( signal( SIGHUP, SIG_IGN ) != SIG_ERR ); assert( signal( SIGPIPE, SIG_IGN ) != SIG_ERR ); assert( signal( SIGALRM, SIG_IGN ) != SIG_ERR ); assert( signal( SIGCHLD, SIG_IGN ) != SIG_ERR ); if ( (pid = fork()) < 0) return (-1); else if (pid) _exit(0); /* child 1 terminates */ /* child 2 continues... */ if( NULL != workdir ) chdir( workdir ); /* change working directory */ /* close off file descriptors */ for (int i = 0; i < 64; i++) close(i); /* redirect stdin, stdout, and stderr to /dev/null */ open("/dev/null", O_RDONLY); open("/dev/null", O_RDWR); open("/dev/null", O_RDWR); return (0); /* success */ }
lgpl-2.1
duythanhphan/qt-creator
src/plugins/qt4projectmanager/wizards/qtwizard.h
5674
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef QTWIZARD_H #define QTWIZARD_H #include "qtprojectparameters.h" #include <projectexplorer/baseprojectwizarddialog.h> #include <projectexplorer/customwizard/customwizard.h> namespace ProjectExplorer { class Kit; } namespace Qt4ProjectManager { class Qt4Project; class TargetSetupPage; namespace Internal { class ModulesPage; /* Base class for wizard creating Qt projects using QtProjectParameters. * To implement a project wizard, overwrite: * - createWizardDialog() to create up the dialog * - generateFiles() to set their contents * The base implementation provides the wizard parameters and opens * the finished project in postGenerateFiles(). * The pro-file must be the last one of the generated files. */ class QtWizard : public Core::BaseFileWizard { Q_OBJECT protected: QtWizard(const QString &id, const QString &category, const QString &displayCategory, const QString &name, const QString &description, const QIcon &icon); public: static QString templateDir(); static QString sourceSuffix(); static QString headerSuffix(); static QString formSuffix(); static QString profileSuffix(); // Query CppTools settings for the class wizard settings static bool lowerCaseFiles(); static bool qt4ProjectPostGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); protected: static bool showModulesPageForApplications(); static bool showModulesPageForLibraries(); private: bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); }; // A custom wizard with an additional Qt 4 target page class CustomQt4ProjectWizard : public ProjectExplorer::CustomProjectWizard { Q_OBJECT public: explicit CustomQt4ProjectWizard(const Core::BaseFileWizardParameters& baseFileParameters, QObject *parent = 0); virtual QWizard *createWizardDialog(QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const; static void registerSelf(); protected: virtual bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage); private: enum { targetPageId = 1 }; }; /* BaseQt4ProjectWizardDialog: Additionally offers modules page * and getter/setter for blank-delimited modules list, transparently * handling the visibility of the modules page list as well as a page * to select targets and Qt versions. */ class BaseQt4ProjectWizardDialog : public ProjectExplorer::BaseProjectWizardDialog { Q_OBJECT protected: explicit BaseQt4ProjectWizardDialog(bool showModulesPage, Utils::ProjectIntroPage *introPage, int introId, QWidget *parent, const Core::WizardDialogParameters &parameters); public: explicit BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent, const Core::WizardDialogParameters &parameters); virtual ~BaseQt4ProjectWizardDialog(); int addModulesPage(int id = -1); int addTargetSetupPage(bool mobile = false, int id = -1); QStringList selectedModulesList() const; void setSelectedModules(const QString &, bool lock = false); QStringList deselectedModulesList() const; void setDeselectedModules(const QString &); bool writeUserFile(const QString &proFileName) const; bool setupProject(Qt4Project *project) const; bool isQtPlatformSelected(const QString &platform) const; QList<Core::Id> selectedKits() const; void addExtensionPages(const QList<QWizardPage *> &wizardPageList); private slots: void generateProfileName(const QString &name, const QString &path); private: inline void init(bool showModulesPage); ModulesPage *m_modulesPage; TargetSetupPage *m_targetSetupPage; QStringList m_selectedModules; QStringList m_deselectedModules; QList<Core::Id> m_profileIds; }; } // namespace Internal } // namespace Qt4ProjectManager #endif // QTWIZARD_H
lgpl-2.1
kitachro/ruby-gnome2
poppler/ext/poppler/rbpoppler-annotation-callout-line.c
4950
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /* * Copyright (C) 2008-2013 Ruby-GNOME2 Project Team * * 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 Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include "rbpoppler-private.h" #define RG_TARGET_NAMESPACE cAnnotation static VALUE rg_initialize(VALUE self, VALUE multiline, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3) { PopplerAnnotCalloutLine *line; line = poppler_annot_callout_line_new(); line->multiline = RVAL2CBOOL(multiline); line->x1 = NUM2DBL(x1); line->y1 = NUM2DBL(y1); line->x2 = NUM2DBL(x2); line->y2 = NUM2DBL(y2); line->x3 = NUM2DBL(x3); line->y3 = NUM2DBL(y3); G_INITIALIZE(self, line); return Qnil; } DEF_ACCESSOR(annot_callout_line, multiline, RVAL2POPPLERANNOTCALLOUTLINE, CBOOL2RVAL, RVAL2CBOOL) DEF_ACCESSOR(annot_callout_line, x1, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) DEF_ACCESSOR(annot_callout_line, y1, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) DEF_ACCESSOR(annot_callout_line, x2, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) DEF_ACCESSOR(annot_callout_line, y2, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) DEF_ACCESSOR(annot_callout_line, x3, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) DEF_ACCESSOR(annot_callout_line, y3, RVAL2POPPLERANNOTCALLOUTLINE, rb_float_new, NUM2DBL) static VALUE rg_to_a(VALUE self) { PopplerAnnotCalloutLine *line; line = RVAL2POPPLERANNOTCALLOUTLINE(self); return rb_ary_new3(7, CBOOL2RVAL(line->multiline), rb_float_new(line->x1), rb_float_new(line->y1), rb_float_new(line->x2), rb_float_new(line->y2), rb_float_new(line->x3), rb_float_new(line->y3)); } static VALUE rg_inspect(VALUE self) { VALUE inspected; gchar *info; PopplerAnnotCalloutLine *line; line = RVAL2POPPLERANNOTCALLOUTLINE(self); inspected = rb_call_super(0, NULL); rb_str_resize(inspected, RSTRING_LEN(inspected) - 1); info = g_strdup_printf(": [%s, %g, %g, %g, %g, %g, %g]>", line->multiline ? "true" : "false", line->x1, line->y1, line->x2, line->y2, line->x3, line->y3); rb_str_cat2(inspected, info); g_free(info); return inspected; } void Init_poppler_annotation_callout_line(VALUE mPoppler) { VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_ANNOT_CALLOUT_LINE, "AnnotationCalloutLine", mPoppler); RG_DEF_METHOD(initialize, 7); rbg_define_method(RG_TARGET_NAMESPACE, "multiline?", annot_callout_line_get_multiline, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_multiline", annot_callout_line_set_multiline, 1); rbg_define_method(RG_TARGET_NAMESPACE, "x1", annot_callout_line_get_x1, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_x1", annot_callout_line_set_x1, 1); rbg_define_method(RG_TARGET_NAMESPACE, "y1", annot_callout_line_get_y1, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_y1", annot_callout_line_set_y1, 1); rbg_define_method(RG_TARGET_NAMESPACE, "x2", annot_callout_line_get_x2, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_x2", annot_callout_line_set_x2, 2); rbg_define_method(RG_TARGET_NAMESPACE, "y2", annot_callout_line_get_y2, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_y2", annot_callout_line_set_y2, 2); rbg_define_method(RG_TARGET_NAMESPACE, "x3", annot_callout_line_get_x3, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_x3", annot_callout_line_set_x3, 3); rbg_define_method(RG_TARGET_NAMESPACE, "y3", annot_callout_line_get_y3, 0); rbg_define_method(RG_TARGET_NAMESPACE, "set_y3", annot_callout_line_set_y3, 3); RG_DEF_METHOD(to_a, 0); RG_DEF_METHOD(inspect, 0); }
lgpl-2.1
jensopetersen/exist
src/org/exist/source/StringSourceWithMapKey.java
1741
package org.exist.source; import java.io.*; import java.util.Map; import org.exist.security.PermissionDeniedException; import org.exist.security.Subject; import org.exist.storage.DBBroker; /** * A simple source object wrapping a single query string, but associating it with a specific * map (e.g., of namespace bindings). This prevents two textually equal queries with different * maps from getting aliased in the query pool. * * @author <a href="mailto:[email protected]">Piotr Kaminski</a> */ public class StringSourceWithMapKey extends AbstractSource { private final Map<String, String> map; /** * Create a new source for the given content and namespace map (string to string). * The map will be taken over and modified by the source, so make a copy first if * you're passing a shared one. * * @param content the content of the query * @param map the map of prefixes to namespace URIs */ public StringSourceWithMapKey(String content, Map<String, String> map) { this.map = map; this.map.put("<query>", content); } @Override public String path() { return type(); } @Override public String type() { return "StringWithMapKey"; } public Object getKey() {return map;} public int isValid(DBBroker broker) {return Source.VALID;} public int isValid(Source other) {return Source.VALID;} public Reader getReader() throws IOException {return new StringReader(map.get("<query>"));} public InputStream getInputStream() throws IOException { // not implemented return null; } public String getContent() throws IOException {return map.get("<query>");} @Override public void validate(Subject subject, int perm) throws PermissionDeniedException { // TODO protected? } }
lgpl-2.1
danimo/qt-creator
src/plugins/cpptools/modelmanagertesthelper.cpp
3946
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms and ** conditions see http://www.qt.io/terms-conditions. For further information ** use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "modelmanagertesthelper.h" #include "cpptoolstestcase.h" #include "cppworkingcopy.h" #include <QtTest> #include <cassert> Q_DECLARE_METATYPE(QSet<QString>) using namespace CppTools::Internal; TestProject::TestProject(const QString &name, QObject *parent) : m_name (name) { setParent(parent); setId(Core::Id::fromString(name)); qRegisterMetaType<QSet<QString> >(); } TestProject::~TestProject() { } ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) : QObject(parent) { CppModelManager *mm = CppModelManager::instance(); connect(this, &ModelManagerTestHelper::aboutToRemoveProject, mm, &CppModelManager::onAboutToRemoveProject); connect(this, &ModelManagerTestHelper::projectAdded, mm, &CppModelManager::onProjectAdded); connect(mm, &CppModelManager::sourceFilesRefreshed, this, &ModelManagerTestHelper::sourceFilesRefreshed); connect(mm, &CppModelManager::gcFinished, this, &ModelManagerTestHelper::gcFinished); cleanup(); QVERIFY(Tests::VerifyCleanCppModelManager::isClean()); } ModelManagerTestHelper::~ModelManagerTestHelper() { cleanup(); QVERIFY(Tests::VerifyCleanCppModelManager::isClean()); } void ModelManagerTestHelper::cleanup() { CppModelManager *mm = CppModelManager::instance(); QList<ProjectInfo> pies = mm->projectInfos(); foreach (const ProjectInfo &pie, pies) emit aboutToRemoveProject(pie.project().data()); if (!pies.isEmpty()) waitForFinishedGc(); } ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(const QString &name) { TestProject *tp = new TestProject(name, this); emit projectAdded(tp); return tp; } void ModelManagerTestHelper::resetRefreshedSourceFiles() { m_lastRefreshedSourceFiles.clear(); m_refreshHappened = false; } QSet<QString> ModelManagerTestHelper::waitForRefreshedSourceFiles() { while (!m_refreshHappened) QCoreApplication::processEvents(); return m_lastRefreshedSourceFiles; } void ModelManagerTestHelper::waitForFinishedGc() { m_gcFinished = false; while (!m_gcFinished) QCoreApplication::processEvents(); } void ModelManagerTestHelper::sourceFilesRefreshed(const QSet<QString> &files) { m_lastRefreshedSourceFiles = files; m_refreshHappened = true; } void ModelManagerTestHelper::gcFinished() { m_gcFinished = true; }
lgpl-2.1
stefanklug/mapnik
include/mapnik/json/topojson_utils.hpp
8585
/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2015 Artem Pavlenko * * 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 MAPNIK_TOPOJSON_UTILS_HPP #define MAPNIK_TOPOJSON_UTILS_HPP // mapnik #include <mapnik/box2d.hpp> #include <mapnik/json/topology.hpp> namespace mapnik { namespace topojson { struct bounding_box_visitor { bounding_box_visitor(topology const& topo) : topo_(topo), num_arcs_(topo_.arcs.size()) {} box2d<double> operator() (mapnik::topojson::point const& pt) const { double x = pt.coord.x; double y = pt.coord.y; if (topo_.tr) { x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } return box2d<double>(x, y, x, y); } box2d<double> operator() (mapnik::topojson::multi_point const& multi_pt) const { box2d<double> bbox; if (num_arcs_ > 0) { bool first = true; for (auto const& pt : multi_pt.points) { double x = pt.x; double y = pt.y; if (topo_.tr) { x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y; // TODO : delta encoded ? } if (first) { first = false; bbox.init(x,y,x,y); } else { bbox.expand_to_include(x,y); } } } return bbox; } box2d<double> operator() (mapnik::topojson::linestring const& line) const { box2d<double> bbox; if (num_arcs_ > 0) { index_type index = line.ring; index_type arc_index = index < 0 ? std::abs(index) - 1 : index; if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_)) { bool first = true; double px = 0, py = 0; auto const& arcs = topo_.arcs[arc_index]; for (auto pt : arcs.coordinates) { double x = pt.x; double y = pt.y; if (topo_.tr) { x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } if (first) { first = false; bbox.init(x, y, x, y); } else { bbox.expand_to_include(x, y); } } } } return bbox; } box2d<double> operator() (mapnik::topojson::multi_linestring const& multi_line) const { box2d<double> bbox; if (num_arcs_ > 0) { bool first = true; for (auto index : multi_line.rings) { index_type arc_index = index < 0 ? std::abs(index) - 1 : index; if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_)) { double px = 0, py = 0; auto const& arcs = topo_.arcs[arc_index]; for (auto pt : arcs.coordinates) { double x = pt.x; double y = pt.y; if (topo_.tr) { x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } if (first) { first = false; bbox.init(x, y, x, y); } else { bbox.expand_to_include(x, y); } } } } } return bbox; } box2d<double> operator() (mapnik::topojson::polygon const& poly) const { box2d<double> bbox; if (num_arcs_ > 0) { bool first = true; for (auto const& ring : poly.rings) { for (auto index : ring) { index_type arc_index = index < 0 ? std::abs(index) - 1 : index; if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_)) { double px = 0, py = 0; auto const& arcs = topo_.arcs[arc_index]; for (auto const& pt : arcs.coordinates) { double x = pt.x; double y = pt.y; if (topo_.tr) { x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } if (first) { first = false; bbox.init( x, y, x, y); } else { bbox.expand_to_include(x, y); } } } } } } return bbox; } box2d<double> operator() (mapnik::topojson::multi_polygon const& multi_poly) const { box2d<double> bbox; if (num_arcs_ > 0) { bool first = true; for (auto const& poly : multi_poly.polygons) { for (auto const& ring : poly) { for (auto index : ring) { index_type arc_index = index < 0 ? std::abs(index) - 1 : index; if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_)) { double px = 0, py = 0; auto const& arcs = topo_.arcs[arc_index]; for (auto const& pt : arcs.coordinates) { double x = pt.x; double y = pt.y; if (topo_.tr) { x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } if (first) { first = false; bbox.init( x, y, x, y); } else { bbox.expand_to_include(x, y); } } } } } } } return bbox; } private: topology const& topo_; std::size_t num_arcs_; }; }} #endif //MAPNIK_TOPOJSON_UTILS_HPP
lgpl-2.1
openprivacy/openscap
src/OVAL/oval_entity.c
13479
/** * @file oval_entity.c * \brief Open Vulnerability and Assessment Language * * See more details at http://oval.mitre.org/ */ /* * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina. * All Rights Reserved. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Authors: * "David Niemoller" <[email protected]> */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include <libxml/tree.h> #include "oval_definitions_impl.h" #include "adt/oval_collection_impl.h" #include "oval_agent_api_impl.h" #include "oval_parser_impl.h" #include "common/util.h" #include "common/debug_priv.h" #include "common/elements.h" #include "common/_error.h" /***************************************************************************/ /* Variable definitions * */ struct oval_entity { struct oval_definition_model *model; oval_entity_type_t type; oval_datatype_t datatype; oval_operation_t operation; int mask; oval_entity_varref_type_t varref_type; char *name; struct oval_variable *variable; struct oval_value *value; bool xsi_nil; ///< @xsi:nil boolean attribute }; struct oval_consume_varref_context { struct oval_definition_model *model; struct oval_variable **variable; struct oval_value **value; }; /* End of variable definitions * */ /***************************************************************************/ static inline bool oval_entity_get_xsi_nil(const struct oval_entity *entity); static inline void oval_entity_set_xsi_nil(struct oval_entity *entity, bool xsi_nil); bool oval_entity_iterator_has_more(struct oval_entity_iterator *oc_entity) { return oval_collection_iterator_has_more((struct oval_iterator *) oc_entity); } struct oval_entity *oval_entity_iterator_next(struct oval_entity_iterator *oc_entity) { return (struct oval_entity *) oval_collection_iterator_next((struct oval_iterator *)oc_entity); } void oval_entity_iterator_free(struct oval_entity_iterator *oc_entity) { oval_collection_iterator_free((struct oval_iterator *)oc_entity); } char *oval_entity_get_name(struct oval_entity *entity) { __attribute__nonnull__(entity); return entity->name; } oval_entity_type_t oval_entity_get_type(struct oval_entity * entity) { __attribute__nonnull__(entity); return entity->type; } oval_datatype_t oval_entity_get_datatype(struct oval_entity * entity) { __attribute__nonnull__(entity); return entity->datatype; } oval_operation_t oval_entity_get_operation(struct oval_entity * entity) { __attribute__nonnull__(entity); return entity->operation; } int oval_entity_get_mask(struct oval_entity *entity) { __attribute__nonnull__(entity); return entity->mask; } static inline bool oval_entity_get_xsi_nil(const struct oval_entity *entity) { __attribute__nonnull__(entity); return entity->xsi_nil; } oval_entity_varref_type_t oval_entity_get_varref_type(struct oval_entity * entity) { __attribute__nonnull__(entity); return entity->varref_type; } struct oval_variable *oval_entity_get_variable(struct oval_entity *entity) { __attribute__nonnull__(entity); return entity->variable; } struct oval_value *oval_entity_get_value(struct oval_entity *entity) { __attribute__nonnull__(entity); return entity->value; } struct oval_entity *oval_entity_new(struct oval_definition_model *model) { struct oval_entity *entity = (struct oval_entity *)oscap_alloc(sizeof(struct oval_entity)); if (entity == NULL) return NULL; entity->datatype = OVAL_DATATYPE_UNKNOWN; entity->mask = 0; entity->xsi_nil = 0; entity->operation = OVAL_OPERATION_UNKNOWN; entity->type = OVAL_ENTITY_TYPE_UNKNOWN; entity->name = NULL; entity->value = NULL; entity->variable = NULL; entity->model = model; return entity; } struct oval_entity *oval_entity_clone(struct oval_definition_model *new_model, struct oval_entity *old_entity) { struct oval_entity *new_entity = oval_entity_new(new_model); oval_datatype_t datatype = oval_entity_get_datatype(old_entity); oval_entity_set_datatype(new_entity, datatype); int mask = oval_entity_get_mask(old_entity); oval_entity_set_mask(new_entity, mask); bool xsi_nil = oval_entity_get_xsi_nil(old_entity); oval_entity_set_xsi_nil(new_entity, xsi_nil); char *name = oval_entity_get_name(old_entity); oval_entity_set_name(new_entity, name); oval_operation_t operation = oval_entity_get_operation(old_entity); oval_entity_set_operation(new_entity, operation); oval_entity_type_t type = oval_entity_get_type(old_entity); oval_entity_set_type(new_entity, type); struct oval_value *value = oval_entity_get_value(old_entity); if (value) { oval_entity_set_value(new_entity, oval_value_clone(value)); } struct oval_variable *old_variable = oval_entity_get_variable(old_entity); if (old_variable) { oval_entity_set_variable(new_entity, oval_variable_clone(new_model, old_variable)); } oval_entity_varref_type_t reftype = oval_entity_get_varref_type(old_entity); oval_entity_set_varref_type(new_entity, reftype); return new_entity; } void oval_entity_free(struct oval_entity *entity) { __attribute__nonnull__(entity); if (entity->value != NULL) oval_value_free(entity->value); if (entity->name != NULL) oscap_free(entity->name); entity->name = NULL; entity->value = NULL; entity->variable = NULL; oscap_free(entity); } void oval_entity_set_type(struct oval_entity *entity, oval_entity_type_t type) { __attribute__nonnull__(entity); entity->type = type; } void oval_entity_set_datatype(struct oval_entity *entity, oval_datatype_t datatype) { __attribute__nonnull__(entity); entity->datatype = datatype; } void oval_entity_set_operation(struct oval_entity *entity, oval_operation_t operation) { __attribute__nonnull__(entity); entity->operation = operation; } void oval_entity_set_mask(struct oval_entity *entity, int mask) { __attribute__nonnull__(entity); entity->mask = mask; } static inline void oval_entity_set_xsi_nil(struct oval_entity *entity, bool xsi_nil) { __attribute__nonnull__(entity); entity->xsi_nil = xsi_nil; } void oval_entity_set_varref_type(struct oval_entity *entity, oval_entity_varref_type_t type) { __attribute__nonnull__(entity); entity->varref_type = type; } void oval_entity_set_variable(struct oval_entity *entity, struct oval_variable *variable) { __attribute__nonnull__(entity); entity->variable = variable; } void oval_entity_set_value(struct oval_entity *entity, struct oval_value *value) { __attribute__nonnull__(entity); entity->value = value; } void oval_entity_set_name(struct oval_entity *entity, char *name) { __attribute__nonnull__(entity); if (entity->name != NULL) oscap_free(entity->name); entity->name = (name == NULL) ? NULL : oscap_strdup(name); } static void oval_consume_varref(char *varref, void *user) { __attribute__nonnull__(user); struct oval_consume_varref_context *ctx = user; *(ctx->variable) = oval_definition_model_get_new_variable((struct oval_definition_model *)ctx->model, varref, OVAL_VARIABLE_UNKNOWN); *(ctx->value) = oval_value_new(OVAL_DATATYPE_STRING, varref); } static void oval_consume_value(struct oval_value *use_value, void *value) { *(struct oval_value **)value = use_value; } //typedef void (*oval_entity_consumer)(struct oval_entity_node*, void*); int oval_entity_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, oscap_consumer_func consumer, void *user) { __attribute__nonnull__(context); struct oval_entity *entity = oval_entity_new(context->definition_model); int return_code = 0; oval_datatype_t datatype = oval_datatype_parse(reader, "datatype", OVAL_DATATYPE_STRING); oval_operation_t operation = oval_operation_parse(reader, "operation", OVAL_OPERATION_EQUALS); int mask = oval_parser_boolean_attribute(reader, "mask", 0); char *nil_attr = (char *) xmlTextReaderGetAttributeNs(reader, BAD_CAST "nil", OSCAP_XMLNS_XSI); int xsi_nil = oscap_streq(nil_attr, "true") != 0; xmlFree(nil_attr); oval_entity_type_t type = OVAL_ENTITY_TYPE_UNKNOWN; //The value of the type field vs. the complexity of extracting type is arguable char *varref = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "var_ref"); struct oval_value *value = NULL; struct oval_variable *variable; char *name = (char *)xmlTextReaderLocalName(reader); oval_entity_varref_type_t varref_type; if (strcmp(name, "var_ref") == 0) { //special case for <var_ref> if (varref == NULL) { struct oval_definition_model *model = context->definition_model; varref_type = OVAL_ENTITY_VARREF_ELEMENT; struct oval_consume_varref_context ctx = {.model = model, .variable = &variable, .value = &value}; return_code = oscap_parser_text_value(reader, &oval_consume_varref, &ctx); } else { varref_type = OVAL_ENTITY_VARREF_ATTRIBUTE; struct oval_definition_model *model = context->definition_model; oval_schema_version_t version = oval_definition_model_get_core_schema_version(model); if (oval_schema_version_cmp(version, OVAL_SCHEMA_VERSION(5.6)) > 0) { oscap_seterr(OSCAP_EFAMILY_OVAL, "The var_ref attribute for the var_ref entity " "of a variable_object is prohibited since OVAL 5.6. Use plain " "var_ref instead."); } variable = oval_definition_model_get_variable(model, varref); if (variable == NULL) { oscap_seterr(OSCAP_EFAMILY_OVAL, "Could not found variable '%s' referenced by var_ref element.", varref); return_code = -1; } else { oscap_free(varref); varref = NULL; value = NULL; } } } else if (varref == NULL) { variable = NULL; varref_type = OVAL_ENTITY_VARREF_NONE; if (datatype == OVAL_DATATYPE_RECORD) { value = NULL; } else { if (xsi_nil) value = NULL; else return_code = oval_value_parse_tag(reader, context, &oval_consume_value, &value); } } else { struct oval_definition_model *model = context->definition_model; variable = oval_definition_model_get_new_variable(model, varref, OVAL_VARIABLE_UNKNOWN); varref_type = OVAL_ENTITY_VARREF_ATTRIBUTE; value = NULL; oscap_free(varref); varref = NULL; } oval_entity_set_name(entity, name); oval_entity_set_type(entity, type); oval_entity_set_datatype(entity, datatype); oval_entity_set_operation(entity, operation); oval_entity_set_mask(entity, mask); oval_entity_set_varref_type(entity, varref_type); oval_entity_set_variable(entity, variable); oval_entity_set_value(entity, value); oval_entity_set_xsi_nil(entity, xsi_nil); (*consumer) (entity, user); if (return_code != 0) { dW("Parsing of <%s> terminated by an error at line %d.", name, xmlTextReaderGetParserLineNumber(reader)); } oscap_free(name); return return_code; } xmlNode *oval_entity_to_dom(struct oval_entity *entity, xmlDoc * doc, xmlNode * parent) { xmlNsPtr ent_ns = parent->ns; xmlNodePtr root_node = xmlDocGetRootElement(doc); xmlNode *entity_node = NULL; char *content = NULL; struct oval_variable *variable = oval_entity_get_variable(entity); oval_entity_varref_type_t vtype = oval_entity_get_varref_type(entity); struct oval_value *value = oval_entity_get_value(entity); if (vtype == OVAL_ENTITY_VARREF_ELEMENT) { content = oval_variable_get_id(variable); } else if (value) { content = oval_value_get_text(value); } char *tagname = oval_entity_get_name(entity); bool mask = oval_entity_get_mask(entity); /* omit the value and operation used for testing in oval_results if mask=true */ /* Omit it only for older versions of OVAL than 5.10 */ oval_schema_version_t oval_version = oval_definition_model_get_core_schema_version(entity->model); if (oval_schema_version_cmp(oval_version, OVAL_SCHEMA_VERSION(5.10)) < 0 && mask && !xmlStrcmp(root_node->name, BAD_CAST OVAL_ROOT_ELM_RESULTS)) { entity_node = xmlNewTextChild(parent, ent_ns, BAD_CAST tagname, BAD_CAST ""); } else { entity_node = xmlNewTextChild(parent, ent_ns, BAD_CAST tagname, BAD_CAST content); oval_operation_t operation = oval_entity_get_operation(entity); if (operation != OVAL_OPERATION_EQUALS) xmlNewProp(entity_node, BAD_CAST "operation", BAD_CAST oval_operation_get_text(operation)); if (oscap_streq(content, "") && oval_entity_get_xsi_nil(entity)) { // Export @xsi:nil="true" only if it was imported and the content is still empty xmlNewNsProp(entity_node, lookup_xsi_ns(doc), BAD_CAST "nil", BAD_CAST "true"); } } oval_datatype_t datatype = oval_entity_get_datatype(entity); if (datatype != OVAL_DATATYPE_STRING) xmlNewProp(entity_node, BAD_CAST "datatype", BAD_CAST oval_datatype_get_text(datatype)); if (mask) xmlNewProp(entity_node, BAD_CAST "mask", BAD_CAST "true"); if (vtype == OVAL_ENTITY_VARREF_ATTRIBUTE) xmlNewProp(entity_node, BAD_CAST "var_ref", BAD_CAST oval_variable_get_id(variable)); return entity_node; }
lgpl-2.1
alexschlueter/cern-root
interpreter/llvm/src/include/llvm/MC/MCSectionCOFF.h
2516
//===- MCSectionCOFF.h - COFF Machine Code Sections -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares the MCSectionCOFF class. // //===----------------------------------------------------------------------===// #ifndef LLVM_MC_MCSECTIONCOFF_H #define LLVM_MC_MCSECTIONCOFF_H #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCSection.h" #include "llvm/Support/COFF.h" namespace llvm { /// MCSectionCOFF - This represents a section on Windows class MCSectionCOFF : public MCSection { // The memory for this string is stored in the same MCContext as *this. StringRef SectionName; /// Characteristics - This is the Characteristics field of a section, // drawn from the enums below. unsigned Characteristics; /// Selection - This is the Selection field for the section symbol, if /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0 int Selection; private: friend class MCContext; MCSectionCOFF(StringRef Section, unsigned Characteristics, int Selection, SectionKind K) : MCSection(SV_COFF, K), SectionName(Section), Characteristics(Characteristics), Selection (Selection) { assert ((Characteristics & 0x00F00000) == 0 && "alignment must not be set upon section creation"); } ~MCSectionCOFF(); public: /// ShouldOmitSectionDirective - Decides whether a '.section' directive /// should be printed before the section name bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; StringRef getSectionName() const { return SectionName; } virtual std::string getLabelBeginName() const { return SectionName.str() + "_begin"; } virtual std::string getLabelEndName() const { return SectionName.str() + "_end"; } unsigned getCharacteristics() const { return Characteristics; } int getSelection () const { return Selection; } virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; virtual bool UseCodeAlign() const; virtual bool isVirtualSection() const; static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; } }; } // end namespace llvm #endif
lgpl-2.1
JordanReiter/railo
railo-java/railo-core/src/railo/runtime/listener/MixedAppListener.java
797
package railo.runtime.listener; import railo.commons.lang.types.RefBoolean; import railo.commons.lang.types.RefBooleanImpl; import railo.runtime.PageContext; import railo.runtime.PageSource; import railo.runtime.exp.PageException; public final class MixedAppListener extends ModernAppListener { @Override public void onRequest(PageContext pc, PageSource requestedPage, RequestListener rl) throws PageException { RefBoolean isCFC=new RefBooleanImpl(false); PageSource appPS=//pc.isCFCRequest()?null: AppListenerUtil.getApplicationPageSource(pc, requestedPage, mode, isCFC); if(isCFC.toBooleanValue())_onRequest(pc, requestedPage,appPS,rl); else ClassicAppListener._onRequest(pc, requestedPage,appPS,rl); } @Override public final String getType() { return "mixed"; } }
lgpl-2.1
hlamer/kate
tests/data/indent/cppstyle/comment11/input.js
93
v.setCursorPosition(0,19); v.type('/'); v.type('/'); v.type('/'); v.type('/'); v.type("ok");
lgpl-2.1
richardmg/qtcreator
src/plugins/classview/classviewparsertreeitem.h
3290
/************************************************************************** ** ** Copyright (c) 2013 Denis Mingulov ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CLASSVIEWPARSERTREEITEM_H #define CLASSVIEWPARSERTREEITEM_H #include "classviewsymbollocation.h" #include "classviewsymbolinformation.h" #include <QSharedPointer> QT_FORWARD_DECLARE_CLASS(QStandardItem) namespace ClassView { namespace Internal { class ParserTreeItemPrivate; class ParserTreeItem { public: typedef QSharedPointer<ParserTreeItem> Ptr; typedef QSharedPointer<const ParserTreeItem> ConstPtr; public: ParserTreeItem(); ~ParserTreeItem(); void copyTree(const ParserTreeItem::ConstPtr &from); void copy(const ParserTreeItem::ConstPtr &from); void addSymbolLocation(const SymbolLocation &location); void addSymbolLocation(const QSet<SymbolLocation> &locations); void removeSymbolLocation(const SymbolLocation &location); void removeSymbolLocations(const QSet<SymbolLocation> &locations); QSet<SymbolLocation> symbolLocations() const; void appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf); void removeChild(const SymbolInformation &inf); ParserTreeItem::Ptr child(const SymbolInformation &inf) const; int childCount() const; void convertTo(QStandardItem *item, bool recursive = true) const; // additional properties //! Assigned icon QIcon icon() const; //! Set an icon for this tree node void setIcon(const QIcon &icon); void add(const ParserTreeItem::ConstPtr &target); void subtract(const ParserTreeItem::ConstPtr &target); bool canFetchMore(QStandardItem *item) const; void fetchMore(QStandardItem *item) const; void debugDump(int ident = 0) const; protected: ParserTreeItem &operator=(const ParserTreeItem &other); private: //! Private class data pointer ParserTreeItemPrivate *d; }; } // namespace Internal } // namespace ClassView #endif // CLASSVIEWPARSERTREEITEM_H
lgpl-2.1
lefou/kdepim-noakonadi
kaddressbook/viewconfigurefilterpage.cpp
4025
/* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <[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. 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include "viewconfigurefilterpage.h" #include <QtGui/QBoxLayout> #include <QtGui/QButtonGroup> #include <QtGui/QHBoxLayout> #include <QtGui/QLabel> #include <QtGui/QRadioButton> #include <QtGui/QVBoxLayout> #include <kconfig.h> #include <kcombobox.h> #include <kdialog.h> #include <klocale.h> #include "filter.h" ViewConfigureFilterPage::ViewConfigureFilterPage( QWidget *parent, const char *name ) : QWidget( parent ) { setObjectName( name ); QBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setSpacing( KDialog::spacingHint() ); topLayout->setMargin( 0 ); mFilterGroup = new QButtonGroup(); connect( mFilterGroup, SIGNAL( buttonClicked( int ) ), SLOT( buttonClicked( int ) ) ); QLabel *label = new QLabel( i18n( "The default filter will be activated whenever" " this view is displayed. This feature allows you to configure views that only" " interact with certain types of information based on the filter. Once the view" " is activated, the filter can be changed at anytime." ), this ); label->setAlignment( Qt::AlignLeft | Qt::AlignTop ); label->setWordWrap( true ); topLayout->addWidget( label ); QWidget *spacer = new QWidget( this ); spacer->setMinimumHeight( 5 ); topLayout->addWidget( spacer ); QRadioButton *button = new QRadioButton( i18n( "No default filter" ), this ); mFilterGroup->addButton( button,0 ); topLayout->addWidget( button ); button = new QRadioButton( i18n( "Use last active filter" ), this ); mFilterGroup->addButton( button,1 ); topLayout->addWidget( button ); QBoxLayout *comboLayout = new QHBoxLayout(); topLayout->addLayout( comboLayout ); button = new QRadioButton( i18n( "Use filter:" ), this ); mFilterGroup->addButton( button,2 ); comboLayout->addWidget( button ); mFilterCombo = new KComboBox( this ); comboLayout->addWidget( mFilterCombo ); topLayout->addStretch( 100 ); } ViewConfigureFilterPage::~ViewConfigureFilterPage() { } void ViewConfigureFilterPage::restoreSettings( const KConfigGroup &config ) { mFilterCombo->clear(); // Load the filter combo const Filter::List list = Filter::restore( config.config(), "Filter" ); Filter::List::ConstIterator it; for ( it = list.begin(); it != list.end(); ++it ) mFilterCombo->addItem( (*it).name() ); int id = config.readEntry( "DefaultFilterType", 1 ); mFilterGroup->button ( id )->setChecked(true); buttonClicked( id ); if ( id == 2 ) // has default filter mFilterCombo->setItemText( mFilterCombo->currentIndex(), config.readEntry( "DefaultFilterName" ) ); } void ViewConfigureFilterPage::saveSettings( KConfigGroup &config ) { config.writeEntry( "DefaultFilterName", mFilterCombo->currentText() ); config.writeEntry( "DefaultFilterType", mFilterGroup->id( mFilterGroup->checkedButton() ) ); } void ViewConfigureFilterPage::buttonClicked( int id ) { mFilterCombo->setEnabled( id == 2 ); } #include "viewconfigurefilterpage.moc"
lgpl-2.1
RLovelett/qt
src/3rdparty/webkit/WebCore/generated/Grammar.cpp
296109
/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, 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, 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/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ #define yyparse jscyyparse #define yylex jscyylex #define yyerror jscyyerror #define yylval jscyylval #define yychar jscyychar #define yydebug jscyydebug #define yynerrs jscyynerrs #define yylloc jscyylloc /* Copy the first part of user declarations. */ /* Line 189 of yacc.c */ #line 3 "../../JavaScriptCore/parser/Grammar.y" /* * Copyright (C) 1999-2000 Harri Porten ([email protected]) * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2007 Eric Seidel <[email protected]> * * 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 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 Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "config.h" #include <string.h> #include <stdlib.h> #include "JSValue.h" #include "JSObject.h" #include "Nodes.h" #include "Lexer.h" #include "JSString.h" #include "JSGlobalData.h" #include "CommonIdentifiers.h" #include "NodeInfo.h" #include "Parser.h" #include <wtf/MathExtras.h> #define YYMAXDEPTH 10000 #define YYENABLE_NLS 0 /* default values for bison */ #define YYDEBUG 0 // Set to 1 to debug a parse error. #define jscyydebug 0 // Set to 1 to debug a parse error. #if !PLATFORM(DARWIN) // avoid triggering warnings in older bison #define YYERROR_VERBOSE #endif int jscyylex(void* lvalp, void* llocp, void* globalPtr); int jscyyerror(const char*); static inline bool allowAutomaticSemicolon(JSC::Lexer&, int); #define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr) #define LEXER (GLOBAL_DATA->lexer) #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0) #define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceCode((divot), (divot) - (start), (end) - (divot)) #define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line) using namespace JSC; using namespace std; static ExpressionNode* makeAssignNode(void*, ExpressionNode* loc, Operator, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end); static ExpressionNode* makePrefixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end); static ExpressionNode* makePostfixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end); static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceCode&); static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo, int start, int divot, int end); static ExpressionNode* makeTypeOfNode(void*, ExpressionNode*); static ExpressionNode* makeDeleteNode(void*, ExpressionNode*, int start, int divot, int end); static ExpressionNode* makeNegateNode(void*, ExpressionNode*); static NumberNode* makeNumberNode(void*, double); static ExpressionNode* makeBitwiseNotNode(void*, ExpressionNode*); static ExpressionNode* makeMultNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static ExpressionNode* makeDivNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static ExpressionNode* makeAddNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static ExpressionNode* makeSubNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static ExpressionNode* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); static StatementNode* makeVarStatementNode(void*, ExpressionNode*); static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init); #if COMPILER(MSVC) #pragma warning(disable: 4065) #pragma warning(disable: 4244) #pragma warning(disable: 4702) // At least some of the time, the declarations of malloc and free that bison // generates are causing warnings. A way to avoid this is to explicitly define // the macros so that bison doesn't try to declare malloc and free. #define YYMALLOC malloc #define YYFREE free #endif #define YYPARSE_PARAM globalPtr #define YYLEX_PARAM globalPtr template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls, ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls, CodeFeatures info, int numConstants) { ASSERT((info & ~AllFeatures) == 0); NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants}; return result; } template <typename T> NodeInfo<T> createNodeInfo(T node, CodeFeatures info, int numConstants) { ASSERT((info & ~AllFeatures) == 0); NodeInfo<T> result = {node, info, numConstants}; return result; } template <typename T> T mergeDeclarationLists(T decls1, T decls2) { // decls1 or both are null if (!decls1) return decls2; // only decls1 is non-null if (!decls2) return decls1; // Both are non-null decls1->data.append(decls2->data); // We manually release the declaration lists to avoid accumulating many many // unused heap allocated vectors decls2->ref(); decls2->deref(); return decls1; } static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, const Identifier& ident, unsigned attrs) { if (!varDecls) varDecls = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); varDecls->data.append(make_pair(ident, attrs)); } static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, ConstDeclNode* decl) { unsigned attrs = DeclarationStacks::IsConstant; if (decl->m_init) attrs |= DeclarationStacks::HasInitializer; appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs); } /* Line 189 of yacc.c */ #line 236 "Grammar.tab.c" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { NULLTOKEN = 258, TRUETOKEN = 259, FALSETOKEN = 260, BREAK = 261, CASE = 262, DEFAULT = 263, FOR = 264, NEW = 265, VAR = 266, CONSTTOKEN = 267, CONTINUE = 268, FUNCTION = 269, RETURN = 270, VOIDTOKEN = 271, DELETETOKEN = 272, IF = 273, THISTOKEN = 274, DO = 275, WHILE = 276, INTOKEN = 277, INSTANCEOF = 278, TYPEOF = 279, SWITCH = 280, WITH = 281, RESERVED = 282, THROW = 283, TRY = 284, CATCH = 285, FINALLY = 286, DEBUGGER = 287, IF_WITHOUT_ELSE = 288, ELSE = 289, EQEQ = 290, NE = 291, STREQ = 292, STRNEQ = 293, LE = 294, GE = 295, OR = 296, AND = 297, PLUSPLUS = 298, MINUSMINUS = 299, LSHIFT = 300, RSHIFT = 301, URSHIFT = 302, PLUSEQUAL = 303, MINUSEQUAL = 304, MULTEQUAL = 305, DIVEQUAL = 306, LSHIFTEQUAL = 307, RSHIFTEQUAL = 308, URSHIFTEQUAL = 309, ANDEQUAL = 310, MODEQUAL = 311, XOREQUAL = 312, OREQUAL = 313, OPENBRACE = 314, CLOSEBRACE = 315, NUMBER = 316, IDENT = 317, STRING = 318, AUTOPLUSPLUS = 319, AUTOMINUSMINUS = 320 }; #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 214 of yacc.c */ #line 157 "../../JavaScriptCore/parser/Grammar.y" int intValue; double doubleValue; Identifier* ident; // expression subtrees ExpressionNodeInfo expressionNode; FuncDeclNodeInfo funcDeclNode; PropertyNodeInfo propertyNode; ArgumentsNodeInfo argumentsNode; ConstDeclNodeInfo constDeclNode; CaseBlockNodeInfo caseBlockNode; CaseClauseNodeInfo caseClauseNode; FuncExprNodeInfo funcExprNode; // statement nodes StatementNodeInfo statementNode; FunctionBodyNode* functionBodyNode; ProgramNode* programNode; SourceElementsInfo sourceElements; PropertyListInfo propertyList; ArgumentListInfo argumentList; VarDeclListInfo varDeclList; ConstDeclListInfo constDeclList; ClauseListInfo clauseList; ElementListInfo elementList; ParameterListInfo parameterList; Operator op; /* Line 214 of yacc.c */ #line 371 "Grammar.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; } YYLTYPE; # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 264 of yacc.c */ #line 396 "Grammar.tab.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 206 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 2349 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 88 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 194 /* YYNRULES -- Number of rules. */ #define YYNRULES 597 /* YYNRULES -- Number of states. */ #define YYNSTATES 1082 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 320 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 77, 2, 2, 2, 79, 82, 2, 68, 69, 78, 74, 70, 75, 73, 66, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 67, 87, 80, 86, 81, 85, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 71, 2, 72, 83, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 84, 2, 76, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint16 yyprhs[] = { 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, 21, 25, 29, 37, 46, 48, 52, 54, 57, 61, 66, 68, 70, 72, 74, 78, 82, 86, 92, 95, 100, 101, 103, 105, 108, 110, 112, 117, 121, 125, 127, 132, 136, 140, 142, 145, 147, 150, 153, 156, 161, 165, 168, 171, 176, 180, 183, 187, 189, 193, 195, 197, 199, 201, 203, 206, 209, 211, 214, 217, 220, 223, 226, 229, 232, 235, 238, 241, 244, 247, 250, 252, 254, 256, 258, 260, 264, 268, 272, 274, 278, 282, 286, 288, 292, 296, 298, 302, 306, 308, 312, 316, 320, 322, 326, 330, 334, 336, 340, 344, 348, 352, 356, 360, 362, 366, 370, 374, 378, 382, 384, 388, 392, 396, 400, 404, 408, 410, 414, 418, 422, 426, 428, 432, 436, 440, 444, 446, 450, 454, 458, 462, 464, 468, 470, 474, 476, 480, 482, 486, 488, 492, 494, 498, 500, 504, 506, 510, 512, 516, 518, 522, 524, 528, 530, 534, 536, 540, 542, 546, 548, 552, 554, 560, 562, 568, 570, 576, 578, 582, 584, 588, 590, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 624, 626, 630, 632, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 673, 677, 681, 685, 687, 690, 694, 699, 701, 704, 708, 713, 717, 721, 723, 727, 729, 732, 735, 738, 740, 743, 746, 752, 760, 768, 776, 782, 792, 803, 811, 820, 830, 831, 833, 834, 836, 839, 842, 846, 850, 853, 856, 860, 864, 867, 870, 874, 878, 884, 890, 894, 900, 901, 903, 905, 908, 912, 917, 920, 924, 928, 932, 936, 941, 949, 959, 962, 965, 973, 982, 989, 997, 1005, 1014, 1016, 1020, 1021, 1023, 1024, 1026, 1028, 1031, 1033, 1035, 1037, 1039, 1041, 1043, 1045, 1049, 1053, 1057, 1065, 1074, 1076, 1080, 1082, 1085, 1089, 1094, 1096, 1098, 1100, 1102, 1106, 1110, 1114, 1120, 1123, 1128, 1129, 1131, 1133, 1136, 1138, 1140, 1145, 1149, 1153, 1155, 1160, 1164, 1168, 1170, 1173, 1175, 1178, 1181, 1184, 1189, 1193, 1196, 1199, 1204, 1208, 1211, 1215, 1217, 1221, 1223, 1225, 1227, 1229, 1231, 1234, 1237, 1239, 1242, 1245, 1248, 1251, 1254, 1257, 1260, 1263, 1266, 1269, 1272, 1275, 1278, 1280, 1282, 1284, 1286, 1288, 1292, 1296, 1300, 1302, 1306, 1310, 1314, 1316, 1320, 1324, 1326, 1330, 1334, 1336, 1340, 1344, 1348, 1350, 1354, 1358, 1362, 1364, 1368, 1372, 1376, 1380, 1384, 1388, 1390, 1394, 1398, 1402, 1406, 1410, 1412, 1416, 1420, 1424, 1428, 1432, 1436, 1438, 1442, 1446, 1450, 1454, 1456, 1460, 1464, 1468, 1472, 1474, 1478, 1482, 1486, 1490, 1492, 1496, 1498, 1502, 1504, 1508, 1510, 1514, 1516, 1520, 1522, 1526, 1528, 1532, 1534, 1538, 1540, 1544, 1546, 1550, 1552, 1556, 1558, 1562, 1564, 1568, 1570, 1574, 1576, 1580, 1582, 1588, 1590, 1596, 1598, 1604, 1606, 1610, 1612, 1616, 1618, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640, 1642, 1644, 1646, 1648, 1652, 1654, 1658, 1660, 1664, 1666, 1668, 1670, 1672, 1674, 1676, 1678, 1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1701, 1705, 1709, 1713, 1715, 1718, 1722, 1727, 1729, 1732, 1736, 1741, 1745, 1749, 1751, 1755, 1757, 1760, 1763, 1766, 1768, 1771, 1774, 1780, 1788, 1796, 1804, 1810, 1820, 1831, 1839, 1848, 1858, 1859, 1861, 1862, 1864, 1867, 1870, 1874, 1878, 1881, 1884, 1888, 1892, 1895, 1898, 1902, 1906, 1912, 1918, 1922, 1928, 1929, 1931, 1933, 1936, 1940, 1945, 1948, 1952, 1956, 1960, 1964, 1969, 1977, 1987, 1990, 1993, 2001, 2010, 2017, 2025, 2033, 2042, 2044, 2048, 2049, 2051, 2053 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { 184, 0, -1, 3, -1, 4, -1, 5, -1, 61, -1, 63, -1, 66, -1, 51, -1, 62, 67, 143, -1, 63, 67, 143, -1, 61, 67, 143, -1, 62, 62, 68, 69, 59, 183, 60, -1, 62, 62, 68, 182, 69, 59, 183, 60, -1, 90, -1, 91, 70, 90, -1, 93, -1, 59, 60, -1, 59, 91, 60, -1, 59, 91, 70, 60, -1, 19, -1, 89, -1, 94, -1, 62, -1, 68, 147, 69, -1, 71, 96, 72, -1, 71, 95, 72, -1, 71, 95, 70, 96, 72, -1, 96, 143, -1, 95, 70, 96, 143, -1, -1, 97, -1, 70, -1, 97, 70, -1, 92, -1, 181, -1, 98, 71, 147, 72, -1, 98, 73, 62, -1, 10, 98, 104, -1, 93, -1, 99, 71, 147, 72, -1, 99, 73, 62, -1, 10, 98, 104, -1, 98, -1, 10, 100, -1, 99, -1, 10, 100, -1, 98, 104, -1, 102, 104, -1, 102, 71, 147, 72, -1, 102, 73, 62, -1, 99, 104, -1, 103, 104, -1, 103, 71, 147, 72, -1, 103, 73, 62, -1, 68, 69, -1, 68, 105, 69, -1, 143, -1, 105, 70, 143, -1, 100, -1, 102, -1, 101, -1, 103, -1, 106, -1, 106, 43, -1, 106, 44, -1, 107, -1, 107, 43, -1, 107, 44, -1, 17, 111, -1, 16, 111, -1, 24, 111, -1, 43, 111, -1, 64, 111, -1, 44, 111, -1, 65, 111, -1, 74, 111, -1, 75, 111, -1, 76, 111, -1, 77, 111, -1, 108, -1, 110, -1, 109, -1, 110, -1, 111, -1, 113, 78, 111, -1, 113, 66, 111, -1, 113, 79, 111, -1, 112, -1, 114, 78, 111, -1, 114, 66, 111, -1, 114, 79, 111, -1, 113, -1, 115, 74, 113, -1, 115, 75, 113, -1, 114, -1, 116, 74, 113, -1, 116, 75, 113, -1, 115, -1, 117, 45, 115, -1, 117, 46, 115, -1, 117, 47, 115, -1, 116, -1, 118, 45, 115, -1, 118, 46, 115, -1, 118, 47, 115, -1, 117, -1, 119, 80, 117, -1, 119, 81, 117, -1, 119, 39, 117, -1, 119, 40, 117, -1, 119, 23, 117, -1, 119, 22, 117, -1, 117, -1, 120, 80, 117, -1, 120, 81, 117, -1, 120, 39, 117, -1, 120, 40, 117, -1, 120, 23, 117, -1, 118, -1, 121, 80, 117, -1, 121, 81, 117, -1, 121, 39, 117, -1, 121, 40, 117, -1, 121, 23, 117, -1, 121, 22, 117, -1, 119, -1, 122, 35, 119, -1, 122, 36, 119, -1, 122, 37, 119, -1, 122, 38, 119, -1, 120, -1, 123, 35, 120, -1, 123, 36, 120, -1, 123, 37, 120, -1, 123, 38, 120, -1, 121, -1, 124, 35, 119, -1, 124, 36, 119, -1, 124, 37, 119, -1, 124, 38, 119, -1, 122, -1, 125, 82, 122, -1, 123, -1, 126, 82, 123, -1, 124, -1, 127, 82, 122, -1, 125, -1, 128, 83, 125, -1, 126, -1, 129, 83, 126, -1, 127, -1, 130, 83, 125, -1, 128, -1, 131, 84, 128, -1, 129, -1, 132, 84, 129, -1, 130, -1, 133, 84, 128, -1, 131, -1, 134, 42, 131, -1, 132, -1, 135, 42, 132, -1, 133, -1, 136, 42, 131, -1, 134, -1, 137, 41, 134, -1, 135, -1, 138, 41, 135, -1, 136, -1, 139, 41, 134, -1, 137, -1, 137, 85, 143, 67, 143, -1, 138, -1, 138, 85, 144, 67, 144, -1, 139, -1, 139, 85, 143, 67, 143, -1, 140, -1, 106, 146, 143, -1, 141, -1, 106, 146, 144, -1, 142, -1, 107, 146, 143, -1, 86, -1, 48, -1, 49, -1, 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, -1, 57, -1, 58, -1, 56, -1, 143, -1, 147, 70, 143, -1, 144, -1, 148, 70, 144, -1, 145, -1, 149, 70, 143, -1, 151, -1, 152, -1, 155, -1, 180, -1, 160, -1, 161, -1, 162, -1, 163, -1, 166, -1, 167, -1, 168, -1, 169, -1, 170, -1, 176, -1, 177, -1, 178, -1, 179, -1, 59, 60, -1, 59, 185, 60, -1, 11, 153, 87, -1, 11, 153, 1, -1, 62, -1, 62, 158, -1, 153, 70, 62, -1, 153, 70, 62, 158, -1, 62, -1, 62, 159, -1, 154, 70, 62, -1, 154, 70, 62, 159, -1, 12, 156, 87, -1, 12, 156, 1, -1, 157, -1, 156, 70, 157, -1, 62, -1, 62, 158, -1, 86, 143, -1, 86, 144, -1, 87, -1, 149, 87, -1, 149, 1, -1, 18, 68, 147, 69, 150, -1, 18, 68, 147, 69, 150, 34, 150, -1, 20, 150, 21, 68, 147, 69, 87, -1, 20, 150, 21, 68, 147, 69, 1, -1, 21, 68, 147, 69, 150, -1, 9, 68, 165, 87, 164, 87, 164, 69, 150, -1, 9, 68, 11, 154, 87, 164, 87, 164, 69, 150, -1, 9, 68, 106, 22, 147, 69, 150, -1, 9, 68, 11, 62, 22, 147, 69, 150, -1, 9, 68, 11, 62, 159, 22, 147, 69, 150, -1, -1, 147, -1, -1, 148, -1, 13, 87, -1, 13, 1, -1, 13, 62, 87, -1, 13, 62, 1, -1, 6, 87, -1, 6, 1, -1, 6, 62, 87, -1, 6, 62, 1, -1, 15, 87, -1, 15, 1, -1, 15, 147, 87, -1, 15, 147, 1, -1, 26, 68, 147, 69, 150, -1, 25, 68, 147, 69, 171, -1, 59, 172, 60, -1, 59, 172, 175, 172, 60, -1, -1, 173, -1, 174, -1, 173, 174, -1, 7, 147, 67, -1, 7, 147, 67, 185, -1, 8, 67, -1, 8, 67, 185, -1, 62, 67, 150, -1, 28, 147, 87, -1, 28, 147, 1, -1, 29, 151, 31, 151, -1, 29, 151, 30, 68, 62, 69, 151, -1, 29, 151, 30, 68, 62, 69, 151, 31, 151, -1, 32, 87, -1, 32, 1, -1, 14, 62, 68, 69, 59, 183, 60, -1, 14, 62, 68, 182, 69, 59, 183, 60, -1, 14, 68, 69, 59, 183, 60, -1, 14, 68, 182, 69, 59, 183, 60, -1, 14, 62, 68, 69, 59, 183, 60, -1, 14, 62, 68, 182, 69, 59, 183, 60, -1, 62, -1, 182, 70, 62, -1, -1, 281, -1, -1, 185, -1, 150, -1, 185, 150, -1, 3, -1, 4, -1, 5, -1, 61, -1, 63, -1, 66, -1, 51, -1, 62, 67, 240, -1, 63, 67, 240, -1, 61, 67, 240, -1, 62, 62, 68, 69, 59, 280, 60, -1, 62, 62, 68, 279, 69, 59, 280, 60, -1, 187, -1, 188, 70, 187, -1, 190, -1, 59, 60, -1, 59, 188, 60, -1, 59, 188, 70, 60, -1, 19, -1, 186, -1, 191, -1, 62, -1, 68, 244, 69, -1, 71, 193, 72, -1, 71, 192, 72, -1, 71, 192, 70, 193, 72, -1, 193, 240, -1, 192, 70, 193, 240, -1, -1, 194, -1, 70, -1, 194, 70, -1, 189, -1, 278, -1, 195, 71, 244, 72, -1, 195, 73, 62, -1, 10, 195, 201, -1, 190, -1, 196, 71, 244, 72, -1, 196, 73, 62, -1, 10, 195, 201, -1, 195, -1, 10, 197, -1, 196, -1, 10, 197, -1, 195, 201, -1, 199, 201, -1, 199, 71, 244, 72, -1, 199, 73, 62, -1, 196, 201, -1, 200, 201, -1, 200, 71, 244, 72, -1, 200, 73, 62, -1, 68, 69, -1, 68, 202, 69, -1, 240, -1, 202, 70, 240, -1, 197, -1, 199, -1, 198, -1, 200, -1, 203, -1, 203, 43, -1, 203, 44, -1, 204, -1, 204, 43, -1, 204, 44, -1, 17, 208, -1, 16, 208, -1, 24, 208, -1, 43, 208, -1, 64, 208, -1, 44, 208, -1, 65, 208, -1, 74, 208, -1, 75, 208, -1, 76, 208, -1, 77, 208, -1, 205, -1, 207, -1, 206, -1, 207, -1, 208, -1, 210, 78, 208, -1, 210, 66, 208, -1, 210, 79, 208, -1, 209, -1, 211, 78, 208, -1, 211, 66, 208, -1, 211, 79, 208, -1, 210, -1, 212, 74, 210, -1, 212, 75, 210, -1, 211, -1, 213, 74, 210, -1, 213, 75, 210, -1, 212, -1, 214, 45, 212, -1, 214, 46, 212, -1, 214, 47, 212, -1, 213, -1, 215, 45, 212, -1, 215, 46, 212, -1, 215, 47, 212, -1, 214, -1, 216, 80, 214, -1, 216, 81, 214, -1, 216, 39, 214, -1, 216, 40, 214, -1, 216, 23, 214, -1, 216, 22, 214, -1, 214, -1, 217, 80, 214, -1, 217, 81, 214, -1, 217, 39, 214, -1, 217, 40, 214, -1, 217, 23, 214, -1, 215, -1, 218, 80, 214, -1, 218, 81, 214, -1, 218, 39, 214, -1, 218, 40, 214, -1, 218, 23, 214, -1, 218, 22, 214, -1, 216, -1, 219, 35, 216, -1, 219, 36, 216, -1, 219, 37, 216, -1, 219, 38, 216, -1, 217, -1, 220, 35, 217, -1, 220, 36, 217, -1, 220, 37, 217, -1, 220, 38, 217, -1, 218, -1, 221, 35, 216, -1, 221, 36, 216, -1, 221, 37, 216, -1, 221, 38, 216, -1, 219, -1, 222, 82, 219, -1, 220, -1, 223, 82, 220, -1, 221, -1, 224, 82, 219, -1, 222, -1, 225, 83, 222, -1, 223, -1, 226, 83, 223, -1, 224, -1, 227, 83, 222, -1, 225, -1, 228, 84, 225, -1, 226, -1, 229, 84, 226, -1, 227, -1, 230, 84, 225, -1, 228, -1, 231, 42, 228, -1, 229, -1, 232, 42, 229, -1, 230, -1, 233, 42, 228, -1, 231, -1, 234, 41, 231, -1, 232, -1, 235, 41, 232, -1, 233, -1, 236, 41, 231, -1, 234, -1, 234, 85, 240, 67, 240, -1, 235, -1, 235, 85, 241, 67, 241, -1, 236, -1, 236, 85, 240, 67, 240, -1, 237, -1, 203, 243, 240, -1, 238, -1, 203, 243, 241, -1, 239, -1, 204, 243, 240, -1, 86, -1, 48, -1, 49, -1, 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, -1, 57, -1, 58, -1, 56, -1, 240, -1, 244, 70, 240, -1, 241, -1, 245, 70, 241, -1, 242, -1, 246, 70, 240, -1, 248, -1, 249, -1, 252, -1, 277, -1, 257, -1, 258, -1, 259, -1, 260, -1, 263, -1, 264, -1, 265, -1, 266, -1, 267, -1, 273, -1, 274, -1, 275, -1, 276, -1, 59, 60, -1, 59, 281, 60, -1, 11, 250, 87, -1, 11, 250, 1, -1, 62, -1, 62, 255, -1, 250, 70, 62, -1, 250, 70, 62, 255, -1, 62, -1, 62, 256, -1, 251, 70, 62, -1, 251, 70, 62, 256, -1, 12, 253, 87, -1, 12, 253, 1, -1, 254, -1, 253, 70, 254, -1, 62, -1, 62, 255, -1, 86, 240, -1, 86, 241, -1, 87, -1, 246, 87, -1, 246, 1, -1, 18, 68, 244, 69, 247, -1, 18, 68, 244, 69, 247, 34, 247, -1, 20, 247, 21, 68, 244, 69, 87, -1, 20, 247, 21, 68, 244, 69, 1, -1, 21, 68, 244, 69, 247, -1, 9, 68, 262, 87, 261, 87, 261, 69, 247, -1, 9, 68, 11, 251, 87, 261, 87, 261, 69, 247, -1, 9, 68, 203, 22, 244, 69, 247, -1, 9, 68, 11, 62, 22, 244, 69, 247, -1, 9, 68, 11, 62, 256, 22, 244, 69, 247, -1, -1, 244, -1, -1, 245, -1, 13, 87, -1, 13, 1, -1, 13, 62, 87, -1, 13, 62, 1, -1, 6, 87, -1, 6, 1, -1, 6, 62, 87, -1, 6, 62, 1, -1, 15, 87, -1, 15, 1, -1, 15, 244, 87, -1, 15, 244, 1, -1, 26, 68, 244, 69, 247, -1, 25, 68, 244, 69, 268, -1, 59, 269, 60, -1, 59, 269, 272, 269, 60, -1, -1, 270, -1, 271, -1, 270, 271, -1, 7, 244, 67, -1, 7, 244, 67, 281, -1, 8, 67, -1, 8, 67, 281, -1, 62, 67, 247, -1, 28, 244, 87, -1, 28, 244, 1, -1, 29, 248, 31, 248, -1, 29, 248, 30, 68, 62, 69, 248, -1, 29, 248, 30, 68, 62, 69, 248, 31, 248, -1, 32, 87, -1, 32, 1, -1, 14, 62, 68, 69, 59, 280, 60, -1, 14, 62, 68, 279, 69, 59, 280, 60, -1, 14, 68, 69, 59, 280, 60, -1, 14, 68, 279, 69, 59, 280, 60, -1, 14, 62, 68, 69, 59, 280, 60, -1, 14, 62, 68, 279, 69, 59, 280, 60, -1, 62, -1, 279, 70, 62, -1, -1, 281, -1, 247, -1, 281, 247, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 290, 290, 291, 292, 293, 294, 295, 304, 316, 317, 318, 319, 320, 332, 336, 343, 344, 345, 347, 351, 352, 353, 354, 355, 359, 360, 361, 365, 369, 377, 378, 382, 383, 387, 388, 389, 393, 397, 404, 405, 409, 413, 420, 421, 428, 429, 436, 437, 438, 442, 448, 449, 450, 454, 461, 462, 466, 470, 477, 478, 482, 483, 487, 488, 489, 493, 494, 495, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 512, 513, 517, 518, 522, 523, 524, 525, 529, 530, 532, 534, 539, 540, 541, 545, 546, 548, 553, 554, 555, 556, 560, 561, 562, 563, 567, 568, 569, 570, 571, 572, 575, 581, 582, 583, 584, 585, 586, 593, 594, 595, 596, 597, 598, 602, 609, 610, 611, 612, 613, 617, 618, 620, 622, 624, 629, 630, 632, 633, 635, 640, 641, 645, 646, 651, 652, 656, 657, 661, 662, 667, 668, 673, 674, 678, 679, 684, 685, 690, 691, 695, 696, 701, 702, 707, 708, 712, 713, 718, 719, 723, 724, 729, 730, 735, 736, 741, 742, 749, 750, 757, 758, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 780, 781, 785, 786, 790, 791, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 815, 817, 822, 824, 830, 837, 846, 854, 867, 874, 883, 891, 904, 906, 912, 920, 932, 933, 937, 941, 945, 949, 951, 956, 959, 968, 970, 972, 974, 980, 987, 996, 1002, 1013, 1014, 1018, 1019, 1023, 1027, 1031, 1035, 1042, 1045, 1048, 1051, 1057, 1060, 1063, 1066, 1072, 1078, 1084, 1085, 1094, 1095, 1099, 1105, 1115, 1116, 1120, 1121, 1125, 1131, 1135, 1142, 1148, 1154, 1164, 1166, 1171, 1172, 1183, 1184, 1191, 1192, 1202, 1205, 1211, 1212, 1216, 1217, 1222, 1229, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1250, 1251, 1252, 1253, 1254, 1258, 1259, 1263, 1264, 1265, 1267, 1271, 1272, 1273, 1274, 1275, 1279, 1280, 1281, 1285, 1286, 1289, 1291, 1295, 1296, 1300, 1301, 1302, 1303, 1304, 1308, 1309, 1310, 1311, 1315, 1316, 1320, 1321, 1325, 1326, 1327, 1328, 1332, 1333, 1334, 1335, 1339, 1340, 1344, 1345, 1349, 1350, 1354, 1355, 1359, 1360, 1361, 1365, 1366, 1367, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1384, 1385, 1389, 1390, 1394, 1395, 1396, 1397, 1401, 1402, 1403, 1404, 1408, 1409, 1410, 1414, 1415, 1416, 1420, 1421, 1422, 1423, 1427, 1428, 1429, 1430, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1444, 1445, 1446, 1447, 1448, 1449, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1463, 1464, 1465, 1466, 1467, 1471, 1472, 1473, 1474, 1475, 1479, 1480, 1481, 1482, 1483, 1487, 1488, 1492, 1493, 1497, 1498, 1502, 1503, 1507, 1508, 1512, 1513, 1517, 1518, 1522, 1523, 1527, 1528, 1532, 1533, 1537, 1538, 1542, 1543, 1547, 1548, 1552, 1553, 1557, 1558, 1562, 1563, 1567, 1568, 1572, 1573, 1577, 1578, 1582, 1583, 1587, 1588, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1607, 1608, 1612, 1613, 1617, 1618, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1642, 1643, 1647, 1648, 1652, 1653, 1654, 1655, 1659, 1660, 1661, 1662, 1666, 1667, 1671, 1672, 1676, 1677, 1681, 1685, 1689, 1693, 1694, 1698, 1699, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1713, 1715, 1718, 1720, 1724, 1725, 1726, 1727, 1731, 1732, 1733, 1734, 1738, 1739, 1740, 1741, 1745, 1749, 1753, 1754, 1757, 1759, 1763, 1764, 1768, 1769, 1773, 1774, 1778, 1782, 1783, 1787, 1788, 1789, 1793, 1794, 1798, 1799, 1803, 1804, 1805, 1806, 1810, 1811, 1814, 1816, 1820, 1821 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "NULLTOKEN", "TRUETOKEN", "FALSETOKEN", "BREAK", "CASE", "DEFAULT", "FOR", "NEW", "VAR", "CONSTTOKEN", "CONTINUE", "FUNCTION", "RETURN", "VOIDTOKEN", "DELETETOKEN", "IF", "THISTOKEN", "DO", "WHILE", "INTOKEN", "INSTANCEOF", "TYPEOF", "SWITCH", "WITH", "RESERVED", "THROW", "TRY", "CATCH", "FINALLY", "DEBUGGER", "IF_WITHOUT_ELSE", "ELSE", "EQEQ", "NE", "STREQ", "STRNEQ", "LE", "GE", "OR", "AND", "PLUSPLUS", "MINUSMINUS", "LSHIFT", "RSHIFT", "URSHIFT", "PLUSEQUAL", "MINUSEQUAL", "MULTEQUAL", "DIVEQUAL", "LSHIFTEQUAL", "RSHIFTEQUAL", "URSHIFTEQUAL", "ANDEQUAL", "MODEQUAL", "XOREQUAL", "OREQUAL", "OPENBRACE", "CLOSEBRACE", "NUMBER", "IDENT", "STRING", "AUTOPLUSPLUS", "AUTOMINUSMINUS", "'/'", "':'", "'('", "')'", "','", "'['", "']'", "'.'", "'+'", "'-'", "'~'", "'!'", "'*'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "'='", "';'", "$accept", "Literal", "Property", "PropertyList", "PrimaryExpr", "PrimaryExprNoBrace", "ArrayLiteral", "ElementList", "ElisionOpt", "Elision", "MemberExpr", "MemberExprNoBF", "NewExpr", "NewExprNoBF", "CallExpr", "CallExprNoBF", "Arguments", "ArgumentList", "LeftHandSideExpr", "LeftHandSideExprNoBF", "PostfixExpr", "PostfixExprNoBF", "UnaryExprCommon", "UnaryExpr", "UnaryExprNoBF", "MultiplicativeExpr", "MultiplicativeExprNoBF", "AdditiveExpr", "AdditiveExprNoBF", "ShiftExpr", "ShiftExprNoBF", "RelationalExpr", "RelationalExprNoIn", "RelationalExprNoBF", "EqualityExpr", "EqualityExprNoIn", "EqualityExprNoBF", "BitwiseANDExpr", "BitwiseANDExprNoIn", "BitwiseANDExprNoBF", "BitwiseXORExpr", "BitwiseXORExprNoIn", "BitwiseXORExprNoBF", "BitwiseORExpr", "BitwiseORExprNoIn", "BitwiseORExprNoBF", "LogicalANDExpr", "LogicalANDExprNoIn", "LogicalANDExprNoBF", "LogicalORExpr", "LogicalORExprNoIn", "LogicalORExprNoBF", "ConditionalExpr", "ConditionalExprNoIn", "ConditionalExprNoBF", "AssignmentExpr", "AssignmentExprNoIn", "AssignmentExprNoBF", "AssignmentOperator", "Expr", "ExprNoIn", "ExprNoBF", "Statement", "Block", "VariableStatement", "VariableDeclarationList", "VariableDeclarationListNoIn", "ConstStatement", "ConstDeclarationList", "ConstDeclaration", "Initializer", "InitializerNoIn", "EmptyStatement", "ExprStatement", "IfStatement", "IterationStatement", "ExprOpt", "ExprNoInOpt", "ContinueStatement", "BreakStatement", "ReturnStatement", "WithStatement", "SwitchStatement", "CaseBlock", "CaseClausesOpt", "CaseClauses", "CaseClause", "DefaultClause", "LabelledStatement", "ThrowStatement", "TryStatement", "DebuggerStatement", "FunctionDeclaration", "FunctionExpr", "FormalParameterList", "FunctionBody", "Program", "SourceElements", "Literal_NoNode", "Property_NoNode", "PropertyList_NoNode", "PrimaryExpr_NoNode", "PrimaryExprNoBrace_NoNode", "ArrayLiteral_NoNode", "ElementList_NoNode", "ElisionOpt_NoNode", "Elision_NoNode", "MemberExpr_NoNode", "MemberExprNoBF_NoNode", "NewExpr_NoNode", "NewExprNoBF_NoNode", "CallExpr_NoNode", "CallExprNoBF_NoNode", "Arguments_NoNode", "ArgumentList_NoNode", "LeftHandSideExpr_NoNode", "LeftHandSideExprNoBF_NoNode", "PostfixExpr_NoNode", "PostfixExprNoBF_NoNode", "UnaryExprCommon_NoNode", "UnaryExpr_NoNode", "UnaryExprNoBF_NoNode", "MultiplicativeExpr_NoNode", "MultiplicativeExprNoBF_NoNode", "AdditiveExpr_NoNode", "AdditiveExprNoBF_NoNode", "ShiftExpr_NoNode", "ShiftExprNoBF_NoNode", "RelationalExpr_NoNode", "RelationalExprNoIn_NoNode", "RelationalExprNoBF_NoNode", "EqualityExpr_NoNode", "EqualityExprNoIn_NoNode", "EqualityExprNoBF_NoNode", "BitwiseANDExpr_NoNode", "BitwiseANDExprNoIn_NoNode", "BitwiseANDExprNoBF_NoNode", "BitwiseXORExpr_NoNode", "BitwiseXORExprNoIn_NoNode", "BitwiseXORExprNoBF_NoNode", "BitwiseORExpr_NoNode", "BitwiseORExprNoIn_NoNode", "BitwiseORExprNoBF_NoNode", "LogicalANDExpr_NoNode", "LogicalANDExprNoIn_NoNode", "LogicalANDExprNoBF_NoNode", "LogicalORExpr_NoNode", "LogicalORExprNoIn_NoNode", "LogicalORExprNoBF_NoNode", "ConditionalExpr_NoNode", "ConditionalExprNoIn_NoNode", "ConditionalExprNoBF_NoNode", "AssignmentExpr_NoNode", "AssignmentExprNoIn_NoNode", "AssignmentExprNoBF_NoNode", "AssignmentOperator_NoNode", "Expr_NoNode", "ExprNoIn_NoNode", "ExprNoBF_NoNode", "Statement_NoNode", "Block_NoNode", "VariableStatement_NoNode", "VariableDeclarationList_NoNode", "VariableDeclarationListNoIn_NoNode", "ConstStatement_NoNode", "ConstDeclarationList_NoNode", "ConstDeclaration_NoNode", "Initializer_NoNode", "InitializerNoIn_NoNode", "EmptyStatement_NoNode", "ExprStatement_NoNode", "IfStatement_NoNode", "IterationStatement_NoNode", "ExprOpt_NoNode", "ExprNoInOpt_NoNode", "ContinueStatement_NoNode", "BreakStatement_NoNode", "ReturnStatement_NoNode", "WithStatement_NoNode", "SwitchStatement_NoNode", "CaseBlock_NoNode", "CaseClausesOpt_NoNode", "CaseClauses_NoNode", "CaseClause_NoNode", "DefaultClause_NoNode", "LabelledStatement_NoNode", "ThrowStatement_NoNode", "TryStatement_NoNode", "DebuggerStatement_NoNode", "FunctionDeclaration_NoNode", "FunctionExpr_NoNode", "FormalParameterList_NoNode", "FunctionBody_NoNode", "SourceElements_NoNode", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 47, 58, 40, 41, 44, 91, 93, 46, 43, 45, 126, 33, 42, 37, 60, 62, 38, 94, 124, 63, 61, 59 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { 0, 88, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90, 91, 91, 92, 92, 92, 92, 93, 93, 93, 93, 93, 94, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 100, 100, 101, 101, 102, 102, 102, 102, 103, 103, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 108, 109, 109, 109, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 111, 111, 112, 112, 113, 113, 113, 113, 114, 114, 114, 114, 115, 115, 115, 116, 116, 116, 117, 117, 117, 117, 118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, 139, 139, 140, 140, 141, 141, 142, 142, 143, 143, 144, 144, 145, 145, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 147, 147, 148, 148, 149, 149, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, 151, 152, 152, 153, 153, 153, 153, 154, 154, 154, 154, 155, 155, 156, 156, 157, 157, 158, 159, 160, 161, 161, 162, 162, 163, 163, 163, 163, 163, 163, 163, 163, 164, 164, 165, 165, 166, 166, 166, 166, 167, 167, 167, 167, 168, 168, 168, 168, 169, 170, 171, 171, 172, 172, 173, 173, 174, 174, 175, 175, 176, 177, 177, 178, 178, 178, 179, 179, 180, 180, 181, 181, 181, 181, 182, 182, 183, 183, 184, 184, 185, 185, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194, 195, 195, 195, 195, 195, 196, 196, 196, 196, 197, 197, 198, 198, 199, 199, 199, 199, 200, 200, 200, 200, 201, 201, 202, 202, 203, 203, 204, 204, 205, 205, 205, 206, 206, 206, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, 209, 209, 210, 210, 210, 210, 211, 211, 211, 211, 212, 212, 212, 213, 213, 213, 214, 214, 214, 214, 215, 215, 215, 215, 216, 216, 216, 216, 216, 216, 216, 217, 217, 217, 217, 217, 217, 218, 218, 218, 218, 218, 218, 218, 219, 219, 219, 219, 219, 220, 220, 220, 220, 220, 221, 221, 221, 221, 221, 222, 222, 223, 223, 224, 224, 225, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 248, 248, 249, 249, 250, 250, 250, 250, 251, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255, 256, 257, 258, 258, 259, 259, 260, 260, 260, 260, 260, 260, 260, 260, 261, 261, 262, 262, 263, 263, 263, 263, 264, 264, 264, 264, 265, 265, 265, 265, 266, 267, 268, 268, 269, 269, 270, 270, 271, 271, 272, 272, 273, 274, 274, 275, 275, 275, 276, 276, 277, 277, 278, 278, 278, 278, 279, 279, 280, 280, 281, 281 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 7, 8, 1, 3, 1, 2, 3, 4, 1, 1, 1, 1, 3, 3, 3, 5, 2, 4, 0, 1, 1, 2, 1, 1, 4, 3, 3, 1, 4, 3, 3, 1, 2, 1, 2, 2, 2, 4, 3, 2, 2, 4, 3, 2, 3, 1, 3, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, 1, 5, 1, 5, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 1, 2, 3, 4, 1, 2, 3, 4, 3, 3, 1, 3, 1, 2, 2, 2, 1, 2, 2, 5, 7, 7, 7, 5, 9, 10, 7, 8, 9, 0, 1, 0, 1, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 5, 5, 3, 5, 0, 1, 1, 2, 3, 4, 2, 3, 3, 3, 3, 4, 7, 9, 2, 2, 7, 8, 6, 7, 7, 8, 1, 3, 0, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 7, 8, 1, 3, 1, 2, 3, 4, 1, 1, 1, 1, 3, 3, 3, 5, 2, 4, 0, 1, 1, 2, 1, 1, 4, 3, 3, 1, 4, 3, 3, 1, 2, 1, 2, 2, 2, 4, 3, 2, 2, 4, 3, 2, 3, 1, 3, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, 1, 5, 1, 5, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 1, 2, 3, 4, 1, 2, 3, 4, 3, 3, 1, 3, 1, 2, 2, 2, 1, 2, 2, 5, 7, 7, 7, 5, 9, 10, 7, 8, 9, 0, 1, 0, 1, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 5, 5, 3, 5, 0, 1, 1, 2, 3, 4, 2, 3, 3, 3, 3, 4, 7, 9, 2, 2, 7, 8, 6, 7, 7, 8, 1, 3, 0, 1, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { 297, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 5, 23, 6, 0, 0, 7, 0, 30, 0, 0, 0, 0, 238, 21, 39, 22, 45, 61, 62, 66, 82, 83, 88, 95, 102, 119, 136, 145, 151, 157, 163, 169, 175, 181, 199, 0, 299, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 204, 0, 298, 260, 0, 259, 253, 0, 0, 0, 23, 34, 16, 43, 46, 35, 222, 0, 234, 0, 232, 256, 0, 255, 0, 264, 263, 43, 59, 60, 63, 80, 81, 84, 92, 98, 106, 126, 141, 147, 153, 159, 165, 171, 177, 195, 0, 63, 70, 69, 0, 0, 0, 71, 0, 0, 0, 0, 286, 285, 72, 74, 218, 0, 0, 73, 75, 0, 32, 0, 0, 31, 76, 77, 78, 79, 0, 0, 0, 51, 0, 0, 52, 67, 68, 184, 185, 186, 187, 188, 189, 190, 191, 194, 192, 193, 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 239, 1, 300, 262, 261, 0, 63, 113, 131, 143, 149, 155, 161, 167, 173, 179, 197, 254, 0, 43, 44, 0, 0, 17, 0, 0, 0, 14, 0, 0, 0, 42, 0, 223, 221, 0, 220, 235, 231, 0, 230, 258, 257, 0, 47, 0, 0, 48, 64, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 266, 0, 265, 0, 0, 0, 0, 0, 281, 280, 0, 0, 219, 279, 24, 30, 26, 25, 28, 33, 55, 0, 57, 0, 41, 0, 54, 182, 90, 89, 91, 96, 97, 103, 104, 105, 125, 124, 122, 123, 120, 121, 137, 138, 139, 140, 146, 152, 158, 164, 170, 0, 200, 226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, 38, 0, 293, 0, 0, 0, 0, 0, 0, 18, 0, 0, 37, 236, 224, 233, 0, 0, 0, 50, 178, 86, 85, 87, 93, 94, 99, 100, 101, 112, 111, 109, 110, 107, 108, 127, 128, 129, 130, 142, 148, 154, 160, 166, 0, 196, 0, 0, 0, 0, 0, 0, 282, 0, 56, 0, 40, 53, 0, 0, 0, 227, 0, 251, 0, 63, 180, 118, 116, 117, 114, 115, 132, 133, 134, 135, 144, 150, 156, 162, 168, 0, 198, 252, 0, 0, 0, 295, 0, 0, 11, 0, 9, 10, 19, 15, 36, 225, 295, 0, 49, 0, 241, 0, 245, 271, 268, 267, 0, 27, 29, 58, 176, 0, 237, 0, 228, 0, 0, 0, 251, 295, 0, 301, 302, 303, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 307, 0, 304, 322, 305, 0, 0, 306, 0, 329, 0, 0, 0, 0, 537, 0, 320, 338, 321, 344, 360, 361, 365, 381, 382, 387, 394, 401, 418, 435, 444, 450, 456, 462, 468, 474, 480, 498, 0, 596, 500, 501, 502, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 503, 296, 295, 294, 0, 0, 0, 295, 172, 0, 0, 0, 0, 272, 273, 0, 0, 0, 229, 251, 248, 174, 0, 0, 295, 559, 0, 558, 552, 0, 0, 0, 322, 333, 315, 342, 345, 334, 521, 0, 533, 0, 531, 555, 0, 554, 0, 563, 562, 342, 358, 359, 362, 379, 380, 383, 391, 397, 405, 425, 440, 446, 452, 458, 464, 470, 476, 494, 0, 362, 369, 368, 0, 0, 0, 370, 0, 0, 0, 0, 585, 584, 371, 373, 517, 0, 0, 372, 374, 0, 331, 0, 0, 330, 375, 376, 377, 378, 289, 0, 0, 0, 350, 0, 0, 351, 366, 367, 483, 484, 485, 486, 487, 488, 489, 490, 493, 491, 492, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 539, 0, 538, 597, 0, 295, 0, 287, 0, 242, 244, 243, 0, 0, 269, 271, 274, 283, 249, 0, 0, 0, 291, 0, 561, 560, 0, 362, 412, 430, 442, 448, 454, 460, 466, 472, 478, 496, 553, 0, 342, 343, 0, 0, 316, 0, 0, 0, 313, 0, 0, 0, 341, 0, 522, 520, 0, 519, 534, 530, 0, 529, 557, 556, 0, 346, 0, 0, 347, 363, 364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 565, 0, 564, 0, 0, 0, 0, 0, 580, 579, 0, 0, 518, 578, 323, 329, 325, 324, 327, 332, 354, 0, 356, 0, 340, 0, 353, 481, 389, 388, 390, 395, 396, 402, 403, 404, 424, 423, 421, 422, 419, 420, 436, 437, 438, 439, 445, 451, 457, 463, 469, 0, 499, 290, 0, 295, 288, 275, 277, 0, 0, 250, 0, 246, 292, 525, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 550, 337, 0, 592, 0, 0, 0, 0, 0, 0, 317, 0, 0, 336, 535, 523, 532, 0, 0, 0, 349, 477, 385, 384, 386, 392, 393, 398, 399, 400, 411, 410, 408, 409, 406, 407, 426, 427, 428, 429, 441, 447, 453, 459, 465, 0, 495, 0, 0, 0, 0, 0, 0, 581, 0, 355, 0, 339, 352, 0, 12, 0, 276, 278, 270, 284, 247, 0, 0, 526, 0, 550, 0, 362, 479, 417, 415, 416, 413, 414, 431, 432, 433, 434, 443, 449, 455, 461, 467, 0, 497, 551, 0, 0, 0, 594, 0, 0, 310, 0, 308, 309, 318, 314, 335, 524, 594, 0, 348, 0, 540, 0, 544, 570, 567, 566, 0, 326, 328, 357, 475, 13, 0, 536, 0, 527, 0, 0, 0, 550, 594, 0, 0, 595, 594, 593, 0, 0, 0, 594, 471, 0, 0, 0, 0, 571, 572, 0, 0, 0, 528, 550, 547, 473, 0, 0, 594, 588, 0, 594, 0, 586, 0, 541, 543, 542, 0, 0, 568, 570, 573, 582, 548, 0, 0, 0, 590, 0, 589, 0, 594, 587, 574, 576, 0, 0, 549, 0, 545, 591, 311, 0, 575, 577, 569, 583, 546, 312 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 41, 232, 233, 92, 93, 43, 150, 151, 152, 108, 44, 109, 45, 110, 46, 160, 301, 128, 47, 112, 48, 113, 114, 50, 115, 51, 116, 52, 117, 53, 118, 213, 54, 119, 214, 55, 120, 215, 56, 121, 216, 57, 122, 217, 58, 123, 218, 59, 124, 219, 60, 125, 220, 61, 126, 221, 62, 336, 437, 222, 63, 64, 65, 66, 98, 334, 67, 100, 101, 238, 415, 68, 69, 70, 71, 438, 223, 72, 73, 74, 75, 76, 460, 570, 571, 572, 718, 77, 78, 79, 80, 81, 96, 358, 517, 82, 83, 518, 751, 752, 591, 592, 520, 649, 650, 651, 607, 521, 608, 522, 609, 523, 660, 820, 627, 524, 611, 525, 612, 613, 527, 614, 528, 615, 529, 616, 530, 617, 732, 531, 618, 733, 532, 619, 734, 533, 620, 735, 534, 621, 736, 535, 622, 737, 536, 623, 738, 537, 624, 739, 538, 625, 740, 539, 867, 975, 741, 540, 541, 542, 543, 597, 865, 544, 599, 600, 757, 953, 545, 546, 547, 548, 976, 742, 549, 550, 551, 552, 553, 998, 1028, 1029, 1030, 1053, 554, 555, 556, 557, 558, 595, 889, 1016, 559 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -941 static const yytype_int16 yypact[] = { 1516, -941, -941, -941, 44, -2, 839, 26, 178, 73, 192, 954, 2114, 2114, 189, -941, 1516, 207, 2114, 245, 275, 2114, 226, 47, 2114, 2114, -941, 1200, -941, 280, -941, 2114, 2114, -941, 2114, 20, 2114, 2114, 2114, 2114, -941, -941, -941, -941, 350, -941, 361, 2201, -941, -941, -941, 6, -21, 437, 446, 264, 269, 315, 306, 364, 9, -941, -941, 69, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, 417, 1516, -941, 88, -941, 1670, 839, 25, 435, -941, -941, -941, 390, -941, -941, 338, 96, 338, 151, -941, -941, 90, -941, 365, -941, -941, 390, -941, 394, 2224, -941, -941, -941, 215, 255, 483, 509, 504, 374, 377, 380, 424, 14, -941, -941, 163, 445, -941, -941, 2114, 452, 2114, -941, 2114, 2114, 164, 486, -941, -941, -941, -941, -941, 1279, 1516, -941, -941, 495, -941, 311, 1706, 400, -941, -941, -941, -941, 1781, 2114, 418, -941, 2114, 432, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, -941, 2114, -941, -941, -941, -941, -941, 442, 737, 483, 355, 583, 428, 440, 453, 491, 17, -941, -941, 481, 469, 390, -941, 505, 187, -941, 513, -5, 521, -941, 177, 2114, 539, -941, 2114, -941, -941, 545, -941, -941, -941, 178, -941, -941, -941, 236, -941, 2114, 547, -941, -941, -941, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, -941, 2114, -941, 499, 548, 559, 582, 617, -941, -941, 556, 226, -941, -941, -941, 20, -941, -941, -941, -941, -941, 628, -941, 314, -941, 329, -941, -941, -941, -941, -941, 215, 215, 255, 255, 255, 483, 483, 483, 483, 483, 483, 509, 509, 509, 509, 504, 374, 377, 380, 424, 546, -941, 29, -11, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, -941, 256, -941, 567, 632, 2114, 563, 2114, 2114, -941, 586, 358, -941, -941, 338, -941, 574, 635, 436, -941, -941, -941, -941, -941, 215, 215, 255, 255, 255, 483, 483, 483, 483, 483, 483, 509, 509, 509, 509, 504, 374, 377, 380, 424, 571, -941, 1516, 2114, 1516, 584, 1516, 591, -941, 1817, -941, 2114, -941, -941, 2114, 2114, 2114, 656, 598, 2114, 648, 2224, -941, 483, 483, 483, 483, 483, 355, 355, 355, 355, 583, 428, 440, 453, 491, 639, -941, 614, 608, 649, 662, 1595, 651, 650, -941, 283, -941, -941, -941, -941, -941, -941, 1595, 660, -941, 2114, 681, 670, -941, 716, -941, -941, 657, -941, -941, -941, -941, 680, -941, 2114, 647, 654, 1516, 2114, 2114, 1595, 677, -941, -941, -941, 141, 688, 1122, 707, 712, 179, 717, 1087, 2150, 2150, 728, -941, 1595, 730, 2150, 732, 743, 2150, 754, 91, 2150, 2150, -941, 1358, -941, 755, -941, 2150, 2150, -941, 2150, 714, 2150, 2150, 2150, 2150, -941, 756, -941, -941, -941, 403, -941, 434, 2240, -941, -941, -941, 257, 581, 498, 619, 630, 747, 769, 753, 828, 23, -941, -941, 185, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, 1595, 1595, -941, 819, 685, 821, 1595, -941, 1516, 171, 2114, 219, 716, -941, 226, 1516, 692, -941, 2114, -941, -941, 810, 822, 1595, -941, 183, -941, 1892, 1122, 305, 609, -941, -941, -941, 441, -941, -941, 797, 195, 797, 203, -941, -941, 197, -941, 816, -941, -941, 441, -941, 447, 2263, -941, -941, -941, 262, 698, 515, 640, 638, 812, 802, 811, 845, 28, -941, -941, 208, 739, -941, -941, 2150, 868, 2150, -941, 2150, 2150, 216, 777, -941, -941, -941, -941, -941, 1437, 1595, -941, -941, 740, -941, 449, 1928, 827, -941, -941, -941, -941, -941, 2003, 2150, 837, -941, 2150, 841, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, -941, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, -941, 2150, -941, -941, 844, 1595, 847, -941, 848, -941, -941, -941, 8, 842, -941, 716, -941, 880, -941, 1516, 849, 1516, -941, 859, -941, -941, 860, 2185, 515, 357, 655, 843, 838, 840, 884, 150, -941, -941, 857, 846, 441, -941, 861, 299, -941, 863, 181, 870, -941, 284, 2150, 866, -941, 2150, -941, -941, 873, -941, -941, -941, 712, -941, -941, -941, 301, -941, 2150, 876, -941, -941, -941, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, -941, 2150, -941, 749, 871, 751, 757, 766, -941, -941, 872, 754, -941, -941, -941, 714, -941, -941, -941, -941, -941, 778, -941, 464, -941, 511, -941, -941, -941, -941, -941, 262, 262, 698, 698, 698, 515, 515, 515, 515, 515, 515, 640, 640, 640, 640, 638, 812, 802, 811, 845, 878, -941, -941, 891, 1595, -941, 1516, 1516, 894, 226, -941, 1516, -941, -941, 39, -7, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2150, -941, 307, -941, 897, 781, 2150, 892, 2150, 2150, -941, 683, 522, -941, -941, 797, -941, 902, 785, 525, -941, -941, -941, -941, -941, 262, 262, 698, 698, 698, 515, 515, 515, 515, 515, 515, 640, 640, 640, 640, 638, 812, 802, 811, 845, 895, -941, 1595, 2150, 1595, 904, 1595, 907, -941, 2039, -941, 2150, -941, -941, 2150, -941, 906, 1516, 1516, -941, -941, -941, 2150, 2150, 950, 912, 2150, 793, 2263, -941, 515, 515, 515, 515, 515, 357, 357, 357, 357, 655, 843, 838, 840, 884, 908, -941, 909, 889, 918, 796, 1595, 921, 919, -941, 313, -941, -941, -941, -941, -941, -941, 1595, 923, -941, 2150, 949, 798, -941, 977, -941, -941, 916, -941, -941, -941, -941, -941, 803, -941, 2150, 900, 901, 1595, 2150, 2150, 1595, 928, 935, 1595, 1595, -941, 937, 805, 939, 1595, -941, 1595, 217, 2150, 237, 977, -941, 754, 1595, 807, -941, 2150, -941, -941, 931, 941, 1595, -941, 942, 1595, 944, -941, 946, -941, -941, -941, 37, 940, -941, 977, -941, 973, -941, 1595, 943, 1595, -941, 948, -941, 951, 1595, -941, 1595, 1595, 961, 754, -941, 1595, -941, -941, -941, 963, 1595, 1595, -941, -941, -941, -941 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -941, -941, 645, -941, -941, 0, -941, -941, 715, -941, 22, -941, 186, -941, -941, -941, -29, -941, 479, -941, -941, -941, 3, 169, -941, 105, -941, 230, -941, 725, -941, 138, 423, -941, -174, 668, -941, 31, 679, -941, 40, 676, -941, 42, 678, -941, 68, 682, -941, -941, -941, -941, -941, -941, -941, -35, -305, -941, 172, 18, -941, -941, -15, -20, -941, -941, -941, -941, -941, 791, -91, 566, -941, -941, -941, -941, -407, -941, -941, -941, -941, -941, -941, -941, 319, -941, 471, -941, -941, -941, -941, -941, -941, -941, -235, -441, -941, -23, -941, 148, -941, -941, -432, -941, -941, 231, -941, -450, -941, -449, -941, -941, -941, -511, -941, 167, -941, -941, -941, -329, 263, -941, -661, -941, -460, -941, -428, -941, -480, -70, -941, -679, 170, -941, -673, 166, -941, -663, 173, -941, -660, 174, -941, -657, 165, -941, -941, -941, -941, -941, -941, -941, -601, -841, -941, -302, -473, -941, -941, -454, -493, -941, -941, -941, -941, -941, 290, -592, 46, -941, -941, -941, -941, -940, -941, -941, -941, -941, -941, -941, -941, 5, -941, 49, -941, -941, -941, -941, -941, -941, -941, -760, -652, -468 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint16 yytable[] = { 42, 132, 138, 49, 144, 637, 761, 902, 242, 519, 471, 564, 663, 371, 626, 1010, 42, 163, 845, 49, 519, 830, 831, 326, 636, 846, 958, 42, 94, 127, 49, 420, 593, 594, 581, 643, 847, 647, 631, 137, 848, 973, 974, 519, 849, 84, 435, 436, 139, 817, 201, 413, 148, 182, 183, 278, 821, 360, 350, 416, 519, 951, 361, 954, 701, 236, 87, 580, 207, 797, 203, 519, 179, 1038, 102, 856, 417, 826, 281, 249, 955, 252, 755, 42, 180, 181, 49, 226, 97, 208, 149, 246, 638, 227, 202, 1058, 768, 239, 771, 279, 393, 850, 351, 851, 1066, 706, 85, 800, 702, 468, 224, 1007, 526, 798, 924, 414, 298, 909, 910, 707, 440, 925, 302, 526, 711, 952, 978, 519, 519, 207, 293, 86, 926, 519, 140, 103, 927, 743, 744, 204, 928, 726, 583, 307, 42, 42, 526, 49, 49, 283, 519, 285, 243, 286, 287, 898, 205, 802, 731, 804, 104, 805, 806, 526, 280, 288, 240, 331, 579, 332, 723, 1037, 713, 905, 526, 209, 303, 247, 639, 305, 601, 129, 130, 241, 727, 822, 703, 134, 824, 706, 812, 881, 95, 141, 142, 354, 758, 929, 765, 930, 146, 147, 367, 584, 762, 153, 154, 155, 156, 799, 563, 519, 519, 841, 842, 843, 844, 807, 1048, 178, 374, 244, 678, 1021, 832, 833, 834, 716, 585, 327, 526, 526, 885, 281, 281, 882, 526, 363, 245, 328, 99, 602, 329, 891, 398, 1051, 399, 364, 892, 356, 282, 289, 365, 526, 105, 704, 357, 131, 714, 835, 836, 837, 838, 839, 840, 759, 603, 853, 372, 330, 728, 406, 705, 763, 225, 133, 519, 451, 800, 717, 896, 256, 760, 255, 766, 27, 800, 311, 312, 982, 764, 984, 985, 257, 258, 801, 903, 1052, 356, 193, 194, 195, 196, 808, 1049, 370, 394, 989, 774, 920, 921, 922, 923, 135, 526, 526, 395, 937, 356, 396, 911, 912, 913, 679, 444, 439, 446, 447, 775, 259, 260, 322, 323, 324, 325, 680, 681, 1002, 1022, 1003, 776, 777, 1004, 136, 894, 356, 397, 145, 308, 309, 310, 197, 562, 418, 895, 914, 915, 916, 917, 918, 919, 887, 1039, 887, 378, 379, 1042, 745, 888, 887, 901, 1046, 464, 746, 465, 887, 977, 466, 337, 526, 868, 295, 1020, 296, 281, 456, 410, 458, 1061, 461, 199, 1063, 1024, 956, 338, 339, 869, 870, 198, 281, 42, 411, 42, 49, 42, 49, 200, 49, 389, 390, 391, 392, 1075, 945, 313, 314, 315, 206, 157, 457, 566, 158, 519, 159, 237, 375, 376, 377, 281, 157, 450, 467, 161, 248, 162, 340, 341, 871, 872, 731, 959, 960, 961, 962, 963, 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, 274, 578, 157, 995, 275, 234, 157, 235, 276, 250, 277, 251, 187, 188, 299, 657, 42, 284, 658, 49, 659, 994, 1006, 996, 304, 999, 184, 185, 186, 189, 190, 575, 253, 254, 111, 380, 381, 382, 306, 228, 229, 230, 231, 519, 111, 519, 657, 519, 333, 661, 281, 662, 454, 657, 346, 1017, 753, 111, 754, 657, 290, 291, 769, 814, 770, 815, 1017, 347, 731, 526, 191, 192, 261, 262, 263, 264, 265, 349, 800, 1033, 941, 348, 1055, 270, 271, 272, 273, 684, 685, 686, 1017, 519, 266, 267, 1017, 352, 712, 720, 1050, 1017, 353, 1036, 519, 721, 780, 781, 782, 706, 294, 281, 211, 42, 400, 281, 49, 1047, 1017, 355, 42, 1017, 1079, 49, 1056, 519, 359, 800, 519, 942, 731, 519, 519, 715, 362, 268, 269, 519, 800, 519, 988, 800, 1017, 992, 1076, 1077, 519, 366, 526, 1070, 526, 1072, 526, 368, 519, 373, 111, 519, 111, 412, 111, 111, 401, 1080, 342, 343, 344, 345, 706, 706, 405, 519, 441, 519, 402, 281, 111, 445, 519, 452, 519, 519, 111, 111, 455, 519, 111, 687, 688, 459, 519, 519, 448, 229, 230, 231, 526, 403, 281, 462, 610, 682, 683, 111, 689, 690, 470, 526, 783, 784, 610, 693, 694, 695, 696, 747, 748, 749, 750, 789, 790, 791, 792, 610, 469, 785, 786, 111, 526, 111, 281, 526, 404, 281, 526, 526, 873, 874, 875, 876, 526, 474, 526, 408, 409, 691, 692, 442, 443, 526, 453, 443, 473, 860, 475, 862, 560, 526, 561, 111, 526, 567, 111, 472, 281, 565, 787, 788, 42, 569, 42, 49, 573, 49, 526, 111, 526, 476, 443, 414, 111, 526, 582, 526, 526, 568, 281, 577, 526, 986, 748, 749, 750, 526, 526, 574, 281, 628, 629, 730, 709, 443, 586, 633, 111, 335, 111, 722, 281, 640, 641, 426, 427, 428, 429, 596, 645, 646, 778, 779, 598, 652, 653, 654, 655, 604, 253, 254, 772, 773, 648, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 630, 610, 632, 610, 634, 610, 610, 964, 965, 966, 967, 809, 810, 813, 800, 635, 212, 503, 111, 419, 656, 610, 931, 800, 933, 800, 644, 177, 610, 610, 934, 800, 610, 697, 419, 419, 111, 946, 947, 935, 800, 699, 111, 949, 111, 111, 1, 2, 3, 610, 950, 939, 940, 88, 980, 981, 698, 89, 991, 981, 42, 42, 15, 49, 49, 42, 1011, 800, 49, 1015, 981, 1026, 800, 610, 700, 610, 1032, 800, 1044, 981, 1057, 800, 708, 724, 111, 710, 725, 756, 767, 794, 111, 796, 111, 803, 26, 111, 111, 419, 793, 795, 111, 818, 90, 823, 28, 91, 30, 825, 852, 33, 854, 34, 855, 857, 35, 859, 316, 317, 318, 319, 320, 321, 861, 863, 610, 878, 864, 610, 879, 877, 880, 883, 897, 886, 890, 207, 207, 884, 111, 899, 610, 893, 904, 932, 936, 610, 827, 828, 829, 943, 42, 42, 111, 49, 49, 944, 419, 111, 948, 106, 979, 1, 2, 3, 983, 990, 993, 997, 88, 610, 1005, 610, 89, 1000, 12, 13, 1008, 15, 1009, 1012, 1013, 1014, 18, 800, 1018, 1019, 1023, 1025, 1027, 1031, 952, 1040, 1035, 383, 384, 385, 386, 387, 388, 1041, 1043, 24, 25, 1045, 1059, 1060, 1062, 1064, 1069, 26, 1065, 1067, 1073, 449, 407, 1074, 1071, 90, 430, 28, 91, 30, 31, 32, 33, 1078, 34, 1081, 432, 35, 431, 433, 36, 37, 38, 39, 434, 610, 957, 369, 576, 858, 906, 907, 908, 107, 719, 987, 969, 938, 972, 968, 111, 957, 957, 610, 970, 900, 971, 1034, 111, 610, 1068, 610, 610, 212, 421, 422, 423, 424, 425, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 1054, 0, 0, 0, 0, 0, 0, 0, 0, 0, 605, 0, 477, 478, 479, 0, 0, 0, 0, 587, 0, 610, 0, 588, 0, 488, 489, 610, 491, 610, 0, 0, 610, 494, 0, 0, 0, 0, 0, 0, 610, 957, 0, 0, 610, 0, 0, 477, 478, 479, 0, 0, 500, 501, 587, 0, 0, 0, 588, 0, 502, 212, 0, 491, 0, 0, 0, 0, 589, 0, 504, 590, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 610, 512, 513, 514, 515, 0, 0, 0, 0, 0, 0, 0, 0, 502, 606, 610, 0, 0, 0, 957, 610, 589, 0, 504, 590, 506, 0, 0, 509, 0, 510, 0, 0, 511, 610, 0, 0, 0, 212, 0, 0, 0, 610, 1, 2, 3, 4, 0, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, 19, 20, 0, 21, 22, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 27, 143, 28, 29, 30, 31, 32, 33, 0, 34, 0, 0, 35, 0, 0, 36, 37, 38, 39, 0, 0, 0, 0, 1, 2, 3, 4, 0, 40, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, 19, 20, 0, 21, 22, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 27, 292, 28, 29, 30, 31, 32, 33, 0, 34, 0, 0, 35, 0, 0, 36, 37, 38, 39, 0, 0, 0, 0, 477, 478, 479, 480, 0, 40, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 0, 0, 494, 495, 496, 0, 497, 498, 0, 0, 499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 503, 642, 504, 505, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 0, 512, 513, 514, 515, 0, 0, 0, 0, 477, 478, 479, 480, 0, 516, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 0, 0, 494, 495, 496, 0, 497, 498, 0, 0, 499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 503, 811, 504, 505, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 0, 512, 513, 514, 515, 0, 0, 0, 0, 1, 2, 3, 4, 0, 516, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, 19, 20, 0, 21, 22, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 29, 30, 31, 32, 33, 0, 34, 0, 0, 35, 0, 0, 36, 37, 38, 39, 0, 0, 0, 0, 477, 478, 479, 480, 0, 40, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 0, 0, 494, 495, 496, 0, 497, 498, 0, 0, 499, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 503, 0, 504, 505, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 0, 512, 513, 514, 515, 1, 2, 3, 0, 0, 0, 0, 88, 210, 516, 0, 89, 0, 12, 13, 0, 15, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 24, 25, 0, 88, 0, 0, 0, 89, 26, 12, 13, 0, 15, 0, 0, 0, 90, 18, 28, 91, 30, 31, 32, 33, 0, 34, 0, 0, 35, 0, 0, 36, 37, 38, 39, 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 90, 0, 28, 91, 30, 31, 32, 33, 0, 34, 0, 0, 35, 297, 0, 36, 37, 38, 39, 1, 2, 3, 0, 0, 0, 0, 88, 0, 0, 0, 89, 0, 12, 13, 0, 15, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 24, 25, 0, 88, 0, 0, 0, 89, 26, 12, 13, 0, 15, 0, 0, 0, 90, 18, 28, 91, 30, 31, 32, 33, 0, 34, 300, 0, 35, 0, 0, 36, 37, 38, 39, 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 90, 0, 28, 91, 30, 31, 32, 33, 0, 34, 0, 0, 35, 463, 0, 36, 37, 38, 39, 477, 478, 479, 0, 0, 0, 0, 587, 729, 0, 0, 588, 0, 488, 489, 0, 491, 0, 0, 0, 0, 494, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 477, 478, 479, 0, 500, 501, 0, 587, 0, 0, 0, 588, 502, 488, 489, 0, 491, 0, 0, 0, 589, 494, 504, 590, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 0, 512, 513, 514, 515, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 589, 0, 504, 590, 506, 507, 508, 509, 0, 510, 0, 0, 511, 816, 0, 512, 513, 514, 515, 477, 478, 479, 0, 0, 0, 0, 587, 0, 0, 0, 588, 0, 488, 489, 0, 491, 0, 0, 0, 0, 494, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 477, 478, 479, 0, 500, 501, 0, 587, 0, 0, 0, 588, 502, 488, 489, 0, 491, 0, 0, 0, 589, 494, 504, 590, 506, 507, 508, 509, 0, 510, 819, 0, 511, 0, 0, 512, 513, 514, 515, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 589, 0, 504, 590, 506, 507, 508, 509, 0, 510, 0, 0, 511, 1001, 0, 512, 513, 514, 515, 1, 2, 3, 0, 0, 0, 0, 88, 0, 0, 0, 89, 0, 12, 13, 0, 15, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 477, 478, 479, 0, 24, 25, 0, 587, 0, 0, 0, 588, 26, 488, 489, 0, 491, 0, 0, 0, 90, 494, 28, 91, 30, 31, 32, 33, 0, 34, 0, 0, 35, 0, 0, 36, 37, 38, 39, 0, 500, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 866, 0, 589, 0, 504, 590, 506, 507, 508, 509, 0, 510, 0, 0, 511, 0, 0, 512, 513, 514, 515, 772, 773, 0, 0, 0, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 164, 165, 0, 0, 0, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 677, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 664, 665, 0, 0, 177, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 0, 0, 0, 0, 0, 0, 0, 772, 773, 0, 0, 177, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 0, 0, 0, 0, 677, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 677 }; static const yytype_int16 yycheck[] = { 0, 16, 22, 0, 27, 498, 598, 767, 99, 441, 417, 452, 523, 248, 487, 955, 16, 46, 697, 16, 452, 682, 683, 197, 497, 698, 867, 27, 6, 11, 27, 336, 482, 482, 475, 503, 699, 510, 492, 21, 700, 882, 883, 475, 701, 1, 351, 352, 1, 650, 41, 22, 34, 74, 75, 41, 657, 62, 41, 70, 492, 22, 67, 70, 41, 94, 68, 474, 83, 41, 1, 503, 66, 1013, 1, 67, 87, 678, 70, 108, 87, 110, 593, 83, 78, 79, 83, 62, 62, 1, 70, 1, 1, 68, 85, 1035, 607, 1, 609, 85, 274, 702, 85, 704, 67, 559, 62, 70, 85, 414, 88, 952, 441, 85, 793, 86, 151, 778, 779, 560, 355, 794, 157, 452, 565, 86, 886, 559, 560, 144, 145, 87, 795, 565, 87, 62, 796, 587, 587, 70, 797, 582, 1, 178, 144, 145, 475, 144, 145, 131, 582, 133, 1, 135, 136, 756, 87, 630, 586, 632, 87, 634, 635, 492, 1, 1, 70, 202, 473, 204, 577, 1012, 1, 774, 503, 87, 158, 87, 87, 161, 1, 12, 13, 87, 1, 658, 1, 18, 661, 643, 644, 41, 6, 24, 25, 224, 1, 798, 1, 800, 31, 32, 237, 62, 1, 36, 37, 38, 39, 1, 445, 643, 644, 693, 694, 695, 696, 1, 1, 47, 255, 70, 524, 983, 684, 685, 686, 8, 87, 198, 559, 560, 743, 70, 70, 85, 565, 60, 87, 199, 62, 62, 200, 62, 279, 8, 281, 70, 67, 62, 87, 87, 234, 582, 62, 70, 69, 68, 87, 687, 688, 689, 690, 691, 692, 70, 87, 708, 250, 201, 87, 291, 87, 70, 88, 68, 708, 368, 70, 60, 753, 66, 87, 111, 87, 59, 70, 182, 183, 890, 87, 892, 893, 78, 79, 87, 769, 60, 62, 35, 36, 37, 38, 87, 87, 69, 275, 899, 610, 789, 790, 791, 792, 68, 643, 644, 276, 810, 62, 277, 780, 781, 782, 66, 359, 69, 361, 362, 66, 74, 75, 193, 194, 195, 196, 78, 79, 938, 990, 940, 78, 79, 943, 68, 60, 62, 278, 67, 179, 180, 181, 82, 69, 335, 70, 783, 784, 785, 786, 787, 788, 62, 1014, 62, 259, 260, 1018, 62, 69, 62, 69, 1023, 407, 68, 409, 62, 69, 412, 23, 708, 23, 70, 69, 72, 70, 400, 72, 402, 1040, 404, 84, 1043, 993, 866, 39, 40, 39, 40, 83, 70, 400, 72, 402, 400, 404, 402, 42, 404, 270, 271, 272, 273, 1064, 854, 184, 185, 186, 0, 68, 401, 455, 71, 854, 73, 86, 256, 257, 258, 70, 68, 72, 413, 71, 68, 73, 80, 81, 80, 81, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 82, 472, 68, 932, 83, 71, 68, 73, 84, 71, 42, 73, 22, 23, 70, 68, 472, 21, 71, 472, 73, 931, 951, 933, 62, 935, 45, 46, 47, 39, 40, 469, 43, 44, 11, 261, 262, 263, 62, 60, 61, 62, 63, 931, 21, 933, 68, 935, 62, 71, 70, 73, 72, 68, 82, 979, 71, 34, 73, 68, 30, 31, 71, 70, 73, 72, 990, 83, 952, 854, 80, 81, 45, 46, 47, 22, 23, 42, 70, 1008, 72, 84, 1031, 35, 36, 37, 38, 45, 46, 47, 1014, 979, 39, 40, 1018, 70, 567, 573, 1027, 1023, 87, 1011, 990, 574, 45, 46, 47, 1017, 69, 70, 87, 567, 69, 70, 567, 1025, 1040, 68, 574, 1043, 1069, 574, 1032, 1011, 67, 70, 1014, 72, 1012, 1017, 1018, 569, 67, 80, 81, 1023, 70, 1025, 72, 70, 1064, 72, 1066, 1067, 1032, 62, 931, 1057, 933, 1059, 935, 62, 1040, 62, 131, 1043, 133, 67, 135, 136, 68, 1071, 35, 36, 37, 38, 1076, 1077, 68, 1057, 59, 1059, 69, 70, 151, 68, 1064, 59, 1066, 1067, 157, 158, 67, 1071, 161, 22, 23, 59, 1076, 1077, 60, 61, 62, 63, 979, 69, 70, 62, 487, 74, 75, 178, 39, 40, 62, 990, 22, 23, 497, 35, 36, 37, 38, 60, 61, 62, 63, 35, 36, 37, 38, 510, 22, 39, 40, 202, 1011, 204, 70, 1014, 69, 70, 1017, 1018, 35, 36, 37, 38, 1023, 87, 1025, 69, 70, 80, 81, 69, 70, 1032, 69, 70, 67, 722, 59, 724, 59, 1040, 62, 234, 1043, 34, 237, 69, 70, 59, 80, 81, 722, 7, 724, 722, 69, 724, 1057, 250, 1059, 69, 70, 86, 255, 1064, 59, 1066, 1067, 69, 70, 87, 1071, 60, 61, 62, 63, 1076, 1077, 69, 70, 488, 489, 586, 69, 70, 68, 494, 279, 22, 281, 69, 70, 500, 501, 342, 343, 344, 345, 62, 507, 508, 74, 75, 62, 512, 513, 514, 515, 62, 43, 44, 43, 44, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 68, 630, 68, 632, 68, 634, 635, 873, 874, 875, 876, 30, 31, 69, 70, 68, 87, 59, 335, 336, 60, 650, 69, 70, 69, 70, 67, 86, 657, 658, 69, 70, 661, 82, 351, 352, 353, 856, 857, 69, 70, 84, 359, 859, 361, 362, 3, 4, 5, 678, 861, 69, 70, 10, 69, 70, 83, 14, 69, 70, 856, 857, 19, 856, 857, 861, 69, 70, 861, 69, 70, 69, 70, 702, 42, 704, 69, 70, 69, 70, 69, 70, 59, 69, 401, 60, 60, 86, 68, 83, 407, 42, 409, 21, 51, 412, 413, 414, 82, 84, 417, 70, 59, 62, 61, 62, 63, 62, 60, 66, 59, 68, 60, 67, 71, 31, 187, 188, 189, 190, 191, 192, 69, 60, 753, 83, 62, 756, 84, 82, 42, 70, 62, 68, 67, 946, 947, 87, 455, 62, 769, 67, 62, 68, 68, 774, 679, 680, 681, 67, 946, 947, 469, 946, 947, 60, 473, 474, 60, 1, 59, 3, 4, 5, 68, 59, 67, 59, 10, 798, 60, 800, 14, 62, 16, 17, 22, 19, 62, 67, 87, 59, 24, 70, 59, 62, 59, 34, 7, 69, 86, 59, 87, 264, 265, 266, 267, 268, 269, 60, 59, 43, 44, 60, 69, 60, 60, 59, 31, 51, 60, 67, 60, 364, 295, 60, 69, 59, 346, 61, 62, 63, 64, 65, 66, 60, 68, 60, 348, 71, 347, 349, 74, 75, 76, 77, 350, 866, 867, 244, 470, 718, 775, 776, 777, 87, 571, 895, 878, 814, 881, 877, 569, 882, 883, 884, 879, 763, 880, 1009, 577, 890, 1053, 892, 893, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 1029, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 3, 4, 5, -1, -1, -1, -1, 10, -1, 932, -1, 14, -1, 16, 17, 938, 19, 940, -1, -1, 943, 24, -1, -1, -1, -1, -1, -1, 951, 952, -1, -1, 955, -1, -1, 3, 4, 5, -1, -1, 43, 44, 10, -1, -1, -1, 14, -1, 51, 414, -1, 19, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, 993, 74, 75, 76, 77, -1, -1, -1, -1, -1, -1, -1, -1, 51, 87, 1008, -1, -1, -1, 1012, 1013, 59, -1, 61, 62, 63, -1, -1, 66, -1, 68, -1, -1, 71, 1027, -1, -1, -1, 473, -1, -1, -1, 1035, 3, 4, 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, 3, 4, 5, 6, -1, 87, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, 3, 4, 5, 6, -1, 87, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, 3, 4, 5, 6, -1, 87, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, 3, 4, 5, 6, -1, 87, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, 3, 4, 5, 6, -1, 87, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, 24, 25, 26, -1, 28, 29, -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, 3, 4, 5, -1, -1, -1, -1, 10, 11, 87, -1, 14, -1, 16, 17, -1, 19, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, 43, 44, -1, 10, -1, -1, -1, 14, 51, 16, 17, -1, 19, -1, -1, -1, 59, 24, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, 72, -1, 74, 75, 76, 77, 3, 4, 5, -1, -1, -1, -1, 10, -1, -1, -1, 14, -1, 16, 17, -1, 19, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, 43, 44, -1, 10, -1, -1, -1, 14, 51, 16, 17, -1, 19, -1, -1, -1, 59, 24, 61, 62, 63, 64, 65, 66, -1, 68, 69, -1, 71, -1, -1, 74, 75, 76, 77, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, 72, -1, 74, 75, 76, 77, 3, 4, 5, -1, -1, -1, -1, 10, 11, -1, -1, 14, -1, 16, 17, -1, 19, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, 43, 44, -1, 10, -1, -1, -1, 14, 51, 16, 17, -1, 19, -1, -1, -1, 59, 24, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, 72, -1, 74, 75, 76, 77, 3, 4, 5, -1, -1, -1, -1, 10, -1, -1, -1, 14, -1, 16, 17, -1, 19, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, 43, 44, -1, 10, -1, -1, -1, 14, 51, 16, 17, -1, 19, -1, -1, -1, 59, 24, 61, 62, 63, 64, 65, 66, -1, 68, 69, -1, 71, -1, -1, 74, 75, 76, 77, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, 72, -1, 74, 75, 76, 77, 3, 4, 5, -1, -1, -1, -1, 10, -1, -1, -1, 14, -1, 16, 17, -1, 19, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, 43, 44, -1, 10, -1, -1, -1, 14, 51, 16, 17, -1, 19, -1, -1, -1, 59, 24, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, -1, 43, 44, -1, -1, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, 22, -1, 59, -1, 61, 62, 63, 64, 65, 66, -1, 68, -1, -1, 71, -1, -1, 74, 75, 76, 77, 43, 44, -1, -1, -1, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 43, 44, -1, -1, -1, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 43, 44, -1, -1, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, -1, -1, -1, -1, -1, -1, -1, 43, 44, -1, -1, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, -1, -1, -1, -1, 86, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { 0, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 28, 29, 32, 43, 44, 51, 59, 61, 62, 63, 64, 65, 66, 68, 71, 74, 75, 76, 77, 87, 89, 93, 94, 99, 101, 103, 107, 109, 110, 112, 114, 116, 118, 121, 124, 127, 130, 133, 136, 139, 142, 145, 149, 150, 151, 152, 155, 160, 161, 162, 163, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 184, 185, 1, 62, 87, 68, 10, 14, 59, 62, 92, 93, 98, 100, 181, 62, 153, 62, 156, 157, 1, 62, 87, 62, 1, 87, 98, 100, 102, 106, 108, 110, 111, 113, 115, 117, 119, 122, 125, 128, 131, 134, 137, 140, 143, 147, 106, 111, 111, 68, 150, 68, 111, 68, 68, 147, 151, 1, 87, 111, 111, 60, 185, 67, 111, 111, 147, 70, 95, 96, 97, 111, 111, 111, 111, 68, 71, 73, 104, 71, 73, 104, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 86, 146, 66, 78, 79, 74, 75, 45, 46, 47, 22, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 1, 70, 87, 0, 150, 1, 87, 11, 106, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 148, 165, 98, 100, 62, 68, 60, 61, 62, 63, 90, 91, 71, 73, 104, 86, 158, 1, 70, 87, 158, 1, 70, 87, 1, 87, 68, 104, 71, 73, 104, 43, 44, 146, 66, 78, 79, 74, 75, 45, 46, 47, 22, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 1, 70, 87, 147, 21, 147, 147, 147, 1, 87, 30, 31, 60, 150, 69, 70, 72, 72, 143, 70, 69, 105, 143, 147, 62, 147, 62, 143, 111, 111, 111, 113, 113, 115, 115, 115, 117, 117, 117, 117, 117, 117, 119, 119, 119, 119, 122, 125, 128, 131, 134, 143, 143, 62, 154, 22, 146, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 70, 87, 104, 68, 62, 69, 182, 67, 62, 67, 67, 60, 70, 147, 62, 143, 62, 157, 69, 182, 147, 62, 143, 111, 111, 111, 113, 113, 115, 115, 115, 117, 117, 117, 117, 117, 117, 119, 119, 119, 119, 122, 125, 128, 131, 134, 143, 143, 69, 68, 69, 69, 69, 68, 151, 96, 69, 70, 72, 72, 67, 22, 86, 159, 70, 87, 147, 106, 144, 117, 117, 117, 117, 117, 120, 120, 120, 120, 123, 126, 129, 132, 135, 144, 144, 147, 164, 69, 182, 59, 69, 70, 143, 68, 143, 143, 60, 90, 72, 158, 59, 69, 72, 67, 150, 147, 150, 59, 171, 150, 62, 72, 143, 143, 143, 147, 144, 22, 62, 164, 69, 67, 87, 59, 69, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 28, 29, 32, 43, 44, 51, 59, 61, 62, 63, 64, 65, 66, 68, 71, 74, 75, 76, 77, 87, 183, 186, 190, 191, 196, 198, 200, 204, 206, 207, 209, 211, 213, 215, 218, 221, 224, 227, 230, 233, 236, 239, 242, 246, 247, 248, 249, 252, 257, 258, 259, 260, 263, 264, 265, 266, 267, 273, 274, 275, 276, 277, 281, 59, 62, 69, 182, 183, 59, 143, 34, 69, 7, 172, 173, 174, 69, 69, 147, 159, 87, 150, 144, 164, 183, 59, 1, 62, 87, 68, 10, 14, 59, 62, 189, 190, 195, 197, 278, 62, 250, 62, 253, 254, 1, 62, 87, 62, 1, 87, 195, 197, 199, 203, 205, 207, 208, 210, 212, 214, 216, 219, 222, 225, 228, 231, 234, 237, 240, 244, 203, 208, 208, 68, 247, 68, 208, 68, 68, 244, 248, 1, 87, 208, 208, 60, 281, 67, 208, 208, 244, 70, 192, 193, 194, 208, 208, 208, 208, 60, 68, 71, 73, 201, 71, 73, 201, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 86, 243, 66, 78, 79, 74, 75, 45, 46, 47, 22, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 1, 70, 87, 247, 183, 59, 69, 60, 183, 150, 1, 87, 147, 8, 60, 175, 174, 151, 150, 69, 164, 69, 60, 183, 1, 87, 11, 203, 214, 217, 220, 223, 226, 229, 232, 235, 238, 241, 245, 262, 195, 197, 62, 68, 60, 61, 62, 63, 187, 188, 71, 73, 201, 86, 255, 1, 70, 87, 255, 1, 70, 87, 1, 87, 68, 201, 71, 73, 201, 43, 44, 243, 66, 78, 79, 74, 75, 45, 46, 47, 22, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 1, 70, 87, 244, 21, 244, 244, 244, 1, 87, 30, 31, 60, 247, 69, 70, 72, 72, 240, 70, 69, 202, 240, 244, 62, 244, 62, 240, 208, 208, 208, 210, 210, 212, 212, 212, 214, 214, 214, 214, 214, 214, 216, 216, 216, 216, 219, 222, 225, 228, 231, 240, 240, 60, 183, 59, 60, 67, 67, 172, 31, 150, 69, 150, 60, 62, 251, 22, 243, 23, 39, 40, 80, 81, 35, 36, 37, 38, 82, 83, 84, 42, 41, 85, 70, 87, 201, 68, 62, 69, 279, 67, 62, 67, 67, 60, 70, 244, 62, 240, 62, 254, 69, 279, 244, 62, 240, 208, 208, 208, 210, 210, 212, 212, 212, 214, 214, 214, 214, 214, 214, 216, 216, 216, 216, 219, 222, 225, 228, 231, 240, 240, 69, 68, 69, 69, 69, 68, 248, 193, 69, 70, 72, 72, 67, 60, 183, 185, 185, 60, 151, 150, 22, 86, 256, 70, 87, 244, 203, 241, 214, 214, 214, 214, 214, 217, 217, 217, 217, 220, 223, 226, 229, 232, 241, 241, 244, 261, 69, 279, 59, 69, 70, 240, 68, 240, 240, 60, 187, 72, 255, 59, 69, 72, 67, 247, 244, 247, 59, 268, 247, 62, 72, 240, 240, 240, 60, 244, 241, 22, 62, 261, 69, 67, 87, 59, 69, 280, 281, 59, 62, 69, 279, 280, 59, 240, 34, 69, 7, 269, 270, 271, 69, 69, 244, 256, 87, 247, 241, 261, 280, 59, 60, 280, 59, 69, 60, 280, 247, 1, 87, 244, 8, 60, 272, 271, 248, 247, 69, 261, 69, 60, 280, 60, 280, 59, 60, 67, 67, 269, 31, 247, 69, 247, 60, 60, 280, 281, 281, 60, 248, 247, 60 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) #else # define YYLEX yylex (&yylval, &yylloc) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; #endif { if (!yyvaluep) return; YYUSE (yylocationp); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) #else static void yy_reduce_print (yyvsp, yylsp, yyrule) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, yylsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) #else static void yydestruct (yymsg, yytype, yyvaluep, yylocationp) const char *yymsg; int yytype; YYSTYPE *yyvaluep; YYLTYPE *yylocationp; #endif { YYUSE (yyvaluep); YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /*-------------------------. | yyparse or yypush_parse. | `-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Location data for the lookahead symbol. */ YYLTYPE yylloc; /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yyls = yylsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; yylsp = yyls; #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; *++yylsp = yylloc; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: /* Line 1455 of yacc.c */ #line 290 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); ;} break; case 3: /* Line 1455 of yacc.c */ #line 291 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); ;} break; case 4: /* Line 1455 of yacc.c */ #line 292 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); ;} break; case 5: /* Line 1455 of yacc.c */ #line 293 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, (yyvsp[(1) - (1)].doubleValue)), 0, 1); ;} break; case 6: /* Line 1455 of yacc.c */ #line 294 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *(yyvsp[(1) - (1)].ident)), 0, 1); ;} break; case 7: /* Line 1455 of yacc.c */ #line 295 "../../JavaScriptCore/parser/Grammar.y" { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags()); int size = l.pattern().size() + 2; // + 2 for the two /'s SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (1)]).first_column, (yylsp[(1) - (1)]).first_column + size, (yylsp[(1) - (1)]).first_column + size); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, 0, 0); ;} break; case 8: /* Line 1455 of yacc.c */ #line 304 "../../JavaScriptCore/parser/Grammar.y" { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags()); int size = l.pattern().size() + 2; // + 2 for the two /'s SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (1)]).first_column, (yylsp[(1) - (1)]).first_column + size, (yylsp[(1) - (1)]).first_column + size); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, 0, 0); ;} break; case 9: /* Line 1455 of yacc.c */ #line 316 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyNode) = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *(yyvsp[(1) - (3)].ident), (yyvsp[(3) - (3)].expressionNode).m_node, PropertyNode::Constant), (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 10: /* Line 1455 of yacc.c */ #line 317 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyNode) = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *(yyvsp[(1) - (3)].ident), (yyvsp[(3) - (3)].expressionNode).m_node, PropertyNode::Constant), (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 11: /* Line 1455 of yacc.c */ #line 318 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyNode) = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from((yyvsp[(1) - (3)].doubleValue))), (yyvsp[(3) - (3)].expressionNode).m_node, PropertyNode::Constant), (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 12: /* Line 1455 of yacc.c */ #line 319 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyNode) = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *(yyvsp[(1) - (7)].ident), *(yyvsp[(2) - (7)].ident), 0, (yyvsp[(6) - (7)].functionBodyNode), LEXER->sourceCode((yyvsp[(5) - (7)].intValue), (yyvsp[(7) - (7)].intValue), (yylsp[(5) - (7)]).first_line)), ClosureFeature, 0); DBG((yyvsp[(6) - (7)].functionBodyNode), (yylsp[(5) - (7)]), (yylsp[(7) - (7)])); if (!(yyval.propertyNode).m_node) YYABORT; ;} break; case 13: /* Line 1455 of yacc.c */ #line 321 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyNode) = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *(yyvsp[(1) - (8)].ident), *(yyvsp[(2) - (8)].ident), (yyvsp[(4) - (8)].parameterList).m_node.head, (yyvsp[(7) - (8)].functionBodyNode), LEXER->sourceCode((yyvsp[(6) - (8)].intValue), (yyvsp[(8) - (8)].intValue), (yylsp[(6) - (8)]).first_line)), (yyvsp[(4) - (8)].parameterList).m_features | ClosureFeature, 0); if ((yyvsp[(4) - (8)].parameterList).m_features & ArgumentsFeature) (yyvsp[(7) - (8)].functionBodyNode)->setUsesArguments(); DBG((yyvsp[(7) - (8)].functionBodyNode), (yylsp[(6) - (8)]), (yylsp[(8) - (8)])); if (!(yyval.propertyNode).m_node) YYABORT; ;} break; case 14: /* Line 1455 of yacc.c */ #line 332 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyList).m_node.head = new PropertyListNode(GLOBAL_DATA, (yyvsp[(1) - (1)].propertyNode).m_node); (yyval.propertyList).m_node.tail = (yyval.propertyList).m_node.head; (yyval.propertyList).m_features = (yyvsp[(1) - (1)].propertyNode).m_features; (yyval.propertyList).m_numConstants = (yyvsp[(1) - (1)].propertyNode).m_numConstants; ;} break; case 15: /* Line 1455 of yacc.c */ #line 336 "../../JavaScriptCore/parser/Grammar.y" { (yyval.propertyList).m_node.head = (yyvsp[(1) - (3)].propertyList).m_node.head; (yyval.propertyList).m_node.tail = new PropertyListNode(GLOBAL_DATA, (yyvsp[(3) - (3)].propertyNode).m_node, (yyvsp[(1) - (3)].propertyList).m_node.tail); (yyval.propertyList).m_features = (yyvsp[(1) - (3)].propertyList).m_features | (yyvsp[(3) - (3)].propertyNode).m_features; (yyval.propertyList).m_numConstants = (yyvsp[(1) - (3)].propertyList).m_numConstants + (yyvsp[(3) - (3)].propertyNode).m_numConstants; ;} break; case 17: /* Line 1455 of yacc.c */ #line 344 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); ;} break; case 18: /* Line 1455 of yacc.c */ #line 345 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, (yyvsp[(2) - (3)].propertyList).m_node.head), (yyvsp[(2) - (3)].propertyList).m_features, (yyvsp[(2) - (3)].propertyList).m_numConstants); ;} break; case 19: /* Line 1455 of yacc.c */ #line 347 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, (yyvsp[(2) - (4)].propertyList).m_node.head), (yyvsp[(2) - (4)].propertyList).m_features, (yyvsp[(2) - (4)].propertyList).m_numConstants); ;} break; case 20: /* Line 1455 of yacc.c */ #line 351 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); ;} break; case 23: /* Line 1455 of yacc.c */ #line 354 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *(yyvsp[(1) - (1)].ident), (yylsp[(1) - (1)]).first_column), (*(yyvsp[(1) - (1)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); ;} break; case 24: /* Line 1455 of yacc.c */ #line 355 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = (yyvsp[(2) - (3)].expressionNode); ;} break; case 25: /* Line 1455 of yacc.c */ #line 359 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, (yyvsp[(2) - (3)].intValue)), 0, (yyvsp[(2) - (3)].intValue) ? 1 : 0); ;} break; case 26: /* Line 1455 of yacc.c */ #line 360 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, (yyvsp[(2) - (3)].elementList).m_node.head), (yyvsp[(2) - (3)].elementList).m_features, (yyvsp[(2) - (3)].elementList).m_numConstants); ;} break; case 27: /* Line 1455 of yacc.c */ #line 361 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, (yyvsp[(4) - (5)].intValue), (yyvsp[(2) - (5)].elementList).m_node.head), (yyvsp[(2) - (5)].elementList).m_features, (yyvsp[(4) - (5)].intValue) ? (yyvsp[(2) - (5)].elementList).m_numConstants + 1 : (yyvsp[(2) - (5)].elementList).m_numConstants); ;} break; case 28: /* Line 1455 of yacc.c */ #line 365 "../../JavaScriptCore/parser/Grammar.y" { (yyval.elementList).m_node.head = new ElementNode(GLOBAL_DATA, (yyvsp[(1) - (2)].intValue), (yyvsp[(2) - (2)].expressionNode).m_node); (yyval.elementList).m_node.tail = (yyval.elementList).m_node.head; (yyval.elementList).m_features = (yyvsp[(2) - (2)].expressionNode).m_features; (yyval.elementList).m_numConstants = (yyvsp[(2) - (2)].expressionNode).m_numConstants; ;} break; case 29: /* Line 1455 of yacc.c */ #line 370 "../../JavaScriptCore/parser/Grammar.y" { (yyval.elementList).m_node.head = (yyvsp[(1) - (4)].elementList).m_node.head; (yyval.elementList).m_node.tail = new ElementNode(GLOBAL_DATA, (yyvsp[(1) - (4)].elementList).m_node.tail, (yyvsp[(3) - (4)].intValue), (yyvsp[(4) - (4)].expressionNode).m_node); (yyval.elementList).m_features = (yyvsp[(1) - (4)].elementList).m_features | (yyvsp[(4) - (4)].expressionNode).m_features; (yyval.elementList).m_numConstants = (yyvsp[(1) - (4)].elementList).m_numConstants + (yyvsp[(4) - (4)].expressionNode).m_numConstants; ;} break; case 30: /* Line 1455 of yacc.c */ #line 377 "../../JavaScriptCore/parser/Grammar.y" { (yyval.intValue) = 0; ;} break; case 32: /* Line 1455 of yacc.c */ #line 382 "../../JavaScriptCore/parser/Grammar.y" { (yyval.intValue) = 1; ;} break; case 33: /* Line 1455 of yacc.c */ #line 383 "../../JavaScriptCore/parser/Grammar.y" { (yyval.intValue) = (yyvsp[(1) - (2)].intValue) + 1; ;} break; case 35: /* Line 1455 of yacc.c */ #line 388 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>((yyvsp[(1) - (1)].funcExprNode).m_node, (yyvsp[(1) - (1)].funcExprNode).m_features, (yyvsp[(1) - (1)].funcExprNode).m_numConstants); ;} break; case 36: /* Line 1455 of yacc.c */ #line 389 "../../JavaScriptCore/parser/Grammar.y" { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (4)]).first_column, (yylsp[(1) - (4)]).last_column, (yylsp[(4) - (4)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (4)].expressionNode).m_features | (yyvsp[(3) - (4)].expressionNode).m_features, (yyvsp[(1) - (4)].expressionNode).m_numConstants + (yyvsp[(3) - (4)].expressionNode).m_numConstants); ;} break; case 37: /* Line 1455 of yacc.c */ #line 393 "../../JavaScriptCore/parser/Grammar.y" { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, *(yyvsp[(3) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(1) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants); ;} break; case 38: /* Line 1455 of yacc.c */ #line 397 "../../JavaScriptCore/parser/Grammar.y" { NewExprNode* node = new NewExprNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].argumentsNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(2) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].argumentsNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].argumentsNode).m_numConstants); ;} break; case 40: /* Line 1455 of yacc.c */ #line 405 "../../JavaScriptCore/parser/Grammar.y" { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (4)]).first_column, (yylsp[(1) - (4)]).last_column, (yylsp[(4) - (4)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (4)].expressionNode).m_features | (yyvsp[(3) - (4)].expressionNode).m_features, (yyvsp[(1) - (4)].expressionNode).m_numConstants + (yyvsp[(3) - (4)].expressionNode).m_numConstants); ;} break; case 41: /* Line 1455 of yacc.c */ #line 409 "../../JavaScriptCore/parser/Grammar.y" { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, *(yyvsp[(3) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(1) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants); ;} break; case 42: /* Line 1455 of yacc.c */ #line 413 "../../JavaScriptCore/parser/Grammar.y" { NewExprNode* node = new NewExprNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].argumentsNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(2) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].argumentsNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].argumentsNode).m_numConstants); ;} break; case 44: /* Line 1455 of yacc.c */ #line 421 "../../JavaScriptCore/parser/Grammar.y" { NewExprNode* node = new NewExprNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 46: /* Line 1455 of yacc.c */ #line 429 "../../JavaScriptCore/parser/Grammar.y" { NewExprNode* node = new NewExprNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 47: /* Line 1455 of yacc.c */ #line 436 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = makeFunctionCallNode(globalPtr, (yyvsp[(1) - (2)].expressionNode), (yyvsp[(2) - (2)].argumentsNode), (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); ;} break; case 48: /* Line 1455 of yacc.c */ #line 437 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = makeFunctionCallNode(globalPtr, (yyvsp[(1) - (2)].expressionNode), (yyvsp[(2) - (2)].argumentsNode), (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); ;} break; case 49: /* Line 1455 of yacc.c */ #line 438 "../../JavaScriptCore/parser/Grammar.y" { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (4)]).first_column, (yylsp[(1) - (4)]).last_column, (yylsp[(4) - (4)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (4)].expressionNode).m_features | (yyvsp[(3) - (4)].expressionNode).m_features, (yyvsp[(1) - (4)].expressionNode).m_numConstants + (yyvsp[(3) - (4)].expressionNode).m_numConstants); ;} break; case 50: /* Line 1455 of yacc.c */ #line 442 "../../JavaScriptCore/parser/Grammar.y" { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, *(yyvsp[(3) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(1) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants); ;} break; case 51: /* Line 1455 of yacc.c */ #line 448 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = makeFunctionCallNode(globalPtr, (yyvsp[(1) - (2)].expressionNode), (yyvsp[(2) - (2)].argumentsNode), (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); ;} break; case 52: /* Line 1455 of yacc.c */ #line 449 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = makeFunctionCallNode(globalPtr, (yyvsp[(1) - (2)].expressionNode), (yyvsp[(2) - (2)].argumentsNode), (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column); ;} break; case 53: /* Line 1455 of yacc.c */ #line 450 "../../JavaScriptCore/parser/Grammar.y" { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_node, (yyvsp[(3) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (4)]).first_column, (yylsp[(1) - (4)]).last_column, (yylsp[(4) - (4)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (4)].expressionNode).m_features | (yyvsp[(3) - (4)].expressionNode).m_features, (yyvsp[(1) - (4)].expressionNode).m_numConstants + (yyvsp[(3) - (4)].expressionNode).m_numConstants); ;} break; case 54: /* Line 1455 of yacc.c */ #line 454 "../../JavaScriptCore/parser/Grammar.y" { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, *(yyvsp[(3) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(1) - (3)]).last_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants); ;} break; case 55: /* Line 1455 of yacc.c */ #line 461 "../../JavaScriptCore/parser/Grammar.y" { (yyval.argumentsNode) = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA), 0, 0); ;} break; case 56: /* Line 1455 of yacc.c */ #line 462 "../../JavaScriptCore/parser/Grammar.y" { (yyval.argumentsNode) = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA, (yyvsp[(2) - (3)].argumentList).m_node.head), (yyvsp[(2) - (3)].argumentList).m_features, (yyvsp[(2) - (3)].argumentList).m_numConstants); ;} break; case 57: /* Line 1455 of yacc.c */ #line 466 "../../JavaScriptCore/parser/Grammar.y" { (yyval.argumentList).m_node.head = new ArgumentListNode(GLOBAL_DATA, (yyvsp[(1) - (1)].expressionNode).m_node); (yyval.argumentList).m_node.tail = (yyval.argumentList).m_node.head; (yyval.argumentList).m_features = (yyvsp[(1) - (1)].expressionNode).m_features; (yyval.argumentList).m_numConstants = (yyvsp[(1) - (1)].expressionNode).m_numConstants; ;} break; case 58: /* Line 1455 of yacc.c */ #line 470 "../../JavaScriptCore/parser/Grammar.y" { (yyval.argumentList).m_node.head = (yyvsp[(1) - (3)].argumentList).m_node.head; (yyval.argumentList).m_node.tail = new ArgumentListNode(GLOBAL_DATA, (yyvsp[(1) - (3)].argumentList).m_node.tail, (yyvsp[(3) - (3)].expressionNode).m_node); (yyval.argumentList).m_features = (yyvsp[(1) - (3)].argumentList).m_features | (yyvsp[(3) - (3)].expressionNode).m_features; (yyval.argumentList).m_numConstants = (yyvsp[(1) - (3)].argumentList).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants; ;} break; case 64: /* Line 1455 of yacc.c */ #line 488 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node, OpPlusPlus, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column), (yyvsp[(1) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (2)].expressionNode).m_numConstants); ;} break; case 65: /* Line 1455 of yacc.c */ #line 489 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node, OpMinusMinus, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column), (yyvsp[(1) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (2)].expressionNode).m_numConstants); ;} break; case 67: /* Line 1455 of yacc.c */ #line 494 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node, OpPlusPlus, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column), (yyvsp[(1) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (2)].expressionNode).m_numConstants); ;} break; case 68: /* Line 1455 of yacc.c */ #line 495 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node, OpMinusMinus, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(2) - (2)]).last_column), (yyvsp[(1) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (2)].expressionNode).m_numConstants); ;} break; case 69: /* Line 1455 of yacc.c */ #line 499 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeDeleteNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).last_column, (yylsp[(2) - (2)]).last_column), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 70: /* Line 1455 of yacc.c */ #line 500 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new VoidNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants + 1); ;} break; case 71: /* Line 1455 of yacc.c */ #line 501 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeTypeOfNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 72: /* Line 1455 of yacc.c */ #line 502 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node, OpPlusPlus, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column), (yyvsp[(2) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 73: /* Line 1455 of yacc.c */ #line 503 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node, OpPlusPlus, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column), (yyvsp[(2) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 74: /* Line 1455 of yacc.c */ #line 504 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node, OpMinusMinus, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column), (yyvsp[(2) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 75: /* Line 1455 of yacc.c */ #line 505 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node, OpMinusMinus, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column), (yyvsp[(2) - (2)].expressionNode).m_features | AssignFeature, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 76: /* Line 1455 of yacc.c */ #line 506 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new UnaryPlusNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 77: /* Line 1455 of yacc.c */ #line 507 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeNegateNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 78: /* Line 1455 of yacc.c */ #line 508 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeBitwiseNotNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 79: /* Line 1455 of yacc.c */ #line 509 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalNotNode(GLOBAL_DATA, (yyvsp[(2) - (2)].expressionNode).m_node), (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 85: /* Line 1455 of yacc.c */ #line 523 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 86: /* Line 1455 of yacc.c */ #line 524 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 87: /* Line 1455 of yacc.c */ #line 525 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 89: /* Line 1455 of yacc.c */ #line 531 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 90: /* Line 1455 of yacc.c */ #line 533 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 91: /* Line 1455 of yacc.c */ #line 535 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 93: /* Line 1455 of yacc.c */ #line 540 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 94: /* Line 1455 of yacc.c */ #line 541 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 96: /* Line 1455 of yacc.c */ #line 547 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 97: /* Line 1455 of yacc.c */ #line 549 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 99: /* Line 1455 of yacc.c */ #line 554 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 100: /* Line 1455 of yacc.c */ #line 555 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 101: /* Line 1455 of yacc.c */ #line 556 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 103: /* Line 1455 of yacc.c */ #line 561 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 104: /* Line 1455 of yacc.c */ #line 562 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 105: /* Line 1455 of yacc.c */ #line 563 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 107: /* Line 1455 of yacc.c */ #line 568 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 108: /* Line 1455 of yacc.c */ #line 569 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 109: /* Line 1455 of yacc.c */ #line 570 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 110: /* Line 1455 of yacc.c */ #line 571 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 111: /* Line 1455 of yacc.c */ #line 572 "../../JavaScriptCore/parser/Grammar.y" { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(3) - (3)]).first_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 112: /* Line 1455 of yacc.c */ #line 575 "../../JavaScriptCore/parser/Grammar.y" { InNode* node = new InNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(3) - (3)]).first_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 114: /* Line 1455 of yacc.c */ #line 582 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 115: /* Line 1455 of yacc.c */ #line 583 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 116: /* Line 1455 of yacc.c */ #line 584 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 117: /* Line 1455 of yacc.c */ #line 585 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 118: /* Line 1455 of yacc.c */ #line 587 "../../JavaScriptCore/parser/Grammar.y" { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(3) - (3)]).first_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 120: /* Line 1455 of yacc.c */ #line 594 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 121: /* Line 1455 of yacc.c */ #line 595 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 122: /* Line 1455 of yacc.c */ #line 596 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 123: /* Line 1455 of yacc.c */ #line 597 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 124: /* Line 1455 of yacc.c */ #line 599 "../../JavaScriptCore/parser/Grammar.y" { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(3) - (3)]).first_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 125: /* Line 1455 of yacc.c */ #line 603 "../../JavaScriptCore/parser/Grammar.y" { InNode* node = new InNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(3) - (3)]).first_column, (yylsp[(3) - (3)]).last_column); (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(node, (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 127: /* Line 1455 of yacc.c */ #line 610 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 128: /* Line 1455 of yacc.c */ #line 611 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 129: /* Line 1455 of yacc.c */ #line 612 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 130: /* Line 1455 of yacc.c */ #line 613 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 132: /* Line 1455 of yacc.c */ #line 619 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 133: /* Line 1455 of yacc.c */ #line 621 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 134: /* Line 1455 of yacc.c */ #line 623 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 135: /* Line 1455 of yacc.c */ #line 625 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 137: /* Line 1455 of yacc.c */ #line 631 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 138: /* Line 1455 of yacc.c */ #line 632 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 139: /* Line 1455 of yacc.c */ #line 634 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 140: /* Line 1455 of yacc.c */ #line 636 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 142: /* Line 1455 of yacc.c */ #line 641 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 144: /* Line 1455 of yacc.c */ #line 647 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 146: /* Line 1455 of yacc.c */ #line 652 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 148: /* Line 1455 of yacc.c */ #line 657 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 150: /* Line 1455 of yacc.c */ #line 663 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 152: /* Line 1455 of yacc.c */ #line 669 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 154: /* Line 1455 of yacc.c */ #line 674 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 156: /* Line 1455 of yacc.c */ #line 680 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 158: /* Line 1455 of yacc.c */ #line 686 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 160: /* Line 1455 of yacc.c */ #line 691 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalAnd), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 162: /* Line 1455 of yacc.c */ #line 697 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalAnd), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 164: /* Line 1455 of yacc.c */ #line 703 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalAnd), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 166: /* Line 1455 of yacc.c */ #line 708 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalOr), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 168: /* Line 1455 of yacc.c */ #line 714 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalOr), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 170: /* Line 1455 of yacc.c */ #line 719 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node, OpLogicalOr), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 172: /* Line 1455 of yacc.c */ #line 725 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, (yyvsp[(1) - (5)].expressionNode).m_node, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].expressionNode).m_node), (yyvsp[(1) - (5)].expressionNode).m_features | (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].expressionNode).m_features, (yyvsp[(1) - (5)].expressionNode).m_numConstants + (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].expressionNode).m_numConstants); ;} break; case 174: /* Line 1455 of yacc.c */ #line 731 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, (yyvsp[(1) - (5)].expressionNode).m_node, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].expressionNode).m_node), (yyvsp[(1) - (5)].expressionNode).m_features | (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].expressionNode).m_features, (yyvsp[(1) - (5)].expressionNode).m_numConstants + (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].expressionNode).m_numConstants); ;} break; case 176: /* Line 1455 of yacc.c */ #line 737 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, (yyvsp[(1) - (5)].expressionNode).m_node, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].expressionNode).m_node), (yyvsp[(1) - (5)].expressionNode).m_features | (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].expressionNode).m_features, (yyvsp[(1) - (5)].expressionNode).m_numConstants + (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].expressionNode).m_numConstants); ;} break; case 178: /* Line 1455 of yacc.c */ #line 743 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(2) - (3)].op), (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(1) - (3)].expressionNode).m_features & AssignFeature, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).first_column + 1, (yylsp[(3) - (3)]).last_column), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 180: /* Line 1455 of yacc.c */ #line 751 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(2) - (3)].op), (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(1) - (3)].expressionNode).m_features & AssignFeature, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).first_column + 1, (yylsp[(3) - (3)]).last_column), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 182: /* Line 1455 of yacc.c */ #line 759 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(2) - (3)].op), (yyvsp[(3) - (3)].expressionNode).m_node, (yyvsp[(1) - (3)].expressionNode).m_features & AssignFeature, (yyvsp[(3) - (3)].expressionNode).m_features & AssignFeature, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).first_column + 1, (yylsp[(3) - (3)]).last_column), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features | AssignFeature, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 183: /* Line 1455 of yacc.c */ #line 765 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpEqual; ;} break; case 184: /* Line 1455 of yacc.c */ #line 766 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpPlusEq; ;} break; case 185: /* Line 1455 of yacc.c */ #line 767 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpMinusEq; ;} break; case 186: /* Line 1455 of yacc.c */ #line 768 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpMultEq; ;} break; case 187: /* Line 1455 of yacc.c */ #line 769 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpDivEq; ;} break; case 188: /* Line 1455 of yacc.c */ #line 770 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpLShift; ;} break; case 189: /* Line 1455 of yacc.c */ #line 771 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpRShift; ;} break; case 190: /* Line 1455 of yacc.c */ #line 772 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpURShift; ;} break; case 191: /* Line 1455 of yacc.c */ #line 773 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpAndEq; ;} break; case 192: /* Line 1455 of yacc.c */ #line 774 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpXOrEq; ;} break; case 193: /* Line 1455 of yacc.c */ #line 775 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpOrEq; ;} break; case 194: /* Line 1455 of yacc.c */ #line 776 "../../JavaScriptCore/parser/Grammar.y" { (yyval.op) = OpModEq; ;} break; case 196: /* Line 1455 of yacc.c */ #line 781 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 198: /* Line 1455 of yacc.c */ #line 786 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 200: /* Line 1455 of yacc.c */ #line 791 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, (yyvsp[(1) - (3)].expressionNode).m_node, (yyvsp[(3) - (3)].expressionNode).m_node), (yyvsp[(1) - (3)].expressionNode).m_features | (yyvsp[(3) - (3)].expressionNode).m_features, (yyvsp[(1) - (3)].expressionNode).m_numConstants + (yyvsp[(3) - (3)].expressionNode).m_numConstants); ;} break; case 218: /* Line 1455 of yacc.c */ #line 815 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 219: /* Line 1455 of yacc.c */ #line 817 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, (yyvsp[(2) - (3)].sourceElements).m_node), (yyvsp[(2) - (3)].sourceElements).m_varDeclarations, (yyvsp[(2) - (3)].sourceElements).m_funcDeclarations, (yyvsp[(2) - (3)].sourceElements).m_features, (yyvsp[(2) - (3)].sourceElements).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 220: /* Line 1455 of yacc.c */ #line 822 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, (yyvsp[(2) - (3)].varDeclList).m_node), (yyvsp[(2) - (3)].varDeclList).m_varDeclarations, (yyvsp[(2) - (3)].varDeclList).m_funcDeclarations, (yyvsp[(2) - (3)].varDeclList).m_features, (yyvsp[(2) - (3)].varDeclList).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 221: /* Line 1455 of yacc.c */ #line 824 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, (yyvsp[(2) - (3)].varDeclList).m_node), (yyvsp[(2) - (3)].varDeclList).m_varDeclarations, (yyvsp[(2) - (3)].varDeclList).m_funcDeclarations, (yyvsp[(2) - (3)].varDeclList).m_features, (yyvsp[(2) - (3)].varDeclList).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 222: /* Line 1455 of yacc.c */ #line 830 "../../JavaScriptCore/parser/Grammar.y" { (yyval.varDeclList).m_node = 0; (yyval.varDeclList).m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(1) - (1)].ident), 0); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (*(yyvsp[(1) - (1)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; (yyval.varDeclList).m_numConstants = 0; ;} break; case 223: /* Line 1455 of yacc.c */ #line 837 "../../JavaScriptCore/parser/Grammar.y" { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *(yyvsp[(1) - (2)].ident), (yyvsp[(2) - (2)].expressionNode).m_node, (yyvsp[(2) - (2)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column); (yyval.varDeclList).m_node = node; (yyval.varDeclList).m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(1) - (2)].ident), DeclarationStacks::HasInitializer); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = ((*(yyvsp[(1) - (2)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(2) - (2)].expressionNode).m_features; (yyval.varDeclList).m_numConstants = (yyvsp[(2) - (2)].expressionNode).m_numConstants; ;} break; case 224: /* Line 1455 of yacc.c */ #line 847 "../../JavaScriptCore/parser/Grammar.y" { (yyval.varDeclList).m_node = (yyvsp[(1) - (3)].varDeclList).m_node; (yyval.varDeclList).m_varDeclarations = (yyvsp[(1) - (3)].varDeclList).m_varDeclarations; appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(3) - (3)].ident), 0); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (yyvsp[(1) - (3)].varDeclList).m_features | ((*(yyvsp[(3) - (3)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); (yyval.varDeclList).m_numConstants = (yyvsp[(1) - (3)].varDeclList).m_numConstants; ;} break; case 225: /* Line 1455 of yacc.c */ #line 855 "../../JavaScriptCore/parser/Grammar.y" { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *(yyvsp[(3) - (4)].ident), (yyvsp[(4) - (4)].expressionNode).m_node, (yyvsp[(4) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(3) - (4)]).first_column, (yylsp[(4) - (4)]).first_column + 1, (yylsp[(4) - (4)]).last_column); (yyval.varDeclList).m_node = combineVarInitializers(GLOBAL_DATA, (yyvsp[(1) - (4)].varDeclList).m_node, node); (yyval.varDeclList).m_varDeclarations = (yyvsp[(1) - (4)].varDeclList).m_varDeclarations; appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(3) - (4)].ident), DeclarationStacks::HasInitializer); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (yyvsp[(1) - (4)].varDeclList).m_features | ((*(yyvsp[(3) - (4)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(4) - (4)].expressionNode).m_features; (yyval.varDeclList).m_numConstants = (yyvsp[(1) - (4)].varDeclList).m_numConstants + (yyvsp[(4) - (4)].expressionNode).m_numConstants; ;} break; case 226: /* Line 1455 of yacc.c */ #line 867 "../../JavaScriptCore/parser/Grammar.y" { (yyval.varDeclList).m_node = 0; (yyval.varDeclList).m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(1) - (1)].ident), 0); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (*(yyvsp[(1) - (1)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; (yyval.varDeclList).m_numConstants = 0; ;} break; case 227: /* Line 1455 of yacc.c */ #line 874 "../../JavaScriptCore/parser/Grammar.y" { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *(yyvsp[(1) - (2)].ident), (yyvsp[(2) - (2)].expressionNode).m_node, (yyvsp[(2) - (2)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(2) - (2)]).first_column + 1, (yylsp[(2) - (2)]).last_column); (yyval.varDeclList).m_node = node; (yyval.varDeclList).m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(1) - (2)].ident), DeclarationStacks::HasInitializer); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = ((*(yyvsp[(1) - (2)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(2) - (2)].expressionNode).m_features; (yyval.varDeclList).m_numConstants = (yyvsp[(2) - (2)].expressionNode).m_numConstants; ;} break; case 228: /* Line 1455 of yacc.c */ #line 884 "../../JavaScriptCore/parser/Grammar.y" { (yyval.varDeclList).m_node = (yyvsp[(1) - (3)].varDeclList).m_node; (yyval.varDeclList).m_varDeclarations = (yyvsp[(1) - (3)].varDeclList).m_varDeclarations; appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(3) - (3)].ident), 0); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (yyvsp[(1) - (3)].varDeclList).m_features | ((*(yyvsp[(3) - (3)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); (yyval.varDeclList).m_numConstants = (yyvsp[(1) - (3)].varDeclList).m_numConstants; ;} break; case 229: /* Line 1455 of yacc.c */ #line 892 "../../JavaScriptCore/parser/Grammar.y" { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *(yyvsp[(3) - (4)].ident), (yyvsp[(4) - (4)].expressionNode).m_node, (yyvsp[(4) - (4)].expressionNode).m_features & AssignFeature); SET_EXCEPTION_LOCATION(node, (yylsp[(3) - (4)]).first_column, (yylsp[(4) - (4)]).first_column + 1, (yylsp[(4) - (4)]).last_column); (yyval.varDeclList).m_node = combineVarInitializers(GLOBAL_DATA, (yyvsp[(1) - (4)].varDeclList).m_node, node); (yyval.varDeclList).m_varDeclarations = (yyvsp[(1) - (4)].varDeclList).m_varDeclarations; appendToVarDeclarationList(GLOBAL_DATA, (yyval.varDeclList).m_varDeclarations, *(yyvsp[(3) - (4)].ident), DeclarationStacks::HasInitializer); (yyval.varDeclList).m_funcDeclarations = 0; (yyval.varDeclList).m_features = (yyvsp[(1) - (4)].varDeclList).m_features | ((*(yyvsp[(3) - (4)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(4) - (4)].expressionNode).m_features; (yyval.varDeclList).m_numConstants = (yyvsp[(1) - (4)].varDeclList).m_numConstants + (yyvsp[(4) - (4)].expressionNode).m_numConstants; ;} break; case 230: /* Line 1455 of yacc.c */ #line 904 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, (yyvsp[(2) - (3)].constDeclList).m_node.head), (yyvsp[(2) - (3)].constDeclList).m_varDeclarations, (yyvsp[(2) - (3)].constDeclList).m_funcDeclarations, (yyvsp[(2) - (3)].constDeclList).m_features, (yyvsp[(2) - (3)].constDeclList).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 231: /* Line 1455 of yacc.c */ #line 907 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, (yyvsp[(2) - (3)].constDeclList).m_node.head), (yyvsp[(2) - (3)].constDeclList).m_varDeclarations, (yyvsp[(2) - (3)].constDeclList).m_funcDeclarations, (yyvsp[(2) - (3)].constDeclList).m_features, (yyvsp[(2) - (3)].constDeclList).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 232: /* Line 1455 of yacc.c */ #line 912 "../../JavaScriptCore/parser/Grammar.y" { (yyval.constDeclList).m_node.head = (yyvsp[(1) - (1)].constDeclNode).m_node; (yyval.constDeclList).m_node.tail = (yyval.constDeclList).m_node.head; (yyval.constDeclList).m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA); appendToVarDeclarationList(GLOBAL_DATA, (yyval.constDeclList).m_varDeclarations, (yyvsp[(1) - (1)].constDeclNode).m_node); (yyval.constDeclList).m_funcDeclarations = 0; (yyval.constDeclList).m_features = (yyvsp[(1) - (1)].constDeclNode).m_features; (yyval.constDeclList).m_numConstants = (yyvsp[(1) - (1)].constDeclNode).m_numConstants; ;} break; case 233: /* Line 1455 of yacc.c */ #line 921 "../../JavaScriptCore/parser/Grammar.y" { (yyval.constDeclList).m_node.head = (yyvsp[(1) - (3)].constDeclList).m_node.head; (yyvsp[(1) - (3)].constDeclList).m_node.tail->m_next = (yyvsp[(3) - (3)].constDeclNode).m_node; (yyval.constDeclList).m_node.tail = (yyvsp[(3) - (3)].constDeclNode).m_node; (yyval.constDeclList).m_varDeclarations = (yyvsp[(1) - (3)].constDeclList).m_varDeclarations; appendToVarDeclarationList(GLOBAL_DATA, (yyval.constDeclList).m_varDeclarations, (yyvsp[(3) - (3)].constDeclNode).m_node); (yyval.constDeclList).m_funcDeclarations = 0; (yyval.constDeclList).m_features = (yyvsp[(1) - (3)].constDeclList).m_features | (yyvsp[(3) - (3)].constDeclNode).m_features; (yyval.constDeclList).m_numConstants = (yyvsp[(1) - (3)].constDeclList).m_numConstants + (yyvsp[(3) - (3)].constDeclNode).m_numConstants; ;} break; case 234: /* Line 1455 of yacc.c */ #line 932 "../../JavaScriptCore/parser/Grammar.y" { (yyval.constDeclNode) = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *(yyvsp[(1) - (1)].ident), 0), (*(yyvsp[(1) - (1)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); ;} break; case 235: /* Line 1455 of yacc.c */ #line 933 "../../JavaScriptCore/parser/Grammar.y" { (yyval.constDeclNode) = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *(yyvsp[(1) - (2)].ident), (yyvsp[(2) - (2)].expressionNode).m_node), ((*(yyvsp[(1) - (2)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(2) - (2)].expressionNode).m_features, (yyvsp[(2) - (2)].expressionNode).m_numConstants); ;} break; case 236: /* Line 1455 of yacc.c */ #line 937 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = (yyvsp[(2) - (2)].expressionNode); ;} break; case 237: /* Line 1455 of yacc.c */ #line 941 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = (yyvsp[(2) - (2)].expressionNode); ;} break; case 238: /* Line 1455 of yacc.c */ #line 945 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); ;} break; case 239: /* Line 1455 of yacc.c */ #line 949 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node), 0, 0, (yyvsp[(1) - (2)].expressionNode).m_features, (yyvsp[(1) - (2)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 240: /* Line 1455 of yacc.c */ #line 951 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, (yyvsp[(1) - (2)].expressionNode).m_node), 0, 0, (yyvsp[(1) - (2)].expressionNode).m_features, (yyvsp[(1) - (2)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(1) - (2)])); AUTO_SEMICOLON; ;} break; case 241: /* Line 1455 of yacc.c */ #line 957 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new IfNode(GLOBAL_DATA, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].statementNode).m_node), (yyvsp[(5) - (5)].statementNode).m_varDeclarations, (yyvsp[(5) - (5)].statementNode).m_funcDeclarations, (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].statementNode).m_features, (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (5)]), (yylsp[(4) - (5)])); ;} break; case 242: /* Line 1455 of yacc.c */ #line 960 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new IfElseNode(GLOBAL_DATA, (yyvsp[(3) - (7)].expressionNode).m_node, (yyvsp[(5) - (7)].statementNode).m_node, (yyvsp[(7) - (7)].statementNode).m_node), mergeDeclarationLists((yyvsp[(5) - (7)].statementNode).m_varDeclarations, (yyvsp[(7) - (7)].statementNode).m_varDeclarations), mergeDeclarationLists((yyvsp[(5) - (7)].statementNode).m_funcDeclarations, (yyvsp[(7) - (7)].statementNode).m_funcDeclarations), (yyvsp[(3) - (7)].expressionNode).m_features | (yyvsp[(5) - (7)].statementNode).m_features | (yyvsp[(7) - (7)].statementNode).m_features, (yyvsp[(3) - (7)].expressionNode).m_numConstants + (yyvsp[(5) - (7)].statementNode).m_numConstants + (yyvsp[(7) - (7)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (7)]), (yylsp[(4) - (7)])); ;} break; case 243: /* Line 1455 of yacc.c */ #line 968 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, (yyvsp[(2) - (7)].statementNode).m_node, (yyvsp[(5) - (7)].expressionNode).m_node), (yyvsp[(2) - (7)].statementNode).m_varDeclarations, (yyvsp[(2) - (7)].statementNode).m_funcDeclarations, (yyvsp[(2) - (7)].statementNode).m_features | (yyvsp[(5) - (7)].expressionNode).m_features, (yyvsp[(2) - (7)].statementNode).m_numConstants + (yyvsp[(5) - (7)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (7)]), (yylsp[(3) - (7)])); ;} break; case 244: /* Line 1455 of yacc.c */ #line 970 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, (yyvsp[(2) - (7)].statementNode).m_node, (yyvsp[(5) - (7)].expressionNode).m_node), (yyvsp[(2) - (7)].statementNode).m_varDeclarations, (yyvsp[(2) - (7)].statementNode).m_funcDeclarations, (yyvsp[(2) - (7)].statementNode).m_features | (yyvsp[(5) - (7)].expressionNode).m_features, (yyvsp[(2) - (7)].statementNode).m_numConstants + (yyvsp[(5) - (7)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (7)]), (yylsp[(3) - (7)])); ;} break; case 245: /* Line 1455 of yacc.c */ #line 972 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new WhileNode(GLOBAL_DATA, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].statementNode).m_node), (yyvsp[(5) - (5)].statementNode).m_varDeclarations, (yyvsp[(5) - (5)].statementNode).m_funcDeclarations, (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].statementNode).m_features, (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (5)]), (yylsp[(4) - (5)])); ;} break; case 246: /* Line 1455 of yacc.c */ #line 975 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, (yyvsp[(3) - (9)].expressionNode).m_node, (yyvsp[(5) - (9)].expressionNode).m_node, (yyvsp[(7) - (9)].expressionNode).m_node, (yyvsp[(9) - (9)].statementNode).m_node, false), (yyvsp[(9) - (9)].statementNode).m_varDeclarations, (yyvsp[(9) - (9)].statementNode).m_funcDeclarations, (yyvsp[(3) - (9)].expressionNode).m_features | (yyvsp[(5) - (9)].expressionNode).m_features | (yyvsp[(7) - (9)].expressionNode).m_features | (yyvsp[(9) - (9)].statementNode).m_features, (yyvsp[(3) - (9)].expressionNode).m_numConstants + (yyvsp[(5) - (9)].expressionNode).m_numConstants + (yyvsp[(7) - (9)].expressionNode).m_numConstants + (yyvsp[(9) - (9)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (9)]), (yylsp[(8) - (9)])); ;} break; case 247: /* Line 1455 of yacc.c */ #line 981 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, (yyvsp[(4) - (10)].varDeclList).m_node, (yyvsp[(6) - (10)].expressionNode).m_node, (yyvsp[(8) - (10)].expressionNode).m_node, (yyvsp[(10) - (10)].statementNode).m_node, true), mergeDeclarationLists((yyvsp[(4) - (10)].varDeclList).m_varDeclarations, (yyvsp[(10) - (10)].statementNode).m_varDeclarations), mergeDeclarationLists((yyvsp[(4) - (10)].varDeclList).m_funcDeclarations, (yyvsp[(10) - (10)].statementNode).m_funcDeclarations), (yyvsp[(4) - (10)].varDeclList).m_features | (yyvsp[(6) - (10)].expressionNode).m_features | (yyvsp[(8) - (10)].expressionNode).m_features | (yyvsp[(10) - (10)].statementNode).m_features, (yyvsp[(4) - (10)].varDeclList).m_numConstants + (yyvsp[(6) - (10)].expressionNode).m_numConstants + (yyvsp[(8) - (10)].expressionNode).m_numConstants + (yyvsp[(10) - (10)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (10)]), (yylsp[(9) - (10)])); ;} break; case 248: /* Line 1455 of yacc.c */ #line 988 "../../JavaScriptCore/parser/Grammar.y" { ForInNode* node = new ForInNode(GLOBAL_DATA, (yyvsp[(3) - (7)].expressionNode).m_node, (yyvsp[(5) - (7)].expressionNode).m_node, (yyvsp[(7) - (7)].statementNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(3) - (7)]).first_column, (yylsp[(3) - (7)]).last_column, (yylsp[(5) - (7)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, (yyvsp[(7) - (7)].statementNode).m_varDeclarations, (yyvsp[(7) - (7)].statementNode).m_funcDeclarations, (yyvsp[(3) - (7)].expressionNode).m_features | (yyvsp[(5) - (7)].expressionNode).m_features | (yyvsp[(7) - (7)].statementNode).m_features, (yyvsp[(3) - (7)].expressionNode).m_numConstants + (yyvsp[(5) - (7)].expressionNode).m_numConstants + (yyvsp[(7) - (7)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (7)]), (yylsp[(6) - (7)])); ;} break; case 249: /* Line 1455 of yacc.c */ #line 997 "../../JavaScriptCore/parser/Grammar.y" { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *(yyvsp[(4) - (8)].ident), 0, (yyvsp[(6) - (8)].expressionNode).m_node, (yyvsp[(8) - (8)].statementNode).m_node, (yylsp[(5) - (8)]).first_column, (yylsp[(5) - (8)]).first_column - (yylsp[(4) - (8)]).first_column, (yylsp[(6) - (8)]).last_column - (yylsp[(5) - (8)]).first_column); SET_EXCEPTION_LOCATION(forIn, (yylsp[(4) - (8)]).first_column, (yylsp[(5) - (8)]).first_column + 1, (yylsp[(6) - (8)]).last_column); appendToVarDeclarationList(GLOBAL_DATA, (yyvsp[(8) - (8)].statementNode).m_varDeclarations, *(yyvsp[(4) - (8)].ident), DeclarationStacks::HasInitializer); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(forIn, (yyvsp[(8) - (8)].statementNode).m_varDeclarations, (yyvsp[(8) - (8)].statementNode).m_funcDeclarations, ((*(yyvsp[(4) - (8)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(6) - (8)].expressionNode).m_features | (yyvsp[(8) - (8)].statementNode).m_features, (yyvsp[(6) - (8)].expressionNode).m_numConstants + (yyvsp[(8) - (8)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (8)]), (yylsp[(7) - (8)])); ;} break; case 250: /* Line 1455 of yacc.c */ #line 1003 "../../JavaScriptCore/parser/Grammar.y" { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *(yyvsp[(4) - (9)].ident), (yyvsp[(5) - (9)].expressionNode).m_node, (yyvsp[(7) - (9)].expressionNode).m_node, (yyvsp[(9) - (9)].statementNode).m_node, (yylsp[(5) - (9)]).first_column, (yylsp[(5) - (9)]).first_column - (yylsp[(4) - (9)]).first_column, (yylsp[(5) - (9)]).last_column - (yylsp[(5) - (9)]).first_column); SET_EXCEPTION_LOCATION(forIn, (yylsp[(4) - (9)]).first_column, (yylsp[(6) - (9)]).first_column + 1, (yylsp[(7) - (9)]).last_column); appendToVarDeclarationList(GLOBAL_DATA, (yyvsp[(9) - (9)].statementNode).m_varDeclarations, *(yyvsp[(4) - (9)].ident), DeclarationStacks::HasInitializer); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(forIn, (yyvsp[(9) - (9)].statementNode).m_varDeclarations, (yyvsp[(9) - (9)].statementNode).m_funcDeclarations, ((*(yyvsp[(4) - (9)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(5) - (9)].expressionNode).m_features | (yyvsp[(7) - (9)].expressionNode).m_features | (yyvsp[(9) - (9)].statementNode).m_features, (yyvsp[(5) - (9)].expressionNode).m_numConstants + (yyvsp[(7) - (9)].expressionNode).m_numConstants + (yyvsp[(9) - (9)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (9)]), (yylsp[(8) - (9)])); ;} break; case 251: /* Line 1455 of yacc.c */ #line 1013 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(0, 0, 0); ;} break; case 253: /* Line 1455 of yacc.c */ #line 1018 "../../JavaScriptCore/parser/Grammar.y" { (yyval.expressionNode) = createNodeInfo<ExpressionNode*>(0, 0, 0); ;} break; case 255: /* Line 1455 of yacc.c */ #line 1023 "../../JavaScriptCore/parser/Grammar.y" { ContinueNode* node = new ContinueNode(GLOBAL_DATA); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 256: /* Line 1455 of yacc.c */ #line 1027 "../../JavaScriptCore/parser/Grammar.y" { ContinueNode* node = new ContinueNode(GLOBAL_DATA); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(1) - (2)])); AUTO_SEMICOLON; ;} break; case 257: /* Line 1455 of yacc.c */ #line 1031 "../../JavaScriptCore/parser/Grammar.y" { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *(yyvsp[(2) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 258: /* Line 1455 of yacc.c */ #line 1035 "../../JavaScriptCore/parser/Grammar.y" { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *(yyvsp[(2) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 259: /* Line 1455 of yacc.c */ #line 1042 "../../JavaScriptCore/parser/Grammar.y" { BreakNode* node = new BreakNode(GLOBAL_DATA); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 260: /* Line 1455 of yacc.c */ #line 1045 "../../JavaScriptCore/parser/Grammar.y" { BreakNode* node = new BreakNode(GLOBAL_DATA); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(1) - (2)])); AUTO_SEMICOLON; ;} break; case 261: /* Line 1455 of yacc.c */ #line 1048 "../../JavaScriptCore/parser/Grammar.y" { BreakNode* node = new BreakNode(GLOBAL_DATA, *(yyvsp[(2) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 262: /* Line 1455 of yacc.c */ #line 1051 "../../JavaScriptCore/parser/Grammar.y" { BreakNode* node = new BreakNode(GLOBAL_DATA, *(yyvsp[(2) - (3)].ident)); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA, *(yyvsp[(2) - (3)].ident)), 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 263: /* Line 1455 of yacc.c */ #line 1057 "../../JavaScriptCore/parser/Grammar.y" { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 264: /* Line 1455 of yacc.c */ #line 1060 "../../JavaScriptCore/parser/Grammar.y" { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (2)]).first_column, (yylsp[(1) - (2)]).last_column, (yylsp[(1) - (2)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(1) - (2)])); AUTO_SEMICOLON; ;} break; case 265: /* Line 1455 of yacc.c */ #line 1063 "../../JavaScriptCore/parser/Grammar.y" { ReturnNode* node = new ReturnNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, (yyvsp[(2) - (3)].expressionNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(3) - (3)])); ;} break; case 266: /* Line 1455 of yacc.c */ #line 1066 "../../JavaScriptCore/parser/Grammar.y" { ReturnNode* node = new ReturnNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, (yyvsp[(2) - (3)].expressionNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 267: /* Line 1455 of yacc.c */ #line 1072 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].statementNode).m_node, (yylsp[(3) - (5)]).last_column, (yylsp[(3) - (5)]).last_column - (yylsp[(3) - (5)]).first_column), (yyvsp[(5) - (5)].statementNode).m_varDeclarations, (yyvsp[(5) - (5)].statementNode).m_funcDeclarations, (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].statementNode).m_features | WithFeature, (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (5)]), (yylsp[(4) - (5)])); ;} break; case 268: /* Line 1455 of yacc.c */ #line 1078 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new SwitchNode(GLOBAL_DATA, (yyvsp[(3) - (5)].expressionNode).m_node, (yyvsp[(5) - (5)].caseBlockNode).m_node), (yyvsp[(5) - (5)].caseBlockNode).m_varDeclarations, (yyvsp[(5) - (5)].caseBlockNode).m_funcDeclarations, (yyvsp[(3) - (5)].expressionNode).m_features | (yyvsp[(5) - (5)].caseBlockNode).m_features, (yyvsp[(3) - (5)].expressionNode).m_numConstants + (yyvsp[(5) - (5)].caseBlockNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (5)]), (yylsp[(4) - (5)])); ;} break; case 269: /* Line 1455 of yacc.c */ #line 1084 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseBlockNode) = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, (yyvsp[(2) - (3)].clauseList).m_node.head, 0, 0), (yyvsp[(2) - (3)].clauseList).m_varDeclarations, (yyvsp[(2) - (3)].clauseList).m_funcDeclarations, (yyvsp[(2) - (3)].clauseList).m_features, (yyvsp[(2) - (3)].clauseList).m_numConstants); ;} break; case 270: /* Line 1455 of yacc.c */ #line 1086 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseBlockNode) = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, (yyvsp[(2) - (5)].clauseList).m_node.head, (yyvsp[(3) - (5)].caseClauseNode).m_node, (yyvsp[(4) - (5)].clauseList).m_node.head), mergeDeclarationLists(mergeDeclarationLists((yyvsp[(2) - (5)].clauseList).m_varDeclarations, (yyvsp[(3) - (5)].caseClauseNode).m_varDeclarations), (yyvsp[(4) - (5)].clauseList).m_varDeclarations), mergeDeclarationLists(mergeDeclarationLists((yyvsp[(2) - (5)].clauseList).m_funcDeclarations, (yyvsp[(3) - (5)].caseClauseNode).m_funcDeclarations), (yyvsp[(4) - (5)].clauseList).m_funcDeclarations), (yyvsp[(2) - (5)].clauseList).m_features | (yyvsp[(3) - (5)].caseClauseNode).m_features | (yyvsp[(4) - (5)].clauseList).m_features, (yyvsp[(2) - (5)].clauseList).m_numConstants + (yyvsp[(3) - (5)].caseClauseNode).m_numConstants + (yyvsp[(4) - (5)].clauseList).m_numConstants); ;} break; case 271: /* Line 1455 of yacc.c */ #line 1094 "../../JavaScriptCore/parser/Grammar.y" { (yyval.clauseList).m_node.head = 0; (yyval.clauseList).m_node.tail = 0; (yyval.clauseList).m_varDeclarations = 0; (yyval.clauseList).m_funcDeclarations = 0; (yyval.clauseList).m_features = 0; (yyval.clauseList).m_numConstants = 0; ;} break; case 273: /* Line 1455 of yacc.c */ #line 1099 "../../JavaScriptCore/parser/Grammar.y" { (yyval.clauseList).m_node.head = new ClauseListNode(GLOBAL_DATA, (yyvsp[(1) - (1)].caseClauseNode).m_node); (yyval.clauseList).m_node.tail = (yyval.clauseList).m_node.head; (yyval.clauseList).m_varDeclarations = (yyvsp[(1) - (1)].caseClauseNode).m_varDeclarations; (yyval.clauseList).m_funcDeclarations = (yyvsp[(1) - (1)].caseClauseNode).m_funcDeclarations; (yyval.clauseList).m_features = (yyvsp[(1) - (1)].caseClauseNode).m_features; (yyval.clauseList).m_numConstants = (yyvsp[(1) - (1)].caseClauseNode).m_numConstants; ;} break; case 274: /* Line 1455 of yacc.c */ #line 1105 "../../JavaScriptCore/parser/Grammar.y" { (yyval.clauseList).m_node.head = (yyvsp[(1) - (2)].clauseList).m_node.head; (yyval.clauseList).m_node.tail = new ClauseListNode(GLOBAL_DATA, (yyvsp[(1) - (2)].clauseList).m_node.tail, (yyvsp[(2) - (2)].caseClauseNode).m_node); (yyval.clauseList).m_varDeclarations = mergeDeclarationLists((yyvsp[(1) - (2)].clauseList).m_varDeclarations, (yyvsp[(2) - (2)].caseClauseNode).m_varDeclarations); (yyval.clauseList).m_funcDeclarations = mergeDeclarationLists((yyvsp[(1) - (2)].clauseList).m_funcDeclarations, (yyvsp[(2) - (2)].caseClauseNode).m_funcDeclarations); (yyval.clauseList).m_features = (yyvsp[(1) - (2)].clauseList).m_features | (yyvsp[(2) - (2)].caseClauseNode).m_features; (yyval.clauseList).m_numConstants = (yyvsp[(1) - (2)].clauseList).m_numConstants + (yyvsp[(2) - (2)].caseClauseNode).m_numConstants; ;} break; case 275: /* Line 1455 of yacc.c */ #line 1115 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseClauseNode) = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node), 0, 0, (yyvsp[(2) - (3)].expressionNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants); ;} break; case 276: /* Line 1455 of yacc.c */ #line 1116 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseClauseNode) = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, (yyvsp[(2) - (4)].expressionNode).m_node, (yyvsp[(4) - (4)].sourceElements).m_node), (yyvsp[(4) - (4)].sourceElements).m_varDeclarations, (yyvsp[(4) - (4)].sourceElements).m_funcDeclarations, (yyvsp[(2) - (4)].expressionNode).m_features | (yyvsp[(4) - (4)].sourceElements).m_features, (yyvsp[(2) - (4)].expressionNode).m_numConstants + (yyvsp[(4) - (4)].sourceElements).m_numConstants); ;} break; case 277: /* Line 1455 of yacc.c */ #line 1120 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseClauseNode) = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); ;} break; case 278: /* Line 1455 of yacc.c */ #line 1121 "../../JavaScriptCore/parser/Grammar.y" { (yyval.caseClauseNode) = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0, (yyvsp[(3) - (3)].sourceElements).m_node), (yyvsp[(3) - (3)].sourceElements).m_varDeclarations, (yyvsp[(3) - (3)].sourceElements).m_funcDeclarations, (yyvsp[(3) - (3)].sourceElements).m_features, (yyvsp[(3) - (3)].sourceElements).m_numConstants); ;} break; case 279: /* Line 1455 of yacc.c */ #line 1125 "../../JavaScriptCore/parser/Grammar.y" { LabelNode* node = new LabelNode(GLOBAL_DATA, *(yyvsp[(1) - (3)].ident), (yyvsp[(3) - (3)].statementNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, (yyvsp[(3) - (3)].statementNode).m_varDeclarations, (yyvsp[(3) - (3)].statementNode).m_funcDeclarations, (yyvsp[(3) - (3)].statementNode).m_features, (yyvsp[(3) - (3)].statementNode).m_numConstants); ;} break; case 280: /* Line 1455 of yacc.c */ #line 1131 "../../JavaScriptCore/parser/Grammar.y" { ThrowNode* node = new ThrowNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, (yyvsp[(2) - (3)].expressionNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); ;} break; case 281: /* Line 1455 of yacc.c */ #line 1135 "../../JavaScriptCore/parser/Grammar.y" { ThrowNode* node = new ThrowNode(GLOBAL_DATA, (yyvsp[(2) - (3)].expressionNode).m_node); SET_EXCEPTION_LOCATION(node, (yylsp[(1) - (3)]).first_column, (yylsp[(2) - (3)]).last_column, (yylsp[(2) - (3)]).last_column); (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, (yyvsp[(2) - (3)].expressionNode).m_features, (yyvsp[(2) - (3)].expressionNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (3)]), (yylsp[(2) - (3)])); AUTO_SEMICOLON; ;} break; case 282: /* Line 1455 of yacc.c */ #line 1142 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, (yyvsp[(2) - (4)].statementNode).m_node, GLOBAL_DATA->propertyNames->nullIdentifier, false, 0, (yyvsp[(4) - (4)].statementNode).m_node), mergeDeclarationLists((yyvsp[(2) - (4)].statementNode).m_varDeclarations, (yyvsp[(4) - (4)].statementNode).m_varDeclarations), mergeDeclarationLists((yyvsp[(2) - (4)].statementNode).m_funcDeclarations, (yyvsp[(4) - (4)].statementNode).m_funcDeclarations), (yyvsp[(2) - (4)].statementNode).m_features | (yyvsp[(4) - (4)].statementNode).m_features, (yyvsp[(2) - (4)].statementNode).m_numConstants + (yyvsp[(4) - (4)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (4)]), (yylsp[(2) - (4)])); ;} break; case 283: /* Line 1455 of yacc.c */ #line 1148 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, (yyvsp[(2) - (7)].statementNode).m_node, *(yyvsp[(5) - (7)].ident), ((yyvsp[(7) - (7)].statementNode).m_features & EvalFeature) != 0, (yyvsp[(7) - (7)].statementNode).m_node, 0), mergeDeclarationLists((yyvsp[(2) - (7)].statementNode).m_varDeclarations, (yyvsp[(7) - (7)].statementNode).m_varDeclarations), mergeDeclarationLists((yyvsp[(2) - (7)].statementNode).m_funcDeclarations, (yyvsp[(7) - (7)].statementNode).m_funcDeclarations), (yyvsp[(2) - (7)].statementNode).m_features | (yyvsp[(7) - (7)].statementNode).m_features | CatchFeature, (yyvsp[(2) - (7)].statementNode).m_numConstants + (yyvsp[(7) - (7)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (7)]), (yylsp[(2) - (7)])); ;} break; case 284: /* Line 1455 of yacc.c */ #line 1155 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, (yyvsp[(2) - (9)].statementNode).m_node, *(yyvsp[(5) - (9)].ident), ((yyvsp[(7) - (9)].statementNode).m_features & EvalFeature) != 0, (yyvsp[(7) - (9)].statementNode).m_node, (yyvsp[(9) - (9)].statementNode).m_node), mergeDeclarationLists(mergeDeclarationLists((yyvsp[(2) - (9)].statementNode).m_varDeclarations, (yyvsp[(7) - (9)].statementNode).m_varDeclarations), (yyvsp[(9) - (9)].statementNode).m_varDeclarations), mergeDeclarationLists(mergeDeclarationLists((yyvsp[(2) - (9)].statementNode).m_funcDeclarations, (yyvsp[(7) - (9)].statementNode).m_funcDeclarations), (yyvsp[(9) - (9)].statementNode).m_funcDeclarations), (yyvsp[(2) - (9)].statementNode).m_features | (yyvsp[(7) - (9)].statementNode).m_features | (yyvsp[(9) - (9)].statementNode).m_features | CatchFeature, (yyvsp[(2) - (9)].statementNode).m_numConstants + (yyvsp[(7) - (9)].statementNode).m_numConstants + (yyvsp[(9) - (9)].statementNode).m_numConstants); DBG((yyval.statementNode).m_node, (yylsp[(1) - (9)]), (yylsp[(2) - (9)])); ;} break; case 285: /* Line 1455 of yacc.c */ #line 1164 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(2) - (2)])); ;} break; case 286: /* Line 1455 of yacc.c */ #line 1166 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0); DBG((yyval.statementNode).m_node, (yylsp[(1) - (2)]), (yylsp[(1) - (2)])); AUTO_SEMICOLON; ;} break; case 287: /* Line 1455 of yacc.c */ #line 1171 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *(yyvsp[(2) - (7)].ident), (yyvsp[(6) - (7)].functionBodyNode), LEXER->sourceCode((yyvsp[(5) - (7)].intValue), (yyvsp[(7) - (7)].intValue), (yylsp[(5) - (7)]).first_line)), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*(yyvsp[(2) - (7)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG((yyvsp[(6) - (7)].functionBodyNode), (yylsp[(5) - (7)]), (yylsp[(7) - (7)])); (yyval.statementNode).m_funcDeclarations->data.append(static_cast<FuncDeclNode*>((yyval.statementNode).m_node)); ;} break; case 288: /* Line 1455 of yacc.c */ #line 1173 "../../JavaScriptCore/parser/Grammar.y" { (yyval.statementNode) = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *(yyvsp[(2) - (8)].ident), (yyvsp[(7) - (8)].functionBodyNode), LEXER->sourceCode((yyvsp[(6) - (8)].intValue), (yyvsp[(8) - (8)].intValue), (yylsp[(6) - (8)]).first_line), (yyvsp[(4) - (8)].parameterList).m_node.head), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*(yyvsp[(2) - (8)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | (yyvsp[(4) - (8)].parameterList).m_features | ClosureFeature, 0); if ((yyvsp[(4) - (8)].parameterList).m_features & ArgumentsFeature) (yyvsp[(7) - (8)].functionBodyNode)->setUsesArguments(); DBG((yyvsp[(7) - (8)].functionBodyNode), (yylsp[(6) - (8)]), (yylsp[(8) - (8)])); (yyval.statementNode).m_funcDeclarations->data.append(static_cast<FuncDeclNode*>((yyval.statementNode).m_node)); ;} break; case 289: /* Line 1455 of yacc.c */ #line 1183 "../../JavaScriptCore/parser/Grammar.y" { (yyval.funcExprNode) = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, (yyvsp[(5) - (6)].functionBodyNode), LEXER->sourceCode((yyvsp[(4) - (6)].intValue), (yyvsp[(6) - (6)].intValue), (yylsp[(4) - (6)]).first_line)), ClosureFeature, 0); DBG((yyvsp[(5) - (6)].functionBodyNode), (yylsp[(4) - (6)]), (yylsp[(6) - (6)])); ;} break; case 290: /* Line 1455 of yacc.c */ #line 1185 "../../JavaScriptCore/parser/Grammar.y" { (yyval.funcExprNode) = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, (yyvsp[(6) - (7)].functionBodyNode), LEXER->sourceCode((yyvsp[(5) - (7)].intValue), (yyvsp[(7) - (7)].intValue), (yylsp[(5) - (7)]).first_line), (yyvsp[(3) - (7)].parameterList).m_node.head), (yyvsp[(3) - (7)].parameterList).m_features | ClosureFeature, 0); if ((yyvsp[(3) - (7)].parameterList).m_features & ArgumentsFeature) (yyvsp[(6) - (7)].functionBodyNode)->setUsesArguments(); DBG((yyvsp[(6) - (7)].functionBodyNode), (yylsp[(5) - (7)]), (yylsp[(7) - (7)])); ;} break; case 291: /* Line 1455 of yacc.c */ #line 1191 "../../JavaScriptCore/parser/Grammar.y" { (yyval.funcExprNode) = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *(yyvsp[(2) - (7)].ident), (yyvsp[(6) - (7)].functionBodyNode), LEXER->sourceCode((yyvsp[(5) - (7)].intValue), (yyvsp[(7) - (7)].intValue), (yylsp[(5) - (7)]).first_line)), ClosureFeature, 0); DBG((yyvsp[(6) - (7)].functionBodyNode), (yylsp[(5) - (7)]), (yylsp[(7) - (7)])); ;} break; case 292: /* Line 1455 of yacc.c */ #line 1193 "../../JavaScriptCore/parser/Grammar.y" { (yyval.funcExprNode) = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *(yyvsp[(2) - (8)].ident), (yyvsp[(7) - (8)].functionBodyNode), LEXER->sourceCode((yyvsp[(6) - (8)].intValue), (yyvsp[(8) - (8)].intValue), (yylsp[(6) - (8)]).first_line), (yyvsp[(4) - (8)].parameterList).m_node.head), (yyvsp[(4) - (8)].parameterList).m_features | ClosureFeature, 0); if ((yyvsp[(4) - (8)].parameterList).m_features & ArgumentsFeature) (yyvsp[(7) - (8)].functionBodyNode)->setUsesArguments(); DBG((yyvsp[(7) - (8)].functionBodyNode), (yylsp[(6) - (8)]), (yylsp[(8) - (8)])); ;} break; case 293: /* Line 1455 of yacc.c */ #line 1202 "../../JavaScriptCore/parser/Grammar.y" { (yyval.parameterList).m_node.head = new ParameterNode(GLOBAL_DATA, *(yyvsp[(1) - (1)].ident)); (yyval.parameterList).m_features = (*(yyvsp[(1) - (1)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; (yyval.parameterList).m_node.tail = (yyval.parameterList).m_node.head; ;} break; case 294: /* Line 1455 of yacc.c */ #line 1205 "../../JavaScriptCore/parser/Grammar.y" { (yyval.parameterList).m_node.head = (yyvsp[(1) - (3)].parameterList).m_node.head; (yyval.parameterList).m_features = (yyvsp[(1) - (3)].parameterList).m_features | ((*(yyvsp[(3) - (3)].ident) == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); (yyval.parameterList).m_node.tail = new ParameterNode(GLOBAL_DATA, (yyvsp[(1) - (3)].parameterList).m_node.tail, *(yyvsp[(3) - (3)].ident)); ;} break; case 295: /* Line 1455 of yacc.c */ #line 1211 "../../JavaScriptCore/parser/Grammar.y" { (yyval.functionBodyNode) = FunctionBodyNode::create(GLOBAL_DATA); ;} break; case 296: /* Line 1455 of yacc.c */ #line 1212 "../../JavaScriptCore/parser/Grammar.y" { (yyval.functionBodyNode) = FunctionBodyNode::create(GLOBAL_DATA); ;} break; case 297: /* Line 1455 of yacc.c */ #line 1216 "../../JavaScriptCore/parser/Grammar.y" { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, (yylsp[(0) - (0)]).last_line, 0); ;} break; case 298: /* Line 1455 of yacc.c */ #line 1217 "../../JavaScriptCore/parser/Grammar.y" { GLOBAL_DATA->parser->didFinishParsing((yyvsp[(1) - (1)].sourceElements).m_node, (yyvsp[(1) - (1)].sourceElements).m_varDeclarations, (yyvsp[(1) - (1)].sourceElements).m_funcDeclarations, (yyvsp[(1) - (1)].sourceElements).m_features, (yylsp[(1) - (1)]).last_line, (yyvsp[(1) - (1)].sourceElements).m_numConstants); ;} break; case 299: /* Line 1455 of yacc.c */ #line 1222 "../../JavaScriptCore/parser/Grammar.y" { (yyval.sourceElements).m_node = new SourceElements(GLOBAL_DATA); (yyval.sourceElements).m_node->append((yyvsp[(1) - (1)].statementNode).m_node); (yyval.sourceElements).m_varDeclarations = (yyvsp[(1) - (1)].statementNode).m_varDeclarations; (yyval.sourceElements).m_funcDeclarations = (yyvsp[(1) - (1)].statementNode).m_funcDeclarations; (yyval.sourceElements).m_features = (yyvsp[(1) - (1)].statementNode).m_features; (yyval.sourceElements).m_numConstants = (yyvsp[(1) - (1)].statementNode).m_numConstants; ;} break; case 300: /* Line 1455 of yacc.c */ #line 1229 "../../JavaScriptCore/parser/Grammar.y" { (yyval.sourceElements).m_node->append((yyvsp[(2) - (2)].statementNode).m_node); (yyval.sourceElements).m_varDeclarations = mergeDeclarationLists((yyvsp[(1) - (2)].sourceElements).m_varDeclarations, (yyvsp[(2) - (2)].statementNode).m_varDeclarations); (yyval.sourceElements).m_funcDeclarations = mergeDeclarationLists((yyvsp[(1) - (2)].sourceElements).m_funcDeclarations, (yyvsp[(2) - (2)].statementNode).m_funcDeclarations); (yyval.sourceElements).m_features = (yyvsp[(1) - (2)].sourceElements).m_features | (yyvsp[(2) - (2)].statementNode).m_features; (yyval.sourceElements).m_numConstants = (yyvsp[(1) - (2)].sourceElements).m_numConstants + (yyvsp[(2) - (2)].statementNode).m_numConstants; ;} break; case 304: /* Line 1455 of yacc.c */ #line 1243 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 305: /* Line 1455 of yacc.c */ #line 1244 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 306: /* Line 1455 of yacc.c */ #line 1245 "../../JavaScriptCore/parser/Grammar.y" { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; ;} break; case 307: /* Line 1455 of yacc.c */ #line 1246 "../../JavaScriptCore/parser/Grammar.y" { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; ;} break; case 308: /* Line 1455 of yacc.c */ #line 1250 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 309: /* Line 1455 of yacc.c */ #line 1251 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 310: /* Line 1455 of yacc.c */ #line 1252 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 311: /* Line 1455 of yacc.c */ #line 1253 "../../JavaScriptCore/parser/Grammar.y" { if (*(yyvsp[(1) - (7)].ident) != "get" && *(yyvsp[(1) - (7)].ident) != "set") YYABORT; ;} break; case 312: /* Line 1455 of yacc.c */ #line 1254 "../../JavaScriptCore/parser/Grammar.y" { if (*(yyvsp[(1) - (8)].ident) != "get" && *(yyvsp[(1) - (8)].ident) != "set") YYABORT; ;} break; case 316: /* Line 1455 of yacc.c */ #line 1264 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 317: /* Line 1455 of yacc.c */ #line 1265 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 318: /* Line 1455 of yacc.c */ #line 1267 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 322: /* Line 1455 of yacc.c */ #line 1274 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 517: /* Line 1455 of yacc.c */ #line 1642 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 518: /* Line 1455 of yacc.c */ #line 1643 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 520: /* Line 1455 of yacc.c */ #line 1648 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 521: /* Line 1455 of yacc.c */ #line 1652 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 522: /* Line 1455 of yacc.c */ #line 1653 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 525: /* Line 1455 of yacc.c */ #line 1659 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 526: /* Line 1455 of yacc.c */ #line 1660 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 530: /* Line 1455 of yacc.c */ #line 1667 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 533: /* Line 1455 of yacc.c */ #line 1676 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 534: /* Line 1455 of yacc.c */ #line 1677 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 539: /* Line 1455 of yacc.c */ #line 1694 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 555: /* Line 1455 of yacc.c */ #line 1725 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 557: /* Line 1455 of yacc.c */ #line 1727 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 559: /* Line 1455 of yacc.c */ #line 1732 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 561: /* Line 1455 of yacc.c */ #line 1734 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 563: /* Line 1455 of yacc.c */ #line 1739 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 565: /* Line 1455 of yacc.c */ #line 1741 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 568: /* Line 1455 of yacc.c */ #line 1753 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 569: /* Line 1455 of yacc.c */ #line 1754 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 578: /* Line 1455 of yacc.c */ #line 1778 "../../JavaScriptCore/parser/Grammar.y" { ;} break; case 580: /* Line 1455 of yacc.c */ #line 1783 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 585: /* Line 1455 of yacc.c */ #line 1794 "../../JavaScriptCore/parser/Grammar.y" { AUTO_SEMICOLON; ;} break; case 592: /* Line 1455 of yacc.c */ #line 1810 "../../JavaScriptCore/parser/Grammar.y" { ;} break; /* Line 1455 of yacc.c */ #line 5110 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } yyerror_range[0] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } /* Line 1675 of yacc.c */ #line 1826 "../../JavaScriptCore/parser/Grammar.y" static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end) { if (!loc->isLocation()) return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot); if (loc->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(loc); if (op == OpEqual) { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments); SET_EXCEPTION_LOCATION(node, start, divot, end); return node; } else return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot); } if (loc->isBracketAccessorNode()) { BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc); if (op == OpEqual) return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot()); else { ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot); node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); return node; } } ASSERT(loc->isDotAccessorNode()); DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc); if (op == OpEqual) return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot()); ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot); node->setSubexpressionInfo(dot->divot(), dot->endOffset()); return node; } static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end) { if (!expr->isLocation()) return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot); if (expr->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(expr); return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot); } if (expr->isBracketAccessorNode()) { BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr); PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot); node->setSubexpressionInfo(bracket->divot(), bracket->startOffset()); return node; } ASSERT(expr->isDotAccessorNode()); DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr); PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot); node->setSubexpressionInfo(dot->divot(), dot->startOffset()); return node; } static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end) { if (!expr->isLocation()) return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot); if (expr->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(expr); return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot); } if (expr->isBracketAccessorNode()) { BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr); PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot); node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); return node; } ASSERT(expr->isDotAccessorNode()); DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr); PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot); node->setSubexpressionInfo(dot->divot(), dot->endOffset()); return node; } static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end) { CodeFeatures features = func.m_features | args.m_features; int numConstants = func.m_numConstants + args.m_numConstants; if (!func.m_node->isLocation()) return createNodeInfo<ExpressionNode*>(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants); if (func.m_node->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node); const Identifier& identifier = resolve->identifier(); if (identifier == GLOBAL_DATA->propertyNames->eval) return createNodeInfo<ExpressionNode*>(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants); return createNodeInfo<ExpressionNode*>(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants); } if (func.m_node->isBracketAccessorNode()) { BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func.m_node); FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot); node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); return createNodeInfo<ExpressionNode*>(node, features, numConstants); } ASSERT(func.m_node->isDotAccessorNode()); DotAccessorNode* dot = static_cast<DotAccessorNode*>(func.m_node); FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot); node->setSubexpressionInfo(dot->divot(), dot->endOffset()); return createNodeInfo<ExpressionNode*>(node, features, numConstants); } static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr) { if (expr->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(expr); return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier()); } return new TypeOfValueNode(GLOBAL_DATA, expr); } static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end) { if (!expr->isLocation()) return new DeleteValueNode(GLOBAL_DATA, expr); if (expr->isResolveNode()) { ResolveNode* resolve = static_cast<ResolveNode*>(expr); return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot); } if (expr->isBracketAccessorNode()) { BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr); return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot); } ASSERT(expr->isDotAccessorNode()); DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr); return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot); } static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source) { PropertyNode::Type type; if (getOrSet == "get") type = PropertyNode::Getter; else if (getOrSet == "set") type = PropertyNode::Setter; else return 0; return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type); } static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n) { if (n->isNumber()) { NumberNode* number = static_cast<NumberNode*>(n); if (number->value() > 0.0) { number->setValue(-number->value()); return number; } } return new NegateNode(GLOBAL_DATA, n); } static NumberNode* makeNumberNode(void* globalPtr, double d) { return new NumberNode(GLOBAL_DATA, d); } static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr) { if (expr->isNumber()) return makeNumberNode(globalPtr, ~toInt32(static_cast<NumberNode*>(expr)->value())); return new BitwiseNotNode(GLOBAL_DATA, expr); } static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { expr1 = expr1->stripUnaryPlus(); expr2 = expr2->stripUnaryPlus(); if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value()); if (expr1->isNumber() && static_cast<NumberNode*>(expr1)->value() == 1) return new UnaryPlusNode(GLOBAL_DATA, expr2); if (expr2->isNumber() && static_cast<NumberNode*>(expr2)->value() == 1) return new UnaryPlusNode(GLOBAL_DATA, expr1); return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { expr1 = expr1->stripUnaryPlus(); expr2 = expr2->stripUnaryPlus(); if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value()); return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value()); return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { expr1 = expr1->stripUnaryPlus(); expr2 = expr2->stripUnaryPlus(); if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value()); return new SubNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, toInt32(static_cast<NumberNode*>(expr1)->value()) << (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f)); return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) { if (expr1->isNumber() && expr2->isNumber()) return makeNumberNode(globalPtr, toInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f)); return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); } /* called by yyparse on error */ int yyerror(const char *) { return 1; } /* may we automatically insert a semicolon ? */ static bool allowAutomaticSemicolon(Lexer& lexer, int yychar) { return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator(); } static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init) { if (!list) return init; return new VarDeclCommaNode(GLOBAL_DATA, list, init); } // We turn variable declarations into either assignments or empty // statements (which later get stripped out), because the actual // declaration work is hoisted up to the start of the function body static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr) { if (!expr) return new EmptyStatementNode(GLOBAL_DATA); return new VarStatementNode(GLOBAL_DATA, expr); } #undef GLOBAL_DATA
lgpl-2.1
kitachro/ruby-gnome2
gtk3-no-gi/ext/gtk3/rbgtk-socket.c
2109
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /* * Copyright (C) 2011 Ruby-GNOME2 Project Team * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team * Copyright (C) 2002 Neil Conway * * 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 Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include "rbgtk3private.h" #ifdef HAVE_GTK_SOCKET_GET_TYPE #include <gtk/gtkx.h> #define RG_TARGET_NAMESPACE cSocket #define _SELF(self) RVAL2GTKSOCKET(self) static VALUE rg_initialize(VALUE self) { RBGTK_INITIALIZE(self, gtk_socket_new()); return Qnil; } static VALUE rg_add_id(VALUE self, VALUE wid) { gtk_socket_add_id(_SELF(self), #ifdef GDK_NATIVE_WINDOW_POINTER GUINT_TO_POINTER(NUM2ULONG(wid)) #else (guint32)NUM2UINT(wid) #endif ); return self; } static VALUE rg_plug_window(VALUE self) { return GOBJ2RVAL(gtk_socket_get_plug_window(_SELF(self))); } static VALUE rg_id(VALUE self) { Window id = gtk_socket_get_id(_SELF(self)); #ifdef GDK_NATIVE_WINDOW_POINTER return UINT2NUM(GPOINTER_TO_UINT(id)); #else return UINT2NUM(id); #endif } #endif void Init_gtk_socket(VALUE mGtk) { #ifdef HAVE_GTK_SOCKET_GET_TYPE VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_SOCKET, "Socket", mGtk); RG_DEF_METHOD(initialize, 0); RG_DEF_METHOD(plug_window, 0); RG_DEF_METHOD(add_id, 1); RG_DEF_METHOD(id, 0); #endif }
lgpl-2.1
step21/inkscape-osx-packaging-native
src/libgdl/gdl-dock-paned.h
2254
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * gdl-dock-paned.h * * This file is part of the GNOME Devtools Libraries. * * Copyright (C) 2002 Gustavo Giráldez <[email protected]> * * 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 __GDL_DOCK_PANED_H__ #define __GDL_DOCK_PANED_H__ #include "libgdl/gdl-dock-item.h" G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_PANED (gdl_dock_paned_get_type ()) #define GDL_DOCK_PANED(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned)) #define GDL_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass)) #define GDL_IS_DOCK_PANED(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_PANED)) #define GDL_IS_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED)) #define GDL_DOCK_PANED_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass)) /* data types & structures */ typedef struct _GdlDockPaned GdlDockPaned; typedef struct _GdlDockPanedClass GdlDockPanedClass; struct _GdlDockPaned { GdlDockItem dock_item; gboolean position_changed; gboolean in_drag; gint last_drag_position; }; struct _GdlDockPanedClass { GdlDockItemClass parent_class; }; /* public interface */ GType gdl_dock_paned_get_type (void); GtkWidget *gdl_dock_paned_new (GtkOrientation orientation); G_END_DECLS #endif /* __GDL_DOCK_PANED_H__ */
lgpl-2.1
Anatoscope/sofa
modules/SofaGeneralDeformable/config.h
1801
/****************************************************************************** * SOFA, Simulation Open-Framework Architecture, development version * * (c) 2006-2017 INRIA, USTL, UJF, CNRS, MGH * * * * 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 2.1 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 Lesser General Public License * * for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************* * Authors: The SOFA Team and external contributors (see Authors.txt) * * * * Contact information: [email protected] * ******************************************************************************/ #ifndef SOFAGENERAL_DEFORMABLE_CONFIG_H #define SOFAGENERAL_DEFORMABLE_CONFIG_H #include <SofaGeneral/config.h> #endif
lgpl-2.1
skariel/pythonium
pythonium/compliant/runtime.py
7045
object = {__bases__: [], __name__: 'object'} object.__mro__ = [object] type = {__bases__: [object], __mro__: [object], __name__: 'type'} object.__metaclass__ = type __ARGUMENTS_PADDING__ = {ARGUMENTS_PADDING: "YES IT IS!"} def __is__(me, other): return (me is other) __is__.is_method = True object.__is__ = __is__ def __isnot__(me, other): return not (me is other) __isnot__.is_method = True object.__isnot__ = __isnot__ def mro(me): if me is object: raw = me.__mro__ elif me.__class__: raw = me.__class__.__mro__ else: raw = me.__mro__ l = pythonium_call(tuple) l.jsobject = raw.slice() return l mro.is_method = True object.mro = mro def __hash__(me): uid = lookup(me, 'uid') if not uid: uid = object._uid object._uid += 1 me.__uid__ = uid return pythonium_call(str, '{' + uid) __hash__.is_method = True object._uid = 1 object.__hash__ = __hash__ def __rcontains__(me, other): contains = lookup(other, '__contains__') return contains(me) __rcontains__.is_method = True object.__rcontains__ = __rcontains__ def issubclass(klass, other): if klass is other: return __TRUE if not klass.__bases__: return __FALSE for base in klass.__bases__: if issubclass(base, other) is __TRUE: return __TRUE return __FALSE def pythonium_is_true(v): if v is False: return False if v is True: return True if v is None: return False if v is __NONE: return False if v is __FALSE: return False if isinstance(v, int) or isinstance(v, float): if v.jsobject == 0: return False length = lookup(v, '__len__') if length and length().jsobject == 0: return False return True def isinstance(obj, klass): if obj.__class__: return issubclass(obj.__class__, klass) return __FALSE def pythonium_obj_to_js_exception(obj): def exception(): this.exception = obj return exception def pythonium_is_exception(obj, exc): if obj is exc: return True return isinstance(obj, exc) def pythonium_call(obj): args = Array.prototype.slice.call(arguments, 1) if obj.__metaclass__: instance = {__class__: obj} init = lookup(instance, '__init__') if init: init.apply(instance, args) return instance else: return obj.apply(None, args) def pythonium_create_empty_dict(): instance = {__class__: dict} instance._keys = pythonium_call(list) instance.jsobject = JSObject() return instance def pythonium_mro(bases): """Calculate the Method Resolution Order of bases using the C3 algorithm. Suppose you intended creating a class K with the given base classes. This function returns the MRO which K would have, *excluding* K itself (since it doesn't yet exist), as if you had actually created the class. Another way of looking at this, if you pass a single class K, this will return the linearization of K (the MRO of K, *including* itself). """ # based on http://code.activestate.com/recipes/577748-calculate-the-mro-of-a-class/ seqs = [C.__mro__.slice() for C in bases] seqs.push(bases.slice()) def cdr(l): l = l.slice() l = l.splice(1) return l def contains(l, c): for i in l: if i is c: return True return False res = [] while True: non_empty = [] for seq in seqs: out = [] for item in seq: if item: out.push(item) if out.length != 0: non_empty.push(out) if non_empty.length == 0: # Nothing left to process, we're done. return res for seq in non_empty: # Find merge candidates among seq heads. candidate = seq[0] not_head = [] for s in non_empty: if contains(cdr(s), candidate): not_head.push(s) if not_head.length != 0: candidate = None else: break if not candidate: raise TypeError("Inconsistent hierarchy, no C3 MRO is possible") res.push(candidate) for seq in non_empty: # Remove candidate. if seq[0] is candidate: seq[0] = None seqs = non_empty def pythonium_create_class(name, bases, attrs): attrs.__name__ = name attrs.__metaclass__ = type attrs.__bases__ = bases mro = pythonium_mro(bases) mro.splice(0, 0, attrs) attrs.__mro__ = mro return attrs def lookup(obj, attr): obj_attr = obj[attr] if obj_attr != None: if obj_attr and {}.toString.call(obj_attr) == '[object Function]' and obj_attr.is_method and not obj_attr.bound: def method_wrapper(): args = Array.prototype.slice.call(arguments) args.splice(0, 0, obj) return obj_attr.apply(None, args) method_wrapper.bound = True return method_wrapper return obj_attr else: if obj.__class__: __mro__ = obj.__class__.__mro__ elif obj.__metaclass__: __mro__ = obj.__metaclass__.__mro__ else: # it's a function return None for base in __mro__: class_attr = base[attr] if class_attr != None: if {}.toString.call(class_attr) == '[object Function]' and class_attr.is_method and not class_attr.bound: def method_wrapper(): args = Array.prototype.slice.call(arguments) args.splice(0, 0, obj) return class_attr.apply(None, args) method_wrapper.bound = True return method_wrapper return class_attr def pythonium_object_get_attribute(obj, attr): r = lookup(obj, attr) if r != None: return r else: getattr = lookup(obj, '__getattr__') if getattr: return getattr(attr) else: console.trace('AttributeError', attr, obj) raise AttributeError pythonium_object_get_attribute.is_method = True object.__getattribute__ = pythonium_object_get_attribute def pythonium_get_attribute(obj, attr): if obj.__class__ or obj.__metaclass__: getattribute = lookup(obj, '__getattribute__') r = getattribute(attr) return r attr = obj[attr] if attr: if {}.toString.call(attr) == '[object Function]': def method_wrapper(): return attr.apply(obj, arguments) return method_wrapper else: return attr def pythonium_set_attribute(obj, attr, value): obj[attr] = value def ASSERT(condition, message): if not condition: raise message or pythonium_call(str, 'Assertion failed')
lgpl-2.1
edwinspire/VSharp
class/Mono.WebBrowser/Mono.WebBrowser/IWebBrowser.cs
10333
// Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // 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. // // Copyright (c) 2007, 2008 Novell, Inc. // // Authors: // Andreia Gaita ([email protected]) // using System; using System.Text; using System.Runtime.InteropServices; using System.Collections; using System.Collections.Specialized; using Mono.WebBrowser.DOM; namespace Mono.WebBrowser { public interface IWebBrowser { /// <summary> /// Initialize a browser instance. /// </summary> /// <param name="handle"> /// A <see cref="IntPtr"/> to the native window handle of the widget /// where the browser engine will draw /// </param> /// <param name="width"> /// A <see cref="System.Int32"/>. Initial width /// </param> /// <param name="height"> /// A <see cref="System.Int32"/>. Initial height /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> bool Load (IntPtr handle, int width, int height); void Shutdown (); void FocusIn (FocusOption focus); void FocusOut (); void Activate (); void Deactivate (); void Resize (int width, int height); void Render (byte[] data); void Render (string html); void Render (string html, string uri, string contentType); void ExecuteScript (string script); bool Initialized { get; } IWindow Window { get; } IDocument Document { get; } bool Offline {get; set;} /// <value> /// Object exposing navigation methods like Go, Back, etc. /// </value> INavigation Navigation { get; } event NodeEventHandler KeyDown; event NodeEventHandler KeyPress; event NodeEventHandler KeyUp; event NodeEventHandler MouseClick; event NodeEventHandler MouseDoubleClick; event NodeEventHandler MouseDown; event NodeEventHandler MouseEnter; event NodeEventHandler MouseLeave; event NodeEventHandler MouseMove; event NodeEventHandler MouseUp; event EventHandler Focus; event CreateNewWindowEventHandler CreateNewWindow; event AlertEventHandler Alert; event LoadStartedEventHandler LoadStarted; event LoadCommitedEventHandler LoadCommited; event ProgressChangedEventHandler ProgressChanged; event LoadFinishedEventHandler LoadFinished; event StatusChangedEventHandler StatusChanged; event SecurityChangedEventHandler SecurityChanged; event ContextMenuEventHandler ContextMenuShown; event NavigationRequestedEventHandler NavigationRequested; } public enum ReloadOption : uint { None = 0, Proxy = 1, Full = 2 } public enum FocusOption { None = 0, FocusFirstElement = 1, FocusLastElement = 2 } [Flags] public enum DialogButtonFlags { BUTTON_POS_0 = 1, BUTTON_POS_1 = 256, BUTTON_POS_2 = 65536, BUTTON_TITLE_OK = 1, BUTTON_TITLE_CANCEL = 2, BUTTON_TITLE_YES = 3, BUTTON_TITLE_NO = 4, BUTTON_TITLE_SAVE = 5, BUTTON_TITLE_DONT_SAVE = 6, BUTTON_TITLE_REVERT = 7, BUTTON_TITLE_IS_STRING = 127, BUTTON_POS_0_DEFAULT = 0, BUTTON_POS_1_DEFAULT = 16777216, BUTTON_POS_2_DEFAULT = 33554432, BUTTON_DELAY_ENABLE = 67108864, STD_OK_CANCEL_BUTTONS = 513 } public enum DialogType { Alert = 1, AlertCheck = 2, Confirm = 3, ConfirmEx = 4, ConfirmCheck = 5, Prompt = 6, PromptUsernamePassword = 7, PromptPassword = 8, Select = 9 } public enum Platform { Unknown = 0, Winforms = 1, Gtk = 2 } public enum SecurityLevel { Insecure= 1, Mixed = 2, Secure = 3 } #region Window Events public delegate bool CreateNewWindowEventHandler (object sender, CreateNewWindowEventArgs e); public class CreateNewWindowEventArgs : EventArgs { private bool isModal; #region Public Constructors public CreateNewWindowEventArgs (bool isModal) : base () { this.isModal = isModal; } #endregion // Public Constructors #region Public Instance Properties public bool IsModal { get { return this.isModal; } } #endregion // Public Instance Properties } #endregion #region Script events public delegate void AlertEventHandler (object sender, AlertEventArgs e); public class AlertEventArgs : EventArgs { private DialogType type; private string title; private string text; private string text2; private string username; private string password; private string checkMsg; private bool checkState; private DialogButtonFlags dialogButtons; private StringCollection buttons; private StringCollection options; private object returnValue; #region Public Constructors /// <summary> /// void (STDCALL *OnAlert) (const PRUnichar * title, const PRUnichar * text); /// </summary> /// <param name="title"></param> /// <param name="text"></param> public AlertEventArgs () : base () { } #endregion // Public Constructors #region Public Instance Properties public DialogType Type { get { return this.type; } set { this.type = value; } } public string Title { get { return this.title; } set { this.title = value; } } public string Text { get { return this.text; } set { this.text = value; } } public string Text2 { get { return this.text2; } set { this.text2 = value; } } public string CheckMessage { get { return this.checkMsg; } set { this.checkMsg = value; } } public bool CheckState { get { return this.checkState; } set { this.checkState = value; } } public DialogButtonFlags DialogButtons { get { return this.dialogButtons; } set { this.dialogButtons = value; } } public StringCollection Buttons { get { return buttons; } set { buttons = value; } } public StringCollection Options { get { return options; } set { options = value; } } public string Username { get { return username; } set { username = value; } } public string Password { get { return password; } set { password = value; } } public bool BoolReturn { get { if (returnValue is bool) return (bool) returnValue; return false; } set { returnValue = value; } } public int IntReturn { get { if (returnValue is int) return (int) returnValue; return -1; } set { returnValue = value; } } public string StringReturn { get { if (returnValue is string) return (string) returnValue; return String.Empty; } set { returnValue = value; } } #endregion } #endregion #region Loading events public delegate void StatusChangedEventHandler (object sender, StatusChangedEventArgs e); public class StatusChangedEventArgs : EventArgs { private string message; public string Message { get { return message; } set { message = value; } } private int status; public int Status { get { return status; } set { status = value; } } public StatusChangedEventArgs (string message, int status) { this.message = message; this.status = status; } } public delegate void ProgressChangedEventHandler (object sender, ProgressChangedEventArgs e); public class ProgressChangedEventArgs : EventArgs { private int progress; public int Progress { get { return progress; } } private int maxProgress; public int MaxProgress { get { return maxProgress; } } public ProgressChangedEventArgs (int progress, int maxProgress) { this.progress = progress; this.maxProgress = maxProgress; } } public delegate void LoadStartedEventHandler (object sender, LoadStartedEventArgs e); public class LoadStartedEventArgs : System.ComponentModel.CancelEventArgs { private string uri; public string Uri { get {return uri;} } private string frameName; public string FrameName { get {return frameName;} } public LoadStartedEventArgs (string uri, string frameName) { this.uri = uri; this.frameName = frameName; } } public delegate void LoadCommitedEventHandler (object sender, LoadCommitedEventArgs e); public class LoadCommitedEventArgs : EventArgs { private string uri; public string Uri { get {return uri;} } public LoadCommitedEventArgs (string uri) { this.uri = uri; } } public delegate void LoadFinishedEventHandler (object sender, LoadFinishedEventArgs e); public class LoadFinishedEventArgs : EventArgs { private string uri; public string Uri { get {return uri;} } public LoadFinishedEventArgs (string uri) { this.uri = uri; } } public delegate void SecurityChangedEventHandler (object sender, SecurityChangedEventArgs e); public class SecurityChangedEventArgs : EventArgs { private SecurityLevel state; public SecurityLevel State { get { return state; } set { state = value; } } public SecurityChangedEventArgs (SecurityLevel state) { this.state = state; } } public delegate void ContextMenuEventHandler (object sender, ContextMenuEventArgs e); public class ContextMenuEventArgs : EventArgs { private int x; private int y; public int X { get { return x; } } public int Y { get { return y; } } public ContextMenuEventArgs (int x, int y) { this.x = x; this.y = y; } } public delegate void NavigationRequestedEventHandler (object sender, NavigationRequestedEventArgs e); public class NavigationRequestedEventArgs : System.ComponentModel.CancelEventArgs { private string uri; public string Uri { get {return uri;} } public NavigationRequestedEventArgs (string uri) { this.uri = uri; } } #endregion }
lgpl-3.0
CDSherrill/psi4
psi4/src/psi4/libmoinfo/slater_determinant.cc
2456
/* * @BEGIN LICENSE * * Psi4: an open-source quantum chemistry software package * * Copyright (c) 2007-2019 The Psi4 Developers. * * The copyrights for code used from other parties are included in * the corresponding files. * * This file is part of Psi4. * * Psi4 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, version 3. * * Psi4 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 Psi4; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * @END LICENSE */ #include "slater_determinant.h" namespace psi { // SlaterDeterminant::SlaterDeterminant() //{ // startup(); //} // SlaterDeterminant::SlaterDeterminant(SlaterDeterminant& det) //{ // alfa_sym = det.alfa_sym; // beta_sym = det.beta_sym; // alfa_string = det.alfa_string; // beta_string = det.beta_string; // alfa_bits = det.alfa_bits; // beta_bits = det.beta_bits; // startup(); //} SlaterDeterminant::SlaterDeterminant(int alfa_sym_, int beta_sym_, std::vector<bool> alfa_bits_, std::vector<bool> beta_bits_) : alfa_sym(alfa_sym_), beta_sym(beta_sym_), alfa_string(-1), beta_string(-1), alfa_bits(alfa_bits_), beta_bits(beta_bits_) { startup(); } SlaterDeterminant::~SlaterDeterminant() { cleanup(); } void SlaterDeterminant::startup() {} void SlaterDeterminant::cleanup() {} bool SlaterDeterminant::is_closed_shell() { return (alfa_bits == beta_bits); } std::string SlaterDeterminant::get_label() { std::string label; label = "|"; int max_i = alfa_bits.size(); for (int i = 0; i < max_i; ++i) label += get_occupation_symbol(i); label += ">"; return label; } char SlaterDeterminant::get_occupation_symbol(int i) { char symbol; if (alfa_bits[i] && beta_bits[i]) symbol = '2'; if (alfa_bits[i] && !beta_bits[i]) symbol = '+'; if (!alfa_bits[i] && beta_bits[i]) symbol = '-'; if (!alfa_bits[i] && !beta_bits[i]) symbol = '0'; return (symbol); } } // namespace psi
lgpl-3.0
riccio82/MateCat
lib/Utils/Engines/YandexTranslate.php
4027
<?php class Engines_YandexTranslate extends Engines_AbstractEngine { protected $_config = array( 'segment' => null, 'source' => null, 'target' => null, ); public function __construct($engineRecord) { parent::__construct($engineRecord); if ( $this->engineRecord->type != "MT" ) { throw new Exception( "Engine {$this->engineRecord->id} is not a MT engine, found {$this->engineRecord->type} -> {$this->engineRecord->class_load}" ); } } /** * @param $lang * * @return mixed * @throws Exception */ protected function _fixLangCode( $lang ) { $l = explode( "-", strtolower( trim( $lang ) ) ); return $l[ 0 ]; } /** * @param $rawValue * * @return array */ protected function _decode( $rawValue ) { $all_args = func_get_args(); if ( is_string( $rawValue ) ) { $decoded = json_decode( $rawValue, true ); if ( $decoded[ "code" ] == 200 ) { $decoded = array( 'data' => array( 'translations' => array( array( 'translatedText' => $this->_resetSpecialStrings( $decoded[ "text" ][ 0 ] ) ) ) ) ); } else { $decoded = array( 'error' => array( 'code' => $decoded[ "code" ], 'message' => $decoded[ "message" ] ) ); } } else { $resp = json_decode( $rawValue[ "error" ][ "response" ], true ); if ( isset( $resp[ "code" ] ) && isset( $resp[ "message" ] )) { $rawValue[ "error" ][ "code" ] = $resp[ "code" ]; $rawValue[ "error" ][ "message" ] = $resp[ "message" ]; } $decoded = $rawValue; // already decoded in case of error } $mt_result = new Engines_Results_MT( $decoded ); if ( $mt_result->error->code < 0 ) { $mt_result = $mt_result->get_as_array(); $mt_result['error'] = (array)$mt_result['error']; return $mt_result; } $mt_match_res = new Engines_Results_MyMemory_Matches( $this->_preserveSpecialStrings( $all_args[ 1 ][ "text" ] ), $mt_result->translatedText, 100 - $this->getPenalty() . "%", "MT-" . $this->getName(), date( "Y-m-d" ) ); $mt_res = $mt_match_res->getMatches(); return $mt_res; } public function get( $_config ) { $_config[ 'segment' ] = $this->_preserveSpecialStrings( $_config[ 'segment' ] ); $_config[ 'source' ] = $this->_fixLangCode( $_config[ 'source' ] ); $_config[ 'target' ] = $this->_fixLangCode( $_config[ 'target' ] ); $parameters = array(); if ( $this->client_secret != '' && $this->client_secret != null ) { $parameters[ 'key' ] = $this->client_secret; } $parameters[ 'srv' ] = "matecat"; $parameters[ 'lang' ] = $_config[ 'source' ] . "-" . $_config[ 'target' ]; $parameters[ 'text' ] = $_config[ 'segment' ]; $parameters[ 'format' ] = "html"; $this->_setAdditionalCurlParams( array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query( $parameters ) ) ); $this->call( "translate_relative_url", $parameters, true ); return $this->result; } public function set( $_config ) { //if engine does not implement SET method, exit return true; } public function update( $config ) { //if engine does not implement UPDATE method, exit return true; } public function delete( $_config ) { //if engine does not implement DELETE method, exit return true; } }
lgpl-3.0
kidaa/Awakening-Core3
bin/scripts/object/tangible/wearables/base/base_wrist_both.lua
2244
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --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 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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser 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 --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_wearables_base_base_wrist_both = object_tangible_wearables_base_shared_base_wrist_both:new { } ObjectTemplates:addTemplate(object_tangible_wearables_base_base_wrist_both, "object/tangible/wearables/base/base_wrist_both.iff")
lgpl-3.0
kieregh/rb
_install/language/english/lang.install.php
9586
<?php $lang['install']['flag'] = 'en'; //en $lang['install']['i001'] = 'KimsQ Rb Installation'; //KimsQ Rb 설치 $lang['install']['i002'] = 'Select the version'; //설치할 패키지를 선택해주세요. *** 사이트 패키지와 용어 혼동 $lang['install']['i003'] = 'Do not refresh this page. It will automatically move on to the next step after the downloading. The time of downloading depends on your network environment.';//다운로드 완료 후 자동으로 다음단계로 이동되니 새로고침 하지 마세요.네트웍 상태에 따라 다운로드에 수초가 소요될수 있습니다. $lang['install']['i004'] = 'Start Installation';//설치하기 *** 실제 설치는 모든 정보를 입력 후 이루어짐. 마지막 Next 버튼이 Install Now가 되어야 함. $lang['install']['i005'] = 'You can also install KimsQ Rb by uploading its files directly.'; //또는 패키지 파일을 업로드해 주세요. $lang['install']['i006'] = 'Browse a (zip) file'; //파일 찾기 *** zip 파일만 허용하는 경우 괄호 해제 $lang['install']['i007'] = 'KimsQ Installer'; //킴스큐 인스톨러 $lang['install']['i008'] = 'Agreement'; //사용조건 동의 $lang['install']['i009'] = 'Set Database'; //데이터베이스 $lang['install']['i010'] = 'Create Admin'; //사용자 등록 *** 사실상 일반 사용자가 아닌 관리자 계정이므로. Regist는 없는 단어. $lang['install']['i011'] = 'Create Site'; //사이트 생성 $lang['install']['i012'] = 'License Agreement'; //사용조건 동의 $lang['install']['i013'] = 'Open Source Software License'; //오픈소스 소프트웨어 라이선스 $lang['install']['i014'] = 'I agree to the license above.'; //위의 라이선스 정책에 동의 합니다. $lang['install']['i015'] = 'Database Information'; //'Database settings'; //데이터베이스 설정 *** DB를 설정하는 게 아님, 설정된 DB의 정보를 입력하는 것 $lang['install']['i016'] = 'Basic Info'; //기본정보 $lang['install']['i017'] = 'Advanced Options'; //고급옵션 $lang['install']['i018'] = 'DBMS'; //'DB kind'; //DB종류 (type) $lang['install']['i019'] = 'DB name'; //DB명 (name) $lang['install']['i020'] = 'Username'; //유저 (username) $lang['install']['i021'] = 'Password'; //암호 (password) $lang['install']['i022'] = 'Type your database information. Installation will be finished successfully only with the correct information.'; //데이터베이스(MySQL) 정보를 정확히 입력해 주십시오. 입력된 정보가 정확해야만 정상적으로 설치가 진행됩니다. *** 입력을 아무렇게나 해도 사실 next step으로는 갈 수 있음. 마지막에 설치가 안 될 뿐. 키보드로 입력하라고 할 때는 input은 어색, type이 자연스러움. $lang['install']['i023'] = 'DB Host'; //호스트 (Host) $lang['install']['i024'] = 'Change this if your DB is running on the remote server'; //데이터베이스가 다른 서버에 있다면 이 설정을 바꾸십시오. $lang['install']['i025'] = 'DB Port'; //포트 (Port) $lang['install']['i026'] = 'Change this if the port of your DB server is different'; //DB서버의 포트가 기본 포트가 아닐 경우 변경하십시오. $lang['install']['i027'] = 'Table Prefix'; //접두어 (Prefix) $lang['install']['i028'] = 'Change this if you want to install more than one KimsQ Rb on your server'; //단일 DB에 킴스큐 복수설치를 원하시면 변경해 주십시오. $lang['install']['i029'] = 'DB Engine'; //형식 (Engine) $lang['install']['i030'] = 'MyISAM is the basic engine'; //기본엔진은 MyISAM 입니다. $lang['install']['i031'] = 'These options are needed only for the specific cases. Do not change if you do not know what to do, or ask your hosting provider'; //이 선택사항은 일부 경우에만 필요합니다.무엇을 입력해야할지 모를경우 그대로 두거나 호스팅 제공자에게 문의하십시오. $lang['install']['i032'] = 'User Registration'; //사용자 등록 $lang['install']['i033'] = 'Basic Info'; //기본정보 $lang['install']['i034'] = 'Extra Info'; //추가정보 $lang['install']['i035'] = 'Name'; //이름 $lang['install']['i036'] = 'Email'; //이메일 $lang['install']['i037'] = 'ID (Username)'; //아이디 $lang['install']['i038'] = '4 to 12 lowercase letters or numbers'; //영문소문자+숫자 4~12자 이내 $lang['install']['i039'] = 'Password'; //패스워드 $lang['install']['i040'] = 'Retype'; //패스워드 확인 $lang['install']['i041'] = 'Nickname'; //닉네임 $lang['install']['i042'] = 'Sex'; //성별 $lang['install']['i043'] = 'Male'; //남성 $lang['install']['i044'] = 'Female'; //여성 *** 워드로 열어서 맞춤법 검사 정도는... $lang['install']['i045'] = 'Birthday'; //생년월일 $lang['install']['i046'] = 'Lunar'; //음력생일 $lang['install']['i047'] = 'Phone'; //연락처 $lang['install']['i048'] = 'Create an administrator account. You can add more detail in the profile page after installation.'; //입력된 정보로 신규 회원등록이 이루어지며 최고관리자 권한이 부여됩니다. 관리자 부가정보는 설치 후 프로필페이지 추가로 등록할 수 있습니다. $lang['install']['i049'] = 'Create a site'; //사이트 생성 $lang['install']['i050'] = 'Site Name'; //사이트명 $lang['install']['i051'] = 'Type the name of your first site'; //이 사이트의 명칭을 입력해 주세요. $lang['install']['i052'] = 'Site Code'; //사이트 코드 $lang['install']['i053'] = 'Site Code makes the site recognizable among multiple sites.'; //이 사이트를 구분하기 위한 코드입니다. *** 설치 후 사이트는 하나인데 others라고 하기엔 어색함. $lang['install']['i054'] = 'sitecode'; //사이트코드 $lang['install']['i055'] = 'Using Permalink'; //고유주소(Permalink) 사용 $lang['install']['i056'] = 'Check if you want to have shortened URLs. (PHP rewrite_mod necessarily loaded)'; //주소를 짧게 줄일 수 있습니다.(서버에서 rewrite_mod 허용시) $lang['install']['i057'] = 'This is the last step. After installation, you can create a navigation bar and pages, or apply a site package to build your own website at once.'; //사이트명 입력 후 다음버튼을 클릭하면 킴스큐 설치가 진행됩니다.설치가 완료된 후에는 메뉴와 페이지를 만들거나 사이트 패키지를 이용하세요. $lang['install']['i058'] = 'Previous'; //이전 $lang['install']['i059'] = 'Next'; //다음 *** 마지막 Next 버튼은 Install Now가 되어야 함. $lang['install']['i060'] = 'Install this version?'; //정말로 선택하신 버젼을 설치하시겠습니까? $lang['install']['i061'] = 'Connecting to KimsQ Rb server...'; //KimsQ Rb 다운로드중.. *** 실제 다운로드 메시지는 i062 $lang['install']['i062'] = 'Now downloading from the server...'; //서버에서 다운로드 받고 있습니다... $lang['install']['i063'] = 'We are sorry. The selected version is not available now.'; //죄송합니다. 선택하신 버젼은 아직 다운로드 받으실 수 없습니다. $lang['install']['i064'] = 'We are sorry. The selected file is not KimsQ Rb.'; //죄송합니다. 킴스큐 패키지가 아닙니다. $lang['install']['i065'] = 'You do not have proper permissions for the destination folder.\nTry again after changing the permission to 707'; //설치폴더의 쓰기권한이 없습니다.\n퍼미션을 707로 변경 후 다시 시도해 주세요. $lang['install']['i066'] = 'Uploading KimsQ Rb...'; //KimsQ Rb 업로드중.. *** 말줄임표 $lang['install']['i067'] = 'Unzipping installation file on the server...'; //서버에서 패키지 압축을 풀고 있습니다... *** 사이트 패키지와 혼동 $lang['install']['i068'] = 'DB Host is required.'; //DB호스트를 입력해 주세요. $lang['install']['i069'] = 'DB Name is required.'; //DB명을 입력해 주세요. $lang['install']['i070'] = 'DB Username is required.'; //DB사용자를 입력해 주세요. $lang['install']['i071'] = 'DB Password is required.'; //DB 패스워드를 입력해 주세요. $lang['install']['i072'] = 'DB Port number is required'; //DB 포트번호를 입력해 주세요. $lang['install']['i073'] = 'Table Prefix is required and cannot be empty'; //DB 접두어를 정확히 입력해 주세요. $lang['install']['i074'] = 'Administrator account`s name is required.'; //이름을 입력해 주세요. $lang['install']['i075'] = 'Administrator`s email address is required.'; //이메일주소를 정확히 입력해 주세요. $lang['install']['i076'] = 'Administrator`s id is required.'; //아이디를 정확히 입력해 주세요. $lang['install']['i077'] = 'Administrator`s password is required.'; //패스워드를 입력해 주세요. $lang['install']['i078'] = 'Fill the both of two blanks for Administrator`s password.'; //패스워드를 다시한번 입력해 주세요. *** 두번째 패스워드 칸이 비었을 경우, 그냥 다시 입력하라는 설명은 너무 모호함 $lang['install']['i079'] = 'The both passwords are not identical.'; //패스워드가 일치하지 않습니다. $lang['install']['i080'] = 'Installing KimsQ Rb now. Please wait a second.'; //설치중입니다. 잠시만 기다려 주세요. $lang['install']['i081'] = 'Type Site Name, please.'; //사이트명을 입력해 주세요. $lang['install']['i082'] = 'Type Site Code, please.'; //사이트 코드를 정확히 입력해 주세요. $lang['install']['i083'] = 'Start the installation with the typed information?'; //정말로 설치하시겠습니까? ?>
lgpl-3.0
UnAfraid/topzone
VotingRewardInterfaceProvider/src/main/java/com/github/unafraid/votingreward/interfaceprovider/model/RewardItemHolder.java
1261
/* * Copyright (C) 2014-2015 Vote Rewarding System * * This file is part of Vote Rewarding System. * * Vote Rewarding System 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. * * Vote Rewarding System 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/>. */ package com.github.unafraid.votingreward.interfaceprovider.model; /** * @author UnAfraid */ public class RewardItemHolder { private final int _id; private final long _count; public RewardItemHolder(int id, long count) { _id = id; _count = count; } /** * @return the ID of the item contained in this object */ public int getId() { return _id; } /** * @return the count of items contained in this object */ public long getCount() { return _count; } }
lgpl-3.0
ufaks/addons-yelizariev
access_apps/__openerp__.py
415
{ 'name': 'Control access to Apps', 'version': '1.0.0', 'author': 'IT-Projects LLC, Ivan Yelizariev', 'category': 'Tools', 'website': 'https://twitter.com/yelizariev', 'price': 10.00, 'currency': 'EUR', 'depends': [ 'access_restricted' ], 'data': [ 'security/access_apps_security.xml', 'security/ir.model.access.csv', ], 'installable': True }
lgpl-3.0
Amethyst-web/vinst
wa-apps/shop/plugins/migrate/lib/transport/shopMigrateStorelandruTransport.class.php
311
<?php /** * Class shopMigrateStorelandruTransport * @title StoreLand ru * @description Перенос данных из магазинов на платформе StoreLand.ru посредством YML файла * @group YML */ class shopMigrateStorelandruTransport extends shopMigrateYmlTransport { }
lgpl-3.0
n0whereman/bitpunch
runtest/results/2016-04-30T21:49:59.491929/src/bitpunch/math/int.h
1559
/* This file is part of BitPunch Copyright (C) 2013-2015 Frantisek Uhrecky <frantisek.uhrecky[what here]gmail.com> Copyright (C) 2013-2014 Andrej Gulyas <andrej.guly[what here]gmail.com> Copyright (C) 2013-2014 Marek Klein <kleinmrk[what here]gmail.com> Copyright (C) 2013-2014 Filip Machovec <filipmachovec[what here]yahoo.com> Copyright (C) 2013-2014 Jozef Kudlac <jozef[what here]kudlac.sk> 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/>. */ #ifndef BPU_INT_H #define BPU_INT_H #include <stdint.h> /** * Check if number is prime number. * @param n [description] * @return [description] */ int BPU_isPrime(int n); /** * Get recursively index of highest set bit in unsigned integer. * @param x integer * @param start start position in recursion * @param len actual processing length in recursion * @param ele_size size of integer * @return index of highest set bit */ int msb32(uint32_t x, int start, int len, int ele_size); #endif // BPU_INT_H
lgpl-3.0
meganchang/Stem
stem/control.py
17273
""" Classes for interacting with the tor control socket. Controllers are a wrapper around a ControlSocket, retaining many of its methods (connect, close, is_alive, etc) in addition to providing its own for interacting at a higher level. **Module Overview:** :: from_port - Provides a Controller based on a port connection. from_socket_file - Provides a Controller based on a socket file connection. Controller - General controller class intended for direct use. +- get_info - issues a GETINFO query BaseController - Base controller class asynchronous message handling. |- msg - communicates with the tor process |- is_alive - reports if our connection to tor is open or closed |- connect - connects or reconnects to tor |- close - shuts down our connection to the tor process |- get_socket - provides the socket used for control communication |- add_status_listener - notifies a callback of changes in our status |- remove_status_listener - prevents further notification of status changes +- __enter__ / __exit__ - manages socket connection """ import time import Queue import threading import stem.response import stem.socket import stem.util.log as log # state changes a control socket can have # INIT - new control connection # RESET - received a reset/sighup signal # CLOSED - control connection closed State = stem.util.enum.Enum("INIT", "RESET", "CLOSED") # Constant to indicate an undefined argument default. Usually we'd use None for # this, but users will commonly provide None as the argument so need something # else fairly unique... UNDEFINED = "<Undefined_ >" class BaseController: """ Controller for the tor process. This is a minimal base class for other controllers, providing basic process communication and event listing. Don't use this directly - subclasses like the Controller provide higher level functionality. Do not continue to directly interacte with the ControlSocket we're constructed from - use our wrapper methods instead. """ def __init__(self, control_socket): self._socket = control_socket self._msg_lock = threading.RLock() self._status_listeners = [] # tuples of the form (callback, spawn_thread) self._status_listeners_lock = threading.RLock() # queues where incoming messages are directed self._reply_queue = Queue.Queue() self._event_queue = Queue.Queue() # thread to continually pull from the control socket self._reader_thread = None # thread to pull from the _event_queue and call handle_event self._event_notice = threading.Event() self._event_thread = None # saves our socket's prior _connect() and _close() methods so they can be # called along with ours self._socket_connect = self._socket._connect self._socket_close = self._socket._close self._socket._connect = self._connect self._socket._close = self._close if self._socket.is_alive(): self._launch_threads() def msg(self, message): """ Sends a message to our control socket and provides back its reply. :param str message: message to be formatted and sent to tor :returns: :class:`stem.response.ControlMessage` with the response :raises: * :class:`stem.socket.ProtocolError` the content from the socket is malformed * :class:`stem.socket.SocketError` if a problem arises in using the socket * :class:`stem.socket.SocketClosed` if the socket is shut down """ with self._msg_lock: # If our _reply_queue isn't empty then one of a few things happened... # # - Our connection was closed and probably re-restablished. This was # in reply to pulling for an asynchronous event and getting this is # expected - ignore it. # # - Pulling for asynchronous events produced an error. If this was a # ProtocolError then it's a tor bug, and if a non-closure SocketError # then it was probably a socket glitch. Deserves an INFO level log # message. # # - This is a leftover response for a msg() call. We can't tell who an # exception was airmarked for, so we only know that this was the case # if it's a ControlMessage. This should not be possable and indicates # a stem bug. This deserves a NOTICE level log message since it # indicates that one of our callers didn't get their reply. while not self._reply_queue.empty(): try: response = self._reply_queue.get_nowait() if isinstance(response, stem.socket.SocketClosed): pass # this is fine elif isinstance(response, stem.socket.ProtocolError): log.info("Tor provided a malformed message (%s)" % response) elif isinstance(response, stem.socket.ControllerError): log.info("Socket experienced a problem (%s)" % response) elif isinstance(response, stem.response.ControlMessage): log.notice("BUG: the msg() function failed to deliver a response: %s" % response) except Queue.Empty: # the empty() method is documented to not be fully reliable so this # isn't entirely surprising break try: self._socket.send(message) response = self._reply_queue.get() # If the message we received back had an exception then re-raise it to the # caller. Otherwise return the response. if isinstance(response, stem.socket.ControllerError): raise response else: return response except stem.socket.SocketClosed, exc: # If the recv() thread caused the SocketClosed then we could still be # in the process of closing. Calling close() here so that we can # provide an assurance to the caller that when we raise a SocketClosed # exception we are shut down afterward for realz. self.close() raise exc def is_alive(self): """ Checks if our socket is currently connected. This is a passthrough for our socket's is_alive() method. :returns: bool that's True if we're shut down and False otherwise """ return self._socket.is_alive() def connect(self): """ Reconnects our control socket. This is a passthrough for our socket's connect() method. :raises: :class:`stem.socket.SocketError` if unable to make a socket """ self._socket.connect() def close(self): """ Closes our socket connection. This is a passthrough for our socket's :func:`stem.socket.ControlSocket.close` method. """ self._socket.close() def get_socket(self): """ Provides the socket used to speak with the tor process. Communicating with the socket directly isn't advised since it may confuse the controller. :returns: :class:`stem.socket.ControlSocket` we're communicating with """ return self._socket def add_status_listener(self, callback, spawn = True): """ Notifies a given function when the state of our socket changes. Functions are expected to be of the form... :: my_function(controller, state, timestamp) The state is a value from stem.socket.State, functions **must** allow for new values in this field. The timestamp is a float for the unix time when the change occured. This class only provides ``State.INIT`` and ``State.CLOSED`` notifications. Subclasses may provide others. If spawn is True then the callback is notified via a new daemon thread. If false then the notice is under our locks, within the thread where the change occured. In general this isn't advised, especially if your callback could block for a while. :param function callback: function to be notified when our state changes :param bool spawn: calls function via a new thread if True, otherwise it's part of the connect/close method call """ with self._status_listeners_lock: self._status_listeners.append((callback, spawn)) def remove_status_listener(self, callback): """ Stops listener from being notified of further events. :param function callback: function to be removed from our listeners :returns: bool that's True if we removed one or more occurances of the callback, False otherwise """ with self._status_listeners_lock: new_listeners, is_changed = [], False for listener, spawn in self._status_listeners: if listener != callback: new_listeners.append((listener, spawn)) else: is_changed = True self._status_listeners = new_listeners return is_changed def __enter__(self): return self def __exit__(self, exit_type, value, traceback): self.close() def _handle_event(self, event_message): """ Callback to be overwritten by subclasses for event listening. This is notified whenever we receive an event from the control socket. :param stem.response.ControlMessage event_message: message received from the control socket """ pass def _connect(self): self._launch_threads() self._notify_status_listeners(State.INIT, True) self._socket_connect() def _close(self): # Our is_alive() state is now false. Our reader thread should already be # awake from recv() raising a closure exception. Wake up the event thread # too so it can end. self._event_notice.set() # joins on our threads if it's safe to do so for t in (self._reader_thread, self._event_thread): if t and t.is_alive() and threading.current_thread() != t: t.join() self._notify_status_listeners(State.CLOSED, False) self._socket_close() def _notify_status_listeners(self, state, expect_alive = None): """ Informs our status listeners that a state change occured. States imply that our socket is either alive or not, which may not hold true when multiple events occure in quick succession. For instance, a sighup could cause two events (``State.RESET`` for the sighup and ``State.CLOSE`` if it causes tor to crash). However, there's no guarentee of the order in which they occure, and it would be bad if listeners got the ``State.RESET`` last, implying that we were alive. If set, the expect_alive flag will discard our event if it conflicts with our current :func:`stem.control.BaseController.is_alive` state. :param stem.socket.State state: state change that has occured :param bool expect_alive: discard event if it conflicts with our :func:`stem.control.BaseController.is_alive` state """ # Any changes to our is_alive() state happen under the send lock, so we # need to have it to ensure it doesn't change beneath us. with self._socket._get_send_lock(), self._status_listeners_lock: change_timestamp = time.time() if expect_alive != None and expect_alive != self.is_alive(): return for listener, spawn in self._status_listeners: if spawn: name = "%s notification" % state args = (self, state, change_timestamp) notice_thread = threading.Thread(target = listener, args = args, name = name) notice_thread.setDaemon(True) notice_thread.start() else: listener(self, state, change_timestamp) def _launch_threads(self): """ Initializes daemon threads. Threads can't be reused so we need to recreate them if we're restarted. """ # In theory concurrent calls could result in multple start() calls on a # single thread, which would cause an unexpeceted exception. Best be safe. with self._socket._get_send_lock(): if not self._reader_thread or not self._reader_thread.is_alive(): self._reader_thread = threading.Thread(target = self._reader_loop, name = "Tor Listener") self._reader_thread.setDaemon(True) self._reader_thread.start() if not self._event_thread or not self._event_thread.is_alive(): self._event_thread = threading.Thread(target = self._event_loop, name = "Event Notifier") self._event_thread.setDaemon(True) self._event_thread.start() def _reader_loop(self): """ Continually pulls from the control socket, directing the messages into queues based on their type. Controller messages come in two varieties... * Responses to messages we've sent (GETINFO, SETCONF, etc). * Asynchronous events, identified by a status code of 650. """ while self.is_alive(): try: control_message = self._socket.recv() if control_message.content()[-1][0] == "650": # asynchronous message, adds to the event queue and wakes up its handler self._event_queue.put(control_message) self._event_notice.set() else: # response to a msg() call self._reply_queue.put(control_message) except stem.socket.ControllerError, exc: # Assume that all exceptions belong to the reader. This isn't always # true, but the msg() call can do a better job of sorting it out. # # Be aware that the msg() method relies on this to unblock callers. self._reply_queue.put(exc) def _event_loop(self): """ Continually pulls messages from the _event_queue and sends them to our handle_event callback. This is done via its own thread so subclasses with a lengthy handle_event implementation don't block further reading from the socket. """ while True: try: event_message = self._event_queue.get_nowait() self._handle_event(event_message) except Queue.Empty: if not self.is_alive(): break self._event_notice.wait() self._event_notice.clear() class Controller(BaseController): """ Communicates with a control socket. This is built on top of the BaseController and provides a more user friendly API for library users. """ def from_port(control_addr = "127.0.0.1", control_port = 9051): """ Constructs a ControlPort based Controller. :param str control_addr: ip address of the controller :param int control_port: port number of the controller :returns: :class:`stem.control.Controller` attached to the given port :raises: :class:`stem.socket.SocketError` if we're unable to establish a connection """ control_port = stem.socket.ControlPort(control_addr, control_port) return Controller(control_port) def from_socket_file(socket_path = "/var/run/tor/control"): """ Constructs a ControlSocketFile based Controller. :param str socket_path: path where the control socket is located :returns: :class:`stem.control.Controller` attached to the given socket file :raises: :class:`stem.socket.SocketError` if we're unable to establish a connection """ control_socket = stem.socket.ControlSocketFile(socket_path) return Controller(control_socket) from_port = staticmethod(from_port) from_socket_file = staticmethod(from_socket_file) def get_info(self, param, default = UNDEFINED): """ Queries the control socket for the given GETINFO option. If provided a default then that's returned if the GETINFO option is undefined or the call fails for any reason (error response, control port closed, initiated, etc). :param str,list param: GETINFO option or options to be queried :param object default: response if the query fails :returns: Response depends upon how we were called as follows... * str with the response if our param was a str * dict with the param => response mapping if our param was a list * default if one was provided and our call failed :raises: :class:`stem.socket.ControllerError` if the call fails, and we weren't provided a default response """ # TODO: add caching? # TODO: special geoip handling? # TODO: add logging, including call runtime if isinstance(param, str): is_multiple = False param = [param] else: is_multiple = True try: response = self.msg("GETINFO %s" % " ".join(param)) stem.response.convert("GETINFO", response) # error if we got back different parameters than we requested requested_params = set(param) reply_params = set(response.entries.keys()) if requested_params != reply_params: requested_label = ", ".join(requested_params) reply_label = ", ".join(reply_params) raise stem.socket.ProtocolError("GETINFO reply doesn't match the parameters that we requested. Queried '%s' but got '%s'." % (requested_label, reply_label)) if is_multiple: return response.entries else: return response.entries[param[0]] except stem.socket.ControllerError, exc: if default == UNDEFINED: raise exc else: return default
lgpl-3.0
hultqvist/SharpKit-SDK
Defs/ExtJs/Ext.grid.property.Store.cs
1987
//*************************************************** //* This file was generated by tool //* SharpKit //* At: 29/08/2012 03:59:41 p.m. //*************************************************** using SharpKit.JavaScript; namespace Ext.grid.property { #region Store /// <inheritdocs /> /// <summary> /// <p>A custom <see cref="Ext.data.Store">Ext.data.Store</see> for the <see cref="Ext.grid.property.Grid">Ext.grid.property.Grid</see>. This class handles the mapping /// between the custom data source objects supported by the grid and the <see cref="Ext.grid.property.Property">Ext.grid.property.Property</see> format /// used by the <see cref="Ext.data.Store">Ext.data.Store</see> base class.</p> /// </summary> [JsType(JsMode.Prototype, Export=false, OmitOptionalParameters=true)] public partial class Store : Ext.data.Store { /// <summary> /// Creates new property store. /// </summary> /// <param name="grid"><p>The grid this store will be bound to</p> /// </param> /// <param name="source"><p>The source data config object</p> /// </param> /// <returns> /// <span><see cref="Object">Object</see></span><div> /// </div> /// </returns> public Store(Ext.grid.Panel grid, object source){} public Store(Ext.grid.property.StoreConfig config){} public Store(){} public Store(params object[] args){} } #endregion #region StoreConfig /// <inheritdocs /> [JsType(JsMode.Json, Export=false, OmitOptionalParameters=true)] public partial class StoreConfig : Ext.data.StoreConfig { public StoreConfig(params object[] args){} } #endregion #region StoreEvents /// <inheritdocs /> [JsType(JsMode.Json, Export=false, OmitOptionalParameters=true)] public partial class StoreEvents : Ext.data.StoreEvents { public StoreEvents(params object[] args){} } #endregion }
lgpl-3.0
edwinspire/VSharp
class/System/System.Net.Configuration/HttpCachePolicyElement.cs
4102
// // System.Net.Configuration.HttpCachePolicyElement.cs // // Authors: // Tim Coleman ([email protected]) // Chris Toshok ([email protected]) // // Copyright (C) Tim Coleman, 2004 // (C) 2004,2005 Novell, Inc. (http://www.novell.com) // // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // 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. // #if CONFIGURATION_DEP using System; using System.Configuration; using System.Net.Cache; using System.Xml; namespace System.Net.Configuration { public sealed class HttpCachePolicyElement : ConfigurationElement { #region Fields static ConfigurationProperty maximumAgeProp; static ConfigurationProperty maximumStaleProp; static ConfigurationProperty minimumFreshProp; static ConfigurationProperty policyLevelProp; static ConfigurationPropertyCollection properties; #endregion // Fields #region Constructors static HttpCachePolicyElement () { maximumAgeProp = new ConfigurationProperty ("maximumAge", typeof (TimeSpan), TimeSpan.MaxValue); maximumStaleProp = new ConfigurationProperty ("maximumStale", typeof (TimeSpan), TimeSpan.MinValue); minimumFreshProp = new ConfigurationProperty ("minimumFresh", typeof (TimeSpan), TimeSpan.MinValue); policyLevelProp = new ConfigurationProperty ("policyLevel", typeof (HttpRequestCacheLevel), HttpRequestCacheLevel.Default, ConfigurationPropertyOptions.IsRequired); properties = new ConfigurationPropertyCollection (); properties.Add (maximumAgeProp); properties.Add (maximumStaleProp); properties.Add (minimumFreshProp); properties.Add (policyLevelProp); } public HttpCachePolicyElement () { } #endregion // Constructors #region Properties [ConfigurationProperty ("maximumAge", DefaultValue = "10675199.02:48:05.4775807")] public TimeSpan MaximumAge { get { return (TimeSpan) base [maximumAgeProp]; } set { base [maximumAgeProp] = value; } } [ConfigurationProperty ("maximumStale", DefaultValue = "-10675199.02:48:05.4775808")] public TimeSpan MaximumStale { get { return (TimeSpan) base [maximumStaleProp]; } set { base [maximumStaleProp] = value; } } [ConfigurationProperty ("minimumFresh", DefaultValue = "-10675199.02:48:05.4775808")] public TimeSpan MinimumFresh { get { return (TimeSpan) base [minimumFreshProp]; } set { base [minimumFreshProp] = value; } } [ConfigurationProperty ("policyLevel", DefaultValue = "Default", Options = ConfigurationPropertyOptions.IsRequired)] public HttpRequestCacheLevel PolicyLevel { get { return (HttpRequestCacheLevel) base [policyLevelProp]; } set { base [policyLevelProp] = value; } } protected override ConfigurationPropertyCollection Properties { get { return properties; } } #endregion // Properties #region Methods [MonoTODO] protected override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) { throw new NotImplementedException (); } [MonoTODO] protected override void Reset (ConfigurationElement parentElement) { throw new NotImplementedException (); } #endregion // Methods } } #endif
lgpl-3.0
mdaus/coda-oss
modules/c++/xml.lite/source/ValidatorInterface.cpp
2255
/* ========================================================================= * This file is part of xml.lite-c++ * ========================================================================= * * (C) Copyright 2004 - 2014, MDA Information Systems LLC * (C) Copyright 2022, Maxar Technologies, Inc. * * xml.lite-c++ 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; If not, * see <http://www.gnu.org/licenses/>. * */ #include <xml/lite/ValidatorInterface.h> #include <algorithm> #include <iterator> #include <std/filesystem> #include <std/memory> #include <sys/OS.h> #include <io/StringStream.h> #include <mem/ScopedArray.h> #include <str/EncodedStringView.h> namespace fs = std::filesystem; #include <xml/lite/xml_lite_config.h> template<typename TStringStream> bool vallidate_(const xml::lite::ValidatorInterface& validator, io::InputStream& xml, TStringStream&& oss, const std::string& xmlID, std::vector<xml::lite::ValidationInfo>& errors) { xml.streamTo(oss); return validator.validate(oss.stream().str(), xmlID, errors); } bool xml::lite::ValidatorInterface::validate( io::InputStream& xml, StringEncoding encoding, const std::string& xmlID, std::vector<ValidationInfo>& errors) const { // convert to the correcrt std::basic_string<T> based on "encoding" if (encoding == StringEncoding::Utf8) { return vallidate_(*this, xml, io::U8StringStream(), xmlID, errors); } if (encoding == StringEncoding::Windows1252) { return vallidate_(*this, xml, io::W1252StringStream(), xmlID, errors); } // this really shouldn't happen return validate(xml, xmlID, errors); }
lgpl-3.0
kidaa/Awakening-Core3
bin/scripts/object/tangible/powerup/base/weapon_base.lua
2220
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --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 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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser 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 --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_powerup_base_weapon_base = object_tangible_powerup_base_shared_weapon_base:new { } ObjectTemplates:addTemplate(object_tangible_powerup_base_weapon_base, "object/tangible/powerup/base/weapon_base.iff")
lgpl-3.0
kidaa/Awakening-Core3
bin/scripts/object/tangible/medicine/pet/pet_vitapack_b.lua
2739
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --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 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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser 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 --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_medicine_pet_pet_vitapack_b = object_tangible_medicine_pet_shared_pet_vitapack_b:new { gameObjectType = 8219, numberExperimentalProperties = {1, 1, 1, 1, 1}, experimentalProperties = {"XX", "XX", "OQ", "XX", "XX"}, experimentalWeights = {1, 1, 1, 1, 1}, experimentalGroupTitles = {"null", "null", "exp_effectiveness", "null", "null"}, experimentalSubGroupTitles = {"null", "null", "strength", "decayrate", "hitpoints"}, experimentalMin = {0, 0, 25, 15, 1000}, experimentalMax = {0, 0, 70, 15, 1000}, experimentalPrecision = {0, 0, 0, 0, 0}, experimentalCombineType = {0, 0, 1, 1, 4}, } ObjectTemplates:addTemplate(object_tangible_medicine_pet_pet_vitapack_b, "object/tangible/medicine/pet/pet_vitapack_b.iff")
lgpl-3.0
mdolz/PMLib
new/stxxl/include/stxxl/bits/common/binary_buffer.h
20063
/*************************************************************************** * include/stxxl/bits/common/binary_buffer.h * * Classes binary_buffer and binary_reader to construct data blocks with * variable length content. Programs construct blocks using * binary_buffer::put<type>() and read them using * binary_reader::get<type>(). The operation sequences should match. * * Part of the STXXL. See http://stxxl.sourceforge.net * * Copyright (C) 2013-2014 Timo Bingmann <[email protected]> * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) **************************************************************************/ #ifndef STXXL_COMMON_BINARY_BUFFER_HEADER #define STXXL_COMMON_BINARY_BUFFER_HEADER #include <cassert> #include <cstdlib> #include <cstring> #include <stdexcept> #include <string> #include <vector> #include <stxxl/bits/namespace.h> #include <stxxl/bits/common/types.h> STXXL_BEGIN_NAMESPACE //! \addtogroup support //! \{ /*! * binary_buffer represents a dynamically growable area of memory, which can be * modified by appending integral data types via put() and other basic * operations. */ class binary_buffer { protected: //! Allocated buffer pointer. char* m_data; //! Size of valid data. size_t m_size; //! Total capacity of buffer. size_t m_capacity; public: //! Create a new empty object inline binary_buffer() : m_data(NULL), m_size(0), m_capacity(0) { } //! Copy-Constructor, duplicates memory content. inline binary_buffer(const binary_buffer& other) : m_data(NULL), m_size(0), m_capacity(0) { assign(other); } //! Constructor, copy memory area. inline binary_buffer(const void* data, size_t n) : m_data(NULL), m_size(0), m_capacity(0) { assign(data, n); } //! Constructor, create object with n bytes pre-allocated. inline binary_buffer(size_t n) : m_data(NULL), m_size(0), m_capacity(0) { alloc(n); } //! Constructor from std::string, copies string content. inline binary_buffer(const std::string& str) : m_data(NULL), m_size(0), m_capacity(0) { assign(str.data(), str.size()); } //! Destroys the memory space. inline ~binary_buffer() { dealloc(); } //! Return a pointer to the currently kept memory area. inline const char * data() const { return m_data; } //! Return a writeable pointer to the currently kept memory area. inline char * data() { return m_data; } //! Return the currently used length in bytes. inline size_t size() const { return m_size; } //! Return the currently allocated buffer capacity. inline size_t capacity() const { return m_capacity; } //! Explicit conversion to std::string (copies memory of course). inline std::string str() const { return std::string(reinterpret_cast<const char*>(m_data), m_size); } //! Set the valid bytes in the buffer, use if the buffer is filled //! directly. inline binary_buffer & set_size(size_t n) { assert(n <= m_capacity); m_size = n; return *this; } //! Make sure that at least n bytes are allocated. inline binary_buffer & alloc(size_t n) { if (m_capacity < n) { m_capacity = n; m_data = static_cast<char*>(realloc(m_data, m_capacity)); } return *this; } //! Deallocates the kept memory space (we use dealloc() instead of free() //! as a name, because sometimes "free" is replaced by the preprocessor) inline binary_buffer & dealloc() { if (m_data) free(m_data); m_data = NULL; m_size = m_capacity = 0; return *this; } //! Detach the memory from the object, returns the memory pointer. inline const char * detach() { const char* data = m_data; m_data = NULL; m_size = m_capacity = 0; return data; } //! Clears the memory contents, does not deallocate the memory. inline binary_buffer & clear() { m_size = 0; return *this; } //! Copy a memory range into the buffer, overwrites all current //! data. Roughly equivalent to clear() followed by append(). inline binary_buffer & assign(const void* data, size_t len) { if (len > m_capacity) alloc(len); memcpy(m_data, data, len); m_size = len; return *this; } //! Copy the contents of another buffer object into this buffer, overwrites //! all current data. Roughly equivalent to clear() followed by append(). inline binary_buffer & assign(const binary_buffer& other) { if (&other != this) assign(other.data(), other.size()); return *this; } //! Assignment operator: copy other's memory range into buffer. inline binary_buffer& operator = (const binary_buffer& other) { if (&other != this) assign(other.data(), other.size()); return *this; } //! Align the size of the buffer to a multiple of n. Fills up with 0s. inline binary_buffer & align(size_t n) { assert(n > 0); size_t rem = m_size % n; if (rem != 0) { size_t add = n - rem; if (m_size + add > m_capacity) dynalloc(m_size + add); memset(m_data + m_size, 0, add); m_size += add; } assert((m_size % n) == 0); return *this; } //! Dynamically allocate more memory. At least n bytes will be available, //! probably more to compensate future growth. inline binary_buffer & dynalloc(size_t n) { if (m_capacity < n) { // place to adapt the buffer growing algorithm as need. size_t newsize = m_capacity; while (newsize < n) { if (newsize < 256) newsize = 512; else if (newsize < 1024 * 1024) newsize = 2 * newsize; else newsize += 1024 * 1024; } alloc(newsize); } return *this; } // *** Appending Write Functions *** //! Append a memory range to the buffer inline binary_buffer & append(const void* data, size_t len) { if (m_size + len > m_capacity) dynalloc(m_size + len); memcpy(m_data + m_size, data, len); m_size += len; return *this; } //! Append the contents of a different buffer object to this one. inline binary_buffer & append(const class binary_buffer& bb) { return append(bb.data(), bb.size()); } //! Append to contents of a std::string, excluding the null (which isn't //! contained in the string size anyway). inline binary_buffer & append(const std::string& s) { return append(s.data(), s.size()); } //! Put (append) a single item of the template type T to the buffer. Be //! careful with implicit type conversions! template <typename Type> inline binary_buffer & put(const Type item) { if (m_size + sizeof(Type) > m_capacity) dynalloc(m_size + sizeof(Type)); *reinterpret_cast<Type*>(m_data + m_size) = item; m_size += sizeof(Type); return *this; } //! Append a varint to the buffer. inline binary_buffer & put_varint(uint32 v) { if (v < 128) { put<uint8>(uint8(v)); } else if (v < 128 * 128) { put<uint8>((uint8)(((v >> 0) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 7) & 0x7F)); } else if (v < 128 * 128 * 128) { put<uint8>((uint8)(((v >> 0) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 7) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 14) & 0x7F)); } else if (v < 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 0) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 7) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 21) & 0x7F)); } else { put<uint8>((uint8)(((v >> 0) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 7) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 28) & 0x7F)); } return *this; } //! Append a varint to the buffer. inline binary_buffer & put_varint(int v) { return put_varint((uint32)v); } //! Append a varint to the buffer. inline binary_buffer & put_varint(uint64 v) { if (v < 128) { put<uint8>(uint8(v)); } else if (v < 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 07) & 0x7F)); } else if (v < 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 14) & 0x7F)); } else if (v < 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 21) & 0x7F)); } else if (v < ((uint64)128) * 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 28) & 0x7F)); } else if (v < ((uint64)128) * 128 * 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 28) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 35) & 0x7F)); } else if (v < ((uint64)128) * 128 * 128 * 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 28) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 35) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 42) & 0x7F)); } else if (v < ((uint64)128) * 128 * 128 * 128 * 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 28) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 35) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 42) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 49) & 0x7F)); } else if (v < ((uint64)128) * 128 * 128 * 128 * 128 * 128 * 128 * 128 * 128) { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 28) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 35) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 42) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 49) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 56) & 0x7F)); } else { put<uint8>((uint8)(((v >> 00) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 07) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 14) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 21) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 28) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 35) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 42) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 49) & 0x7F) | 0x80)); put<uint8>((uint8)(((v >> 56) & 0x7F) | 0x80)); put<uint8>((uint8)((v >> 63) & 0x7F)); } return *this; } //! Put a string by saving it's length followed by the data itself. inline binary_buffer & put_string(const char* data, size_t len) { return put_varint((uint32)len).append(data, len); } //! Put a string by saving it's length followed by the data itself. inline binary_buffer & put_string(const std::string& str) { return put_string(str.data(), str.size()); } //! Put a binary_buffer by saving it's length followed by the data itself. inline binary_buffer & put_string(const binary_buffer& bb) { return put_string(bb.data(), bb.size()); } }; /*! * binary_buffer_ref represents a memory area as pointer and valid length. It * is not deallocated or otherwise managed. This class can be used to pass * around references to binary_buffer objects. */ class binary_buffer_ref { protected: //! Allocated buffer pointer. const char* m_data; //! Size of valid data. size_t m_size; public: //! Constructor, assign memory area from binary_buffer. binary_buffer_ref(const binary_buffer& bb) : m_data(bb.data()), m_size(bb.size()) { } //! Constructor, assign memory area from pointer and length. binary_buffer_ref(const void* data, size_t n) : m_data(reinterpret_cast<const char*>(data)), m_size(n) { } //! Constructor, assign memory area from string, does NOT copy. inline binary_buffer_ref(const std::string& str) : m_data(str.data()), m_size(str.size()) { } //! Return a pointer to the currently kept memory area. const void * data() const { return m_data; } //! Return the currently valid length in bytes. size_t size() const { return m_size; } //! Explicit conversion to std::string (copies memory of course). inline std::string str() const { return std::string(reinterpret_cast<const char*>(m_data), m_size); } //! Compare contents of two binary_buffer_refs. bool operator == (const binary_buffer_ref& br) const { if (m_size != br.m_size) return false; return memcmp(m_data, br.m_data, m_size) == 0; } //! Compare contents of two binary_buffer_refs. bool operator != (const binary_buffer_ref& br) const { if (m_size != br.m_size) return true; return memcmp(m_data, br.m_data, m_size) != 0; } }; /*! * binary_reader represents a binary_buffer_ref with an additional cursor with which * the memory can be read incrementally. */ class binary_reader : public binary_buffer_ref { protected: //! Current read cursor size_t m_curr; public: //! Constructor, assign memory area from binary_buffer. inline binary_reader(const binary_buffer_ref& br) : binary_buffer_ref(br), m_curr(0) { } //! Constructor, assign memory area from pointer and length. inline binary_reader(const void* data, size_t n) : binary_buffer_ref(data, n), m_curr(0) { } //! Constructor, assign memory area from string, does NOT copy. inline binary_reader(const std::string& str) : binary_buffer_ref(str), m_curr(0) { } //! Return the current read cursor. inline size_t curr() const { return m_curr; } //! Reset the read cursor. inline binary_reader & rewind() { m_curr = 0; return *this; } //! Check that n bytes are available at the cursor. inline bool cursor_available(size_t n) const { return (m_curr + n <= m_size); } //! Throws a std::underflow_error unless n bytes are available at the //! cursor. inline void check_available(size_t n) const { if (!cursor_available(n)) throw (std::underflow_error("binary_reader underrun")); } //! Return true if the cursor is at the end of the buffer. inline bool empty() const { return (m_curr == m_size); } //! Advance the cursor given number of bytes without reading them. inline binary_reader & skip(size_t n) { check_available(n); m_curr += n; return *this; } //! Fetch a number of unstructured bytes from the buffer, advancing the //! cursor. inline binary_reader & read(void* outdata, size_t datalen) { check_available(datalen); memcpy(outdata, m_data + m_curr, datalen); m_curr += datalen; return *this; } //! Fetch a number of unstructured bytes from the buffer as std::string, //! advancing the cursor. inline std::string read(size_t datalen) { check_available(datalen); std::string out(m_data + m_curr, datalen); m_curr += datalen; return out; } //! Fetch a single item of the template type Type from the buffer, //! advancing the cursor. Be careful with implicit type conversions! template <typename Type> inline Type get() { check_available(sizeof(Type)); Type ret = *reinterpret_cast<const Type*>(m_data + m_curr); m_curr += sizeof(Type); return ret; } //! Fetch a varint with up to 32-bit from the buffer at the cursor. inline uint32 get_varint() { uint32 u, v = get<uint8>(); if (!(v & 0x80)) return v; v &= 0x7F; u = get<uint8>(), v |= (u & 0x7F) << 7; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 14; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 21; if (!(u & 0x80)) return v; u = get<uint8>(); if (u & 0xF0) throw (std::overflow_error("Overflow during varint decoding.")); v |= (u & 0x7F) << 28; return v; } //! Fetch a 64-bit varint from the buffer at the cursor. inline uint64 get_varint64() { uint64 u, v = get<uint8>(); if (!(v & 0x80)) return v; v &= 0x7F; u = get<uint8>(), v |= (u & 0x7F) << 7; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 14; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 21; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 28; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 35; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 42; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 49; if (!(u & 0x80)) return v; u = get<uint8>(), v |= (u & 0x7F) << 56; if (!(u & 0x80)) return v; u = get<uint8>(); if (u & 0xFE) throw (std::overflow_error("Overflow during varint64 decoding.")); v |= (u & 0x7F) << 63; return v; } //! Fetch a string which was put via put_string(). inline std::string get_string() { uint32 len = get_varint(); return read(len); } //! Fetch a binary_buffer_ref to a binary string or blob which was put via //! put_string(). Does NOT copy the data. inline binary_buffer_ref get_binary_buffer_ref() { uint32 len = get_varint(); // save object binary_buffer_ref br(m_data + m_curr, len); // skip over sub block data skip(len); return br; } }; //! \} STXXL_END_NAMESPACE #endif // !STXXL_COMMON_BINARY_BUFFER_HEADER
lgpl-3.0
fshh520/Camkit
src/ffmpeg_encode.c
6045
/* * Copyright (c) 2014 Andy Huang <[email protected]> * * This file is part of Camkit. * * Camkit 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. * * Camkit 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 Camkit; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "ffmpeg_common.h" #include "camkit/encode.h" struct enc_handle { AVCodec *codec; AVCodecContext *ctx; AVFrame *frame; uint8_t *inbuffer; int inbufsize; AVPacket packet; unsigned long frame_counter; struct enc_param params; }; struct enc_handle *encode_open(struct enc_param param) { struct enc_handle *handle = malloc(sizeof(struct enc_handle)); if (!handle) { printf("--- malloc enc handle failed\n"); return NULL; } CLEAR(*handle); handle->codec = NULL; handle->ctx = NULL; handle->frame = NULL; handle->inbuffer = NULL; handle->inbufsize = 0; handle->frame_counter = 0; handle->params.src_picwidth = param.src_picwidth; handle->params.src_picheight = param.src_picheight; handle->params.enc_picwidth = param.enc_picwidth; handle->params.enc_picheight = param.enc_picheight; handle->params.fps = param.fps; handle->params.bitrate = param.bitrate; handle->params.gop = param.gop; handle->params.chroma_interleave = param.chroma_interleave; avcodec_register_all(); handle->codec = avcodec_find_encoder(AV_CODEC_ID_H264); if (!handle->codec) { printf("--- H264 codec not found\n"); goto err0; } handle->ctx = avcodec_alloc_context3(handle->codec); if (!handle->ctx) { printf("--- Could not allocate video codec context\n"); goto err0; } handle->ctx->bit_rate = handle->params.bitrate * 1000; // to kbps handle->ctx->width = handle->params.src_picwidth; handle->ctx->height = handle->params.src_picheight; handle->ctx->time_base = (AVRational ) { 1, handle->params.fps }; // frames per second handle->ctx->gop_size = handle->params.gop; handle->ctx->max_b_frames = 1; handle->ctx->pix_fmt = AV_PIX_FMT_YUV420P; // handle->ctx->thread_count = 1; // eliminate frame delay! av_opt_set(handle->ctx->priv_data, "preset", "ultrafast", 0); av_opt_set(handle->ctx->priv_data, "tune", "zerolatency", 0); av_opt_set(handle->ctx->priv_data, "x264opts", "no-mbtree:sliced-threads:sync-lookahead=0", 0); if (avcodec_open2(handle->ctx, handle->codec, NULL) < 0) { printf("--- Could not open codec\n"); goto err1; } handle->frame = av_frame_alloc(); if (!handle->frame) { printf("--- Could not allocate video frame\n"); goto err2; } handle->frame->format = handle->ctx->pix_fmt; handle->frame->width = handle->ctx->width; handle->frame->height = handle->ctx->height; handle->inbufsize = avpicture_get_size(AV_PIX_FMT_YUV420P, handle->params.src_picwidth, handle->params.src_picheight); handle->inbuffer = av_malloc(handle->inbufsize); if (!handle->inbuffer) { printf("--- Could not allocate inbuffer\n"); goto err3; } avpicture_fill((AVPicture *) handle->frame, handle->inbuffer, AV_PIX_FMT_YUV420P, handle->params.src_picwidth, handle->params.src_picheight); av_init_packet(&handle->packet); handle->packet.data = NULL; handle->packet.size = 0; printf("+++ Encode Opened\n"); return handle; err3: av_frame_free(&handle->frame); err2: avcodec_close(handle->ctx); err1: av_free(handle->ctx); err0: free(handle); return NULL; } void encode_close(struct enc_handle *handle) { av_free_packet(&handle->packet); av_free(handle->inbuffer); av_frame_free(&handle->frame); avcodec_close(handle->ctx); av_free(handle->ctx); free(handle); printf("+++ Encode Closed\n"); } int encode_do(struct enc_handle *handle, void *ibuf, int ilen, void **pobuf, int *polen, enum pic_t *type) { int got_output, ret; // reinit pkt av_free_packet(&handle->packet); av_init_packet(&handle->packet); handle->packet.data = NULL; handle->packet.size = 0; assert(handle->inbufsize == ilen); memcpy(handle->inbuffer, ibuf, ilen); handle->frame->pts = handle->frame_counter++; ret = avcodec_encode_video2(handle->ctx, &handle->packet, handle->frame, &got_output); // cancel key frame handle->frame->pict_type = 0; handle->frame->key_frame = 0; if (ret < 0) { printf("--- Error encoding frame\n"); return -1; } if (got_output) { *pobuf = handle->packet.data; *polen = handle->packet.size; switch (handle->ctx->coded_frame->pict_type) { case AV_PICTURE_TYPE_I: *type = I; break; case AV_PICTURE_TYPE_P: *type = P; break; case AV_PICTURE_TYPE_B: *type = B; break; default: *type = NONE; break; } } else // get the delayed frame { printf("!!! encoded frame delayed!\n"); *pobuf = NULL; *polen = 0; *type = NONE; } return 0; } int encode_get_headers(struct enc_handle *handle, void **pbuf, int *plen, enum pic_t *type) { *pbuf = NULL; *plen = 0; *type = NONE; return 0; } int encode_set_qp(struct enc_handle *handle, int val) { UNUSED(handle); UNUSED(val); printf("*** %s.%s: This function is not implemented\n", __FILE__, __FUNCTION__); return -1; } int encode_set_bitrate(struct enc_handle *handle, int val) { handle->ctx->bit_rate = val; return 0; } int encode_set_framerate(struct enc_handle *handle, int val) { handle->ctx->time_base = (AVRational ) { 1, val }; return 0; } void encode_force_Ipic(struct enc_handle *handle) { handle->frame->pict_type = AV_PICTURE_TYPE_I; handle->frame->key_frame = 1; return; }
lgpl-3.0
edwinspire/VSharp
class/System/System.Net.Sockets/SendPacketsElement.cs
2838
// System.Net.Sockets.SocketAsyncEventArgs.cs // // Authors: // Marek Habersack ([email protected]) // // Copyright (c) 2008 Novell, Inc. (http://www.novell.com) // // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // 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. // using System; namespace System.Net.Sockets { public class SendPacketsElement { public byte[] Buffer { get; private set; } public int Count { get; private set; } public bool EndOfPacket { get; private set; } public string FilePath { get; private set; } public int Offset { get; private set; } public SendPacketsElement (byte[] buffer) : this (buffer, 0, buffer != null ? buffer.Length : 0) { } public SendPacketsElement (byte[] buffer, int offset, int count) : this (buffer, offset, count, false) { } public SendPacketsElement (byte[] buffer, int offset, int count, bool endOfPacket) { if (buffer == null) throw new ArgumentNullException ("buffer"); int buflen = buffer.Length; if (offset < 0 || offset >= buflen) throw new ArgumentOutOfRangeException ("offset"); if (count < 0 || offset + count >= buflen) throw new ArgumentOutOfRangeException ("count"); Buffer = buffer; Offset = offset; Count = count; EndOfPacket = endOfPacket; FilePath = null; } public SendPacketsElement (string filepath) : this (filepath, 0, 0, false) { } public SendPacketsElement (string filepath, int offset, int count) : this (filepath, offset, count, false) { } // LAME SPEC: only ArgumentNullException for filepath is thrown public SendPacketsElement (string filepath, int offset, int count, bool endOfPacket) { if (filepath == null) throw new ArgumentNullException ("filepath"); Buffer = null; Offset = offset; Count = count; EndOfPacket = endOfPacket; FilePath = filepath; } } }
lgpl-3.0
edwinspire/VSharp
class/System.Windows.Forms.DataVisualization/System.Windows.Forms.DataVisualization.Charting/CustomizeLegendEventArgs.cs
1400
// Authors: // Francis Fisher ([email protected]) // // (C) Francis Fisher 2013 // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // 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. namespace System.Windows.Forms.DataVisualization.Charting { public class CustomizeLegendEventArgs : EventArgs { public LegendItemsCollection LegendItems { get; private set; } public string LegendName { get; private set; } } }
lgpl-3.0
olikasg/erlang-scala-metrics
otp_src_17.4/lib/jinterface/doc/src/Makefile
4645
# -*-Makefile-*- # # %CopyrightBegin% # # Copyright Ericsson AB 2000-2012. All Rights Reserved. # # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # %CopyrightEnd% # include $(ERL_TOP)/make/target.mk include $(ERL_TOP)/make/$(TARGET)/otp.mk # ---------------------------------------------------- # Application version # ---------------------------------------------------- include ../../vsn.mk VSN=$(JINTERFACE_VSN) APPLICATION=jinterface # ---------------------------------------------------- # Release directory specification # ---------------------------------------------------- RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN) # ---------------------------------------------------- # Target Specs # ---------------------------------------------------- # Renamed this var to fool otp.mk.in XML_APP_FILES = ref_man.xml XML_REF3_FILES = jinterface.xml XML_PART_FILES = \ part.xml \ part_notes.xml \ part_notes_history.xml XML_CHAPTER_FILES = \ notes.xml \ notes_history.xml \ jinterface_users_guide.xml BOOK_FILES = book.xml XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF3_FILES) \ $(XML_PART_FILES) $(XML_CHAPTER_FILES) GIF_FILES = \ notes.gif \ ref_man.gif \ user_guide.gif #------------------------------------------------------ HTML_REF_MAN_FILE = $(HTMLDIR)/index.html TOP_PDF_FILE = $(PDFDIR)/$(APPLICATION)-$(VSN).pdf JAVADOC = javadoc JAVADOC_PKGS = com.ericsson.otp.erlang JAVA_PKG_PATH = com/ericsson/otp/erlang JAVADOC_TITLE = 'Java-Erlang Interface Library' JAVADOC_DEST = ../doc/html/java JAVA_SRC_PATH = $(ERL_TOP)/lib/$(APPLICATION)/java_src/$(JAVA_PKG_PATH) # don't add filenames to the Makefile! # all java sourcefiles listed in common include file include $(JAVA_SRC_PATH)/java_files JAVA_SRC_FILES = $(JAVA_FILES:%=$(JAVA_SRC_PATH)/%.java) JAVA_DOC_FILES = \ overview-tree.html \ index-all.html \ deprecated-list.html \ allclasses-frame.html \ index.html \ serialized-form.html \ package-list \ stylesheet.css \ help-doc.html INFO_FILE = ../../info JAVA_EXTRA_FILES = $(JAVA_DOC_FILES:%=$(HTMLDIR)/java/%) JAVA_GEN_FILES = \ $(JAVA_FILES:%=$(JAVADOC_DEST)/$(JAVA_PKG_PATH)/%.html) \ $(JAVADOC_DEST)/$(JAVA_PKG_PATH)/package-summary.html \ $(JAVADOC_DEST)/$(JAVA_PKG_PATH)/package-tree.html \ $(JAVADOC_DEST)/$(JAVA_PKG_PATH)/package-frame.html # ---------------------------------------------------- HTML_FILES = \ $(XML_PART_FILES:%.xml=$(HTMLDIR)/%.html) TOP_HTML_FILES = $(INDEX_TARGET) INDEX_FILE = index.html INDEX_SRC = $(INDEX_FILE).src INDEX_TARGET = $(DOCDIR)/$(INDEX_FILE) # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- XML_FLAGS += DVIPS_FLAGS += # ---------------------------------------------------- # Targets # ---------------------------------------------------- $(HTMLDIR)/%.gif: %.gif $(INSTALL_DATA) $< $@ docs: pdf html jdoc man $(TOP_PDF_FILE): $(XML_FILES) pdf: $(TOP_PDF_FILE) html: gifs $(HTML_REF_MAN_FILE) clean clean_docs: rm -rf $(HTMLDIR)/* rm -f $(MAN3DIR)/* rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo) rm -f errs core *~ jdoc:$(JAVA_SRC_FILES) (cd ../../java_src;$(JAVADOC) -sourcepath . -d $(JAVADOC_DEST) \ -windowtitle $(JAVADOC_TITLE) $(JAVADOC_PKGS)) man: gifs: $(GIF_FILES:%=$(HTMLDIR)/%) #$(INDEX_TARGET): $(INDEX_SRC) ../../vsn.mk # sed -e 's;%VSN%;$(VSN);' $< > $@ debug opt: # ---------------------------------------------------- # Release Target # ---------------------------------------------------- include $(ERL_TOP)/make/otp_release_targets.mk release_docs_spec: docs $(INSTALL_DIR) "$(RELSYSDIR)/doc/pdf" $(INSTALL_DATA) $(TOP_PDF_FILE) "$(RELSYSDIR)/doc/pdf" $(INSTALL_DIR) "$(RELSYSDIR)/doc/html" $(INSTALL_DIR) "$(RELSYSDIR)/doc/html/java/$(JAVA_PKG_PATH)" $(INSTALL_DATA) $(INFO_FILE) "$(RELSYSDIR)" (/bin/cp -rf ../html "$(RELSYSDIR)/doc") # $(INSTALL_DATA) $(GIF_FILES) $(EXTRA_FILES) $(HTML_FILES) \ # "$(RELSYSDIR)/doc/html" # $(INSTALL_DATA) $(JAVA_EXTRA_FILES) "$(RELSYSDIR)/doc/html/java" # $(INSTALL_DATA) $(TOP_HTML_FILES) "$(RELSYSDIR)/doc" release_spec:
lgpl-3.0
sprouvez/uploader-plus
surf/src/main/amp/config/alfresco/web-extension/site-webscripts/uploader-plus/uploader-plus-admin.get.js
204
function main() { // Widget instantiation metadata... var widget = { id: "UploaderPlusAdmin", name: "SoftwareLoop.UploaderPlusAdmin", }; model.widgets = [widget]; } main();
lgpl-3.0
aronsky/radare2
libr/bin/format/omf/omf.h
1604
#ifndef OMF_H_ #define OMF_H_ #include <r_util.h> #include <r_types.h> #include <r_bin.h> #include "omf_specs.h" typedef struct OMF_record_handler { OMF_record record; struct OMF_record_handler *next; } OMF_record_handler; typedef struct { ut32 nb_elem; void *elems; } OMF_multi_datas; typedef struct OMF_DATA{ ut64 paddr; // offset in file ut64 size; ut32 offset; ut16 seg_idx; struct OMF_DATA *next; } OMF_data; // sections return by the plugin are the addr of datas because sections are // separate on non contiguous block on the omf file typedef struct { ut32 name_idx; ut64 size; ut8 bits; ut64 vaddr; OMF_data *data; } OMF_segment; typedef struct { char *name; ut16 seg_idx; ut32 offset; } OMF_symbol; typedef struct { ut8 bits; char **names; ut32 nb_name; OMF_segment **sections; ut32 nb_section; OMF_symbol **symbols; ut32 nb_symbol; OMF_record_handler *records; } r_bin_omf_obj; // this value was chosen arbitrarily to made the loader work correctly // if someone want to implement rellocation for omf he has to remove this #define OMF_BASE_ADDR 0x1000 int r_bin_checksum_omf_ok(const ut8 *buf, ut64 buf_size); r_bin_omf_obj *r_bin_internal_omf_load(const ut8 *buf, ut64 size); void r_bin_free_all_omf_obj(r_bin_omf_obj *obj); bool r_bin_omf_get_entry(r_bin_omf_obj *obj, RBinAddr *addr); int r_bin_omf_get_bits(r_bin_omf_obj *obj); int r_bin_omf_send_sections(RList *list, OMF_segment *section, r_bin_omf_obj *obj); ut64 r_bin_omf_get_paddr_sym(r_bin_omf_obj *obj, OMF_symbol *sym); ut64 r_bin_omf_get_vaddr_sym(r_bin_omf_obj *obj, OMF_symbol *sym); #endif
lgpl-3.0
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/utils/text.py
25044
# encoding: utf-8 """ Utilities for working with strings and text. """ #----------------------------------------------------------------------------- # Copyright (C) 2008-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- import __main__ import os import re import shutil import sys import textwrap from string import Formatter from IPython.external.path import path from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest from IPython.utils import py3compat from IPython.utils.io import nlprint from IPython.utils.data import flatten #----------------------------------------------------------------------------- # Code #----------------------------------------------------------------------------- def unquote_ends(istr): """Remove a single pair of quotes from the endpoints of a string.""" if not istr: return istr if (istr[0]=="'" and istr[-1]=="'") or \ (istr[0]=='"' and istr[-1]=='"'): return istr[1:-1] else: return istr class LSString(str): """String derivative with a special access attributes. These are normal strings, but with the special attributes: .l (or .list) : value as list (split on newlines). .n (or .nlstr): original value (the string itself). .s (or .spstr): value as whitespace-separated string. .p (or .paths): list of path objects Any values which require transformations are computed only once and cached. Such strings are very useful to efficiently interact with the shell, which typically only understands whitespace-separated options for commands.""" def get_list(self): try: return self.__list except AttributeError: self.__list = self.split('\n') return self.__list l = list = property(get_list) def get_spstr(self): try: return self.__spstr except AttributeError: self.__spstr = self.replace('\n',' ') return self.__spstr s = spstr = property(get_spstr) def get_nlstr(self): return self n = nlstr = property(get_nlstr) def get_paths(self): try: return self.__paths except AttributeError: self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)] return self.__paths p = paths = property(get_paths) # FIXME: We need to reimplement type specific displayhook and then add this # back as a custom printer. This should also be moved outside utils into the # core. # def print_lsstring(arg): # """ Prettier (non-repr-like) and more informative printer for LSString """ # print "LSString (.p, .n, .l, .s available). Value:" # print arg # # # print_lsstring = result_display.when_type(LSString)(print_lsstring) class SList(list): """List derivative with a special access attributes. These are normal lists, but with the special attributes: .l (or .list) : value as list (the list itself). .n (or .nlstr): value as a string, joined on newlines. .s (or .spstr): value as a string, joined on spaces. .p (or .paths): list of path objects Any values which require transformations are computed only once and cached.""" def get_list(self): return self l = list = property(get_list) def get_spstr(self): try: return self.__spstr except AttributeError: self.__spstr = ' '.join(self) return self.__spstr s = spstr = property(get_spstr) def get_nlstr(self): try: return self.__nlstr except AttributeError: self.__nlstr = '\n'.join(self) return self.__nlstr n = nlstr = property(get_nlstr) def get_paths(self): try: return self.__paths except AttributeError: self.__paths = [path(p) for p in self if os.path.exists(p)] return self.__paths p = paths = property(get_paths) def grep(self, pattern, prune = False, field = None): """ Return all strings matching 'pattern' (a regex or callable) This is case-insensitive. If prune is true, return all items NOT matching the pattern. If field is specified, the match must occur in the specified whitespace-separated field. Examples:: a.grep( lambda x: x.startswith('C') ) a.grep('Cha.*log', prune=1) a.grep('chm', field=-1) """ def match_target(s): if field is None: return s parts = s.split() try: tgt = parts[field] return tgt except IndexError: return "" if isinstance(pattern, basestring): pred = lambda x : re.search(pattern, x, re.IGNORECASE) else: pred = pattern if not prune: return SList([el for el in self if pred(match_target(el))]) else: return SList([el for el in self if not pred(match_target(el))]) def fields(self, *fields): """ Collect whitespace-separated fields from string list Allows quick awk-like usage of string lists. Example data (in var a, created by 'a = !ls -l'):: -rwxrwxrwx 1 ville None 18 Dec 14 2006 ChangeLog drwxrwxrwx+ 6 ville None 0 Oct 24 18:05 IPython a.fields(0) is ['-rwxrwxrwx', 'drwxrwxrwx+'] a.fields(1,0) is ['1 -rwxrwxrwx', '6 drwxrwxrwx+'] (note the joining by space). a.fields(-1) is ['ChangeLog', 'IPython'] IndexErrors are ignored. Without args, fields() just split()'s the strings. """ if len(fields) == 0: return [el.split() for el in self] res = SList() for el in [f.split() for f in self]: lineparts = [] for fd in fields: try: lineparts.append(el[fd]) except IndexError: pass if lineparts: res.append(" ".join(lineparts)) return res def sort(self,field= None, nums = False): """ sort by specified fields (see fields()) Example:: a.sort(1, nums = True) Sorts a by second field, in numerical order (so that 21 > 3) """ #decorate, sort, undecorate if field is not None: dsu = [[SList([line]).fields(field), line] for line in self] else: dsu = [[line, line] for line in self] if nums: for i in range(len(dsu)): numstr = "".join([ch for ch in dsu[i][0] if ch.isdigit()]) try: n = int(numstr) except ValueError: n = 0; dsu[i][0] = n dsu.sort() return SList([t[1] for t in dsu]) # FIXME: We need to reimplement type specific displayhook and then add this # back as a custom printer. This should also be moved outside utils into the # core. # def print_slist(arg): # """ Prettier (non-repr-like) and more informative printer for SList """ # print "SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):" # if hasattr(arg, 'hideonce') and arg.hideonce: # arg.hideonce = False # return # # nlprint(arg) # # print_slist = result_display.when_type(SList)(print_slist) def esc_quotes(strng): """Return the input string with single and double quotes escaped out""" return strng.replace('"','\\"').replace("'","\\'") def qw(words,flat=0,sep=None,maxsplit=-1): """Similar to Perl's qw() operator, but with some more options. qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) words can also be a list itself, and with flat=1, the output will be recursively flattened. Examples: >>> qw('1 2') ['1', '2'] >>> qw(['a b','1 2',['m n','p q']]) [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] >>> qw(['a b','1 2',['m n','p q']],flat=1) ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ if isinstance(words, basestring): return [word.strip() for word in words.split(sep,maxsplit) if word and not word.isspace() ] if flat: return flatten(map(qw,words,[1]*len(words))) return map(qw,words) def qwflat(words,sep=None,maxsplit=-1): """Calls qw(words) in flat mode. It's just a convenient shorthand.""" return qw(words,1,sep,maxsplit) def qw_lol(indata): """qw_lol('a b') -> [['a','b']], otherwise it's just a call to qw(). We need this to make sure the modules_some keys *always* end up as a list of lists.""" if isinstance(indata, basestring): return [qw(indata)] else: return qw(indata) def grep(pat,list,case=1): """Simple minded grep-like function. grep(pat,list) returns occurrences of pat in list, None on failure. It only does simple string matching, with no support for regexps. Use the option case=0 for case-insensitive matching.""" # This is pretty crude. At least it should implement copying only references # to the original data in case it's big. Now it copies the data for output. out=[] if case: for term in list: if term.find(pat)>-1: out.append(term) else: lpat=pat.lower() for term in list: if term.lower().find(lpat)>-1: out.append(term) if len(out): return out else: return None def dgrep(pat,*opts): """Return grep() on dir()+dir(__builtins__). A very common use of grep() when working interactively.""" return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) def idgrep(pat): """Case-insensitive dgrep()""" return dgrep(pat,0) def igrep(pat,list): """Synonym for case-insensitive grep.""" return grep(pat,list,case=0) def indent(instr,nspaces=4, ntabs=0, flatten=False): """Indent a string a given number of spaces or tabstops. indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. Parameters ---------- instr : basestring The string to be indented. nspaces : int (default: 4) The number of spaces to be indented. ntabs : int (default: 0) The number of tabs to be indented. flatten : bool (default: False) Whether to scrub existing indentation. If True, all lines will be aligned to the same indentation. If False, existing indentation will be strictly increased. Returns ------- str|unicode : string indented by ntabs and nspaces. """ if instr is None: return ind = '\t'*ntabs+' '*nspaces if flatten: pat = re.compile(r'^\s*', re.MULTILINE) else: pat = re.compile(r'^', re.MULTILINE) outstr = re.sub(pat, ind, instr) if outstr.endswith(os.linesep+ind): return outstr[:-len(ind)] else: return outstr def native_line_ends(filename,backup=1): """Convert (in-place) a file to line-ends native to the current OS. If the optional backup argument is given as false, no backup of the original file is left. """ backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} bak_filename = filename + backup_suffixes[os.name] original = open(filename).read() shutil.copy2(filename,bak_filename) try: new = open(filename,'wb') new.write(os.linesep.join(original.splitlines())) new.write(os.linesep) # ALWAYS put an eol at the end of the file new.close() except: os.rename(bak_filename,filename) if not backup: try: os.remove(bak_filename) except: pass def list_strings(arg): """Always return a list of strings, given a string or list of strings as input. :Examples: In [7]: list_strings('A single string') Out[7]: ['A single string'] In [8]: list_strings(['A single string in a list']) Out[8]: ['A single string in a list'] In [9]: list_strings(['A','list','of','strings']) Out[9]: ['A', 'list', 'of', 'strings'] """ if isinstance(arg,basestring): return [arg] else: return arg def marquee(txt='',width=78,mark='*'): """Return the input string centered in a 'marquee'. :Examples: In [16]: marquee('A test',40) Out[16]: '**************** A test ****************' In [17]: marquee('A test',40,'-') Out[17]: '---------------- A test ----------------' In [18]: marquee('A test',40,' ') Out[18]: ' A test ' """ if not txt: return (mark*width)[:width] nmark = (width-len(txt)-2)//len(mark)//2 if nmark < 0: nmark =0 marks = mark*nmark return '%s %s %s' % (marks,txt,marks) ini_spaces_re = re.compile(r'^(\s+)') def num_ini_spaces(strng): """Return the number of initial spaces in a string""" ini_spaces = ini_spaces_re.match(strng) if ini_spaces: return ini_spaces.end() else: return 0 def format_screen(strng): """Format a string for screen printing. This removes some latex-type format codes.""" # Paragraph continue par_re = re.compile(r'\\$',re.MULTILINE) strng = par_re.sub('',strng) return strng def dedent(text): """Equivalent of textwrap.dedent that ignores unindented first line. This means it will still dedent strings like: '''foo is a bar ''' For use in wrap_paragraphs. """ if text.startswith('\n'): # text starts with blank line, don't ignore the first line return textwrap.dedent(text) # split first line splits = text.split('\n',1) if len(splits) == 1: # only one line return textwrap.dedent(text) first, rest = splits # dedent everything but the first line rest = textwrap.dedent(rest) return '\n'.join([first, rest]) def wrap_paragraphs(text, ncols=80): """Wrap multiple paragraphs to fit a specified width. This is equivalent to textwrap.wrap, but with support for multiple paragraphs, as separated by empty lines. Returns ------- list of complete paragraphs, wrapped to fill `ncols` columns. """ paragraph_re = re.compile(r'\n(\s*\n)+', re.MULTILINE) text = dedent(text).strip() paragraphs = paragraph_re.split(text)[::2] # every other entry is space out_ps = [] indent_re = re.compile(r'\n\s+', re.MULTILINE) for p in paragraphs: # presume indentation that survives dedent is meaningful formatting, # so don't fill unless text is flush. if indent_re.search(p) is None: # wrap paragraph p = textwrap.fill(p, ncols) out_ps.append(p) return out_ps def long_substr(data): """Return the longest common substring in a list of strings. Credit: http://stackoverflow.com/questions/2892931/longest-common-substring-from-more-than-two-strings-python """ substr = '' if len(data) > 1 and len(data[0]) > 0: for i in range(len(data[0])): for j in range(len(data[0])-i+1): if j > len(substr) and all(data[0][i:i+j] in x for x in data): substr = data[0][i:i+j] elif len(data) == 1: substr = data[0] return substr def strip_email_quotes(text): """Strip leading email quotation characters ('>'). Removes any combination of leading '>' interspersed with whitespace that appears *identically* in all lines of the input text. Parameters ---------- text : str Examples -------- Simple uses:: In [2]: strip_email_quotes('> > text') Out[2]: 'text' In [3]: strip_email_quotes('> > text\\n> > more') Out[3]: 'text\\nmore' Note how only the common prefix that appears in all lines is stripped:: In [4]: strip_email_quotes('> > text\\n> > more\\n> more...') Out[4]: '> text\\n> more\\nmore...' So if any line has no quote marks ('>') , then none are stripped from any of them :: In [5]: strip_email_quotes('> > text\\n> > more\\nlast different') Out[5]: '> > text\\n> > more\\nlast different' """ lines = text.splitlines() matches = set() for line in lines: prefix = re.match(r'^(\s*>[ >]*)', line) if prefix: matches.add(prefix.group(1)) else: break else: prefix = long_substr(list(matches)) if prefix: strip = len(prefix) text = '\n'.join([ ln[strip:] for ln in lines]) return text class EvalFormatter(Formatter): """A String Formatter that allows evaluation of simple expressions. Note that this version interprets a : as specifying a format string (as per standard string formatting), so if slicing is required, you must explicitly create a slice. This is to be used in templating cases, such as the parallel batch script templates, where simple arithmetic on arguments is useful. Examples -------- In [1]: f = EvalFormatter() In [2]: f.format('{n//4}', n=8) Out [2]: '2' In [3]: f.format("{greeting[slice(2,4)]}", greeting="Hello") Out [3]: 'll' """ def get_field(self, name, args, kwargs): v = eval(name, kwargs) return v, name @skip_doctest_py3 class FullEvalFormatter(Formatter): """A String Formatter that allows evaluation of simple expressions. Any time a format key is not found in the kwargs, it will be tried as an expression in the kwargs namespace. Note that this version allows slicing using [1:2], so you cannot specify a format string. Use :class:`EvalFormatter` to permit format strings. Examples -------- In [1]: f = FullEvalFormatter() In [2]: f.format('{n//4}', n=8) Out[2]: u'2' In [3]: f.format('{list(range(5))[2:4]}') Out[3]: u'[2, 3]' In [4]: f.format('{3*2}') Out[4]: u'6' """ # copied from Formatter._vformat with minor changes to allow eval # and replace the format_spec code with slicing def _vformat(self, format_string, args, kwargs, used_args, recursion_depth): if recursion_depth < 0: raise ValueError('Max string recursion exceeded') result = [] for literal_text, field_name, format_spec, conversion in \ self.parse(format_string): # output the literal text if literal_text: result.append(literal_text) # if there's a field, output it if field_name is not None: # this is some markup, find the object and do # the formatting if format_spec: # override format spec, to allow slicing: field_name = ':'.join([field_name, format_spec]) # eval the contents of the field for the object # to be formatted obj = eval(field_name, kwargs) # do any conversion on the resulting object obj = self.convert_field(obj, conversion) # format the object and append to the result result.append(self.format_field(obj, '')) return u''.join(py3compat.cast_unicode(s) for s in result) @skip_doctest_py3 class DollarFormatter(FullEvalFormatter): """Formatter allowing Itpl style $foo replacement, for names and attribute access only. Standard {foo} replacement also works, and allows full evaluation of its arguments. Examples -------- In [1]: f = DollarFormatter() In [2]: f.format('{n//4}', n=8) Out[2]: u'2' In [3]: f.format('23 * 76 is $result', result=23*76) Out[3]: u'23 * 76 is 1748' In [4]: f.format('$a or {b}', a=1, b=2) Out[4]: u'1 or 2' """ _dollar_pattern = re.compile("(.*?)\$(\$?[\w\.]+)") def parse(self, fmt_string): for literal_txt, field_name, format_spec, conversion \ in Formatter.parse(self, fmt_string): # Find $foo patterns in the literal text. continue_from = 0 txt = "" for m in self._dollar_pattern.finditer(literal_txt): new_txt, new_field = m.group(1,2) # $$foo --> $foo if new_field.startswith("$"): txt += new_txt + new_field else: yield (txt + new_txt, new_field, "", None) txt = "" continue_from = m.end() # Re-yield the {foo} style pattern yield (txt + literal_txt[continue_from:], field_name, format_spec, conversion) #----------------------------------------------------------------------------- # Utils to columnize a list of string #----------------------------------------------------------------------------- def _chunks(l, n): """Yield successive n-sized chunks from l.""" for i in xrange(0, len(l), n): yield l[i:i+n] def _find_optimal(rlist , separator_size=2 , displaywidth=80): """Calculate optimal info to columnize a list of string""" for nrow in range(1, len(rlist)+1) : chk = map(max,_chunks(rlist, nrow)) sumlength = sum(chk) ncols = len(chk) if sumlength+separator_size*(ncols-1) <= displaywidth : break; return {'columns_numbers' : ncols, 'optimal_separator_width':(displaywidth - sumlength)/(ncols-1) if (ncols -1) else 0, 'rows_numbers' : nrow, 'columns_width' : chk } def _get_or_default(mylist, i, default=None): """return list item number, or default if don't exist""" if i >= len(mylist): return default else : return mylist[i] @skip_doctest def compute_item_matrix(items, empty=None, *args, **kwargs) : """Returns a nested list, and info to columnize items Parameters : ------------ items : list of strings to columize empty : (default None) default value to fill list if needed separator_size : int (default=2) How much caracters will be used as a separation between each columns. displaywidth : int (default=80) The width of the area onto wich the columns should enter Returns : --------- Returns a tuple of (strings_matrix, dict_info) strings_matrix : nested list of string, the outer most list contains as many list as rows, the innermost lists have each as many element as colums. If the total number of elements in `items` does not equal the product of rows*columns, the last element of some lists are filled with `None`. dict_info : some info to make columnize easier: columns_numbers : number of columns rows_numbers : number of rows columns_width : list of with of each columns optimal_separator_width : best separator width between columns Exemple : --------- In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l'] ...: compute_item_matrix(l,displaywidth=12) Out[1]: ([['aaa', 'f', 'k'], ['b', 'g', 'l'], ['cc', 'h', None], ['d', 'i', None], ['eeeee', 'j', None]], {'columns_numbers': 3, 'columns_width': [5, 1, 1], 'optimal_separator_width': 2, 'rows_numbers': 5}) """ info = _find_optimal(map(len, items), *args, **kwargs) nrow, ncol = info['rows_numbers'], info['columns_numbers'] return ([[ _get_or_default(items, c*nrow+i, default=empty) for c in range(ncol) ] for i in range(nrow) ], info) def columnize(items, separator=' ', displaywidth=80): """ Transform a list of strings into a single string with columns. Parameters ---------- items : sequence of strings The strings to process. separator : str, optional [default is two spaces] The string that separates columns. displaywidth : int, optional [default is 80] Width of the display in number of characters. Returns ------- The formatted string. """ if not items : return '\n' matrix, info = compute_item_matrix(items, separator_size=len(separator), displaywidth=displaywidth) fmatrix = [filter(None, x) for x in matrix] sjoin = lambda x : separator.join([ y.ljust(w, ' ') for y, w in zip(x, info['columns_width'])]) return '\n'.join(map(sjoin, fmatrix))+'\n'
lgpl-3.0
Builders-SonarSource/sonarqube-bis
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql
3031
CREATE TABLE "SNAPSHOTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "CREATED_AT" BIGINT, "BUILD_DATE" BIGINT, "PROJECT_ID" INTEGER NOT NULL, "COMPONENT_UUID" VARCHAR(50), "PARENT_SNAPSHOT_ID" INTEGER, "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', "PURGE_STATUS" INTEGER, "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, "SCOPE" VARCHAR(3), "QUALIFIER" VARCHAR(10), "ROOT_SNAPSHOT_ID" INTEGER, "VERSION" VARCHAR(500), "PATH" VARCHAR(500), "DEPTH" INTEGER, "ROOT_PROJECT_ID" INTEGER, "ROOT_COMPONENT_UUID" VARCHAR(50), "PERIOD1_MODE" VARCHAR(100), "PERIOD1_PARAM" VARCHAR(100), "PERIOD1_DATE" BIGINT, "PERIOD2_MODE" VARCHAR(100), "PERIOD2_PARAM" VARCHAR(100), "PERIOD2_DATE" BIGINT, "PERIOD3_MODE" VARCHAR(100), "PERIOD3_PARAM" VARCHAR(100), "PERIOD3_DATE" BIGINT, "PERIOD4_MODE" VARCHAR(100), "PERIOD4_PARAM" VARCHAR(100), "PERIOD4_DATE" BIGINT, "PERIOD5_MODE" VARCHAR(100), "PERIOD5_PARAM" VARCHAR(100), "PERIOD5_DATE" BIGINT ); CREATE TABLE "DUPLICATIONS_INDEX" ( "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, "SNAPSHOT_ID" INTEGER NOT NULL, "HASH" VARCHAR(50) NOT NULL, "INDEX_IN_FILE" INTEGER NOT NULL, "START_LINE" INTEGER NOT NULL, "END_LINE" INTEGER NOT NULL ); CREATE TABLE "PROJECT_MEASURES" ( "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "VALUE" DOUBLE, "METRIC_ID" INTEGER NOT NULL, "SNAPSHOT_ID" INTEGER, "RULE_ID" INTEGER, "RULES_CATEGORY_ID" INTEGER, "TEXT_VALUE" VARCHAR(4000), "TENDENCY" INTEGER, "MEASURE_DATE" TIMESTAMP, "PROJECT_ID" INTEGER, "ALERT_STATUS" VARCHAR(5), "ALERT_TEXT" VARCHAR(4000), "URL" VARCHAR(2000), "DESCRIPTION" VARCHAR(4000), "RULE_PRIORITY" INTEGER, "CHARACTERISTIC_ID" INTEGER, "PERSON_ID" INTEGER, "VARIATION_VALUE_1" DOUBLE, "VARIATION_VALUE_2" DOUBLE, "VARIATION_VALUE_3" DOUBLE, "VARIATION_VALUE_4" DOUBLE, "VARIATION_VALUE_5" DOUBLE, "MEASURE_DATA" BINARY(167772150) ); CREATE TABLE "CE_ACTIVITY" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "UUID" VARCHAR(40) NOT NULL, "TASK_TYPE" VARCHAR(15) NOT NULL, "COMPONENT_UUID" VARCHAR(40) NULL, "SNAPSHOT_ID" INTEGER NULL, "STATUS" VARCHAR(15) NOT NULL, "IS_LAST" BOOLEAN NOT NULL, "IS_LAST_KEY" VARCHAR(55) NOT NULL, "SUBMITTER_LOGIN" VARCHAR(255) NULL, "SUBMITTED_AT" BIGINT NOT NULL, "STARTED_AT" BIGINT NULL, "EXECUTED_AT" BIGINT NULL, "CREATED_AT" BIGINT NOT NULL, "UPDATED_AT" BIGINT NOT NULL, "EXECUTION_TIME_MS" BIGINT NULL ); CREATE TABLE "EVENTS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "NAME" VARCHAR(400), "COMPONENT_UUID" VARCHAR(50), "SNAPSHOT_ID" INTEGER, "CATEGORY" VARCHAR(50), "EVENT_DATE" BIGINT NOT NULL, "CREATED_AT" BIGINT NOT NULL, "DESCRIPTION" VARCHAR(4000), "EVENT_DATA" VARCHAR(4000) );
lgpl-3.0
daryllxd/lifelong-learning
web-design/sass/scalable-and-modular-architecture-for-css.md
3548
## CSS Rules 1. Base: html, body, form { margin: 0; padding: 0; }, input[type=text] { border: 1px solid #999; }, a { color: #039; }, a:hover { color: #03C; } 2. Layout: Divide the page into sections. 3. Module: Reusable, modular parts of our design. Callouts, sidebars 4. State: Stuff to describe when hidden or expanded etc. 5. Theme: How modules or layouts should look. #### Naming Layout: l- Grid: g- State: is- (is-hidden, is-collapsed) Modules: The bulk of the project, use the name of the module itself (.example, .callout, .callout.is-collapsed) #### Base Rules Base styles include setting heading sizes, default link styles, default font styles, and body backgrounds. There should be no need to use !important in a Base style. #### Module Rules - Only include a selector that has semantics (no generic `span` or `div`). - Battle against specificity. - State can be combined (.callout.is-collapsed). #### Theme Rules - Define theme-specific cases: Keep the theming to specific regions of the page. - Applies also to typography. ## Changing States - Class name change: Happens with JavaScript. - Pseudo-class change: Done via any number of pseudo-classes. - Media queries: Describe how things should be styled under defined criteria, such as different viewports. You want to apply to the source itself, not the parent or the sibling. Ex: Dropdown active style applies to the button and not the toolbar. .btn { color: #333; } .btn-pressed { color: #000; } .btn-disabled { opacity: .5; pointer-events: none; } Pseudo-classes can be combined with the shits .btn, .btn:focus, .btn:focus, .btn.is-pressed, .btn.is-pressed:hover Media queries #### Depth of Applicability We hate things like this. They depend on the underlying HTML structure. #sidebar div #sidebar div h3 #sidebar div ul ## Selector Performance The style of an element is evaluated on element creation. See `body`, determine styles. See `div`, think it's empty, figure out styles, `div` gets painted. CSS gets evaluated from right to left. Inefficient, according to Google: 1. Rules with descendant selectors (`#content h3`) 2. Rules with child or adjacent selectors (`#content > h3`) 3. Rules with overly qualified selectors (`div#content > h3`) 4. Rules that apply `:hover` to non-link elements. *But what is important to note is that the evaluation of any more than a single element to determine styling is inefficient. This means you should only ever use a single selector in your rules: a class selector, an ID selector, an element selector, and an attribute selector.* Consider selector performance but honestly the difference is just 50ms... so. ## Drop the base When making a table, since you may make different types of table in the future just have some kind of "base table" that you can add a module to. table{} # base for all tables, such as the border-collapse: collapse thingie .comparison{} .comparison > tr > td{} .comparions > tr > td:nth-child(2n){} .info > tr > th{} # Different component for info tables .info > tr > td{} Icons .ico { display: inline-block; background: url(/img/sprite.png) no-repeat; line-height: 0; vertical-align: bottom; } .ico-16 { height: 16px; width: 16px; } .ico-inbox { background-position: 20px 20px; } .ico-drafts { background-position: 20px 40px; } (For IE, you can use `zoom:1; display: inline;` for IE to behave like the inline-block elements.) To optimize images, use Smush.it or ImageOptim.
unlicense
ddacoak/Fallen-Instinct
Assets/Scripts/OtrosScripts/Input/InputBehaviour.cs
514
using UnityEngine; using System.Collections; public class InputBehaviour : MonoBehaviour { // Cuando se llama, notifica a todos los métodos que hacen referencia al delegate (DownHandler). public delegate void DownHandler( int button ); // evento que se activa cuando aparece el DownHandler public event DownHandler onDown; // Funcion que se llama desde InputManger, activa el evento onDown de éste y otras clases public void triggerDown(int button){ if( onDown != null ) onDown(button); } }
unlicense
leonardodutra/arduino
arduino-1.5.4/libraries/ICMPPing/ICMPPing.h
2089
/* * Copyright (c) 2010 by Blake Foster <[email protected]> * * This file is free software; you can redistribute it and/or modify * it under the terms of either the GNU General Public License version 2 * or the GNU Lesser General Public License version 2.1, both as * published by the Free Software Foundation. */ #include <SPI.h> #include <Ethernet.h> #include <utility/w5100.h> #define REQ_DATASIZE 32 #define ICMP_ECHOREPLY 0 #define ICMP_ECHOREQ 8 #define PING_TIMEOUT 1000 typedef unsigned long time_t; class ICMPHeader; template <int dataSize> class ICMPMessage; class ICMPPing { public: ICMPPing(SOCKET s); // construct an ICMPPing object for socket s bool operator()(int nRetries, byte * addr, char * result); // Ping addr, retrying nRetries times if no response is received. // The respone is store in result. The return value is true if a response is received, and false otherwise. private: bool waitForEchoReply(); // wait for a response size_t sendEchoRequest(byte * addr); // send an ICMP echo request uint8_t receiveEchoReply(byte * addr, uint8_t& TTL, time_t& time); // read a respone SOCKET socket; // socket number to send ping }; class ICMPHeader { friend class ICMPPing; public: ICMPHeader(uint8_t Type); ICMPHeader(); uint8_t type; uint8_t code; uint16_t checksum; uint16_t id; uint16_t seq; static int lastSeq; static int lastId; }; template <int dataSize> class ICMPMessage { friend class ICMPPing; public: ICMPMessage(uint8_t type); ICMPMessage(); void initChecksum(); uint8_t& operator[](int i); const uint8_t& operator[](int i) const; ICMPHeader icmpHeader; time_t time; private: uint8_t data [dataSize]; }; template <int dataSize> inline uint8_t& ICMPMessage<dataSize>::operator[](int i) { return data[i]; } template <int dataSize> inline const uint8_t& ICMPMessage<dataSize>::operator[](int i) const { return data[i]; } typedef ICMPMessage<REQ_DATASIZE> EchoRequest; typedef ICMPMessage<REQ_DATASIZE> EchoReply; #pragma pack(1)
unlicense
GliderWinchItems/GliderWinchj2
lib/JFreeChart-1.0.17/javadoc/index-files/index-20.html
74188
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.6.0_30) on Sat Mar 22 15:16:01 EDT 2014 --> <title>T-Index (JFreeChart Class Library (version 1.0.17))</title> <meta name="date" content="2014-03-22"> <link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="T-Index (JFreeChart Class Library (version 1.0.17))"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../overview-summary.html">Overview</a></li> <li>Package</li> <li>Class</li> <li>Use</li> <li><a href="../overview-tree.html">Tree</a></li> <li><a href="../deprecated-list.html">Deprecated</a></li> <li class="navBarCell1Rev">Index</li> <li><a href="../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="index-19.html">PREV LETTER</a></li> <li><a href="index-21.html">NEXT LETTER</a></li> </ul> <ul class="navList"> <li><a href="../index.html?index-filesindex-20.html" target="_top">FRAMES</a></li> <li><a href="index-20.html" target="_top">NO FRAMES</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="contentContainer"><a href="index-1.html">A</a>&nbsp;<a href="index-2.html">B</a>&nbsp;<a href="index-3.html">C</a>&nbsp;<a href="index-4.html">D</a>&nbsp;<a href="index-5.html">E</a>&nbsp;<a href="index-6.html">F</a>&nbsp;<a href="index-7.html">G</a>&nbsp;<a href="index-8.html">H</a>&nbsp;<a href="index-9.html">I</a>&nbsp;<a href="index-10.html">J</a>&nbsp;<a href="index-11.html">K</a>&nbsp;<a href="index-12.html">L</a>&nbsp;<a href="index-13.html">M</a>&nbsp;<a href="index-14.html">N</a>&nbsp;<a href="index-15.html">O</a>&nbsp;<a href="index-16.html">P</a>&nbsp;<a href="index-17.html">Q</a>&nbsp;<a href="index-18.html">R</a>&nbsp;<a href="index-19.html">S</a>&nbsp;<a href="index-20.html">T</a>&nbsp;<a href="index-21.html">U</a>&nbsp;<a href="index-22.html">V</a>&nbsp;<a href="index-23.html">W</a>&nbsp;<a href="index-24.html">X</a>&nbsp;<a href="index-25.html">Y</a>&nbsp;<a href="index-26.html">Z</a>&nbsp;<a name="_T_"> <!-- --> </a> <h2 class="title">T</h2> <dl> <dt><a href="../org/jfree/data/xy/TableXYDataset.html" title="interface in org.jfree.data.xy"><span class="strong">TableXYDataset</span></a> - Interface in <a href="../org/jfree/data/xy/package-summary.html">org.jfree.data.xy</a></dt> <dd> <div class="block">A dataset containing one or more data series containing (x, y) data items, where all series in the dataset share the same set of x-values.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/renderer/AreaRendererEndType.html#TAPER">TAPER</a></span> - Static variable in class org.jfree.chart.renderer.<a href="../org/jfree/chart/renderer/AreaRendererEndType.html" title="class in org.jfree.chart.renderer">AreaRendererEndType</a></dt> <dd> <div class="block">The area tapers from the first or last value down to zero.</div> </dd> <dt><a href="../org/jfree/data/gantt/Task.html" title="class in org.jfree.data.gantt"><span class="strong">Task</span></a> - Class in <a href="../org/jfree/data/gantt/package-summary.html">org.jfree.data.gantt</a></dt> <dd> <div class="block">A simple representation of a task.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/gantt/Task.html#Task(java.lang.String, org.jfree.data.time.TimePeriod)">Task(String, TimePeriod)</a></span> - Constructor for class org.jfree.data.gantt.<a href="../org/jfree/data/gantt/Task.html" title="class in org.jfree.data.gantt">Task</a></dt> <dd> <div class="block">Creates a new task.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/gantt/Task.html#Task(java.lang.String, java.util.Date, java.util.Date)">Task(String, Date, Date)</a></span> - Constructor for class org.jfree.data.gantt.<a href="../org/jfree/data/gantt/Task.html" title="class in org.jfree.data.gantt">Task</a></dt> <dd> <div class="block">Creates a new task.</div> </dd> <dt><a href="../org/jfree/data/gantt/TaskSeries.html" title="class in org.jfree.data.gantt"><span class="strong">TaskSeries</span></a> - Class in <a href="../org/jfree/data/gantt/package-summary.html">org.jfree.data.gantt</a></dt> <dd> <div class="block">A series that contains zero, one or many <a href="../org/jfree/data/gantt/Task.html" title="class in org.jfree.data.gantt"><code>Task</code></a> objects.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/gantt/TaskSeries.html#TaskSeries(java.lang.String)">TaskSeries(String)</a></span> - Constructor for class org.jfree.data.gantt.<a href="../org/jfree/data/gantt/TaskSeries.html" title="class in org.jfree.data.gantt">TaskSeries</a></dt> <dd> <div class="block">Constructs a new series with the specified name.</div> </dd> <dt><a href="../org/jfree/data/gantt/TaskSeriesCollection.html" title="class in org.jfree.data.gantt"><span class="strong">TaskSeriesCollection</span></a> - Class in <a href="../org/jfree/data/gantt/package-summary.html">org.jfree.data.gantt</a></dt> <dd> <div class="block">A collection of <a href="../org/jfree/data/gantt/TaskSeries.html" title="class in org.jfree.data.gantt"><code>TaskSeries</code></a> objects.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/gantt/TaskSeriesCollection.html#TaskSeriesCollection()">TaskSeriesCollection()</a></span> - Constructor for class org.jfree.data.gantt.<a href="../org/jfree/data/gantt/TaskSeriesCollection.html" title="class in org.jfree.data.gantt">TaskSeriesCollection</a></dt> <dd> <div class="block">Default constructor.</div> </dd> <dt><a href="../org/jfree/chart/annotations/TextAnnotation.html" title="class in org.jfree.chart.annotations"><span class="strong">TextAnnotation</span></a> - Class in <a href="../org/jfree/chart/annotations/package-summary.html">org.jfree.chart.annotations</a></dt> <dd> <div class="block">A base class for text annotations.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/annotations/TextAnnotation.html#TextAnnotation(java.lang.String)">TextAnnotation(String)</a></span> - Constructor for class org.jfree.chart.annotations.<a href="../org/jfree/chart/annotations/TextAnnotation.html" title="class in org.jfree.chart.annotations">TextAnnotation</a></dt> <dd> <div class="block">Creates a text annotation with default settings.</div> </dd> <dt><a href="../org/jfree/chart/title/TextTitle.html" title="class in org.jfree.chart.title"><span class="strong">TextTitle</span></a> - Class in <a href="../org/jfree/chart/title/package-summary.html">org.jfree.chart.title</a></dt> <dd> <div class="block">A chart title that displays a text string with automatic wrapping as required.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/TextTitle.html#TextTitle()">TextTitle()</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/TextTitle.html" title="class in org.jfree.chart.title">TextTitle</a></dt> <dd> <div class="block">Creates a new title, using default attributes where necessary.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/TextTitle.html#TextTitle(java.lang.String)">TextTitle(String)</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/TextTitle.html" title="class in org.jfree.chart.title">TextTitle</a></dt> <dd> <div class="block">Creates a new title, using default attributes where necessary.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/TextTitle.html#TextTitle(java.lang.String, java.awt.Font)">TextTitle(String, Font)</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/TextTitle.html" title="class in org.jfree.chart.title">TextTitle</a></dt> <dd> <div class="block">Creates a new title, using default attributes where necessary.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/TextTitle.html#TextTitle(java.lang.String, java.awt.Font, java.awt.Paint, org.jfree.ui.RectangleEdge, org.jfree.ui.HorizontalAlignment, org.jfree.ui.VerticalAlignment, org.jfree.ui.RectangleInsets)">TextTitle(String, Font, Paint, RectangleEdge, HorizontalAlignment, VerticalAlignment, RectangleInsets)</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/TextTitle.html" title="class in org.jfree.chart.title">TextTitle</a></dt> <dd> <div class="block">Creates a new title.</div> </dd> <dt><a href="../org/jfree/chart/plot/ThermometerPlot.html" title="class in org.jfree.chart.plot"><span class="strong">ThermometerPlot</span></a> - Class in <a href="../org/jfree/chart/plot/package-summary.html">org.jfree.chart.plot</a></dt> <dd> <div class="block">A plot that displays a single value (from a <a href="../org/jfree/data/general/ValueDataset.html" title="interface in org.jfree.data.general"><code>ValueDataset</code></a>) in a thermometer type display.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/ThermometerPlot.html#ThermometerPlot()">ThermometerPlot()</a></span> - Constructor for class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/ThermometerPlot.html" title="class in org.jfree.chart.plot">ThermometerPlot</a></dt> <dd> <div class="block">Creates a new thermometer plot.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/ThermometerPlot.html#ThermometerPlot(org.jfree.data.general.ValueDataset)">ThermometerPlot(ValueDataset)</a></span> - Constructor for class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/ThermometerPlot.html" title="class in org.jfree.chart.plot">ThermometerPlot</a></dt> <dd> <div class="block">Creates a new thermometer plot, using default attributes where necessary.</div> </dd> <dt><a href="../org/jfree/chart/axis/Tick.html" title="class in org.jfree.chart.axis"><span class="strong">Tick</span></a> - Class in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">The base class used to represent labeled ticks along an axis.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/Tick.html#Tick(java.lang.String, org.jfree.ui.TextAnchor, org.jfree.ui.TextAnchor, double)">Tick(String, TextAnchor, TextAnchor, double)</a></span> - Constructor for class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/Tick.html" title="class in org.jfree.chart.axis">Tick</a></dt> <dd> <div class="block">Creates a new tick.</div> </dd> <dt><a href="../org/jfree/chart/entity/TickLabelEntity.html" title="class in org.jfree.chart.entity"><span class="strong">TickLabelEntity</span></a> - Class in <a href="../org/jfree/chart/entity/package-summary.html">org.jfree.chart.entity</a></dt> <dd> <div class="block">A chart entity representing a tick label.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/TickLabelEntity.html#TickLabelEntity(java.awt.Shape, java.lang.String, java.lang.String)">TickLabelEntity(Shape, String, String)</a></span> - Constructor for class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/TickLabelEntity.html" title="class in org.jfree.chart.entity">TickLabelEntity</a></dt> <dd> <div class="block">Creates a new entity.</div> </dd> <dt><a href="../org/jfree/chart/axis/TickType.html" title="class in org.jfree.chart.axis"><span class="strong">TickType</span></a> - Class in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">Used to indicate the tick type (MAJOR or MINOR).</div> </dd> <dt><a href="../org/jfree/chart/axis/TickUnit.html" title="class in org.jfree.chart.axis"><span class="strong">TickUnit</span></a> - Class in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">Base class representing a tick unit.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/TickUnit.html#TickUnit(double)">TickUnit(double)</a></span> - Constructor for class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/TickUnit.html" title="class in org.jfree.chart.axis">TickUnit</a></dt> <dd> <div class="block">Constructs a new tick unit.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/TickUnit.html#TickUnit(double, int)">TickUnit(double, int)</a></span> - Constructor for class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/TickUnit.html" title="class in org.jfree.chart.axis">TickUnit</a></dt> <dd> <div class="block">Constructs a new tick unit.</div> </dd> <dt><a href="../org/jfree/chart/axis/TickUnits.html" title="class in org.jfree.chart.axis"><span class="strong">TickUnits</span></a> - Class in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">A collection of tick units, used by the <a href="../org/jfree/chart/axis/DateAxis.html" title="class in org.jfree.chart.axis"><code>DateAxis</code></a> and <a href="../org/jfree/chart/axis/NumberAxis.html" title="class in org.jfree.chart.axis"><code>NumberAxis</code></a> classes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/TickUnits.html#TickUnits()">TickUnits()</a></span> - Constructor for class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/TickUnits.html" title="class in org.jfree.chart.axis">TickUnits</a></dt> <dd> <div class="block">Constructs a new collection of tick units.</div> </dd> <dt><a href="../org/jfree/chart/axis/TickUnitSource.html" title="interface in org.jfree.chart.axis"><span class="strong">TickUnitSource</span></a> - Interface in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">An interface used by the <a href="../org/jfree/chart/axis/DateAxis.html" title="class in org.jfree.chart.axis"><code>DateAxis</code></a> and <a href="../org/jfree/chart/axis/NumberAxis.html" title="class in org.jfree.chart.axis"><code>NumberAxis</code></a> classes to obtain a suitable <a href="../org/jfree/chart/axis/TickUnit.html" title="class in org.jfree.chart.axis"><code>TickUnit</code></a>.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/ColorPalette.html#tickValues">tickValues</a></span> - Variable in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/ColorPalette.html" title="class in org.jfree.chart.plot">ColorPalette</a></dt> <dd> <div class="block"><span class="strong">Deprecated.</span></div> <div class="block">Tick values are stored for use with stepped palette.</div> </dd> <dt><a href="../org/jfree/chart/axis/Timeline.html" title="interface in org.jfree.chart.axis"><span class="strong">Timeline</span></a> - Interface in <a href="../org/jfree/chart/axis/package-summary.html">org.jfree.chart.axis</a></dt> <dd> <div class="block">An interface that defines the contract for a Timeline.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriod.html" title="interface in org.jfree.data.time"><span class="strong">TimePeriod</span></a> - Interface in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">A period of time measured to millisecond precision using two instances of <code>java.util.Date</code>.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriodAnchor.html" title="class in org.jfree.data.time"><span class="strong">TimePeriodAnchor</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">Used to indicate one of three positions in a time period: <code>START</code>, <code>MIDDLE</code> and <code>END</code>.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeries.html#timePeriodClass">timePeriodClass</a></span> - Variable in class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time">TimeSeries</a></dt> <dd> <div class="block">The type of period for the data.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriodFormatException.html" title="class in org.jfree.data.time"><span class="strong">TimePeriodFormatException</span></a> - Exception in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">An exception that indicates an invalid format in a string representing a time period.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodFormatException.html#TimePeriodFormatException(java.lang.String)">TimePeriodFormatException(String)</a></span> - Constructor for exception org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodFormatException.html" title="class in org.jfree.data.time">TimePeriodFormatException</a></dt> <dd> <div class="block">Creates a new exception.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriodValue.html" title="class in org.jfree.data.time"><span class="strong">TimePeriodValue</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">Represents a time period and an associated value.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValue.html#TimePeriodValue(org.jfree.data.time.TimePeriod, java.lang.Number)">TimePeriodValue(TimePeriod, Number)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValue.html" title="class in org.jfree.data.time">TimePeriodValue</a></dt> <dd> <div class="block">Constructs a new data item.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValue.html#TimePeriodValue(org.jfree.data.time.TimePeriod, double)">TimePeriodValue(TimePeriod, double)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValue.html" title="class in org.jfree.data.time">TimePeriodValue</a></dt> <dd> <div class="block">Constructs a new data item.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriodValues.html" title="class in org.jfree.data.time"><span class="strong">TimePeriodValues</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">A structure containing zero, one or many <a href="../org/jfree/data/time/TimePeriodValue.html" title="class in org.jfree.data.time"><code>TimePeriodValue</code></a> instances.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValues.html#TimePeriodValues(java.lang.String)">TimePeriodValues(String)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValues.html" title="class in org.jfree.data.time">TimePeriodValues</a></dt> <dd> <div class="block">Creates a new (empty) collection of time period values.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValues.html#TimePeriodValues(java.lang.String, java.lang.String, java.lang.String)">TimePeriodValues(String, String, String)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValues.html" title="class in org.jfree.data.time">TimePeriodValues</a></dt> <dd> <div class="block">Creates a new time series that contains no data.</div> </dd> <dt><a href="../org/jfree/data/time/TimePeriodValuesCollection.html" title="class in org.jfree.data.time"><span class="strong">TimePeriodValuesCollection</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">A collection of <a href="../org/jfree/data/time/TimePeriodValues.html" title="class in org.jfree.data.time"><code>TimePeriodValues</code></a> objects.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValuesCollection.html#TimePeriodValuesCollection()">TimePeriodValuesCollection()</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValuesCollection.html" title="class in org.jfree.data.time">TimePeriodValuesCollection</a></dt> <dd> <div class="block">Constructs an empty dataset.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValuesCollection.html#TimePeriodValuesCollection(org.jfree.data.time.TimePeriodValues)">TimePeriodValuesCollection(TimePeriodValues)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValuesCollection.html" title="class in org.jfree.data.time">TimePeriodValuesCollection</a></dt> <dd> <div class="block">Constructs a dataset containing a single series.</div> </dd> <dt><a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time"><span class="strong">TimeSeries</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">Represents a sequence of zero or more data items in the form (period, value) where 'period' is some instance of a subclass of <a href="../org/jfree/data/time/RegularTimePeriod.html" title="class in org.jfree.data.time"><code>RegularTimePeriod</code></a>.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeries.html#TimeSeries(java.lang.Comparable)">TimeSeries(Comparable)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time">TimeSeries</a></dt> <dd> <div class="block">Creates a new (empty) time series.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeries.html#TimeSeries(java.lang.Comparable, java.lang.String, java.lang.String)">TimeSeries(Comparable, String, String)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time">TimeSeries</a></dt> <dd> <div class="block">Creates a new time series that contains no data.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeries.html#TimeSeries(java.lang.Comparable, java.lang.Class)">TimeSeries(Comparable, Class)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time">TimeSeries</a></dt> <dd> <div class="block"><span class="strong">Deprecated.</span> <div class="block"><i>As of 1.0.13, it is not necessary to specify the <code>timePeriodClass</code> as this will be inferred when the first data item is added to the dataset.</i></div> </div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeries.html#TimeSeries(java.lang.Comparable, java.lang.String, java.lang.String, java.lang.Class)">TimeSeries(Comparable, String, String, Class)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeries.html" title="class in org.jfree.data.time">TimeSeries</a></dt> <dd> <div class="block"><span class="strong">Deprecated.</span> <div class="block"><i>As of 1.0.13, it is not necessary to specify the <code>timePeriodClass</code> as this will be inferred when the first data item is added to the dataset.</i></div> </div> </dd> <dt><a href="../org/jfree/chart/demo/TimeSeriesChartDemo1.html" title="class in org.jfree.chart.demo"><span class="strong">TimeSeriesChartDemo1</span></a> - Class in <a href="../org/jfree/chart/demo/package-summary.html">org.jfree.chart.demo</a></dt> <dd> <div class="block">An example of a time series chart.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/demo/TimeSeriesChartDemo1.html#TimeSeriesChartDemo1(java.lang.String)">TimeSeriesChartDemo1(String)</a></span> - Constructor for class org.jfree.chart.demo.<a href="../org/jfree/chart/demo/TimeSeriesChartDemo1.html" title="class in org.jfree.chart.demo">TimeSeriesChartDemo1</a></dt> <dd> <div class="block">A demonstration application showing how to create a simple time series chart.</div> </dd> <dt><a href="../org/jfree/data/time/TimeSeriesCollection.html" title="class in org.jfree.data.time"><span class="strong">TimeSeriesCollection</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">A collection of time series objects.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesCollection.html#TimeSeriesCollection()">TimeSeriesCollection()</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesCollection.html" title="class in org.jfree.data.time">TimeSeriesCollection</a></dt> <dd> <div class="block">Constructs an empty dataset, tied to the default timezone.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesCollection.html#TimeSeriesCollection(java.util.TimeZone)">TimeSeriesCollection(TimeZone)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesCollection.html" title="class in org.jfree.data.time">TimeSeriesCollection</a></dt> <dd> <div class="block">Constructs an empty dataset, tied to a specific timezone.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesCollection.html#TimeSeriesCollection(org.jfree.data.time.TimeSeries)">TimeSeriesCollection(TimeSeries)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesCollection.html" title="class in org.jfree.data.time">TimeSeriesCollection</a></dt> <dd> <div class="block">Constructs a dataset containing a single series (more can be added), tied to the default timezone.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesCollection.html#TimeSeriesCollection(org.jfree.data.time.TimeSeries, java.util.TimeZone)">TimeSeriesCollection(TimeSeries, TimeZone)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesCollection.html" title="class in org.jfree.data.time">TimeSeriesCollection</a></dt> <dd> <div class="block">Constructs a dataset containing a single series (more can be added), tied to a specific timezone.</div> </dd> <dt><a href="../org/jfree/data/time/TimeSeriesDataItem.html" title="class in org.jfree.data.time"><span class="strong">TimeSeriesDataItem</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">Represents one data item in a time series.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesDataItem.html#TimeSeriesDataItem(org.jfree.data.time.RegularTimePeriod, java.lang.Number)">TimeSeriesDataItem(RegularTimePeriod, Number)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesDataItem.html" title="class in org.jfree.data.time">TimeSeriesDataItem</a></dt> <dd> <div class="block">Constructs a new data item that associates a value with a time period.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesDataItem.html#TimeSeriesDataItem(org.jfree.data.time.RegularTimePeriod, double)">TimeSeriesDataItem(RegularTimePeriod, double)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesDataItem.html" title="class in org.jfree.data.time">TimeSeriesDataItem</a></dt> <dd> <div class="block">Constructs a new data item that associates a value with a time period.</div> </dd> <dt><a href="../org/jfree/data/time/TimeSeriesTableModel.html" title="class in org.jfree.data.time"><span class="strong">TimeSeriesTableModel</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">Wrapper around a time series to convert it to a table model for use in a <code>JTable</code>.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesTableModel.html#TimeSeriesTableModel()">TimeSeriesTableModel()</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesTableModel.html" title="class in org.jfree.data.time">TimeSeriesTableModel</a></dt> <dd> <div class="block">Default constructor.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesTableModel.html#TimeSeriesTableModel(org.jfree.data.time.TimeSeries)">TimeSeriesTableModel(TimeSeries)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesTableModel.html" title="class in org.jfree.data.time">TimeSeriesTableModel</a></dt> <dd> <div class="block">Constructs a table model for a time series.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeSeriesTableModel.html#TimeSeriesTableModel(org.jfree.data.time.TimeSeries, boolean)">TimeSeriesTableModel(TimeSeries, boolean)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeSeriesTableModel.html" title="class in org.jfree.data.time">TimeSeriesTableModel</a></dt> <dd> <div class="block">Creates a table model based on a time series.</div> </dd> <dt><a href="../org/jfree/chart/urls/TimeSeriesURLGenerator.html" title="class in org.jfree.chart.urls"><span class="strong">TimeSeriesURLGenerator</span></a> - Class in <a href="../org/jfree/chart/urls/package-summary.html">org.jfree.chart.urls</a></dt> <dd> <div class="block">A URL generator for time series charts.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/urls/TimeSeriesURLGenerator.html#TimeSeriesURLGenerator()">TimeSeriesURLGenerator()</a></span> - Constructor for class org.jfree.chart.urls.<a href="../org/jfree/chart/urls/TimeSeriesURLGenerator.html" title="class in org.jfree.chart.urls">TimeSeriesURLGenerator</a></dt> <dd> <div class="block">Default constructor.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/urls/TimeSeriesURLGenerator.html#TimeSeriesURLGenerator(java.text.DateFormat, java.lang.String, java.lang.String, java.lang.String)">TimeSeriesURLGenerator(DateFormat, String, String, String)</a></span> - Constructor for class org.jfree.chart.urls.<a href="../org/jfree/chart/urls/TimeSeriesURLGenerator.html" title="class in org.jfree.chart.urls">TimeSeriesURLGenerator</a></dt> <dd> <div class="block">Construct TimeSeriesURLGenerator overriding defaults.</div> </dd> <dt><a href="../org/jfree/data/time/TimeTableXYDataset.html" title="class in org.jfree.data.time"><span class="strong">TimeTableXYDataset</span></a> - Class in <a href="../org/jfree/data/time/package-summary.html">org.jfree.data.time</a></dt> <dd> <div class="block">A dataset for regular time periods that implements the <a href="../org/jfree/data/xy/TableXYDataset.html" title="interface in org.jfree.data.xy"><code>TableXYDataset</code></a> interface.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeTableXYDataset.html#TimeTableXYDataset()">TimeTableXYDataset()</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeTableXYDataset.html" title="class in org.jfree.data.time">TimeTableXYDataset</a></dt> <dd> <div class="block">Creates a new dataset.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeTableXYDataset.html#TimeTableXYDataset(java.util.TimeZone)">TimeTableXYDataset(TimeZone)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeTableXYDataset.html" title="class in org.jfree.data.time">TimeTableXYDataset</a></dt> <dd> <div class="block">Creates a new dataset with the given time zone.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimeTableXYDataset.html#TimeTableXYDataset(java.util.TimeZone, java.util.Locale)">TimeTableXYDataset(TimeZone, Locale)</a></span> - Constructor for class org.jfree.data.time.<a href="../org/jfree/data/time/TimeTableXYDataset.html" title="class in org.jfree.data.time">TimeTableXYDataset</a></dt> <dd> <div class="block">Creates a new dataset with the given time zone and locale.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.html#title">title</a></span> - Variable in class org.jfree.chart.imagemap.<a href="../org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.html" title="class in org.jfree.chart.imagemap">DynamicDriveToolTipTagFragmentGenerator</a></dt> <dd> <div class="block">The title, empty string not to display</div> </dd> <dt><a href="../org/jfree/chart/title/Title.html" title="class in org.jfree.chart.title"><span class="strong">Title</span></a> - Class in <a href="../org/jfree/chart/title/package-summary.html">org.jfree.chart.title</a></dt> <dd> <div class="block">The base class for all chart titles.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/Title.html#Title()">Title()</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/Title.html" title="class in org.jfree.chart.title">Title</a></dt> <dd> <div class="block">Creates a new title, using default attributes where necessary.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/Title.html#Title(org.jfree.ui.RectangleEdge, org.jfree.ui.HorizontalAlignment, org.jfree.ui.VerticalAlignment)">Title(RectangleEdge, HorizontalAlignment, VerticalAlignment)</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/Title.html" title="class in org.jfree.chart.title">Title</a></dt> <dd> <div class="block">Creates a new title, using default attributes where necessary.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/title/Title.html#Title(org.jfree.ui.RectangleEdge, org.jfree.ui.HorizontalAlignment, org.jfree.ui.VerticalAlignment, org.jfree.ui.RectangleInsets)">Title(RectangleEdge, HorizontalAlignment, VerticalAlignment, RectangleInsets)</a></span> - Constructor for class org.jfree.chart.title.<a href="../org/jfree/chart/title/Title.html" title="class in org.jfree.chart.title">Title</a></dt> <dd> <div class="block">Creates a new title.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/event/TitleChangeListener.html#titleChanged(org.jfree.chart.event.TitleChangeEvent)">titleChanged(TitleChangeEvent)</a></span> - Method in interface org.jfree.chart.event.<a href="../org/jfree/chart/event/TitleChangeListener.html" title="interface in org.jfree.chart.event">TitleChangeListener</a></dt> <dd> <div class="block">Receives notification of a chart title change event.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/JFreeChart.html#titleChanged(org.jfree.chart.event.TitleChangeEvent)">titleChanged(TitleChangeEvent)</a></span> - Method in class org.jfree.chart.<a href="../org/jfree/chart/JFreeChart.html" title="class in org.jfree.chart">JFreeChart</a></dt> <dd> <div class="block">Receives notification that a chart title has changed, and passes this on to registered listeners.</div> </dd> <dt><a href="../org/jfree/chart/event/TitleChangeEvent.html" title="class in org.jfree.chart.event"><span class="strong">TitleChangeEvent</span></a> - Class in <a href="../org/jfree/chart/event/package-summary.html">org.jfree.chart.event</a></dt> <dd> <div class="block">A change event that encapsulates information about a change to a chart title.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/event/TitleChangeEvent.html#TitleChangeEvent(org.jfree.chart.title.Title)">TitleChangeEvent(Title)</a></span> - Constructor for class org.jfree.chart.event.<a href="../org/jfree/chart/event/TitleChangeEvent.html" title="class in org.jfree.chart.event">TitleChangeEvent</a></dt> <dd> <div class="block">Default constructor.</div> </dd> <dt><a href="../org/jfree/chart/event/TitleChangeListener.html" title="interface in org.jfree.chart.event"><span class="strong">TitleChangeListener</span></a> - Interface in <a href="../org/jfree/chart/event/package-summary.html">org.jfree.chart.event</a></dt> <dd> <div class="block">The interface that must be supported by classes that wish to receive notification of changes to a chart title.</div> </dd> <dt><a href="../org/jfree/chart/entity/TitleEntity.html" title="class in org.jfree.chart.entity"><span class="strong">TitleEntity</span></a> - Class in <a href="../org/jfree/chart/entity/package-summary.html">org.jfree.chart.entity</a></dt> <dd> <div class="block">A class that captures information about a Title of a chart.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/TitleEntity.html#TitleEntity(java.awt.Shape, org.jfree.chart.title.Title)">TitleEntity(Shape, Title)</a></span> - Constructor for class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/TitleEntity.html" title="class in org.jfree.chart.entity">TitleEntity</a></dt> <dd> <div class="block">Creates a new chart entity.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/TitleEntity.html#TitleEntity(java.awt.Shape, org.jfree.chart.title.Title, java.lang.String)">TitleEntity(Shape, Title, String)</a></span> - Constructor for class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/TitleEntity.html" title="class in org.jfree.chart.entity">TitleEntity</a></dt> <dd> <div class="block">Creates a new chart entity.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/TitleEntity.html#TitleEntity(java.awt.Shape, org.jfree.chart.title.Title, java.lang.String, java.lang.String)">TitleEntity(Shape, Title, String, String)</a></span> - Constructor for class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/TitleEntity.html" title="class in org.jfree.chart.entity">TitleEntity</a></dt> <dd> <div class="block">Creates a new entity.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/xy/XYSeries.html#toArray()">toArray()</a></span> - Method in class org.jfree.data.xy.<a href="../org/jfree/data/xy/XYSeries.html" title="class in org.jfree.data.xy">XYSeries</a></dt> <dd> <div class="block">Returns a new array containing the x and y values from this series.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#toContentConstraint(org.jfree.chart.block.RectangleConstraint)">toContentConstraint(RectangleConstraint)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Returns a constraint for the content of this block that will result in the bounds of the block matching the specified constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toFixedHeight(double)">toFixedHeight(double)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the width attributes, but has a fixed height constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toFixedWidth(double)">toFixedWidth(double)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the height attributes, but has a fixed width constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/editor/DefaultLogAxisEditor.html#toggleAutoTick()">toggleAutoTick()</a></span> - Method in class org.jfree.chart.editor.<a href="../org/jfree/chart/editor/DefaultLogAxisEditor.html" title="class in org.jfree.chart.editor">DefaultLogAxisEditor</a></dt> <dd> <div class="block">Toggles the auto-tick-unit setting.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/SegmentedTimeline.html#toMillisecond(long)">toMillisecond(long)</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/SegmentedTimeline.html" title="class in org.jfree.chart.axis">SegmentedTimeline</a></dt> <dd> <div class="block">Translates a value relative to the timeline into a millisecond.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/Timeline.html#toMillisecond(long)">toMillisecond(long)</a></span> - Method in interface org.jfree.chart.axis.<a href="../org/jfree/chart/axis/Timeline.html" title="interface in org.jfree.chart.axis">Timeline</a></dt> <dd> <div class="block">Translates a value relative to this timeline into a domain value.</div> </dd> <dt><a href="../org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.html" title="interface in org.jfree.chart.imagemap"><span class="strong">ToolTipTagFragmentGenerator</span></a> - Interface in <a href="../org/jfree/chart/imagemap/package-summary.html">org.jfree.chart.imagemap</a></dt> <dd> <div class="block">Interface for generating the tooltip fragment of an HTML image map area tag.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/AxisLocation.html#TOP_OR_LEFT">TOP_OR_LEFT</a></span> - Static variable in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/AxisLocation.html" title="class in org.jfree.chart.axis">AxisLocation</a></dt> <dd> <div class="block">Axis at the top or left.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/AxisLocation.html#TOP_OR_RIGHT">TOP_OR_RIGHT</a></span> - Static variable in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/AxisLocation.html" title="class in org.jfree.chart.axis">AxisLocation</a></dt> <dd> <div class="block">Axis at the top or right.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toRangeHeight(org.jfree.data.Range)">toRangeHeight(Range)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the width attributes, but has a range height constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toRangeWidth(org.jfree.data.Range)">toRangeWidth(Range)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the height attributes, but has a range width constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/AxisLabelLocation.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/AxisLabelLocation.html" title="class in org.jfree.chart.axis">AxisLabelLocation</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/AxisLocation.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/AxisLocation.html" title="class in org.jfree.chart.axis">AxisLocation</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/AxisSpace.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/AxisSpace.html" title="class in org.jfree.chart.axis">AxisSpace</a></dt> <dd> <div class="block">Returns a string representing the object (for debugging purposes).</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/CategoryAnchor.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/CategoryAnchor.html" title="class in org.jfree.chart.axis">CategoryAnchor</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/CategoryLabelWidthType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/CategoryLabelWidthType.html" title="class in org.jfree.chart.axis">CategoryLabelWidthType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/DateTickMarkPosition.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/DateTickMarkPosition.html" title="class in org.jfree.chart.axis">DateTickMarkPosition</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/DateTickUnit.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/DateTickUnit.html" title="class in org.jfree.chart.axis">DateTickUnit</a></dt> <dd> <div class="block">Returns a string representation of this instance, primarily used for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/DateTickUnitType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/DateTickUnitType.html" title="class in org.jfree.chart.axis">DateTickUnitType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/NumberTickUnit.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/NumberTickUnit.html" title="class in org.jfree.chart.axis">NumberTickUnit</a></dt> <dd> <div class="block">Returns a string representing this unit.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/Tick.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/Tick.html" title="class in org.jfree.chart.axis">Tick</a></dt> <dd> <div class="block">Returns a string representation of the tick.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/TickType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/TickType.html" title="class in org.jfree.chart.axis">TickType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/LengthConstraintType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/LengthConstraintType.html" title="class in org.jfree.chart.block">LengthConstraintType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toString()">toString()</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a string representation of this instance, mostly used for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/AxisEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/AxisEntity.html" title="class in org.jfree.chart.entity">AxisEntity</a></dt> <dd> <div class="block">Returns a string representation of the chart entity, useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/CategoryItemEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/CategoryItemEntity.html" title="class in org.jfree.chart.entity">CategoryItemEntity</a></dt> <dd> <div class="block">Returns a string representing this object (useful for debugging purposes).</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/CategoryLabelEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/CategoryLabelEntity.html" title="class in org.jfree.chart.entity">CategoryLabelEntity</a></dt> <dd> <div class="block">Returns a string representation of this entity.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/ChartEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/ChartEntity.html" title="class in org.jfree.chart.entity">ChartEntity</a></dt> <dd> <div class="block">Returns a string representation of the chart entity, useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/JFreeChartEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/JFreeChartEntity.html" title="class in org.jfree.chart.entity">JFreeChartEntity</a></dt> <dd> <div class="block">Returns a string representation of the chart entity, useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/LegendItemEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/LegendItemEntity.html" title="class in org.jfree.chart.entity">LegendItemEntity</a></dt> <dd> <div class="block">Returns a string representing this object (useful for debugging purposes).</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/PieSectionEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/PieSectionEntity.html" title="class in org.jfree.chart.entity">PieSectionEntity</a></dt> <dd> <div class="block">Returns a string representing the entity.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/PlotEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/PlotEntity.html" title="class in org.jfree.chart.entity">PlotEntity</a></dt> <dd> <div class="block">Returns a string representation of the plot entity, useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/TitleEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/TitleEntity.html" title="class in org.jfree.chart.entity">TitleEntity</a></dt> <dd> <div class="block">Returns a string representation of the chart entity, useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/entity/XYItemEntity.html#toString()">toString()</a></span> - Method in class org.jfree.chart.entity.<a href="../org/jfree/chart/entity/XYItemEntity.html" title="class in org.jfree.chart.entity">XYItemEntity</a></dt> <dd> <div class="block">Returns a string representation of this instance, useful for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/event/ChartChangeEventType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.event.<a href="../org/jfree/chart/event/ChartChangeEventType.html" title="class in org.jfree.chart.event">ChartChangeEventType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/labels/ItemLabelAnchor.html#toString()">toString()</a></span> - Method in class org.jfree.chart.labels.<a href="../org/jfree/chart/labels/ItemLabelAnchor.html" title="class in org.jfree.chart.labels">ItemLabelAnchor</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/LegendRenderingOrder.html#toString()">toString()</a></span> - Method in class org.jfree.chart.<a href="../org/jfree/chart/LegendRenderingOrder.html" title="class in org.jfree.chart">LegendRenderingOrder</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/DatasetRenderingOrder.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/DatasetRenderingOrder.html" title="class in org.jfree.chart.plot">DatasetRenderingOrder</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/DialShape.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/DialShape.html" title="class in org.jfree.chart.plot">DialShape</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PieLabelDistributor.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PieLabelDistributor.html" title="class in org.jfree.chart.plot">PieLabelDistributor</a></dt> <dd> <div class="block">Returns a string containing a description of the object for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PieLabelLinkStyle.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PieLabelLinkStyle.html" title="class in org.jfree.chart.plot">PieLabelLinkStyle</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PieLabelRecord.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PieLabelRecord.html" title="class in org.jfree.chart.plot">PieLabelRecord</a></dt> <dd> <div class="block">Returns a string describing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PlotOrientation.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PlotOrientation.html" title="class in org.jfree.chart.plot">PlotOrientation</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PolarAxisLocation.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PolarAxisLocation.html" title="class in org.jfree.chart.plot">PolarAxisLocation</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/SeriesRenderingOrder.html#toString()">toString()</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/SeriesRenderingOrder.html" title="class in org.jfree.chart.plot">SeriesRenderingOrder</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/renderer/AreaRendererEndType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.renderer.<a href="../org/jfree/chart/renderer/AreaRendererEndType.html" title="class in org.jfree.chart.renderer">AreaRendererEndType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/renderer/Outlier.html#toString()">toString()</a></span> - Method in class org.jfree.chart.renderer.<a href="../org/jfree/chart/renderer/Outlier.html" title="class in org.jfree.chart.renderer">Outlier</a></dt> <dd> <div class="block">Returns a textual representation of the outlier.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/util/XYCoordinateType.html#toString()">toString()</a></span> - Method in class org.jfree.chart.util.<a href="../org/jfree/chart/util/XYCoordinateType.html" title="class in org.jfree.chart.util">XYCoordinateType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/DefaultKeyedValue.html#toString()">toString()</a></span> - Method in class org.jfree.data.<a href="../org/jfree/data/DefaultKeyedValue.html" title="class in org.jfree.data">DefaultKeyedValue</a></dt> <dd> <div class="block">Returns a string representing this instance, primarily useful for debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/DomainOrder.html#toString()">toString()</a></span> - Method in class org.jfree.data.<a href="../org/jfree/data/DomainOrder.html" title="class in org.jfree.data">DomainOrder</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/KeyedValueComparatorType.html#toString()">toString()</a></span> - Method in class org.jfree.data.<a href="../org/jfree/data/KeyedValueComparatorType.html" title="class in org.jfree.data">KeyedValueComparatorType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/Range.html#toString()">toString()</a></span> - Method in class org.jfree.data.<a href="../org/jfree/data/Range.html" title="class in org.jfree.data">Range</a></dt> <dd> <div class="block">Returns a string representation of this Range.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/RangeType.html#toString()">toString()</a></span> - Method in class org.jfree.data.<a href="../org/jfree/data/RangeType.html" title="class in org.jfree.data">RangeType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/statistics/BoxAndWhiskerItem.html#toString()">toString()</a></span> - Method in class org.jfree.data.statistics.<a href="../org/jfree/data/statistics/BoxAndWhiskerItem.html" title="class in org.jfree.data.statistics">BoxAndWhiskerItem</a></dt> <dd> <div class="block">Returns a string representation of this instance, primarily for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/statistics/HistogramType.html#toString()">toString()</a></span> - Method in class org.jfree.data.statistics.<a href="../org/jfree/data/statistics/HistogramType.html" title="class in org.jfree.data.statistics">HistogramType</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/statistics/MeanAndStandardDeviation.html#toString()">toString()</a></span> - Method in class org.jfree.data.statistics.<a href="../org/jfree/data/statistics/MeanAndStandardDeviation.html" title="class in org.jfree.data.statistics">MeanAndStandardDeviation</a></dt> <dd> <div class="block">Returns a string representing this instance.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/DateRange.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/DateRange.html" title="class in org.jfree.data.time">DateRange</a></dt> <dd> <div class="block">Returns a string representing the date range (useful for debugging).</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Day.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Day.html" title="class in org.jfree.data.time">Day</a></dt> <dd> <div class="block">Returns a string representing the day.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Hour.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Hour.html" title="class in org.jfree.data.time">Hour</a></dt> <dd> <div class="block">Returns a string representation of this instance, for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Month.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Month.html" title="class in org.jfree.data.time">Month</a></dt> <dd> <div class="block">Returns a string representing the month (e.g.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Quarter.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Quarter.html" title="class in org.jfree.data.time">Quarter</a></dt> <dd> <div class="block">Returns a string representing the quarter (e.g.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/RegularTimePeriod.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/RegularTimePeriod.html" title="class in org.jfree.data.time">RegularTimePeriod</a></dt> <dd> <div class="block">Returns a string representation of the time period.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodAnchor.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodAnchor.html" title="class in org.jfree.data.time">TimePeriodAnchor</a></dt> <dd> <div class="block">Returns a string representing the object.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/TimePeriodValue.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/TimePeriodValue.html" title="class in org.jfree.data.time">TimePeriodValue</a></dt> <dd> <div class="block">Returns a string representing this instance, primarily for use in debugging.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Week.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Week.html" title="class in org.jfree.data.time">Week</a></dt> <dd> <div class="block">Returns a string representing the week (e.g.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/Year.html#toString()">toString()</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/Year.html" title="class in org.jfree.data.time">Year</a></dt> <dd> <div class="block">Returns a string representing the year..</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/xy/XYCoordinate.html#toString()">toString()</a></span> - Method in class org.jfree.data.xy.<a href="../org/jfree/data/xy/XYCoordinate.html" title="class in org.jfree.data.xy">XYCoordinate</a></dt> <dd> <div class="block">Returns a string representation of this instance, primarily for debugging purposes.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/xy/XYDataItem.html#toString()">toString()</a></span> - Method in class org.jfree.data.xy.<a href="../org/jfree/data/xy/XYDataItem.html" title="class in org.jfree.data.xy">XYDataItem</a></dt> <dd> <div class="block">Returns a string representing this instance, primarily for debugging use.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/SegmentedTimeline.html#toTimelineValue(long)">toTimelineValue(long)</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/SegmentedTimeline.html" title="class in org.jfree.chart.axis">SegmentedTimeline</a></dt> <dd> <div class="block">Translates a value relative to the domain value (all Dates) into a value relative to the segmented timeline.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/SegmentedTimeline.html#toTimelineValue(java.util.Date)">toTimelineValue(Date)</a></span> - Method in class org.jfree.chart.axis.<a href="../org/jfree/chart/axis/SegmentedTimeline.html" title="class in org.jfree.chart.axis">SegmentedTimeline</a></dt> <dd> <div class="block">Translates a date into a value relative to the segmented timeline.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/Timeline.html#toTimelineValue(long)">toTimelineValue(long)</a></span> - Method in interface org.jfree.chart.axis.<a href="../org/jfree/chart/axis/Timeline.html" title="interface in org.jfree.chart.axis">Timeline</a></dt> <dd> <div class="block">Translates a millisecond (as defined by java.util.Date) into an index along this timeline.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/axis/Timeline.html#toTimelineValue(java.util.Date)">toTimelineValue(Date)</a></span> - Method in interface org.jfree.chart.axis.<a href="../org/jfree/chart/axis/Timeline.html" title="interface in org.jfree.chart.axis">Timeline</a></dt> <dd> <div class="block">Translates a date into a value on this timeline.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toUnconstrainedHeight()">toUnconstrainedHeight()</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the width attributes, but has no height constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/RectangleConstraint.html#toUnconstrainedWidth()">toUnconstrainedWidth()</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/RectangleConstraint.html" title="class in org.jfree.chart.block">RectangleConstraint</a></dt> <dd> <div class="block">Returns a constraint that matches this one on the height attributes, but has no width constraint.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/needle/MeterNeedle.html#transform">transform</a></span> - Static variable in class org.jfree.chart.needle.<a href="../org/jfree/chart/needle/MeterNeedle.html" title="class in org.jfree.chart.needle">MeterNeedle</a></dt> <dd> <div class="block">A transform.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/util/DirectionalGradientPaintTransformer.html#transform(java.awt.GradientPaint, java.awt.Shape)">transform(GradientPaint, Shape)</a></span> - Method in class org.jfree.chart.util.<a href="../org/jfree/chart/util/DirectionalGradientPaintTransformer.html" title="class in org.jfree.chart.util">DirectionalGradientPaintTransformer</a></dt> <dd> <div class="block">Transforms a <code>GradientPaint</code> instance to fit some target shape.</div> </dd> <dt><span class="strong"><a href="../org/jfree/data/time/DynamicTimeSeriesCollection.html#translateGet(int)">translateGet(int)</a></span> - Method in class org.jfree.data.time.<a href="../org/jfree/data/time/DynamicTimeSeriesCollection.html" title="class in org.jfree.data.time">DynamicTimeSeriesCollection</a></dt> <dd> <div class="block">Re-map an index, for use in retrieving data.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/ChartPanel.html#translateJava2DToScreen(java.awt.geom.Point2D)">translateJava2DToScreen(Point2D)</a></span> - Method in class org.jfree.chart.<a href="../org/jfree/chart/ChartPanel.html" title="class in org.jfree.chart">ChartPanel</a></dt> <dd> <div class="block">Translates a Java2D point on the chart to a screen location.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/ChartPanel.html#translateScreenToJava2D(java.awt.Point)">translateScreenToJava2D(Point)</a></span> - Method in class org.jfree.chart.<a href="../org/jfree/chart/ChartPanel.html" title="class in org.jfree.chart">ChartPanel</a></dt> <dd> <div class="block">Translates a panel (component) location to a Java2D point.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PolarPlot.html#translateToJava2D(double, double, org.jfree.chart.axis.ValueAxis, java.awt.geom.Rectangle2D)">translateToJava2D(double, double, ValueAxis, Rectangle2D)</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PolarPlot.html" title="class in org.jfree.chart.plot">PolarPlot</a></dt> <dd> <div class="block">Translates a (theta, radius) pair into Java2D coordinates.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/plot/PolarPlot.html#translateValueThetaRadiusToJava2D(double, double, java.awt.geom.Rectangle2D)">translateValueThetaRadiusToJava2D(double, double, Rectangle2D)</a></span> - Method in class org.jfree.chart.plot.<a href="../org/jfree/chart/plot/PolarPlot.html" title="class in org.jfree.chart.plot">PolarPlot</a></dt> <dd> <div class="block"><span class="strong">Deprecated.</span> <div class="block"><i>Since 1.0.14, use <a href="../org/jfree/chart/plot/PolarPlot.html#translateToJava2D(double, double, org.jfree.chart.axis.ValueAxis, java.awt.geom.Rectangle2D)"><code>PolarPlot.translateToJava2D(double, double, org.jfree.chart.axis.ValueAxis, java.awt.geom.Rectangle2D)</code></a> instead.</i></div> </div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#trimBorder(java.awt.geom.Rectangle2D)">trimBorder(Rectangle2D)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Reduces the specified area by the amount of space consumed by the border.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#trimMargin(java.awt.geom.Rectangle2D)">trimMargin(Rectangle2D)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Reduces the specified area by the amount of space consumed by the margin.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#trimPadding(java.awt.geom.Rectangle2D)">trimPadding(Rectangle2D)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Reduces the specified area by the amount of space consumed by the padding.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#trimToContentHeight(double)">trimToContentHeight(double)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Calculate the height available for content after subtracting the margin, border and padding space from the specified fixed height.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/block/AbstractBlock.html#trimToContentWidth(double)">trimToContentWidth(double)</a></span> - Method in class org.jfree.chart.block.<a href="../org/jfree/chart/block/AbstractBlock.html" title="class in org.jfree.chart.block">AbstractBlock</a></dt> <dd> <div class="block">Calculate the width available for content after subtracting the margin, border and padding space from the specified fixed width.</div> </dd> <dt><span class="strong"><a href="../org/jfree/chart/renderer/AreaRendererEndType.html#TRUNCATE">TRUNCATE</a></span> - Static variable in class org.jfree.chart.renderer.<a href="../org/jfree/chart/renderer/AreaRendererEndType.html" title="class in org.jfree.chart.renderer">AreaRendererEndType</a></dt> <dd> <div class="block">The area is truncated at the first or last value.</div> </dd> </dl> <a href="index-1.html">A</a>&nbsp;<a href="index-2.html">B</a>&nbsp;<a href="index-3.html">C</a>&nbsp;<a href="index-4.html">D</a>&nbsp;<a href="index-5.html">E</a>&nbsp;<a href="index-6.html">F</a>&nbsp;<a href="index-7.html">G</a>&nbsp;<a href="index-8.html">H</a>&nbsp;<a href="index-9.html">I</a>&nbsp;<a href="index-10.html">J</a>&nbsp;<a href="index-11.html">K</a>&nbsp;<a href="index-12.html">L</a>&nbsp;<a href="index-13.html">M</a>&nbsp;<a href="index-14.html">N</a>&nbsp;<a href="index-15.html">O</a>&nbsp;<a href="index-16.html">P</a>&nbsp;<a href="index-17.html">Q</a>&nbsp;<a href="index-18.html">R</a>&nbsp;<a href="index-19.html">S</a>&nbsp;<a href="index-20.html">T</a>&nbsp;<a href="index-21.html">U</a>&nbsp;<a href="index-22.html">V</a>&nbsp;<a href="index-23.html">W</a>&nbsp;<a href="index-24.html">X</a>&nbsp;<a href="index-25.html">Y</a>&nbsp;<a href="index-26.html">Z</a>&nbsp;</div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../overview-summary.html">Overview</a></li> <li>Package</li> <li>Class</li> <li>Use</li> <li><a href="../overview-tree.html">Tree</a></li> <li><a href="../deprecated-list.html">Deprecated</a></li> <li class="navBarCell1Rev">Index</li> <li><a href="../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="index-19.html">PREV LETTER</a></li> <li><a href="index-21.html">NEXT LETTER</a></li> </ul> <ul class="navList"> <li><a href="../index.html?index-filesindex-20.html" target="_top">FRAMES</a></li> <li><a href="index-20.html" target="_top">NO FRAMES</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
unlicense
lanchun/myrobotlab
src/org/myrobotlab/logging/LoggerFactory.java
771
package org.myrobotlab.logging; import org.myrobotlab.framework.Platform; import org.slf4j.Logger; public class LoggerFactory { public static Logger getLogger(Class<?> clazz) { return getLogger(clazz.toString()); } public static Logger getLogger(String name) { Platform platform = Platform.getLocalInstance(); if (platform.isDalvik()) { String android = name.substring(name.lastIndexOf(".") + 1); if (android.length() > 23) android = android.substring(0, 23); // http://slf4j.42922.n3.nabble.com/ // Bug-173-New-slf4j-android-Android-throws-an-IllegalArgumentException-when-Log-Tag-length-exceeds-23-s-td443886.html return org.slf4j.LoggerFactory.getLogger(android); } else { return org.slf4j.LoggerFactory.getLogger(name); } } }
apache-2.0
Azure/azure-linux-extensions
VMBackup/main/workloadPatch/DefaultScripts/preOracleMaster.sql
6652
REM ================================================================================ REM File: preOracleMaster.sql REM Date: 16-Sep 2020 REM Type: Oracle SQL*Plus script REM Author: Microsoft CAE team REM REM Description: REM Oracle SQL*Plus script called as an Azure Backup "pre" script, to REM be run immediately prior to a backup snapshot. REM REM SQL*Plus is executed in RESTRICTED LEVEL 2 mode, which means that REM commands like HOST and SPOOL are not permitted, but commands like REM START are permitted. REM ================================================================================ REM REM ******************************************************************************** REM Format standard output to be terse... REM ******************************************************************************** SET ECHO OFF FEEDBACK OFF TIMING OFF PAGESIZE 0 LINESIZE 130 TRIMOUT ON TRIMSPOOL ON REM REM ******************************************************************************** REM Uncomment the following SET command to make commands, status feedback, and REM timings visible for debugging... REM ******************************************************************************** REM SET ECHO ON FEEDBACK ON TIMING ON REM REM ******************************************************************************** REM Connect this SQL*Plus session to the current database instance as SYSBACKUP... REM (be sure to leave one blank line before the CONNECT command) REM ******************************************************************************** CONNECT / AS SYSBACKUP REM REM ******************************************************************************** REM Retrieve the status of the Oracle database instance, and exit from SQL*Plus REM with SUCCESS exit status if database instance is not OPEN... REM ******************************************************************************** WHENEVER OSERROR EXIT SUCCESS WHENEVER SQLERROR EXIT SUCCESS COL STATUS NEW_VALUE V_STATUS SELECT 'STATUS='||STATUS AS STATUS FROM V$INSTANCE; EXEC IF '&&V_STATUS' <> 'STATUS=OPEN' THEN RAISE NOT_LOGGED_ON; END IF; REM REM ******************************************************************************** REM Next, if SQL*Plus hasn't exited as a result of the last command, now ensure that REM the failure of any command results in a FAILURE exit status from SQL*Plus... REM ******************************************************************************** WHENEVER OSERROR EXIT FAILURE WHENEVER SQLERROR EXIT FAILURE REM REM ******************************************************************************** REM Display the LOG_MODE of the database to be captured by the calling Python code... REM ******************************************************************************** SELECT 'LOG_MODE='||LOG_MODE AS LOG_MODE FROM V$DATABASE; REM REM ******************************************************************************** REM Enable emitting DBMS_OUTPUT to standard output... REM ******************************************************************************** SET SERVEROUTPUT ON SIZE 1000000 REM REM ******************************************************************************** REM Force a switch of the online redo logfiles, which will force a full checkpoint, REM and then archive the current logfile... REM ******************************************************************************** DECLARE -- v_errcontext varchar2(128); noArchiveLogMode exception; pragma exception_init(noArchiveLogMode, -258); -- BEGIN -- v_errcontext := 'azmessage-1'; sysbackup.azmessage('INFO - AzBackup pre-script: starting ARCHIVE LOG CURRENT...'); -- v_errcontext := 'ARCHIVE LOG CURRENT'; execute immediate 'ALTER SYSTEM ARCHIVE LOG CURRENT'; -- v_errcontext := 'azmessage-2'; sysbackup.azmessage('INFO - AzBackup pre-script: ARCHIVE LOG CURRENT succeeded'); -- EXCEPTION -- when noArchiveLogMode then begin -- v_errcontext := 'azmessage-3'; sysbackup.azmessage('INFO - AzBackup pre-script: starting SWITCH LOGFILE...'); -- v_errcontext := 'SWITCH LOGFILE'; execute immediate 'ALTER SYSTEM SWITCH LOGFILE'; -- v_errcontext := 'azmessage-4'; sysbackup.azmessage('INFO - AzBackup pre-script: SWITCH LOGFILE succeeded'); -- exception when others then sysbackup.azmessage('FAIL - AzBackup pre-script: ' || v_errcontext || ' failed'); raise; end; -- when others then sysbackup.azmessage('FAIL - AzBackup pre-script: ' || v_errcontext || ' failed'); raise; -- END; / REM REM ******************************************************************************** REM Attempt to put the database into BACKUP mode, which will succeed only if the REM database is presently in ARCHIVELOG mode REM ******************************************************************************** DECLARE -- v_errcontext varchar2(128); noArchiveLogMode exception; pragma exception_init(noArchiveLogMode, -1123); -- BEGIN -- v_errcontext := 'azmessage-5'; sysbackup.azmessage('INFO - AzBackup pre-script: BEGIN BACKUP starting...'); -- v_errcontext := 'BEGIN BACKUP'; execute immediate 'ALTER DATABASE BEGIN BACKUP'; -- v_errcontext := 'azmessage-6'; sysbackup.azmessage('INFO - AzBackup pre-script: BEGIN BACKUP succeeded'); -- EXCEPTION -- when noArchiveLogMode then -- sysbackup.azmessage('INFO - AzBackup pre-script: BEGIN BACKUP in NOARCHIVELOG failed - no action needed...'); -- when others then sysbackup.azmessage('FAIL - AzBackup pre-script: ' || v_errcontext || ' failed'); raise; -- END; / REM REM ******************************************************************************** REM Exit from Oracle SQL*Plus with SUCCESS exit status... REM ******************************************************************************** EXIT SUCCESS
apache-2.0
diogo149/treeano
examples/simple_rnn_comparison/with_treeano.py
2330
from __future__ import division, absolute_import from __future__ import print_function, unicode_literals import numpy as np import theano import theano.tensor as T import treeano import treeano.nodes as tn fX = theano.config.floatX # ################################## config ################################## N_TRAIN = 5000 LAG = 20 LENGTH = 50 HIDDEN_STATE_SIZE = 10 # ############################### prepare data ############################### def binary_toy_data(lag=1, length=20): inputs = np.random.randint(0, 2, length).astype(fX) outputs = np.array(lag * [0] + list(inputs), dtype=fX)[:length] return inputs, outputs # ############################## prepare model ############################## model = tn.HyperparameterNode( "model", tn.SequentialNode( "seq", [tn.InputNode("x", shape=(None, 1)), tn.recurrent.SimpleRecurrentNode( "srn", tn.TanhNode("nonlin"), batch_size=None, num_units=HIDDEN_STATE_SIZE), tn.scan.ScanNode( "scan", tn.DenseNode("fc", num_units=1)), tn.SigmoidNode("pred"), ]), inits=[treeano.inits.NormalWeightInit(0.01)], batch_axis=None, scan_axis=0 ) with_updates = tn.HyperparameterNode( "with_updates", tn.SGDNode( "adam", {"subtree": model, "cost": tn.TotalCostNode("cost", { "pred": tn.ReferenceNode("pred_ref", reference="model"), "target": tn.InputNode("y", shape=(None, 1))}, )}), learning_rate=0.1, cost_function=treeano.utils.squared_error, ) network = with_updates.network() train_fn = network.function(["x", "y"], ["cost"], include_updates=True) valid_fn = network.function(["x"], ["model"]) # ################################# training ################################# print("Starting training...") import time st = time.time() for i in range(N_TRAIN): inputs, outputs = binary_toy_data(lag=LAG, length=LENGTH) loss = train_fn(inputs.reshape(-1, 1), outputs.reshape(-1, 1))[0] if (i % (N_TRAIN // 100)) == 0: print(loss) print("total_time: %s" % (time.time() - st)) inputs, outputs = binary_toy_data(lag=LAG, length=LENGTH) pred = valid_fn(inputs.reshape(-1, 1))[0].flatten() print(np.round(pred) == outputs)
apache-2.0
zhaobj/MyHadoop
docs/api/org/apache/hadoop/examples/dancing/class-use/DistributedPentomino.html
6215
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_26) on Tue Feb 14 08:16:38 UTC 2012 --> <TITLE> Uses of Class org.apache.hadoop.examples.dancing.DistributedPentomino (Hadoop 1.0.1 API) </TITLE> <META NAME="date" CONTENT="2012-02-14"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.apache.hadoop.examples.dancing.DistributedPentomino (Hadoop 1.0.1 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../org/apache/hadoop/examples/dancing/DistributedPentomino.html" title="class in org.apache.hadoop.examples.dancing"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?org/apache/hadoop/examples/dancing//class-useDistributedPentomino.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="DistributedPentomino.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Class<br>org.apache.hadoop.examples.dancing.DistributedPentomino</B></H2> </CENTER> No usage of org.apache.hadoop.examples.dancing.DistributedPentomino <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../org/apache/hadoop/examples/dancing/DistributedPentomino.html" title="class in org.apache.hadoop.examples.dancing"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?org/apache/hadoop/examples/dancing//class-useDistributedPentomino.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="DistributedPentomino.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> Copyright &copy; 2009 The Apache Software Foundation </BODY> </HTML>
apache-2.0
nsivabalan/ambry
ambry-api/src/main/java/com.github.ambry/store/StoreKeyFactory.java
929
/** * Copyright 2016 LinkedIn Corp. 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. */ package com.github.ambry.store; import java.io.DataInputStream; import java.io.IOException; /** * Factory to create an index key */ public interface StoreKeyFactory { /** * The store key created using the stream provided * @param stream The stream used to create the store key * @return The store key created from the stream */ StoreKey getStoreKey(DataInputStream stream) throws IOException; }
apache-2.0
JoyIfBam5/aws-sdk-cpp
aws-cpp-sdk-route53/source/model/ListTrafficPoliciesRequest.cpp
1614
/* * Copyright 2010-2017 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. */ #include <aws/route53/model/ListTrafficPoliciesRequest.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <aws/core/http/URI.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <utility> using namespace Aws::Route53::Model; using namespace Aws::Utils::Xml; using namespace Aws::Utils; using namespace Aws::Http; ListTrafficPoliciesRequest::ListTrafficPoliciesRequest() : m_trafficPolicyIdMarkerHasBeenSet(false), m_maxItemsHasBeenSet(false) { } Aws::String ListTrafficPoliciesRequest::SerializePayload() const { return ""; } void ListTrafficPoliciesRequest::AddQueryStringParameters(URI& uri) const { Aws::StringStream ss; if(m_trafficPolicyIdMarkerHasBeenSet) { ss << m_trafficPolicyIdMarker; uri.AddQueryStringParameter("trafficpolicyid", ss.str()); ss.str(""); } if(m_maxItemsHasBeenSet) { ss << m_maxItems; uri.AddQueryStringParameter("maxitems", ss.str()); ss.str(""); } }
apache-2.0
gluke77/kubernetes
pkg/kubectl/cmd/autoscale.go
6991
/* Copyright 2015 The Kubernetes 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 cmd import ( "fmt" "io" "github.com/renstrom/dedent" "k8s.io/kubernetes/pkg/kubectl" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/resource" utilerrors "k8s.io/kubernetes/pkg/util/errors" "github.com/spf13/cobra" ) var ( autoscaleLong = dedent.Dedent(` Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster. Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference. An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.`) autoscaleExample = dedent.Dedent(` # Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used: kubectl autoscale deployment foo --min=2 --max=10 # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%: kubectl autoscale rc foo --max=5 --cpu-percent=80`) ) func NewCmdAutoscale(f cmdutil.Factory, out io.Writer) *cobra.Command { options := &resource.FilenameOptions{} validArgs := []string{"deployment", "replicaset", "replicationcontroller"} argAliases := kubectl.ResourceAliases(validArgs) cmd := &cobra.Command{ Use: "autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]", Short: "Auto-scale a Deployment, ReplicaSet, or ReplicationController", Long: autoscaleLong, Example: autoscaleExample, Run: func(cmd *cobra.Command, args []string) { err := RunAutoscale(f, out, cmd, args, options) cmdutil.CheckErr(err) }, ValidArgs: validArgs, ArgAliases: argAliases, } cmdutil.AddPrinterFlags(cmd) cmd.Flags().String("generator", "horizontalpodautoscaler/v1", "The name of the API generator to use. Currently there is only 1 generator.") cmd.Flags().Int("min", -1, "The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value.") cmd.Flags().Int("max", -1, "The upper limit for the number of pods that can be set by the autoscaler. Required.") cmd.MarkFlagRequired("max") cmd.Flags().Int("cpu-percent", -1, fmt.Sprintf("The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used.")) cmd.Flags().String("name", "", "The name for the newly created object. If not specified, the name of the input resource will be used.") cmdutil.AddDryRunFlag(cmd) usage := "identifying the resource to autoscale." cmdutil.AddFilenameOptionFlags(cmd, options, usage) cmdutil.AddApplyAnnotationFlags(cmd) cmdutil.AddRecordFlag(cmd) cmdutil.AddInclude3rdPartyFlags(cmd) return cmd } func RunAutoscale(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, options *resource.FilenameOptions) error { namespace, enforceNamespace, err := f.DefaultNamespace() if err != nil { return err } // validate flags if err := validateFlags(cmd); err != nil { return err } mapper, typer := f.Object() r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)). ContinueOnError(). NamespaceParam(namespace).DefaultNamespace(). FilenameParam(enforceNamespace, options). ResourceTypeOrNameArgs(false, args...). Flatten(). Do() err = r.Err() if err != nil { return err } // Get the generator, setup and validate all required parameters generatorName := cmdutil.GetFlagString(cmd, "generator") generators := f.Generators("autoscale") generator, found := generators[generatorName] if !found { return cmdutil.UsageError(cmd, fmt.Sprintf("generator %q not found.", generatorName)) } names := generator.ParamNames() count := 0 err = r.Visit(func(info *resource.Info, err error) error { if err != nil { return err } mapping := info.ResourceMapping() if err := f.CanBeAutoscaled(mapping.GroupVersionKind.GroupKind()); err != nil { return err } name := info.Name params := kubectl.MakeParams(cmd, names) params["default-name"] = name params["scaleRef-kind"] = mapping.GroupVersionKind.Kind params["scaleRef-name"] = name params["scaleRef-apiVersion"] = mapping.GroupVersionKind.GroupVersion().String() if err = kubectl.ValidateParams(names, params); err != nil { return err } // Check for invalid flags used against the present generator. if err := kubectl.EnsureFlagsValid(cmd, generators, generatorName); err != nil { return err } // Generate new object object, err := generator.Generate(params) if err != nil { return err } resourceMapper := &resource.Mapper{ ObjectTyper: typer, RESTMapper: mapper, ClientMapper: resource.ClientMapperFunc(f.ClientForMapping), Decoder: f.Decoder(true), } hpa, err := resourceMapper.InfoForObject(object, nil) if err != nil { return err } if cmdutil.ShouldRecord(cmd, hpa) { if err := cmdutil.RecordChangeCause(hpa.Object, f.Command()); err != nil { return err } object = hpa.Object } if cmdutil.GetDryRunFlag(cmd) { return f.PrintObject(cmd, mapper, object, out) } if err := kubectl.CreateOrUpdateAnnotation(cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag), hpa, f.JSONEncoder()); err != nil { return err } object, err = resource.NewHelper(hpa.Client, hpa.Mapping).Create(namespace, false, object) if err != nil { return err } count++ if len(cmdutil.GetFlagString(cmd, "output")) > 0 { return f.PrintObject(cmd, mapper, object, out) } cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, cmdutil.GetDryRunFlag(cmd), "autoscaled") return nil }) if err != nil { return err } if count == 0 { return fmt.Errorf("no objects passed to autoscale") } return nil } func validateFlags(cmd *cobra.Command) error { errs := []error{} max, min := cmdutil.GetFlagInt(cmd, "max"), cmdutil.GetFlagInt(cmd, "min") if max < 1 { errs = append(errs, fmt.Errorf("--max=MAXPODS is required and must be at least 1, max: %d", max)) } if max < min { errs = append(errs, fmt.Errorf("--max=MAXPODS must be larger or equal to --min=MINPODS, max: %d, min: %d", max, min)) } return utilerrors.NewAggregate(errs) }
apache-2.0
mnubo/kubernetes-py
kubernetes_py/K8sReplicaSet.py
2940
#!/usr/bin/env python # -*- coding: utf-8 -*- # # This file is subject to the terms and conditions defined in # file 'LICENSE.md', which is part of this source code package. # from kubernetes_py.K8sExceptions import NotFoundException from kubernetes_py.K8sObject import K8sObject from kubernetes_py.K8sPod import K8sPod from kubernetes_py.models.v1beta1.ReplicaSet import ReplicaSet class K8sReplicaSet(K8sObject): """ http://kubernetes.io/docs/api-reference/extensions/v1beta1/definitions/#_v1beta1_replicaset """ REVISION_ANNOTATION = "deployment.kubernetes.io/revision" REVISION_HISTORY_ANNOTATION = "deployment.kubernetes.io/revision-history" def __init__(self, config=None, name=None): super(K8sReplicaSet, self).__init__(config=config, obj_type="ReplicaSet", name=name) # ------------------------------------------------------------------------------------- override def get(self): self.model = ReplicaSet(self.get_model()) return self def list(self, pattern=None, reverse=True, labels=None): ls = super(K8sReplicaSet, self).list(labels=labels) rsets = list(map(lambda x: ReplicaSet(x), ls)) if pattern is not None: rsets = list(filter(lambda x: pattern in x.name, rsets)) k8s = [] for x in rsets: j = K8sReplicaSet(config=self.config, name=x.name).from_model(m=x) k8s.append(j) k8s.sort(key=lambda x: x.creation_timestamp, reverse=reverse) return k8s def delete(self, cascade=False): super(K8sReplicaSet, self).delete(cascade) if cascade: pods = K8sPod(config=self.config, name="yo").list(pattern=self.name) for pod in pods: try: pod.delete(cascade) except NotFoundException: pass return self # ------------------------------------------------------------------------------------- revision @property def revision(self): if self.REVISION_ANNOTATION in self.model.metadata.annotations: return self.model.metadata.annotations[self.REVISION_ANNOTATION] return None @revision.setter def revision(self, r=None): raise NotImplementedError("K8sReplicaSet: revision is read-only.") # ------------------------------------------------------------------------------------- revision history @property def revision_history(self): if self.REVISION_HISTORY_ANNOTATION in self.model.metadata.annotations: comma_string = self.model.metadata.annotations[self.REVISION_HISTORY_ANNOTATION] version_array = comma_string.split(",") return map(lambda x: int(x), version_array) return None @revision_history.setter def revision_history(self, r=None): raise NotImplementedError("K8sReplicaSet: revision_history is read-only.")
apache-2.0
asiainfoLDP/datafactory
assets/app/views/directives/logs/_log-viewer.html
3387
<div class="log-header" ng-if="!chromeless"> <div ng-transclude class="log-status"><!-- expect start time, end time, status details --></div> <div class="log-actions"> <span ng-if="kibanaAuthUrl"> <form action="{{kibanaAuthUrl}}" method="POST"> <input type="hidden" name="redirect" value="{{kibanaArchiveUrl}}"> <input type="hidden" name="access_token" value="{{access_token}}"> <button class="btn btn-link">View archive</button> </form> <span ng-if="state !== 'empty'" class="action-divider">|</span> </span> <a ng-if="state !== 'empty'" href="" ng-click="goChromeless(options)" role="button"> Expand <i class="fa fa-external-link"></i> </a> </div> </div> <div ng-if="largeLog" class="alert alert-info log-size-warning"> <span class="pficon pficon-info" aria-hidden="true"></span> Only the previous {{options.tailLines || 1000}} log lines and new log messages will be displayed because of the large log size. </div> <!-- show this spinner until the log viewer starts. important for pending state, etc --> <div class="text-center gutter-top" ng-if="(!state)"> <ellipsis-loader></ellipsis-loader> </div> <div class="empty-state-message text-center" ng-if="state=='empty'"> <h2>Logs are not available.</h2> <p> {{emptyStateMessage}} </p> <div ng-if="kibanaAuthUrl"> <form action="{{kibanaAuthUrl}}" method="POST"> <input type="hidden" name="redirect" value="{{archiveLocation}}"> <input type="hidden" name="access_token" value="{{access_token}}"> <button class="btn btn-primary btn-lg"> View Archive </button> </form> </div> </div> <!-- must be ng-show rather than ng-if, else DOM is not rendered in time to cache nodes --> <div ng-show="state=='logs'"> <a name="logTop" id="logTop"></a> <div class="log-view"> <div ng-show="showScrollLinks" id="affixedFollow" class="log-scroll log-scroll-top"> <a ng-if="loading" href="" ng-click="toggleAutoScroll()"> <span ng-if="!autoScrollActive">Follow</span> <span ng-if="autoScrollActive">Stop following</span> </a> <a ng-if="!loading" href="" ng-click="onScrollBottom()"> Go to end </a> </div> <div class="log-view-output"> <table> <tbody id="logContent"></tbody> </table> <!-- show this spinner indicating logs are still streaming --> <ellipsis-loader ng-show="loading"></ellipsis-loader> <div ng-if="(!loading) && (!limitReached) && (!errorWhileRunning) && state=='logs'" class="log-end-msg"> End of log </div> </div> <div ng-show="showScrollLinks" class="log-scroll log-scroll-bottom"> <a href="" ng-click="onScrollTop()">Go to top</a> </div> </div> <a id="logBottom" name="logBottom"></a> </div> <!-- Show a different messsage if the log might have stopped because we reached the byte limit --> <div ng-if="limitReached" class="text-muted"> The maximum web console log size has been reached. Use the command-line interface or <a href="" ng-click="restartLogs()">reload</a> the log to see new messages. </div> <div ng-if="errorWhileRunning" class="text-muted"> An error occurred loading the log. <a href="" ng-click="restartLogs()">Reload</a> </div>
apache-2.0
kjniemi/activemq-artemis
artemis-commons/src/test/java/org/apache/activemq/artemis/utils/network/NetUtil.java
6434
/* * 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.activemq.artemis.utils.network; import java.io.PrintWriter; import java.io.StringWriter; import java.net.InetAddress; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.core.server.NetworkHealthCheck; import org.apache.activemq.artemis.utils.ExecuteUtil; import org.junit.Assert; import org.junit.Assume; import org.junit.Test; /** * This utility class will use sudo commands to start "fake" network cards on a given address. * It's used on tests that need to emmulate network outages and split brains. * * If you write a new test using this class, please make special care on undoing the config, * especially in case of failures. * * Usually the class {@link NetUtilResource} is pretty accurate on undoing this, but you also need to *test your test* well. * * You need special sudo authorizations on your system to let this class work: * * Add the following at the end of your /etc/sudoers (use the sudo visudo command)"); * # ------------------------------------------------------- "); * yourUserName ALL = NOPASSWD: /sbin/ifconfig"); * # ------------------------------------------------------- "); * */ public class NetUtil extends ExecuteUtil { public static boolean checkIP(String ip) throws Exception { InetAddress ipAddress = null; try { ipAddress = InetAddress.getByName(ip); } catch (Exception e) { e.printStackTrace(); // not supposed to happen return false; } NetworkHealthCheck healthCheck = new NetworkHealthCheck(null, 100, 100); return healthCheck.check(ipAddress); } public static AtomicInteger nextDevice = new AtomicInteger(0); // IP / device (device being only valid on linux) public static Map<String, String> networks = new ConcurrentHashMap<>(); private enum OS { MAC, LINUX, NON_SUPORTED; } static final OS osUsed; static final String user = System.getProperty("user.name"); static { OS osTmp; String propOS = System.getProperty("os.name").toUpperCase(); if (propOS.contains("MAC")) { osTmp = OS.MAC; } else if (propOS.contains("LINUX")) { osTmp = OS.LINUX; } else { osTmp = OS.NON_SUPORTED; } osUsed = osTmp; } public static void failIfNotSudo() { Assume.assumeTrue("non supported OS", osUsed != OS.NON_SUPORTED); if (!canSudo()) { StringWriter writer = new StringWriter(); PrintWriter out = new PrintWriter(writer); out.println("Add the following at the end of your /etc/sudoers (use the visudo command)"); out.println("# ------------------------------------------------------- "); out.println(user + " ALL = NOPASSWD: /sbin/ifconfig"); out.println("# ------------------------------------------------------- "); Assert.fail(writer.toString()); } } public static void cleanup() { nextDevice.set(0); Set entrySet = networks.entrySet(); Iterator iter = entrySet.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = (Map.Entry<String, String>) iter.next(); try { netDown(entry.getKey(), entry.getValue(), true); } catch (Exception e) { e.printStackTrace(); } } } public static void netUp(String ip) throws Exception { String deviceID = "lo:" + nextDevice.incrementAndGet(); netUp(ip, deviceID); } public static void netUp(String ip, String deviceID) throws Exception { if (osUsed == OS.MAC) { if (runCommand(false, "sudo", "-n", "ifconfig", "lo0", "alias", ip) != 0) { Assert.fail("Cannot sudo ifconfig for ip " + ip); } networks.put(ip, "lo0"); } else if (osUsed == OS.LINUX) { if (runCommand(false, "sudo", "-n", "ifconfig", deviceID, ip, "netmask", "255.0.0.0") != 0) { Assert.fail("Cannot sudo ifconfig for ip " + ip); } networks.put(ip, deviceID); } else { Assert.fail("OS not supported"); } } public static void netDown(String ip) throws Exception { netDown(ip, false); } public static void netDown(String ip, boolean force) throws Exception { String device = networks.remove(ip); if (!force) { // in case the netDown is coming from a different VM (spawned tests) Assert.assertNotNull("ip " + ip + "wasn't set up before", device); } netDown(ip, device, force); } public static void netDown(String ip, String device, boolean force) throws Exception { networks.remove(ip); if (osUsed == OS.MAC) { if (runCommand(false, "sudo", "-n", "ifconfig", "lo0", "-alias", ip) != 0) { if (!force) { Assert.fail("Cannot sudo ifconfig for ip " + ip); } } } else if (osUsed == OS.LINUX) { if (runCommand(false, "sudo", "-n", "ifconfig", device, "down") != 0) { if (!force) { Assert.fail("Cannot sudo ifconfig for ip " + ip); } } } else { Assert.fail("OS not supported"); } } public static boolean canSudo() { try { return runCommand(false, "sudo", "-n", "ifconfig") == 0; } catch (Exception e) { e.printStackTrace(); return false; } } @Test public void testCanSudo() throws Exception { Assert.assertTrue(canSudo()); } }
apache-2.0
hequn8128/flink
docs/concepts/index.md
4797
--- title: Concepts in Depth nav-id: concepts nav-pos: 3 nav-title: '<i class="fa fa-map-o title appetizer" aria-hidden="true"></i> Concepts in Depth' nav-parent_id: root nav-show_overview: true permalink: /concepts/index.html always-expand: true --- <!-- 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. --> The [Hands-on Training]({% link training/index.md %}) explains the basic concepts of stateful and timely stream processing that underlie Flink's APIs, and provides examples of how these mechanisms are used in applications. Stateful stream processing is introduced in the context of [Data Pipelines & ETL]({% link training/etl.md %}#stateful-transformations) and is further developed in the section on [Fault Tolerance]({% link training/fault_tolerance.md %}). Timely stream processing is introduced in the section on [Streaming Analytics]({% link training/streaming_analytics.md %}). This _Concepts in Depth_ section provides a deeper understanding of how Flink's architecture and runtime implement these concepts. ## Flink's APIs Flink offers different levels of abstraction for developing streaming/batch applications. <img src="{{ site.baseurl }}/fig/levels_of_abstraction.svg" alt="Programming levels of abstraction" class="offset" width="80%" /> - The lowest level abstraction simply offers **stateful and timely stream processing**. It is embedded into the [DataStream API]({% link dev/datastream_api.md %}) via the [Process Function]({% link dev/stream/operators/process_function.md %}). It allows users to freely process events from one or more streams, and provides consistent, fault tolerant *state*. In addition, users can register event time and processing time callbacks, allowing programs to realize sophisticated computations. - In practice, many applications do not need the low-level abstractions described above, and can instead program against the **Core APIs**: the [DataStream API]({% link dev/datastream_api.md %}) (bounded/unbounded streams) and the [DataSet API]({% link dev/batch/index.md %}) (bounded data sets). These fluent APIs offer the common building blocks for data processing, like various forms of user-specified transformations, joins, aggregations, windows, state, etc. Data types processed in these APIs are represented as classes in the respective programming languages. The low level *Process Function* integrates with the *DataStream API*, making it possible to use the lower-level abstraction on an as-needed basis. The *DataSet API* offers additional primitives on bounded data sets, like loops/iterations. - The **Table API** is a declarative DSL centered around *tables*, which may be dynamically changing tables (when representing streams). The [Table API]({% link dev/table/index.md %}) follows the (extended) relational model: Tables have a schema attached (similar to tables in relational databases) and the API offers comparable operations, such as select, project, join, group-by, aggregate, etc. Table API programs declaratively define *what logical operation should be done* rather than specifying exactly *how the code for the operation looks*. Though the Table API is extensible by various types of user-defined functions, it is less expressive than the *Core APIs*, and more concise to use (less code to write). In addition, Table API programs also go through an optimizer that applies optimization rules before execution. One can seamlessly convert between tables and *DataStream*/*DataSet*, allowing programs to mix the *Table API* with the *DataStream* and *DataSet* APIs. - The highest level abstraction offered by Flink is **SQL**. This abstraction is similar to the *Table API* both in semantics and expressiveness, but represents programs as SQL query expressions. The [SQL]({{ site.baseurl }}{% link dev/table/index.md %}#sql) abstraction closely interacts with the Table API, and SQL queries can be executed over tables defined in the *Table API*.
apache-2.0
NixaSoftware/CVis
venv/bin/doc/html/boost/date_time/parse_delimite_idp52042600.html
4896
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Function template parse_delimited_time_duration</title> <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="../../date_time/doxy.html#header.boost.date_time.time_parsing_hpp" title="Header &lt;boost/date_time/time_parsing.hpp&gt;"> <link rel="prev" href="str_from_delim_idp21488264.html" title="Function template str_from_delimited_time_duration"> <link rel="next" href="time_resolutio_idp22503048.html" title="Struct time_resolution_traits_bi32_impl"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> <td align="center"><a href="../../../../index.html">Home</a></td> <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="str_from_delim_idp21488264.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.time_parsing_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="time_resolutio_idp22503048.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="refentry"> <a name="boost.date_time.parse_delimite_idp52042600"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Function template parse_delimited_time_duration</span></h2> <p>boost::date_time::parse_delimited_time_duration &#8212; Creates a <a class="link" href="time_duration.html" title="Class template time_duration">time_duration</a> object from a delimited string. </p> </div> <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.time_parsing_hpp" title="Header &lt;boost/date_time/time_parsing.hpp&gt;">boost/date_time/time_parsing.hpp</a>&gt; </span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> time_duration<span class="special">&gt;</span> <a class="link" href="time_duration.html" title="Class template time_duration">time_duration</a> <span class="identifier">parse_delimited_time_duration</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span> s<span class="special">)</span><span class="special">;</span></pre></div> <div class="refsect1"> <a name="idp90527848"></a><h2>Description</h2> <p>Expected format for string is "[-]h[h][:mm][:ss][.fff]". If the number of fractional digits provided is greater than the precision of the time duration type then the extra digits are truncated.</p> <p>A negative duration will be created if the first character in string is a '-', all other '-' will be treated as delimiters. Accepted delimiters are "-:,.". </p> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="str_from_delim_idp21488264.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.time_parsing_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="time_resolutio_idp22503048.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
apache-2.0
denilsonm/advance-toolchain
fvtr/gccgo/test.go
669
/* Copyright 2017 IBM Corporation * * 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 main import "fmt" func main() { fmt.Println("Hello, World") }
apache-2.0
googleapis/google-cloud-php-pubsub
tests/Snippet/BatchPublisherTest.php
1948
<?php /** * Copyright 2016 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. */ namespace Google\Cloud\PubSub\Tests\Snippet; use Google\Cloud\Core\Testing\Snippet\SnippetTestCase; use Google\Cloud\PubSub\BatchPublisher; use Google\Cloud\PubSub\PubSubClient; use Google\Cloud\PubSub\Topic; use Prophecy\Argument; /** * @group pubsub */ class BatchPublisherTest extends SnippetTestCase { private $batchPublisher; public function setUp() { $this->batchPublisher = $this->prophesize(BatchPublisher::class); $this->batchPublisher->publish([ 'data' => 'An important message.' ]) ->willReturn(true); } public function testClass() { $snippet = $this->snippetFromClass(BatchPublisher::class); $topic = $this->prophesize(Topic::class); $topic->batchPublisher() ->willReturn($this->batchPublisher->reveal()); $pubsub = $this->prophesize(PubSubClient::class); $pubsub->topic(Argument::type('string')) ->willReturn($topic->reveal()); $snippet->setLine(2, ''); $snippet->addLocal('pubsub', $pubsub->reveal()); $snippet->invoke(); } public function testPublish() { $snippet = $this->snippetFromMethod(BatchPublisher::class, 'publish'); $snippet->addLocal('batchPublisher', $this->batchPublisher->reveal()); $snippet->invoke(); } }
apache-2.0
mdanielwork/intellij-community
platform/platform-api/src/com/intellij/execution/IllegalEnvVarException.java
314
// Copyright 2000-2018 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.execution; public class IllegalEnvVarException extends ExecutionException { public IllegalEnvVarException(String message) { super(message); } }
apache-2.0
walkeralencar/ci-php-analyzer
res/php-5.4-core-api/AMQPExchangeException.php
273
<?php // Start of AMQPExchangeException from php-amqp v.1.4.0beta2 /** * stub class representing AMQPExchangeException from pecl-amqp * @jms-builtin */ class AMQPExchangeException extends AMQPException { } // End of AMQPExchangeException from php-amqp v.1.4.0beta2 ?>
apache-2.0
googleapis/google-cloud-php-game-servers
src/V1/GetGameServerDeploymentRequest.php
2444
<?php # Generated by the protocol buffer compiler. DO NOT EDIT! # source: google/cloud/gaming/v1/game_server_deployments.proto namespace Google\Cloud\Gaming\V1; use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** * Request message for GameServerDeploymentsService.GetGameServerDeployment. * * Generated from protobuf message <code>google.cloud.gaming.v1.GetGameServerDeploymentRequest</code> */ class GetGameServerDeploymentRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the game server delpoyment to retrieve, in the following form: * `projects/{project}/locations/{location}/gameServerDeployments/{deployment}`. * * Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> */ private $name = ''; /** * Constructor. * * @param array $data { * Optional. Data for populating the Message object. * * @type string $name * Required. The name of the game server delpoyment to retrieve, in the following form: * `projects/{project}/locations/{location}/gameServerDeployments/{deployment}`. * } */ public function __construct($data = NULL) { \GPBMetadata\Google\Cloud\Gaming\V1\GameServerDeployments::initOnce(); parent::__construct($data); } /** * Required. The name of the game server delpoyment to retrieve, in the following form: * `projects/{project}/locations/{location}/gameServerDeployments/{deployment}`. * * Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> * @return string */ public function getName() { return $this->name; } /** * Required. The name of the game server delpoyment to retrieve, in the following form: * `projects/{project}/locations/{location}/gameServerDeployments/{deployment}`. * * Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> * @param string $var * @return $this */ public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; return $this; } }
apache-2.0
adjackura/compute-image-tools
proto/go/pbtesting/gomock_matcher.go
1340
// Copyright 2020 Google Inc. 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. package pbtesting import ( "fmt" "github.com/golang/mock/gomock" "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "google.golang.org/protobuf/testing/protocmp" ) type protoMatcher struct { expected proto.Message } func (m protoMatcher) Got(got interface{}) string { message, ok := got.(proto.Message) if !ok { return fmt.Sprintf("%v", ok) } return proto.MarshalTextString(message) } func (m protoMatcher) Matches(actual interface{}) bool { return cmp.Diff(m.expected, actual, protocmp.Transform()) == "" } func (m protoMatcher) String() string { return proto.MarshalTextString(m.expected) } func ProtoEquals(expected proto.Message) gomock.Matcher { return protoMatcher{expected} }
apache-2.0
afamorim/Vortice
apps/vortice-webapp/target/vortice-webapp/nucleo/themes/zune/css/calendar.css
9390
.DHTMLSuite_calendar{ /* Main div for the calendar */ border:1px solid #444444; background-color:#FFF; width:220px; position:relative; overflow:hidden; } .DHTMLSuite_calendarContent{ /* Sub div inside DHTMLSuite_calendar - this is the div where content is added */ position:relative; /* IMPORTANT - This must always be like this in order to make it possible to position sub elements correctly, especially the iframe */ z-index:10; /* IMPORTANT - This must always be like this in order to make it possible to position sub elements correctly, especially the iframe */ background-color:#FFF; font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif; } /******************* START CSS FOR THE HEADER ROW - WHERE YOU SEE MONTH AND YEAR ********************/ .DHTMLSuite_calendar .DHTMLSuite_calendarHeading{ /* Heading of calendar, where you see the month and year */ background-image:url(../images/calendar/calendar_heading.png); background-repeat:repeat-x; height:21px; border-bottom:1px solid #444444; } .DHTMLSuite_calendarHeadingTxt{ /* Inner div in the heading */ padding:1px; text-align:center; font-size:13px; color:#FFF; } .DHTMLSuite_calendarCloseButton{ /* Close button at the top right corner of the calendar */ background-image:url(../images/calendar/calendar-close.gif); background-repeat:no-repeat; width:13px; height:13px; position:absolute; right:3px; top:3px; padding:1px; background-position:center center; cursor:pointer; } .DHTMLSuite_calendarHeaderMonthAndYear{ /* Div elements for year and month in the heading */ padding:1px; padding-right:2px; padding-left:2px; cursor:pointer; line-height:17px; } .DHTMLSuite_calendarHeaderMonthAndYearOver{ /* Mouse over effect - month and year in the heading */ background-color:#444; border:1px solid #555; padding:0px; padding-left:1px; padding-right:1px; } /******************* START CSS FOR THE TIME BAR - THE DIV WHERE YOU SEE "Time: " and the hour and minute ********************/ .DHTMLSuite_calendar_timeBar{ /* Time bar - where users can select hour and minutes */ background-color:#555; height:21px; border-top:1px solid #444444; text-align:center; position:relative; color:#FFF; } .DHTMLSuite_calendar_timeBarHourAndMinute{ /* General rules for the displayed hours and minutes - the ones you can click on the bring out the drop down boxes */ padding:1px; padding-left:2px; padding-right:2px; margin-right:2px; cursor:pointer; } .DHTMLSuite_calendarTimeBarHourAndMinuteOver{ /* Mouse over effect for the hour and minute displayed in the time bar */ background-color:#444; border:1px solid #555; padding:0px; padding-left:1px; padding-right:1px; } .DHTMLSuite_calendarTimeBarTimeString{ /* String "Time:" */ position:absolute; left:2px; top:2px; } /******************* START CSS FOR THE NAVIGATION BAR - THE DIV WITH THE LEFT AND RIGHT ARROWS ********************/ .DHTMLSuite_calendar_navigationBar{ /* Navigation bar below the heading */ background-color:#555; height:17px; border-bottom:1px solid #444444; position:relative; } .DHTMLSuite_calendar_navigationBarToday{ /* Div for the string "Today" in the navigation bar */ text-align:center; color:#FFF; } .DHTMLSuite_calendar_navigationBarToday span{ /* The "Today" string inside the navigation bar */ cursor:pointer; } .DHTMLSuite_calendar_btnNextYear,.DHTMLSuite_calendar_btnPreviousYear,.DHTMLSuite_calendar_btnNextMonth,.DHTMLSuite_calendar_btnPreviousMonth{ /* Buttons - previous/next month and year */ position:absolute; background-repeat:no-repeat; background-position:center center; width:13px; height:13px; padding:1px; top:1px; } .DHTMLSuite_calendar_btnNextYear{ /* Next year button */ background-image:url(../images/calendar/calendar-next-year.gif); right:2px; } .DHTMLSuite_calendar_btnPreviousYear{ /* Previous year button */ background-image:url(../images/calendar/calendar-previous-year.gif); left:2px; } .DHTMLSuite_calendar_btnNextMonth{ /* Next month button */ background-image:url(../images/calendar/calendar-next-month.gif); right:18px; } .DHTMLSuite_calendar_btnPreviousMonth{ /* Previous month button */ background-image:url(../images/calendar/calendar-previous-month.gif); left:18px; } /******************* START CSS FOR THE MAIN DIV CONTAINING ALL THE DAYS WITHIN A MONTH AND HEADINGS (weeks, days(Mon-Sun) etc.) ********************/ .DHTMLSuite_calendar_monthView{ /* Main div element for the days in a month */ } .DHTMLSuite_calendar_monthView_headerCell{ /* Main div element for the days in a month */ background-color:#FFF; border-bottom:1px solid #444444; } .DHTMLSuite_calendar_monthView_firstColumn{ /* First column - the week column */ background-color:#555; border-right:1px solid #444444; text-align:left; color:#FFF; } .DHTMLSuite_calendar_monthView td{ /* Default css for all the cells inside the calendar, i.e. week heading, label for the days, and the days */ text-align:center; cursor:default; } .DHTMLSuite_calendar_monthView_headerSunday{ /* Sunday in the header */ color:red; border-bottom:1px solid #444444; } .DHTMLSuite_calendar_monthView_daysInOtherMonths{ /* Days in previous or next month, i.e. before start of current displayed month or after days in the currently displayed month */ color:#999; } .DHTMLSuite_calendar_monthView_daysInThisMonth{ /* Layout - ordinary days(mon-sat) in this month */ } .DHTMLSuite_calendar_monthView_sundayInThisMonth{ /* Layout - sundays in current displayed month */ color:red; } .DHTMLSuite_calendar_monthView_initialDate{ /* Inital set date, example: the date in an input field which you are populating with the calendar */ background-color:#444444; color:white; } .DHTMLSuite_calendar_monthView_invalidDate{ /* Inital set date, example: the date in an input field which you are populating with the calendar */ color:#AAA; } .DHTMLSuite_calendar_monthView_currentDate{ /* Date of today */ background-color:#E2E2E2; } /*************************************************** * * START CSS - DROP DOWN BOXES * * ***************************************************/ /*** MINUTES ***/ .DHTMLSuite_calendar_minuteDropDown{ /* Drop down box for minutes */ background-color:#555; border:1px solid #444444; width:23px; padding:1px; font-size:12px; text-align:center; /* You shouldn't change these 3 options */ position:absolute; z-index:152000; cursor:pointer; } .DHTMLSuite_calendar_minuteDropDownCurrentMinute{ /* Minute in drop down when it's equal to current minute of the display, i.e. the minute you see where you click on the drop down */ color:red; } .DHTMLSuite_calendar_dropDownAMinute{ color:#FFF; } .DHTMLSuite_calendar_dropdownAMinuteOver{ background-color:#E2E2E2; color:#222; } /*** HOURS ***/ .DHTMLSuite_calendar_hourDropDown{ /* Drop down box for hours */ background-color:#555; border:1px solid #444444; width:23px; position:absolute; z-index:152000; padding:1px; cursor:pointer; font-size:12px; text-align:center; } .DHTMLSuite_calendar_dropDownAnHour{ color:#FFF; } .DHTMLSuite_calendar_dropdownAnHourOver{ background-color:#E2E2E2; color:#222; } .DHTMLSuite_calendar_hourDropDownCurrentHour{ color:red; } /*** MONTHS ***/ .DHTMLSuite_calendar_monthDropDown{ background-color:#555; border:1px solid #444444; width:70px; position:absolute; z-index:152000; cursor:pointer; padding:1px; font-size:12px; } .DHTMLSuite_calendar_dropDownAMonth{ color:#FFF; } .DHTMLSuite_calendar_dropdownAMonthOver{ background-color:#E2E2E2; color:#000; } .DHTMLSuite_calendar_yearDropDownCurrentMonth{ color:red; } /***** YEAR ****/ .DHTMLSuite_calendar_yearDropDown{ background-color:#555; border:1px solid #444444; width:30px; position:absolute; z-index:152000; cursor:pointer; padding:1px; font-size:12px; text-align:center; } .DHTMLSuite_calendar_dropDownAYear{ color:#FFF; } .DHTMLSuite_calendar_dropdownAYearOver{ background-color:#E2E2E2; color:#000; } .DHTMLSuite_calendar_yearDropDownCurrentYear{ /* Current year */ color:red; } /* UP AND DOWN ARROWS INSIDE DROP DOWNS **/ .DHTMLSuite_calendar_dropDown_arrowUp{ /* Drop down - moving to previous year */ background-image:url(../images/calendar/calendar-dropdown-up.gif); background-repeat:no-repeat; background-position:center center; height:8px; } .DHTMLSuite_calendar_dropDown_arrowDown{ /* Drop down - moving to previous year */ background-image:url(../images/calendar/calendar-dropdown-down.gif); background-repeat:no-repeat; background-position:center center; height:8px; } .DHTMLSuite_calendarDropDown_dropDownArrowOver{ background-color:#BBB; } /* IT'S IMPORTANT TO HAVE THIS CSS RULE AT THE BOTTOM IN ORDER TO MAKE THE PADDING OVERRIDE PADDING OF OTHER ELEMENTS */ .DHTMLSuite_calendarButtonOver{ /* Mouse over effect for the close button */ background-color:#444; border:1px solid #555; padding:0px; /* The sum border+padding of this element should be the same as border+padding of .DHTMLSuite_calendarCloseButton */ } .DHTMLSuite_calendarDayOver{ /* Mouse over effect - days in the calendar, i.e. days in current displayed month */ background-color:#555; color:#E2E2E2; } /* YOU SHOULD NEVER MODIFY THIS ONE */ .DHTMLSuite_calendar_iframe{ /* Iframe used to cover select boxes below in older IE browsers(version 6 and prior) */ position:absolute; top:1px; left:1px; z-index:1; }
apache-2.0
m0ppers/arangodb
3rdParty/V8/V8-5.0.71.39/test/test262/data/test/built-ins/Boolean/prototype/S15.6.3.1_A1.js
694
// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- info: > The initial value of Boolean.prototype is the Boolean prototype object es5id: 15.6.3.1_A1 description: Checking Boolean.prototype property ---*/ //CHECK#1 if (typeof Boolean.prototype !== "object") { $ERROR('#1: typeof Boolean.prototype === "object"'); } //CHECK#2 if (Boolean.prototype != false) { $ERROR('#2: Boolean.prototype == false'); } delete Boolean.prototype.toString; if (Boolean.prototype.toString() !== "[object Boolean]") { $ERROR('#3: The [[Class]] property of the Boolean prototype object is set to "Boolean"'); }
apache-2.0
craigyam/amalgam8
testing/build_and_run.sh
1032
#!/bin/bash # # Copyright 2016 IBM Corporation # # 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. set -x set -o errexit if [ -z "$A8_TEST_DOCKER" ]; then A8_TEST_DOCKER="true" fi #if [ -z "$A8_TEST_K8S" ]; then # A8_TEST_K8S="true" #fi SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) $SCRIPTDIR/build-scripts/build-amalgam8.sh if [ "$A8_TEST_DOCKER" == "true" ]; then $SCRIPTDIR/docker/test-docker.sh fi if [ "$A8_TEST_K8S" == "true" ]; then $SCRIPTDIR/kubernetes/test-kubernetes.sh fi
apache-2.0
irblsensitivity/irblsensitivity
techniques/BRTracer/src/japa/parser/ast/expr/ArrayInitializerExpr.java
1995
/* * Copyright (C) 2007 Júlio Vilmar Gesser. * * This file is part of Java 1.5 parser and Abstract Syntax Tree. * * Java 1.5 parser and Abstract Syntax Tree 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. * * Java 1.5 parser and Abstract Syntax Tree 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 Java 1.5 parser and Abstract Syntax Tree. If not, see <http://www.gnu.org/licenses/>. */ /* * Created on 05/10/2006 */ package japa.parser.ast.expr; import japa.parser.ast.visitor.GenericVisitor; import japa.parser.ast.visitor.VoidVisitor; import java.util.List; /** * @author Julio Vilmar Gesser */ public final class ArrayInitializerExpr extends Expression { private List<Expression> values; public ArrayInitializerExpr() { } public ArrayInitializerExpr(List<Expression> values) { this.values = values; } public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List<Expression> values) { super(beginLine, beginColumn, endLine, endColumn); this.values = values; } @Override public <R, A> R accept(GenericVisitor<R, A> v, A arg) { return v.visit(this, arg); } @Override public <A> void accept(VoidVisitor<A> v, A arg) { v.visit(this, arg); } public List<Expression> getValues() { return values; } public void setValues(List<Expression> values) { this.values = values; } }
apache-2.0
commons-app/apps-android-commons
app/src/main/java/fr/free/nrw/commons/explore/ParentViewPager.java
1500
package fr.free.nrw.commons.explore; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import androidx.viewpager.widget.ViewPager; /** * ParentViewPager A custom viewPager whose scrolling can be enabled and disabled. */ public class ParentViewPager extends ViewPager { /** * Boolean variable that stores the current state of pager scroll i.e(enabled or disabled) */ private boolean canScroll = true; /** * Default constructors */ public ParentViewPager(Context context) { super(context); } public ParentViewPager(Context context, AttributeSet attrs) { super(context, attrs); } /** * Setter method for canScroll. */ public void setCanScroll(boolean canScroll) { this.canScroll = canScroll; } /** * Getter method for canScroll. */ public boolean isCanScroll() { return canScroll; } /** * Method that prevents scrolling if canScroll is set to false. */ @Override public boolean onTouchEvent(MotionEvent ev) { return canScroll && super.onTouchEvent(ev); } /** * A facilitator method that allows parent to intercept touch events before its children. thus * making it possible to prevent swiping parent on child end. */ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return canScroll && super.onInterceptTouchEvent(ev); } }
apache-2.0
yeahdongcn/ITPullToRefreshScrollView
ITPullToRefreshScrollView/ITPullToRefreshScrollView/AppDelegate.h
633
// // AppDelegate.h // ITPullToRefreshScrollView // // Created by Ilija Tovilo on 9/25/13. // Copyright (c) 2013 Ilija Tovilo. All rights reserved. // #import <Cocoa/Cocoa.h> #import "ITPullToRefreshScrollView.h" @interface AppDelegate : NSObject <NSApplicationDelegate, NSTableViewDataSource, NSTableViewDelegate, ITPullToRefreshScrollViewDelegate> @property (assign) IBOutlet NSWindow *window; @property (assign) IBOutlet NSTableView *tableView; @property (assign) IBOutlet ITPullToRefreshScrollView *scrollView; @end
apache-2.0
liquibase/liquibase
liquibase-core/src/main/java/liquibase/diff/compare/core/CommonCatalogSchemaComparator.java
1666
package liquibase.diff.compare.core; import liquibase.CatalogAndSchema; import liquibase.database.Database; import liquibase.diff.compare.CompareControl; import liquibase.diff.compare.DatabaseObjectComparator; import liquibase.util.StringUtil; /** * DatabaseObjectComparator for Catalog and Schema comparators with common stuff */ public abstract class CommonCatalogSchemaComparator implements DatabaseObjectComparator { protected boolean equalsSchemas(Database accordingTo, String schemaName1, String schemaName2) { if (CatalogAndSchema.CatalogAndSchemaCase.ORIGINAL_CASE.equals(accordingTo.getSchemaAndCatalogCase())){ return StringUtil.trimToEmpty(schemaName1).equals(StringUtil.trimToEmpty(schemaName2)); } else { return StringUtil.trimToEmpty(schemaName1).equalsIgnoreCase(StringUtil.trimToEmpty(schemaName2)); } } protected String getComparisonSchemaOrCatalog(Database accordingTo, CompareControl.SchemaComparison comparison) { if (accordingTo.supportsSchemas()) { return comparison.getComparisonSchema().getSchemaName(); } else if (accordingTo.supportsCatalogs()) { return comparison.getComparisonSchema().getCatalogName(); } return null; } protected String getReferenceSchemaOrCatalog(Database accordingTo, CompareControl.SchemaComparison comparison) { if (accordingTo.supportsSchemas()) { return comparison.getReferenceSchema().getSchemaName(); } else if (accordingTo.supportsCatalogs()) { return comparison.getReferenceSchema().getCatalogName(); } return null; } }
apache-2.0
hanw/p4c
midend/noMatch.cpp
1905
/* Copyright 2016 VMware, 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. */ #include "noMatch.h" #include "frontends/p4/coreLibrary.h" namespace P4 { const IR::Node* DoHandleNoMatch::postorder(IR::SelectExpression* expression) { for (auto c : expression->selectCases) { if (c->keyset->is<IR::DefaultExpression>()) return expression; } CHECK_NULL(noMatch); auto sc = new IR::SelectCase( new IR::DefaultExpression(), new IR::PathExpression(noMatch->getName())); expression->selectCases.push_back(sc); return expression; } const IR::Node* DoHandleNoMatch::preorder(IR::P4Parser* parser) { P4CoreLibrary& lib = P4CoreLibrary::instance; cstring name = nameGen->newName("noMatch"); LOG2("Inserting " << name << " state"); auto args = new IR::Vector<IR::Argument>(); args->push_back(new IR::Argument(new IR::BoolLiteral(false))); args->push_back(new IR::Argument(new IR::Member( new IR::TypeNameExpression(IR::Type_Error::error), lib.noMatch.Id()))); auto verify = new IR::MethodCallExpression( new IR::PathExpression(IR::ID(IR::ParserState::verify)), args); noMatch = new IR::ParserState(IR::ID(name), { new IR::MethodCallStatement(verify) }, new IR::PathExpression(IR::ID(IR::ParserState::reject))); parser->states.push_back(noMatch); return parser; } } // namespace P4
apache-2.0
rvs/gpdb
src/backend/utils/sort/tuplesort_mk.c
103621
/*------------------------------------------------------------------------- * * tuplesort.c * Generalized tuple sorting routines. * * This module handles sorting of heap tuples, index tuples, or single * Datums (and could easily support other kinds of sortable objects, * if necessary). It works efficiently for both small and large amounts * of data. Small amounts are sorted in-memory using qsort(). Large * amounts are sorted using temporary files and a standard external sort * algorithm. * * See Knuth, volume 3, for more than you want to know about the external * sorting algorithm. We divide the input into sorted runs using replacement * selection, in the form of a priority tree implemented as a heap * (essentially his Algorithm 5.2.3H), then merge the runs using polyphase * merge, Knuth's Algorithm 5.4.2D. The logical "tapes" used by Algorithm D * are implemented by logtape.c, which avoids space wastage by recycling * disk space as soon as each block is read from its "tape". * * We do not form the initial runs using Knuth's recommended replacement * selection data structure (Algorithm 5.4.1R), because it uses a fixed * number of records in memory at all times. Since we are dealing with * tuples that may vary considerably in size, we want to be able to vary * the number of records kept in memory to ensure full utilization of the * allowed sort memory space. So, we keep the tuples in a variable-size * heap, with the next record to go out at the top of the heap. Like * Algorithm 5.4.1R, each record is stored with the run number that it * must go into, and we use (run number, key) as the ordering key for the * heap. When the run number at the top of the heap changes, we know that * no more records of the prior run are left in the heap. * * The approximate amount of memory allowed for any one sort operation * is specified in kilobytes by the caller (most pass work_mem). Initially, * we absorb tuples and simply store them in an unsorted array as long as * we haven't exceeded workMem. If we reach the end of the input without * exceeding workMem, we sort the array using qsort() and subsequently return * tuples just by scanning the tuple array sequentially. If we do exceed * workMem, we construct a heap using Algorithm H and begin to emit tuples * into sorted runs in temporary tapes, emitting just enough tuples at each * step to get back within the workMem limit. Whenever the run number at * the top of the heap changes, we begin a new run with a new output tape * (selected per Algorithm D). After the end of the input is reached, * we dump out remaining tuples in memory into a final run (or two), * then merge the runs using Algorithm D. * * When merging runs, we use a heap containing just the frontmost tuple from * each source run; we repeatedly output the smallest tuple and insert the * next tuple from its source tape (if any). When the heap empties, the merge * is complete. The basic merge algorithm thus needs very little memory --- * only M tuples for an M-way merge, and M is constrained to a small number. * However, we can still make good use of our full workMem allocation by * pre-reading additional tuples from each source tape. Without prereading, * our access pattern to the temporary file would be very erratic; on average * we'd read one block from each of M source tapes during the same time that * we're writing M blocks to the output tape, so there is no sequentiality of * access at all, defeating the read-ahead methods used by most Unix kernels. * Worse, the output tape gets written into a very random sequence of blocks * of the temp file, ensuring that things will be even worse when it comes * time to read that tape. A straightforward merge pass thus ends up doing a * lot of waiting for disk seeks. We can improve matters by prereading from * each source tape sequentially, loading about workMem/M bytes from each tape * in turn. Then we run the merge algorithm, writing but not reading until * one of the preloaded tuple series runs out. Then we switch back to preread * mode, fill memory again, and repeat. This approach helps to localize both * read and write accesses. * * When the caller requests random access to the sort result, we form * the final sorted run on a logical tape which is then "frozen", so * that we can access it randomly. When the caller does not need random * access, we return from tuplesort_performsort() as soon as we are down * to one run per logical tape. The final merge is then performed * on-the-fly as the caller repeatedly calls tuplesort_getXXX; this * saves one cycle of writing all the data out to disk and reading it in. * * Before Postgres 8.2, we always used a seven-tape polyphase merge, on the * grounds that 7 is the "sweet spot" on the tapes-to-passes curve according * to Knuth's figure 70 (section 5.4.2). However, Knuth is assuming that * tape drives are expensive beasts, and in particular that there will always * be many more runs than tape drives. In our implementation a "tape drive" * doesn't cost much more than a few Kb of memory buffers, so we can afford * to have lots of them. In particular, if we can have as many tape drives * as sorted runs, we can eliminate any repeated I/O at all. In the current * code we determine the number of tapes M on the basis of workMem: we want * workMem/M to be large enough that we read a fair amount of data each time * we preread from a tape, so as to maintain the locality of access described * above. Nonetheless, with large workMem we can have many tapes. * * * Portions Copyright (c) 2007-2008, Greenplum inc * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.70 2006/10/04 00:30:04 momjian Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" #include "access/heapam.h" #include "access/nbtree.h" #include "access/tuptoaster.h" #include "catalog/pg_type.h" #include "catalog/pg_amop.h" #include "catalog/pg_operator.h" #include "executor/instrument.h" /* Instrumentation */ #include "lib/stringinfo.h" /* StringInfo */ #include "executor/nodeSort.h" /* gpmon */ #include "miscadmin.h" #include "utils/datum.h" #include "executor/execWorkfile.h" #include "utils/logtape.h" #include "utils/lsyscache.h" #include "utils/memutils.h" #include "utils/pg_rusage.h" #include "utils/syscache.h" #include "utils/tuplesort.h" #include "utils/pg_locale.h" #include "utils/builtins.h" #include "utils/tuplesort_mk.h" #include "utils/tuplesort_mk_details.h" #include "utils/string_wrapper.h" #include "utils/faultinjector.h" #include "cdb/cdbvars.h" /* * Possible states of a Tuplesort object. These denote the states that * persist between calls of Tuplesort routines. */ typedef enum { TSS_INITIAL, /* Loading tuples; still within memory limit */ TSS_BUILDRUNS, /* Loading tuples; writing to tape */ TSS_SORTEDINMEM, /* Sort completed entirely in memory */ TSS_SORTEDONTAPE, /* Sort completed, final run is on tape */ TSS_FINALMERGE /* Performing final merge on-the-fly */ } TupSortStatus; /* * Parameters for calculation of number of tapes to use --- see inittapes() * and tuplesort_merge_order(). * * In this calculation we assume that each tape will cost us about 3 blocks * worth of buffer space (which is an underestimate for very large data * volumes, but it's probably close enough --- see logtape.c). * * MERGE_BUFFER_SIZE is how much data we'd like to read from each input * tape during a preread cycle (see discussion at top of file). */ #define MINORDER 6 /* minimum merge order */ #define MAXORDER 250 /* maximum merge order */ #define TAPE_BUFFER_OVERHEAD (BLCKSZ * 3) #define MERGE_BUFFER_SIZE (BLCKSZ * 32) // #define PRINT_SPILL_AND_MEMORY_MESSAGES /* * Current position of Tuplesort operation. */ struct TuplesortPos_mk { /* * These variables are used after completion of sorting to keep track of * the next tuple to return. (In the tape case, the tape's current read * position is also critical state.) */ int current; /* array index (only used if SORTEDINMEM) */ bool eof_reached; /* reached EOF (needed for cursors) */ /* markpos_xxx holds marked position for mark and restore */ union { LogicalTapePos tapepos; long mempos; } markpos; bool markpos_eof; LogicalTape *cur_work_tape; /* current tape that I am working on */ }; /* Merge reader (read back from runs) context for mk_heap */ typedef struct TupsortMergeReadCtxt { Tuplesortstate_mk *tsstate; TuplesortPos_mk pos; /* Buffer for preread */ MKEntry *p; int allocsz; int cnt; int cur; int64 mem_allowed; int64 mem_used; } TupsortMergeReadCtxt; /* * Private state of a Tuplesort operation. */ struct Tuplesortstate_mk { TupSortStatus status; /* enumerated value as shown above */ int nKeys; /* number of columns in sort key */ bool randomAccess; /* did caller request random access? */ int64 memAllowed; int maxTapes; /* number of tapes (Knuth's T) */ int tapeRange; /* maxTapes-1 (Knuth's P) */ MemoryContext sortcontext; /* memory context holding all sort data */ LogicalTapeSet *tapeset; /* logtape.c object for tapes in a temp file */ ScanState *ss; /* Representation of all spill file names, for spill file reuse */ workfile_set *work_set; /* * MUST be set * * Function to copy a supplied input tuple into palloc'd space and set up * its SortTuple representation (ie, set tuple/datum1/isnull1). Also, * state->availMem must be decreased by the amount of space used for the * tuple copy (note the SortTuple struct itself is not counted). */ void (*copytup) (Tuplesortstate_mk *state, MKEntry *e, void *tup); /* * MUST be set * * Function to write a stored tuple onto tape. The representation of the * tuple on tape need not be the same as it is in memory; requirements on * the tape representation are given below. After writing the tuple, * pfree() the out-of-line data (not the SortTuple struct!), and increase * state->availMem by the amount of memory space thereby released. */ long (*writetup) (Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e); /* * MUST be set * * Function to read a stored tuple from tape back into memory. 'len' is * the already-read length of the stored tuple. Create a palloc'd copy, * initialize tuple/datum1/isnull1 in the target SortTuple struct, and * decrease state->availMem by the amount of memory space consumed. */ void (*readtup) (Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len); /* * This array holds the tuples now in sort memory. If we are in state * INITIAL, the tuples are in no particular order; if we are in state * SORTEDINMEM, the tuples are in final sorted order; */ MKEntry *entries; long entry_allocsize; long entry_count; /* * BUILDRUNS and FINALMERGE: Heap for producing and merging runs */ MKHeap *mkheap; MKHeapReader *mkhreader; TupsortMergeReadCtxt *mkhreader_ctxt; int mkhreader_allocsize; /* * MK context, holds info needed by compare/prepare functions */ MKContext mkctxt; /* * A flag to indicate whether the stats for this tuplesort has been * finalized. */ bool statsFinalized; int currentRun; /* * Unless otherwise noted, all pointer variables below are pointers to * arrays of length maxTapes, holding per-tape data. */ /* * These variables are only used during merge passes. mergeactive[i] is * true if we are reading an input run from (actual) tape number i and * have not yet exhausted that run. mergenext[i] is the memtuples index * of the next pre-read tuple (next to be loaded into the heap) for tape * i, or 0 if we are out of pre-read tuples. mergelast[i] similarly * points to the last pre-read tuple from each tape. mergeavailslots[i] * is the number of unused memtuples[] slots reserved for tape i, and * mergeavailmem[i] is the amount of unused space allocated for tape i. * mergefreelist and mergefirstfree keep track of unused locations in the * memtuples[] array. The memtuples[].tupindex fields link together * pre-read tuples for each tape as well as recycled locations in * mergefreelist. It is OK to use 0 as a null link in these lists, because * memtuples[0] is part of the merge heap and is never a pre-read tuple. */ bool *mergeactive; /* active input run source? */ int *mergenext; /* first preread tuple for each source */ int *mergelast; /* last preread tuple for each source */ int *mergeavailslots; /* slots left for prereading each tape */ long *mergeavailmem; /* availMem for prereading each tape */ int mergefreelist; /* head of freelist of recycled slots */ int mergefirstfree; /* first slot never used in this merge */ /* * Variables for Algorithm D. Note that destTape is a "logical" tape * number, ie, an index into the tp_xxx[] arrays. Be careful to keep * "logical" and "actual" tape numbers straight! */ int Level; /* Knuth's l */ int destTape; /* current output tape (Knuth's j, less 1) */ int *tp_fib; /* Target Fibonacci run counts (A[]) */ int *tp_runs; /* # of real runs on each tape */ int *tp_dummy; /* # of dummy runs for each tape (D[]) */ int *tp_tapenum; /* Actual tape numbers (TAPE[]) */ int activeTapes; /* # of active input tapes in merge pass */ LogicalTape *result_tape; /* actual tape of finished output */ TuplesortPos_mk pos; /* current postion */ /* * Tuple desc and binding, for MemTuple. */ TupleDesc tupDesc; MemTupleBinding *mt_bind; ScanKey cmpScanKey; /* * These variables are specific to the IndexTuple case; they are set by * tuplesort_begin_index and used only by the IndexTuple routines. */ Relation indexRel; /* * These variables are specific to the Datum case; they are set by * tuplesort_begin_datum and used only by the DatumTuple routines. */ Oid datumType; Oid sortOperator; bool nullfirst; /* we need typelen and byval in order to know how to copy the Datums. */ int datumTypeLen; bool datumTypeByVal; /* * CDB: EXPLAIN ANALYZE reporting interface and statistics. */ struct Instrumentation *instrument; struct StringInfoData *explainbuf; uint64 totalTupleBytes; uint64 totalNumTuples; uint64 numTuplesInMem; uint64 memUsedBeforeSpill; /* memory that is used by Sort at the * time of spilling */ long arraySizeBeforeSpill; /* the value for entry_allocsize at * the time of spilling */ /* * File for dump/load logical tape set. Used by sharing sort across slice */ char *tapeset_file_prefix; /* * State file used to load a logical tape set. Used by sharing sort across * slice */ ExecWorkFile *tapeset_state_file; /* Gpmon */ gpmon_packet_t *gpmon_pkt; int *gpmon_sort_tick; }; static void tuplesort_get_stats_mk(Tuplesortstate_mk* state, const char **sortMethod, const char **spaceType, long *spaceUsed); static bool is_sortstate_rwfile(Tuplesortstate_mk *state) { return state->tapeset_state_file != NULL; } #ifdef USE_ASSERT_CHECKING static bool is_under_sort_or_exec_ctxt(Tuplesortstate_mk *state) { /* * Check if this is executed under sortcontext (most cases) or under * es_query_cxt (when under a SharedInputScan) */ return CurrentMemoryContext == state->sortcontext || CurrentMemoryContext == state->ss->ps.state->es_query_cxt; } #endif /** * Any strings that are STRXFRM_INPUT_LENGTH_LIMIT or larger will store only the * first STRXFRM_INPUT_LENGTH_LIMIT bytes of the transformed string. * * Note that this is actually less transformed data in some cases than if the string were * just a little smaller than STRXFRM_INPUT_LENGTH_LIMIT. We can probably make the * transition more gradual but will still want this fading off -- for long strings * that differ within the first STRXFRM_INPUT_LENGTH_LIMIT bytes then the prefix * will be sufficient for all but equal cases -- in which case a longer prefix does * not help (we must resort to datum for comparison) * * If less than the whole transformed size is stored then the transformed string itself is also * not copied -- so for large strings we must resort to datum-based comparison. */ #define STRXFRM_INPUT_LENGTH_LIMIT (512) #define COPYTUP(state,stup,tup) ((*(state)->copytup) (state, stup, tup)) #define WRITETUP(state,tape,stup) ((*(state)->writetup) (state, tape, stup)) #define READTUP(state,pos,stup,tape,len) ((*(state)->readtup) (state, pos, stup, tape, len)) static inline bool LACKMEM_WITH_ESTIMATE(Tuplesortstate_mk *state) { /* * Assert: lackmem is only effective during initial run build because we * don't maintain the estimate after that. */ Assert(state->status == TSS_INITIAL); return MemoryContextGetCurrentSpace(state->sortcontext) + state->mkctxt.estimatedExtraForPrep > state->memAllowed; } /* * NOTES about on-tape representation of tuples: * * We require the first "unsigned int" of a stored tuple to be the total size * on-tape of the tuple, including itself (so it is never zero; an all-zero * unsigned int is used to delimit runs). The remainder of the stored tuple * may or may not match the in-memory representation of the tuple --- * any conversion needed is the job of the writetup and readtup routines. * * If state->randomAccess is true, then the stored representation of the * tuple must be followed by another "unsigned int" that is a copy of the * length --- so the total tape space used is actually sizeof(unsigned int) * more than the stored length value. This allows read-backwards. When * randomAccess is not true, the write/read routines may omit the extra * length word. * * writetup is expected to write both length words as well as the tuple * data. When readtup is called, the tape is positioned just after the * front length word; readtup must read the tuple data and advance past * the back length word (if present). * * The write/read routines can make use of the tuple description data * stored in the Tuplesortstate_mk record, if needed. They are also expected * to adjust state->availMem by the amount of memory space (not tape space!) * released or consumed. There is no error return from either writetup * or readtup; they should ereport() on failure. * * * NOTES about memory consumption calculations: * * We count space allocated for tuples against the workMem limit, plus * the space used by the variable-size memtuples array. Fixed-size space * is not counted; it's small enough to not be interesting. * * Note that we count actual space used (as shown by GetMemoryChunkSpace) * rather than the originally-requested size. This is important since * palloc can add substantial overhead. It's not a complete answer since * we won't count any wasted space in palloc allocation blocks, but it's * a lot better than what we were doing before 7.3. */ static Tuplesortstate_mk *tuplesort_begin_common(ScanState *ss, int workMem, bool randomAccess, bool allocmemtuple); static void puttuple_common(Tuplesortstate_mk *state, MKEntry *e); static void selectnewtape_mk(Tuplesortstate_mk *state); static void mergeruns(Tuplesortstate_mk *state); static void beginmerge(Tuplesortstate_mk *state); static uint32 getlen(Tuplesortstate_mk *state, TuplesortPos_mk *pos, LogicalTape *lt, bool eofOK); static void markrunend(Tuplesortstate_mk *state, int tapenum); static void copytup_heap(Tuplesortstate_mk *state, MKEntry *e, void *tup); static long writetup_heap(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e); static void freetup_heap(MKEntry *e); static void readtup_heap(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len); static void copytup_index(Tuplesortstate_mk *state, MKEntry *e, void *tup); static long writetup_index(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e); static void freetup_index(MKEntry *e); static void readtup_index(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len); static void freetup_noop(MKEntry *e); static void copytup_datum(Tuplesortstate_mk *state, MKEntry *e, void *tup); static long writetup_datum(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e); static void freetup_datum(MKEntry *e); static void readtup_datum(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len); static void tupsort_prepare_char(MKEntry *a, bool isChar); static int tupsort_compare_char(MKEntry *v1, MKEntry *v2, MKLvContext *lvctxt, MKContext *mkContext); static Datum tupsort_fetch_datum_mtup(MKEntry *a, MKContext *mkctxt, MKLvContext *lvctxt, bool *isNullOut); static Datum tupsort_fetch_datum_itup(MKEntry *a, MKContext *mkctxt, MKLvContext *lvctxt, bool *isNullOut); static int32 estimateMaxPrepareSizeForEntry(MKEntry *a, struct MKContext *mkctxt); static int32 estimatePrepareSpaceForChar(struct MKContext *mkContext, MKEntry *e, Datum d, bool isCHAR); static void tuplesort_inmem_limit_insert(Tuplesortstate_mk *state, MKEntry *e); static void tuplesort_inmem_nolimit_insert(Tuplesortstate_mk *state, MKEntry *e); static void tuplesort_heap_insert(Tuplesortstate_mk *state, MKEntry *e); static void tuplesort_limit_sort(Tuplesortstate_mk *state); static void tupsort_refcnt(void *vp, int ref); /* Declare the following as extern so that older dtrace will not complain */ extern void inittapes_mk(Tuplesortstate_mk *state, const char *rwfile_prefix); extern void dumptuples_mk(Tuplesortstate_mk *state, bool alltuples); extern void mergeonerun_mk(Tuplesortstate_mk *state); extern void mkheap_verify_heap(MKHeap *heap, int top); /* * tuplesort_begin_xxx * * Initialize for a tuple sort operation. * * After calling tuplesort_begin, the caller should call tuplesort_putXXX * zero or more times, then call tuplesort_performsort when all the tuples * have been supplied. After performsort, retrieve the tuples in sorted * order by calling tuplesort_getXXX until it returns false/NULL. (If random * access was requested, rescan, markpos, and restorepos can also be called.) * Call tuplesort_end to terminate the operation and release memory/disk space. * * Each variant of tuplesort_begin has a workMem parameter specifying the * maximum number of kilobytes of RAM to use before spilling data to disk. * (The normal value of this parameter is work_mem, but some callers use * other values.) Each variant also has a randomAccess parameter specifying * whether the caller needs non-sequential access to the sort result. * * CDB: During EXPLAIN ANALYZE, after tuplesort_begin_xxx() the caller should * use tuplesort_set_instrument() (q.v.) to enable statistical reporting. */ static Tuplesortstate_mk * tuplesort_begin_common(ScanState *ss, int workMem, bool randomAccess, bool allocmemtuple) { Tuplesortstate_mk *state; MemoryContext sortcontext; MemoryContext oldcontext; /* * Create a working memory context for this sort operation. All data * needed by the sort will live inside this context. */ sortcontext = AllocSetContextCreate(CurrentMemoryContext, "TupleSort", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); /* * Make the Tuplesortstate_mk within the per-sort context. This way, we * don't need a separate pfree() operation for it at shutdown. */ oldcontext = MemoryContextSwitchTo(sortcontext); /* * palloc0, need to zero out memeories, so we do not need to set every var * of the tuplestate to 0 below. */ state = (Tuplesortstate_mk *) palloc0(sizeof(Tuplesortstate_mk)); state->status = TSS_INITIAL; state->randomAccess = randomAccess; state->mkctxt.bounded = false; state->mkctxt.boundUsed = false; state->memAllowed = workMem * 1024L; state->work_set = NULL; state->ss = ss; state->sortcontext = sortcontext; if (allocmemtuple) { int i; state->entry_allocsize = 1024; state->entries = (MKEntry *) palloc0(state->entry_allocsize * sizeof(MKEntry)); for (i = 0; i < state->entry_allocsize; ++i) mke_blank(state->entries + i); /* workMem must be large enough for the minimal memtuples array */ if (LACKMEM_WITH_ESTIMATE(state)) elog(ERROR, "insufficient memory allowed for sort"); } /* * maxTapes, tapeRange, and Algorithm D variables will be initialized by * inittapes(), if needed */ MemoryContextSwitchTo(oldcontext); Assert(!state->statsFinalized); return state; } /* * Initialize some extra CDB attributes for the sort, including limit * and uniqueness. Should do this after begin_heap. * */ void cdb_tuplesort_init_mk(Tuplesortstate_mk *state, int unique, int sort_flags, int64 maxdistinct) { UnusedArg(sort_flags); UnusedArg(maxdistinct); if (unique) state->mkctxt.unique = true; } /* make a copy of current state pos */ void tuplesort_begin_pos_mk(Tuplesortstate_mk *st, TuplesortPos_mk ** pos) { TuplesortPos_mk *st_pos; Assert(st); st_pos = (TuplesortPos_mk *) palloc(sizeof(TuplesortPos_mk)); memcpy(st_pos, &(st->pos), sizeof(TuplesortPos_mk)); if (st->result_tape) { st_pos->cur_work_tape = LogicalTapeSetDuplicateTape(st->tapeset, st->result_tape); } else { /* * sort did not finish completely due to QueryFinishPending so pretend * that there are no tuples */ st_pos->eof_reached = true; } *pos = st_pos; } void create_mksort_context( MKContext *mkctxt, int nkeys, AttrNumber *attNums, Oid *sortOperators, bool *nullsFirstFlags, ScanKey sk, MKFetchDatumForPrepare fetchForPrep, MKFreeTuple freeTupleFn, TupleDesc tupdesc, bool tbyv, int tlen) { int i; Assert(mkctxt); mkctxt->total_lv = nkeys; mkctxt->lvctxt = (MKLvContext *) palloc0(sizeof(MKLvContext) * nkeys); AssertEquivalent(sortOperators == NULL, sk != NULL); AssertEquivalent(fetchForPrep == NULL, tupdesc == NULL); mkctxt->fetchForPrep = fetchForPrep; mkctxt->tupdesc = tupdesc; if (tupdesc) mkctxt->mt_bind = create_memtuple_binding(tupdesc); mkctxt->cpfr = tupsort_cpfr; mkctxt->freeTup = freeTupleFn; mkctxt->estimatedExtraForPrep = 0; lc_guess_strxfrm_scaling_factor(&mkctxt->strxfrmScaleFactor, &mkctxt->strxfrmConstantFactor); for (i = 0; i < nkeys; ++i) { Oid sortFunction; bool reverse; MKLvContext *sinfo = mkctxt->lvctxt + i; if (sortOperators) { Assert(sortOperators[i] != 0); /* Select a sort function */ if (!get_compare_function_for_ordering_op(sortOperators[i], &sortFunction, &reverse)) elog(ERROR, "operator %u is not a valid ordering operator", sortOperators[i]); /* * We needn't fill in sk_strategy or sk_subtype since these * scankeys will never be passed to an index. */ ScanKeyInit(&sinfo->scanKey, attNums ? attNums[i] : i + 1, InvalidStrategy, sortFunction, (Datum) 0); /* However, we use btree's conventions for encoding directionality */ if (reverse) sinfo->scanKey.sk_flags |= SK_BT_DESC; if (nullsFirstFlags[i]) sinfo->scanKey.sk_flags |= SK_BT_NULLS_FIRST; } else { sinfo->scanKey = sk[i]; /* structural copy */ } AssertImply(attNums, attNums[i] != 0); /* Per lv context info. Need later for prep */ sinfo->attno = attNums ? attNums[i] : i + 1; sinfo->lvtype = MKLV_TYPE_NONE; if (tupdesc) { sinfo->typByVal = tupdesc->attrs[sinfo->attno - 1]->attbyval; sinfo->typLen = tupdesc->attrs[sinfo->attno - 1]->attlen; if (sinfo->scanKey.sk_func.fn_addr == btint4cmp) sinfo->lvtype = MKLV_TYPE_INT32; if (!lc_collate_is_c()) { if (sinfo->scanKey.sk_func.fn_addr == bpcharcmp) sinfo->lvtype = MKLV_TYPE_CHAR; else if (sinfo->scanKey.sk_func.fn_addr == bttextcmp) sinfo->lvtype = MKLV_TYPE_TEXT; } } else { sinfo->typByVal = tbyv; sinfo->typLen = tlen; } sinfo->mkctxt = mkctxt; } } Tuplesortstate_mk * tuplesort_begin_heap_mk(ScanState *ss, TupleDesc tupDesc, int nkeys, AttrNumber *attNums, Oid *sortOperators, bool *nullsFirstFlags, int workMem, bool randomAccess) { Tuplesortstate_mk *state = tuplesort_begin_common(ss, workMem, randomAccess, true); MemoryContext oldcontext; oldcontext = MemoryContextSwitchTo(state->sortcontext); AssertArg(nkeys > 0); if (trace_sort) PG_TRACE3(tuplesort__begin, nkeys, workMem, randomAccess); state->nKeys = nkeys; state->copytup = copytup_heap; state->writetup = writetup_heap; state->readtup = readtup_heap; state->tupDesc = tupDesc; /* assume we need not copy tupDesc */ state->mt_bind = create_memtuple_binding(tupDesc); state->cmpScanKey = NULL; create_mksort_context( &state->mkctxt, nkeys, attNums, sortOperators, nullsFirstFlags, NULL, tupsort_fetch_datum_mtup, freetup_heap, tupDesc, 0, 0); MemoryContextSwitchTo(oldcontext); return state; } Tuplesortstate_mk * tuplesort_begin_heap_file_readerwriter_mk(ScanState *ss, const char *rwfile_prefix, bool isWriter, TupleDesc tupDesc, int nkeys, AttrNumber *attNums, Oid *sortOperators, bool *nullsFirstFlags, int workMem, bool randomAccess) { Tuplesortstate_mk *state; char statedump[MAXPGPATH]; char full_prefix[MAXPGPATH]; Assert(randomAccess); int len = snprintf(statedump, sizeof(statedump), "%s/%s_sortstate", PG_TEMP_FILES_DIR, rwfile_prefix); insist_log(len <= MAXPGPATH - 1, "could not generate temporary file name"); len = snprintf(full_prefix, sizeof(full_prefix), "%s/%s", PG_TEMP_FILES_DIR, rwfile_prefix); insist_log(len <= MAXPGPATH - 1, "could not generate temporary file name"); if (isWriter) { /* * Writer is a ordinary tuplesort, except the underlying buf file are * named by rwfile_prefix. */ state = tuplesort_begin_heap_mk(ss, tupDesc, nkeys, attNums, sortOperators, nullsFirstFlags, workMem, randomAccess); state->tapeset_file_prefix = MemoryContextStrdup(state->sortcontext, full_prefix); state->tapeset_state_file = ExecWorkFile_Create(statedump, BUFFILE, true /* delOnClose */ , 0 /* compressType */ ); Assert(state->tapeset_state_file != NULL); return state; } else { /* * For reader, we really don't know anything about sort op, attNums, * etc. All the readers cares are the data on the logical tape set. * The state of the logical tape set has been dumped, so we load it * back and that is it. */ MemoryContext oldctxt; state = tuplesort_begin_common(ss, workMem, randomAccess, false); state->status = TSS_SORTEDONTAPE; state->randomAccess = true; state->readtup = readtup_heap; oldctxt = MemoryContextSwitchTo(state->sortcontext); state->tapeset_file_prefix = MemoryContextStrdup(state->sortcontext, full_prefix); state->tapeset_state_file = ExecWorkFile_Open(statedump, BUFFILE, false /* delOnClose */ , 0 /* compressType */ ); ExecWorkFile *tapefile = ExecWorkFile_Open(full_prefix, BUFFILE, false /* delOnClose */ , 0 /* compressType */ ); state->tapeset = LoadLogicalTapeSetState(state->tapeset_state_file, tapefile); state->currentRun = 0; state->result_tape = LogicalTapeSetGetTape(state->tapeset, 0); state->pos.eof_reached = false; state->pos.markpos.tapepos.blkNum = 0; state->pos.markpos.tapepos.offset = 0; state->pos.markpos.mempos = 0; state->pos.markpos_eof = false; state->pos.cur_work_tape = NULL; MemoryContextSwitchTo(oldctxt); return state; } } Tuplesortstate_mk * tuplesort_begin_index_mk(Relation indexRel, bool enforceUnique, int workMem, bool randomAccess) { Tuplesortstate_mk *state = tuplesort_begin_common(NULL, workMem, randomAccess, true); MemoryContext oldcontext; TupleDesc tupdesc; oldcontext = MemoryContextSwitchTo(state->sortcontext); if (trace_sort) PG_TRACE3(tuplesort__begin, enforceUnique, workMem, randomAccess); state->nKeys = RelationGetNumberOfAttributes(indexRel); tupdesc = RelationGetDescr(indexRel); state->copytup = copytup_index; state->writetup = writetup_index; state->readtup = readtup_index; state->indexRel = indexRel; state->cmpScanKey = _bt_mkscankey_nodata(indexRel); create_mksort_context( &state->mkctxt, state->nKeys, NULL, NULL, NULL, state->cmpScanKey, tupsort_fetch_datum_itup, freetup_index, tupdesc, 0, 0); state->mkctxt.enforceUnique = enforceUnique; state->mkctxt.indexname = RelationGetRelationName(indexRel); state->mkctxt.indexRel = indexRel; MemoryContextSwitchTo(oldcontext); return state; } Tuplesortstate_mk * tuplesort_begin_datum_mk(ScanState *ss, Oid datumType, Oid sortOperator, bool nullsFirstFlag, int workMem, bool randomAccess) { Tuplesortstate_mk *state = tuplesort_begin_common(ss, workMem, randomAccess, true); MemoryContext oldcontext; int16 typlen; bool typbyval; oldcontext = MemoryContextSwitchTo(state->sortcontext); if (trace_sort) PG_TRACE3(tuplesort__begin, datumType, workMem, randomAccess); state->nKeys = 1; /* always a one-column sort */ state->copytup = copytup_datum; state->writetup = writetup_datum; state->readtup = readtup_datum; state->datumType = datumType; /* lookup necessary attributes of the datum type */ get_typlenbyval(datumType, &typlen, &typbyval); state->datumTypeLen = typlen; state->datumTypeByVal = typbyval; state->sortOperator = sortOperator; state->cmpScanKey = NULL; create_mksort_context( &state->mkctxt, 1, NULL, &sortOperator, &nullsFirstFlag, NULL, NULL, /* tupsort_prepare_datum, */ typbyval ? freetup_noop : freetup_datum, NULL, typbyval, typlen); MemoryContextSwitchTo(oldcontext); return state; } /* * tuplesort_set_bound * * Advise tuplesort that at most the first N result tuples are required. * * Must be called before inserting any tuples. (Actually, we could allow it * as long as the sort hasn't spilled to disk, but there seems no need for * delayed calls at the moment.) * * This is a hint only. The tuplesort may still return more tuples than * requested. */ void tuplesort_set_bound_mk(Tuplesortstate_mk *state, int64 bound) { Assert(!state->mkctxt.bounded); #ifdef DEBUG_BOUNDED_SORT /* Honor GUC setting that disables the feature (for easy testing) */ if (!optimize_bounded_sort) return; #endif /* We want to be able to compute bound * 2, so limit the setting */ if (bound > (int64) (INT_MAX / 2)) return; state->mkctxt.bounded = true; state->mkctxt.bound = (int) bound; state->mkctxt.limitmask = -1; } /* * tuplesort_end * * Release resources and clean up. * * NOTE: after calling this, any pointers returned by tuplesort_getXXX are * pointing to garbage. Be careful not to attempt to use or free such * pointers afterwards! */ void tuplesort_end_mk(Tuplesortstate_mk *state) { long spaceUsed; if (state->tapeset) spaceUsed = LogicalTapeSetBlocks(state->tapeset) * (BLCKSZ / 1024); else spaceUsed = (MemoryContextGetCurrentSpace(state->sortcontext) + 1024) / 1024; /* * Call before state->tapeset is closed. */ tuplesort_finalize_stats_mk(state); /* * Delete temporary "tape" files, if any. * * Note: want to include this in reported total cost of sort, hence need * for two #ifdef TRACE_SORT sections. */ if (state->tapeset) { LogicalTapeSetClose(state->tapeset, state->work_set); state->tapeset = NULL; if (state->tapeset_state_file) { workfile_mgr_close_file(state->work_set, state->tapeset_state_file); } } if (state->work_set) { workfile_mgr_close_set(state->work_set); } if (trace_sort) PG_TRACE2(tuplesort__end, state->tapeset ? 1 : 0, spaceUsed); /* * Free the per-sort memory context, thereby releasing all working memory, * including the Tuplesortstate_mk struct itself. */ MemoryContextDelete(state->sortcontext); } /* * tuplesort_finalize_stats_mk * * Finalize the EXPLAIN ANALYZE stats. */ void tuplesort_finalize_stats_mk(Tuplesortstate_mk *state) { if (state->instrument && !state->statsFinalized) { Size maxSpaceUsedOnSort = MemoryContextGetPeakSpace(state->sortcontext); /* Report executor memory used by our memory context. */ state->instrument->execmemused += (double) maxSpaceUsedOnSort; if (state->instrument->workmemused < maxSpaceUsedOnSort) { state->instrument->workmemused = maxSpaceUsedOnSort; } if (state->numTuplesInMem < state->totalNumTuples) { uint64 mem_for_metadata = sizeof(Tuplesortstate_mk) + state->arraySizeBeforeSpill * sizeof(MKEntry); double tupleRatio = ((double) state->totalNumTuples) / ((double) state->numTuplesInMem); /* * The memwanted is summed up of the following: (1) metadata (2) * the array size (3) the prorated number of bytes for all tuples, * estimated from the memUsedBeforeSpill. Note that because of our * memory allocation algorithm, the used memory for tuples may be * much larger than the actual bytes needed for tuples. (4) the * prorated number of bytes for extra space needed. */ uint64 memwanted = sizeof(Tuplesortstate_mk) /* (1) */ + state->totalNumTuples * sizeof(MKEntry) /* (2) */ + (uint64) (tupleRatio * (double) (state->memUsedBeforeSpill - mem_for_metadata)) /* (3) */ + (uint64) (tupleRatio * (double) state->mkctxt.estimatedExtraForPrep) /* (4) */ ; state->instrument->workmemwanted = Max(state->instrument->workmemwanted, memwanted); } state->statsFinalized = true; tuplesort_get_stats_mk(state, &state->instrument->sortMethod, &state->instrument->sortSpaceType, &state->instrument->sortSpaceUsed); } } /* * tuplesort_set_instrument * * May be called after tuplesort_begin_xxx() to enable reporting of * statistics and events for EXPLAIN ANALYZE. * * The 'instr' and 'explainbuf' ptrs are retained in the 'state' object for * possible use anytime during the sort, up to and including tuplesort_end(). * The caller must ensure that the referenced objects remain allocated and * valid for the life of the Tuplesortstate_mk object; or if they are to be * freed early, disconnect them by calling again with NULL pointers. */ void tuplesort_set_instrument_mk(Tuplesortstate_mk *state, struct Instrumentation *instrument, struct StringInfoData *explainbuf) { state->instrument = instrument; state->explainbuf = explainbuf; } /* tuplesort_set_instrument */ /* * Accept one tuple while collecting input data for sort. * * Note that the input data is always copied; the caller need not save it. */ void tuplesort_puttupleslot_mk(Tuplesortstate_mk *state, TupleTableSlot *slot) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); MKEntry e; mke_blank(&e); COPYTUP(state, &e, (void *) slot); puttuple_common(state, &e); MemoryContextSwitchTo(oldcontext); } /* * Accept one index tuple while collecting input data for sort. * * Note that the input tuple is always copied; the caller need not save it. */ void tuplesort_putindextuple_mk(Tuplesortstate_mk *state, IndexTuple tuple) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); MKEntry e; mke_blank(&e); COPYTUP(state, &e, (void *) tuple); puttuple_common(state, &e); MemoryContextSwitchTo(oldcontext); } /* * Accept one Datum while collecting input data for sort. * * If the Datum is pass-by-ref type, the value will be copied. */ void tuplesort_putdatum_mk(Tuplesortstate_mk *state, Datum val, bool isNull) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); MKEntry e; mke_blank(&e); /* * If it's a pass-by-reference value, copy it into memory we control, and * decrease availMem. Then call the common code. */ if (isNull || state->datumTypeByVal) { e.d = val; if (isNull) mke_set_null(&e, state->nullfirst); else mke_set_not_null(&e); } else { mke_set_not_null(&e); e.d = datumCopy(val, false, state->datumTypeLen); state->totalTupleBytes += state->datumTypeLen; } puttuple_common(state, &e); MemoryContextSwitchTo(oldcontext); } /* * grow_unsorted_array * Grow the unsorted array to allow more entries to be inserted later. * If there are no enough memory available for the growth, this function * returns false. Otherwsie, returns true. */ static bool grow_unsorted_array(Tuplesortstate_mk *state) { /* * We want to grow the array twice as large as the previous one. However, * when we are close to the memory limit, we do not want to do so. * Otherwise, too much memory got allocated for the metadata, not to the * tuple itself. We estimate the maximum number of entries that is * possible under the current memory limit by considering both metadata * and tuple size. */ if (state->memAllowed < MemoryContextGetCurrentSpace(state->sortcontext)) return false; uint64 availMem = state->memAllowed - MemoryContextGetCurrentSpace(state->sortcontext); uint64 avgTupSize = (uint64) (((double) state->totalTupleBytes) / ((double) state->totalNumTuples)); uint64 avgExtraForPrep = (uint64) (((double) state->mkctxt.estimatedExtraForPrep) / ((double) state->totalNumTuples)); if ((availMem / (sizeof(MKEntry) + avgTupSize + avgExtraForPrep)) == 0) return false; int maxNumEntries = state->entry_allocsize + (availMem / (sizeof(MKEntry) + avgTupSize + avgExtraForPrep)); int newNumEntries = Min(maxNumEntries, state->entry_allocsize * 2); state->entries = (MKEntry *) repalloc(state->entries, newNumEntries * sizeof(MKEntry)); for (int entryNo = state->entry_allocsize; entryNo < newNumEntries; entryNo++) mke_blank(state->entries + entryNo); state->entry_allocsize = newNumEntries; return true; } /* * Shared code for tuple and datum cases. */ static void puttuple_common(Tuplesortstate_mk *state, MKEntry *e) { Assert(is_under_sort_or_exec_ctxt(state)); state->totalNumTuples++; if (state->gpmon_pkt) Gpmon_Incr_Rows_In(state->gpmon_pkt); bool growSucceed = true; switch (state->status) { case TSS_INITIAL: /* * Save the tuple into the unsorted array. First, grow the array * as needed. Note that we try to grow the array when there is * still one free slot remaining --- if we fail, there'll still be * room to store the incoming tuple, and then we'll switch to * tape-based operation. */ if (!state->mkheap && state->entry_count >= state->entry_allocsize - 1) { growSucceed = grow_unsorted_array(state); } /* full sort? */ if (!state->mkctxt.bounded) { tuplesort_inmem_nolimit_insert(state, e); } else { /* Limit sort insert */ tuplesort_inmem_limit_insert(state, e); } /* If out of work_mem, switch to diskmode */ if (!growSucceed) { if (state->mkheap != NULL) { /* * Corner case. LIMIT == amount of entries in memory. In * this case, we failed to grow array, but we just created * the heap. No need to spill in this case, we'll just use * the in-memory heap. */ Assert(state->mkctxt.bounded); Assert(state->numTuplesInMem == state->mkheap->count); } else { Assert(state->mkheap == NULL); Assert(state->entry_count > 0); state->arraySizeBeforeSpill = state->entry_allocsize; state->memUsedBeforeSpill = MemoryContextGetPeakSpace(state->sortcontext); inittapes_mk(state, is_sortstate_rwfile(state) ? state->tapeset_file_prefix : NULL); Assert(state->status == TSS_BUILDRUNS); } if (state->instrument) { state->instrument->workfileCreated = true; } } break; case TSS_BUILDRUNS: /* * Insert the tuple into the heap */ Assert(state->mkheap); tuplesort_heap_insert(state, e); break; default: elog(ERROR, "invalid tuplesort state"); break; } } /* * All tuples have been provided; finish the sort. */ void tuplesort_performsort_mk(Tuplesortstate_mk *state) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); if (trace_sort) PG_TRACE(tuplesort__perform__sort); switch (state->status) { case TSS_INITIAL: /* * We were able to accumulate all the tuples within the allowed * amount of memory. Just qsort 'em and we're done. */ if (!state->mkctxt.bounded) mk_qsort(state->entries, state->entry_count, &state->mkctxt); else tuplesort_limit_sort(state); state->pos.current = 0; state->pos.eof_reached = false; state->pos.markpos.mempos = 0; state->pos.markpos_eof = false; state->status = TSS_SORTEDINMEM; if (state->mkctxt.bounded) { state->mkctxt.boundUsed = true; } /* Not shareinput sort, we are done. */ if (!is_sortstate_rwfile(state)) break; /* Shareinput sort, need to put this stuff onto disk */ inittapes_mk(state, state->tapeset_file_prefix); /* Fall through */ case TSS_BUILDRUNS: #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, "Done building runs. Mem peak is now %ld", (long) MemoryContextGetPeakSpace(state->sortcontext)); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ dumptuples_mk(state, true); #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, "Done tuple dump. Mem peak is now %ld", (long) MemoryContextGetPeakSpace(state->sortcontext)); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ HOLD_INTERRUPTS(); /* * MPP-18288: Do not change this log message, it is used to test * mksort query cancellation */ elog(DEBUG1, "ExecSort: mksort starting merge runs >>======== "); RESUME_INTERRUPTS(); mergeruns(state); HOLD_INTERRUPTS(); /* * MPP-18288: Do not change this log message, it is used to test * mksort query cancellation */ elog(DEBUG1, "ExecSort: mksort finished merge runs ++++++++>> "); RESUME_INTERRUPTS(); state->pos.eof_reached = false; state->pos.markpos.tapepos.blkNum = 0; state->pos.markpos.tapepos.offset = 0; state->pos.markpos_eof = false; break; default: elog(ERROR, "Invalid tuplesort state"); break; } MemoryContextSwitchTo(oldcontext); } void tuplesort_flush_mk(Tuplesortstate_mk *state) { Assert(state->status == TSS_SORTEDONTAPE); Assert(state->tapeset && state->tapeset_state_file); Assert(state->pos.cur_work_tape == NULL); elog(gp_workfile_caching_loglevel, "tuplesort_mk: writing logical tape state to file"); LogicalTapeFlush(state->tapeset, state->result_tape, state->tapeset_state_file); ExecWorkFile_Flush(state->tapeset_state_file); } /* * Internal routine to fetch the next tuple in either forward or back * direction into *stup. Returns FALSE if no more tuples. * If *should_free is set, the caller must pfree stup.tuple when done with it. */ static bool tuplesort_gettuple_common_pos(Tuplesortstate_mk *state, TuplesortPos_mk *pos, bool forward, MKEntry *e, bool *should_free) { uint32 tuplen; LogicalTape *work_tape; bool fOK; Assert(is_under_sort_or_exec_ctxt(state)); /* * No output if we are told to finish execution. */ if (QueryFinishPending) { *should_free = false; return false; } switch (state->status) { case TSS_SORTEDINMEM: Assert(forward || state->randomAccess); *should_free = false; if (forward) { if (state->mkctxt.unique) { /** * request to skip duplicates. qsort has already replaced all but one of each * values with empty so skip the empties * When limit heap sort was used, the limit heap sort should have done this */ while (pos->current < state->entry_count && mke_is_empty(&state->entries[pos->current])) { pos->current++; } } if (pos->current < state->entry_count) { *e = state->entries[pos->current]; pos->current++; return true; } pos->eof_reached = true; return false; } else { if (pos->current <= 0) return false; /* * if all tuples are fetched already then we return last * tuple, else - tuple before last returned. */ if (pos->eof_reached) pos->eof_reached = false; else { pos->current--; /* pos->current points to one above * the last returned tuple */ if (pos->current <= 0) return false; } if (state->mkctxt.unique) { /** * request to skip duplicates. qsort has already replaced all but one of each * values with empty so skip the empties * When limit heap sort was used, the limit heap sort should have done this */ while (pos->current - 1 >= 0 && mke_is_empty(&state->entries[pos->current - 1])) { pos->current--; } if (pos->current <= 0) return false; } *e = state->entries[pos->current - 1]; return true; } break; case TSS_SORTEDONTAPE: AssertEquivalent((pos == &state->pos), (pos->cur_work_tape == NULL)); Assert(forward || state->randomAccess); *should_free = true; work_tape = pos->cur_work_tape == NULL ? state->result_tape : pos->cur_work_tape; if (forward) { if (pos->eof_reached) return false; if ((tuplen = getlen(state, pos, work_tape, true)) != 0) { READTUP(state, pos, e, work_tape, tuplen); return true; } else { pos->eof_reached = true; return false; } } /* * Backward. * * if all tuples are fetched already then we return last tuple, * else - tuple before last returned. */ /* * Seek position is pointing just past the zero tuplen at the end * of file; back up to fetch last tuple's ending length word. If * seek fails we must have a completely empty file. */ fOK = LogicalTapeBackspace(state->tapeset, work_tape, 2 * sizeof(uint32)); if (!fOK) return false; if (pos->eof_reached) { pos->eof_reached = false; } else { tuplen = getlen(state, pos, work_tape, false); /* * Back up to get ending length word of tuple before it. */ fOK = LogicalTapeBackspace(state->tapeset, work_tape, tuplen + 2 * sizeof(uint32)); if (!fOK) { /* * If that fails, presumably the prev tuple is the first * in the file. Back up so that it becomes next to read * in forward direction (not obviously right, but that is * what in-memory case does). */ fOK = LogicalTapeBackspace(state->tapeset, work_tape, tuplen + 2 * sizeof(uint32)); if (!fOK) elog(ERROR, "bogus tuple length in backward scan"); return false; } } tuplen = getlen(state, pos, work_tape, false); /* * Now we have the length of the prior tuple, back up and read it. * Note: READTUP expects we are positioned after the initial * length word of the tuple, so back up to that point. */ fOK = LogicalTapeBackspace(state->tapeset, work_tape, tuplen); if (!fOK) elog(ERROR, "bogus tuple length in backward scan"); READTUP(state, pos, e, work_tape, tuplen); return true; case TSS_FINALMERGE: Assert(forward); Assert(pos == &state->pos && pos->cur_work_tape == NULL); *should_free = true; mkheap_putAndGet(state->mkheap, e); return !mke_is_empty(e); default: elog(ERROR, "invalid tuplesort state"); return false; /* keep compiler quiet */ } } /* * Fetch the next tuple in either forward or back direction. * If successful, put tuple in slot and return TRUE; else, clear the slot * and return FALSE. */ bool tuplesort_gettupleslot_mk(Tuplesortstate_mk *state, bool forward, TupleTableSlot *slot) { return tuplesort_gettupleslot_pos_mk(state, &state->pos, forward, slot, state->sortcontext); } bool tuplesort_gettupleslot_pos_mk(Tuplesortstate_mk *state, TuplesortPos_mk *pos, bool forward, TupleTableSlot *slot, MemoryContext mcontext) { MemoryContext oldcontext = MemoryContextSwitchTo(mcontext); MKEntry e; bool should_free = false; bool fOK; mke_set_empty(&e); fOK = tuplesort_gettuple_common_pos(state, pos, forward, &e, &should_free); MemoryContextSwitchTo(oldcontext); if (fOK) { Assert(!mke_is_empty(&e)); ExecStoreMinimalTuple(e.ptr, slot, should_free); #ifdef USE_ASSERT_CHECKING if (should_free && state->mkheap != NULL && state->mkheap->count > 0) { Assert(e.ptr != NULL && (e.ptr != state->mkheap->lvtops->ptr)); } #endif if (state->gpmon_pkt) Gpmon_Incr_Rows_Out(state->gpmon_pkt); return true; } ExecClearTuple(slot); return false; } /* * Fetch the next index tuple in either forward or back direction. * Returns NULL if no more tuples. If *should_free is set, the * caller must pfree the returned tuple when done with it. */ IndexTuple tuplesort_getindextuple_mk(Tuplesortstate_mk *state, bool forward, bool *should_free) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); MKEntry e; bool fOK = tuplesort_gettuple_common_pos(state, &state->pos, forward, &e, should_free); MemoryContextSwitchTo(oldcontext); if (fOK) return (IndexTuple) (e.ptr); return NULL; } /* * Fetch the next Datum in either forward or back direction. * Returns FALSE if no more datums. * * If the Datum is pass-by-ref type, the returned value is freshly palloc'd * and is now owned by the caller. */ bool tuplesort_getdatum_mk(Tuplesortstate_mk *state, bool forward, Datum *val, bool *isNull) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); MKEntry e; bool should_free = false; bool fOK = tuplesort_gettuple_common_pos(state, &state->pos, forward, &e, &should_free); if (fOK) { *isNull = mke_is_null(&e); if (*isNull || state->datumTypeByVal || should_free) *val = e.d; else *val = datumCopy(e.d, false, state->datumTypeLen); } MemoryContextSwitchTo(oldcontext); return fOK; } /* * inittapes - initialize for tape sorting. * * This is called only if we have found we don't have room to sort in memory. */ void inittapes_mk(Tuplesortstate_mk *state, const char *rwfile_prefix) { int maxTapes; int j; long tapeSpace; Assert(is_under_sort_or_exec_ctxt(state)); /* Compute number of tapes to use: merge order plus 1 */ maxTapes = tuplesort_merge_order(state->memAllowed) + 1; #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, "Spilling after %d", (int) state->entry_count); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ /* * We must have at least 2*maxTapes slots in the memtuples[] array, else * we'd not have room for merge heap plus preread. It seems unlikely that * this case would ever occur, but be safe. */ maxTapes = Min(maxTapes, state->entry_count / 2); maxTapes = Max(maxTapes, 1); #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, " maxtapes %d Mem peak is now %ld", maxTapes, (long) MemoryContextGetPeakSpace(state->sortcontext)); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ /* * XXX XXX: with losers, only need 1x slots because we don't need a merge * heap */ state->maxTapes = maxTapes; state->tapeRange = maxTapes - 1; if (trace_sort) PG_TRACE1(tuplesort__switch__external, maxTapes); /* * Decrease availMem to reflect the space needed for tape buffers; but * don't decrease it to the point that we have no room for tuples. (That * case is only likely to occur if sorting pass-by-value Datums; in all * other scenarios the memtuples[] array is unlikely to occupy more than * half of allowedMem. In the pass-by-value case it's not important to * account for tuple space, so we don't care if LACKMEM becomes * inaccurate.) */ tapeSpace = maxTapes * TAPE_BUFFER_OVERHEAD; Assert(state->work_set == NULL); /* * Create the tape set and allocate the per-tape data arrays. */ if (!rwfile_prefix) { state->work_set = workfile_mgr_create_set(BUFFILE, false /* can_be_reused */ , NULL /* ps */ ); state->tapeset_state_file = workfile_mgr_create_fileno(state->work_set, WORKFILE_NUM_MKSORT_METADATA); ExecWorkFile *tape_file = workfile_mgr_create_fileno(state->work_set, WORKFILE_NUM_MKSORT_TAPESET); state->tapeset = LogicalTapeSetCreate_File(tape_file, maxTapes); } else { /* * We are shared XSLICE, use given prefix to create files so that * consumers can find them */ ExecWorkFile *tape_file = ExecWorkFile_Create(rwfile_prefix, BUFFILE, true /* delOnClose */ , 0 /* compressType */ ); state->tapeset = LogicalTapeSetCreate_File(tape_file, maxTapes); } state->mergeactive = (bool *) palloc0(maxTapes * sizeof(bool)); state->mergenext = (int *) palloc0(maxTapes * sizeof(int)); state->mergelast = (int *) palloc0(maxTapes * sizeof(int)); state->mergeavailslots = (int *) palloc0(maxTapes * sizeof(int)); state->mergeavailmem = (long *) palloc0(maxTapes * sizeof(long)); state->tp_fib = (int *) palloc0(maxTapes * sizeof(int)); state->tp_runs = (int *) palloc0(maxTapes * sizeof(int)); state->tp_dummy = (int *) palloc0(maxTapes * sizeof(int)); state->tp_tapenum = (int *) palloc0(maxTapes * sizeof(int)); /* * Convert the unsorted contents of memtuples[] into a heap. Each tuple is * marked as belonging to run number zero. * * NOTE: we pass false for checkIndex since there's no point in comparing * indexes in this step, even though we do intend the indexes to be part * of the sort key... */ Assert(state->mkheap == NULL); Assert(state->status == TSS_INITIAL || state->status == TSS_SORTEDINMEM); #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, " about to make heap mem peak is now %ld", (long) MemoryContextGetPeakSpace(CurrentMemoryContext)); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ if (state->status == TSS_INITIAL) { /* * We are now building heap from array for run-building using * replacement-selection algorithm. Such run-building heap need to be * a MIN-HEAP, but for limit sorting, we use a MAX-HEAP. The way we * convert MIN-HEAP to MAX-HEAP is by setting the limitmask to -1, and * then using the limitmask in mkheap_compare() in tuplesort_mkheap.c. * So, to restore the MAX-HEAP to a MIN-HEAP, we can just revert the * limitmask to 0. This is needed for MPP-19310 and MPP-19857 */ state->mkctxt.limitmask = 0; state->mkheap = mkheap_from_array(state->entries, state->entry_allocsize, state->entry_count, &state->mkctxt); state->entries = NULL; state->entry_allocsize = 0; state->entry_count = 0; } state->currentRun = 0; /* * Initialize variables of Algorithm D (step D1). */ for (j = 0; j < maxTapes; j++) { state->tp_fib[j] = 1; state->tp_runs[j] = 0; state->tp_dummy[j] = 1; state->tp_tapenum[j] = j; } state->tp_fib[state->tapeRange] = 0; state->tp_dummy[state->tapeRange] = 0; state->Level = 1; state->destTape = 0; state->status = TSS_BUILDRUNS; #ifdef PRINT_SPILL_AND_MEMORY_MESSAGES elog(INFO, " build-run ready mem peak is now %ld", (long) MemoryContextGetPeakSpace(state->sortcontext)); #endif /* // PRINT_SPILL_AND_MEMORY_MESSAGES */ } /* * selectnewtape -- select new tape for new initial run. * * This is called after finishing a run when we know another run * must be started. This implements steps D3, D4 of Algorithm D. */ static void selectnewtape_mk(Tuplesortstate_mk *state) { int j; int a; /* Step D3: advance j (destTape) */ if (state->tp_dummy[state->destTape] < state->tp_dummy[state->destTape + 1]) { state->destTape++; return; } if (state->tp_dummy[state->destTape] != 0) { state->destTape = 0; return; } /* Step D4: increase level */ state->Level++; a = state->tp_fib[0]; for (j = 0; j < state->tapeRange; j++) { state->tp_dummy[j] = a + state->tp_fib[j + 1] - state->tp_fib[j]; state->tp_fib[j] = a + state->tp_fib[j + 1]; } state->destTape = 0; } /* * mergeruns -- merge all the completed initial runs. * * This implements steps D5, D6 of Algorithm D. All input data has * already been written to initial runs on tape (see dumptuples). */ static void mergeruns(Tuplesortstate_mk *state) { int tapenum, svTape, svRuns, svDummy; LogicalTape *lt = NULL; Assert(state->status == TSS_BUILDRUNS); #ifdef FAULT_INJECTOR /* * MPP-18288: We're injecting an interrupt here. We have to hold * interrupts while we're injecting it to make sure the interrupt is not * handled within the fault injector itself. */ HOLD_INTERRUPTS(); FaultInjector_InjectFaultIfSet( ExecSortMKSortMergeRuns, DDLNotSpecified, "", //databaseName ""); //tableName RESUME_INTERRUPTS(); #endif if (QueryFinishPending) { state->status = TSS_SORTEDONTAPE; return; } /* * If we produced only one initial run (quite likely if the total data * volume is between 1X and 2X workMem), we can just use that tape as the * finished output, rather than doing a useless merge. (This obvious * optimization is not in Knuth's algorithm.) */ if (state->currentRun == 1) { state->result_tape = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->destTape]); /* must freeze and rewind the finished output tape */ LogicalTapeFreeze(state->tapeset, state->result_tape); state->status = TSS_SORTEDONTAPE; return; } /* End of step D2: rewind all output tapes to prepare for merging */ for (tapenum = 0; tapenum < state->tapeRange; tapenum++) { lt = LogicalTapeSetGetTape(state->tapeset, tapenum); LogicalTapeRewind(state->tapeset, lt, false); } for (;;) { /* * At this point we know that tape[T] is empty. If there's just one * (real or dummy) run left on each input tape, then only one merge * pass remains. If we don't have to produce a materialized sorted * tape, we can stop at this point and do the final merge on-the-fly. */ if (!state->randomAccess) { bool allOneRun = true; Assert(state->tp_runs[state->tapeRange] == 0); for (tapenum = 0; tapenum < state->tapeRange; tapenum++) { if (state->tp_runs[tapenum] + state->tp_dummy[tapenum] != 1) { allOneRun = false; break; } } if (allOneRun) { /* Tell logtape.c we won't be writing anymore */ LogicalTapeSetForgetFreeSpace(state->tapeset); /* Initialize for the final merge pass */ beginmerge(state); state->status = TSS_FINALMERGE; return; } } /* Step D5: merge runs onto tape[T] until tape[P] is empty */ while (state->tp_runs[state->tapeRange - 1] || state->tp_dummy[state->tapeRange - 1]) { bool allDummy = true; /* * We stop processing the input if we are asked to finish. * Although we haven't finished on each tape yet, we will safely * clean them up. Make sure we don't get into this code path * again. */ if (QueryFinishPending) { /* pretend we are done */ state->status = TSS_SORTEDONTAPE; return; } for (tapenum = 0; tapenum < state->tapeRange; tapenum++) { if (state->tp_dummy[tapenum] == 0) { allDummy = false; break; } } if (allDummy) { state->tp_dummy[state->tapeRange]++; for (tapenum = 0; tapenum < state->tapeRange; tapenum++) state->tp_dummy[tapenum]--; } else mergeonerun_mk(state); } /* Step D6: decrease level */ if (--state->Level == 0) break; /* rewind output tape T to use as new input */ lt = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->tapeRange]); LogicalTapeRewind(state->tapeset, lt, false); /* rewind used-up input tape P, and prepare it for write pass */ lt = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->tapeRange - 1]); LogicalTapeRewind(state->tapeset, lt, true); state->tp_runs[state->tapeRange - 1] = 0; /* * reassign tape units per step D6; note we no longer care about A[] */ svTape = state->tp_tapenum[state->tapeRange]; svDummy = state->tp_dummy[state->tapeRange]; svRuns = state->tp_runs[state->tapeRange]; for (tapenum = state->tapeRange; tapenum > 0; tapenum--) { state->tp_tapenum[tapenum] = state->tp_tapenum[tapenum - 1]; state->tp_dummy[tapenum] = state->tp_dummy[tapenum - 1]; state->tp_runs[tapenum] = state->tp_runs[tapenum - 1]; } state->tp_tapenum[0] = svTape; state->tp_dummy[0] = svDummy; state->tp_runs[0] = svRuns; } /* * Done. Knuth says that the result is on TAPE[1], but since we exited * the loop without performing the last iteration of step D6, we have not * rearranged the tape unit assignment, and therefore the result is on * TAPE[T]. We need to do it this way so that we can freeze the final * output tape while rewinding it. The last iteration of step D6 would be * a waste of cycles anyway... */ state->result_tape = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->tapeRange]); LogicalTapeFreeze(state->tapeset, state->result_tape); state->status = TSS_SORTEDONTAPE; } /* * Merge one run from each input tape, except ones with dummy runs. * * This is the inner loop of Algorithm D step D5. We know that the * output tape is TAPE[T]. */ void mergeonerun_mk(Tuplesortstate_mk *state) { int destTape = state->tp_tapenum[state->tapeRange]; MKEntry e; LogicalTape *lt = NULL; /* * Start the merge by loading one tuple from each active source tape into * the heap. We can also decrease the input run/dummy run counts. */ beginmerge(state); /* * Execute merge by repeatedly extracting lowest tuple in heap, writing it * out, and replacing it with next tuple from same tape (if there is * another one). */ lt = LogicalTapeSetGetTape(state->tapeset, destTape); Assert(state->mkheap); while (mkheap_putAndGet(state->mkheap, &e) >= 0) WRITETUP(state, lt, &e); /* * When the heap empties, we're done. Write an end-of-run marker on the * output tape, and increment its count of real runs. */ markrunend(state, destTape); state->tp_runs[state->tapeRange]++; if (trace_sort) PG_TRACE1(tuplesort__mergeonerun, state->activeTapes); } static bool tupsort_preread(TupsortMergeReadCtxt * ctxt) { uint32 tuplen; Assert(ctxt->mem_allowed > 0); if (!ctxt->pos.cur_work_tape || ctxt->pos.eof_reached) return false; ctxt->mem_used = 0; Assert(ctxt->p && ctxt->allocsz > 0); Assert(ctxt->mem_allowed > 0); for (ctxt->cnt = 0; ctxt->cnt < ctxt->allocsz && ctxt->mem_used < ctxt->mem_allowed; ++ctxt->cnt) { tuplen = getlen(ctxt->tsstate, &ctxt->pos, ctxt->pos.cur_work_tape, true); if (tuplen != 0) { MKEntry *e = ctxt->p + ctxt->cnt; READTUP(ctxt->tsstate, &ctxt->pos, e, ctxt->pos.cur_work_tape, tuplen); ctxt->mem_used += tuplen; } else { ctxt->pos.eof_reached = true; break; } } ctxt->cur = 0; return ctxt->cnt > ctxt->cur; } static bool tupsort_mergeread(void *pvctxt, MKEntry *e) { TupsortMergeReadCtxt *ctxt = (TupsortMergeReadCtxt *) pvctxt; Assert(ctxt->mem_allowed > 0); if (ctxt->cur < ctxt->cnt) { *e = ctxt->p[ctxt->cur++]; return true; } if (!tupsort_preread(ctxt)) return false; Assert(ctxt->cur == 0 && ctxt->cnt > 0); *e = ctxt->p[ctxt->cur++]; return true; } /* * beginmerge - initialize for a merge pass * * We decrease the counts of real and dummy runs for each tape, and mark * which tapes contain active input runs in mergeactive[]. Then, load * as many tuples as we can from each active input tape, and finally * fill the merge heap with the first tuple from each active tape. */ static void beginmerge(Tuplesortstate_mk *state) { int activeTapes; int tapenum; int srcTape; int totalSlots; int slotsPerTape; int64 spacePerTape; int i; MemoryContext oldctxt; /* Heap should be empty here */ Assert(mkheap_empty(state->mkheap)); /* Adjust run counts and mark the active tapes */ memset(state->mergeactive, 0, state->maxTapes * sizeof(*state->mergeactive)); activeTapes = 0; for (tapenum = 0; tapenum < state->tapeRange; tapenum++) { if (state->tp_dummy[tapenum] > 0) state->tp_dummy[tapenum]--; else { Assert(state->tp_runs[tapenum] > 0); state->tp_runs[tapenum]--; srcTape = state->tp_tapenum[tapenum]; state->mergeactive[srcTape] = true; activeTapes++; } } state->activeTapes = activeTapes; /* Clear merge-pass state variables */ memset(state->mergenext, 0, state->maxTapes * sizeof(*state->mergenext)); memset(state->mergelast, 0, state->maxTapes * sizeof(*state->mergelast)); state->mergefreelist = 0; /* nothing in the freelist */ state->mergefirstfree = activeTapes; /* 1st slot avail for preread */ /* * Initialize space allocation to let each active input tape have an equal * share of preread space. */ Assert(activeTapes > 0); totalSlots = (state->mkheap == NULL) ? state->entry_allocsize : state->mkheap->alloc_size; slotsPerTape = (totalSlots - state->mergefirstfree) / activeTapes; slotsPerTape = Max(slotsPerTape, 128); spacePerTape = state->memAllowed / activeTapes; oldctxt = MemoryContextSwitchTo(state->sortcontext); if (state->mkheap) { mkheap_destroy(state->mkheap); state->mkheap = NULL; } if (state->mkhreader) { Assert(state->mkhreader_ctxt); for (i = 0; i < state->mkhreader_allocsize; ++i) { TupsortMergeReadCtxt *mkhr_ctxt = state->mkhreader_ctxt + i; AssertEquivalent(mkhr_ctxt->p != NULL, mkhr_ctxt->allocsz > 0); if (mkhr_ctxt->p) pfree(mkhr_ctxt->p); } pfree(state->mkhreader_ctxt); pfree(state->mkhreader); } state->mkhreader = palloc0(sizeof(MKHeapReader) * activeTapes); state->mkhreader_ctxt = palloc0(sizeof(TupsortMergeReadCtxt) * activeTapes); for (i = 0; i < activeTapes; ++i) { TupsortMergeReadCtxt *mkhr_ctxt = state->mkhreader_ctxt + i; state->mkhreader[i].reader = tupsort_mergeread; state->mkhreader[i].mkhr_ctxt = mkhr_ctxt; mkhr_ctxt->tsstate = state; } state->mkhreader_allocsize = activeTapes; for (i = 0, srcTape = 0; srcTape < state->maxTapes; srcTape++) { if (state->mergeactive[srcTape]) { TupsortMergeReadCtxt *mkhr_ctxt = state->mkhreader_ctxt + i; mkhr_ctxt->pos.cur_work_tape = LogicalTapeSetGetTape(state->tapeset, srcTape); mkhr_ctxt->pos.eof_reached = false; mkhr_ctxt->mem_allowed = spacePerTape; Assert(mkhr_ctxt->mem_allowed > 0); mkhr_ctxt->mem_used = 0; mkhr_ctxt->cur = 0; mkhr_ctxt->cnt = 0; Assert(mkhr_ctxt->p == NULL); Assert(slotsPerTape > 0); mkhr_ctxt->p = (MKEntry *) palloc(sizeof(MKEntry) * slotsPerTape); mkhr_ctxt->allocsz = slotsPerTape; ++i; } } Assert(i == activeTapes); state->mkheap = mkheap_from_reader(state->mkhreader, i, &state->mkctxt); Assert(state->mkheap); MemoryContextSwitchTo(oldctxt); } /* * dumptuples - remove tuples from heap and write to tape * * This is used during initial-run building, but not during merging. * * When alltuples = false, dump only enough tuples to get under the * availMem limit (and leave at least one tuple in the heap in any case, * since puttuple assumes it always has a tuple to compare to). We also * insist there be at least one free slot in the memtuples[] array. * * When alltuples = true, dump everything currently in memory. * (This case is only used at end of input data.) * * If we empty the heap, close out the current run and return (this should * only happen at end of input data). If we see that the tuple run number * at the top of the heap has changed, start a new run. */ void dumptuples_mk(Tuplesortstate_mk *state, bool alltuples) { int i; int bDumped = 0; LogicalTape *lt = NULL; MKEntry e; Assert(is_under_sort_or_exec_ctxt(state)); if (alltuples && !state->mkheap) { /* Dump a sorted array. Must be shared input that sends up here */ /* * ShareInput or sort: The sort may sort nothing, we still need to * handle it here */ if (state->entry_count != 0) { lt = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->destTape]); if (state->mkctxt.unique) { for (i = 0; i < state->entry_count; ++i) if (!mke_is_empty(&state->entries[i])) /* can be empty because * the qsort may have * marked duplicates */ WRITETUP(state, lt, &state->entries[i]); } else { for (i = 0; i < state->entry_count; ++i) WRITETUP(state, lt, &state->entries[i]); } } markrunend(state, state->tp_tapenum[state->destTape]); state->currentRun++; state->tp_runs[state->destTape]++; state->tp_dummy[state->destTape]--; /* per Alg D step D2 */ return; } /* OK. Normal case */ Assert(state->mkheap); while (1) { /* * Done if we heap is empty, or pretend so if we are told to finish * execution. */ if (mkheap_empty(state->mkheap) || QueryFinishPending) { markrunend(state, state->tp_tapenum[state->destTape]); state->currentRun++; state->tp_runs[state->destTape]++; state->tp_dummy[state->destTape]--; /* per Alg D step D2 */ break; } if (!bDumped) bDumped = 1; /* * Dump the heap's frontmost entry, and sift up to remove it from the * heap. */ Assert(!mkheap_empty(state->mkheap)); lt = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->destTape]); mke_set_empty(&e); mke_set_run(&e, state->currentRun + 1); mkheap_putAndGet(state->mkheap, &e); Assert(!mke_is_empty(&e)); WRITETUP(state, lt, &e); /* * If the heap is empty *or* top run number has changed, we've * finished the current run. */ if (mkheap_empty(state->mkheap) || !mkheap_run_match(state->mkheap, state->currentRun)) { #ifdef USE_ASSERT_CHECKING mkheap_verify_heap(state->mkheap, 0); #endif markrunend(state, state->tp_tapenum[state->destTape]); state->currentRun++; state->tp_runs[state->destTape]++; state->tp_dummy[state->destTape]--; /* per Alg D step D2 */ if (trace_sort) PG_TRACE3(tuplesort__dumptuples, state->entry_count, state->currentRun, state->destTape); /* * Done if heap is empty, else prepare for new run. */ if (mkheap_empty(state->mkheap)) break; Assert(mkheap_run_match(state->mkheap, state->currentRun)); selectnewtape_mk(state); } } if (state->gpmon_pkt) tuplesort_checksend_gpmonpkt(state->gpmon_pkt, state->gpmon_sort_tick); } /* * Put pos at the begining of the tuplesort. Create pos->work_tape if necessary */ void tuplesort_rescan_pos_mk(Tuplesortstate_mk *state, TuplesortPos_mk *pos) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); Assert(state->randomAccess); switch (state->status) { case TSS_SORTEDINMEM: pos->current = 0; pos->eof_reached = false; pos->markpos.mempos = 0; pos->markpos_eof = false; pos->cur_work_tape = NULL; break; case TSS_SORTEDONTAPE: if (NULL == state->result_tape) { Assert(pos->eof_reached); pos->markpos.tapepos.blkNum = 0L; pos->markpos.tapepos.offset = 0; pos->markpos_eof = true; break; } if (pos == &state->pos) { Assert(pos->cur_work_tape == NULL); LogicalTapeRewind(state->tapeset, state->result_tape, false); } else { if (pos->cur_work_tape == NULL) pos->cur_work_tape = state->result_tape; LogicalTapeRewind(state->tapeset, pos->cur_work_tape, false); } pos->eof_reached = false; pos->markpos.tapepos.blkNum = 0L; pos->markpos.tapepos.offset = 0; pos->markpos_eof = false; break; default: elog(ERROR, "invalid tuplesort state"); break; } MemoryContextSwitchTo(oldcontext); } /* * tuplesort_rescan - rewind and replay the scan */ void tuplesort_rescan_mk(Tuplesortstate_mk *state) { tuplesort_rescan_pos_mk(state, &state->pos); } /* * tuplesort_markpos - saves current position in the merged sort file */ void tuplesort_markpos_pos_mk(Tuplesortstate_mk *state, TuplesortPos_mk *pos) { LogicalTape *work_tape = NULL; MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); Assert(state->randomAccess); switch (state->status) { case TSS_SORTEDINMEM: pos->markpos.mempos = pos->current; pos->markpos_eof = pos->eof_reached; break; case TSS_SORTEDONTAPE: AssertEquivalent(pos == &state->pos, pos->cur_work_tape == NULL); work_tape = pos->cur_work_tape == NULL ? state->result_tape : pos->cur_work_tape; LogicalTapeTell(state->tapeset, work_tape, &pos->markpos.tapepos); pos->markpos_eof = pos->eof_reached; break; default: elog(ERROR, "invalid tuplesort state"); break; } MemoryContextSwitchTo(oldcontext); } void tuplesort_markpos_mk(Tuplesortstate_mk *state) { tuplesort_markpos_pos_mk(state, &state->pos); } /* * tuplesort_restorepos - restores current position in merged sort file to * last saved position */ void tuplesort_restorepos_pos_mk(Tuplesortstate_mk *state, TuplesortPos_mk *pos) { MemoryContext oldcontext = MemoryContextSwitchTo(state->sortcontext); Assert(state->randomAccess); switch (state->status) { case TSS_SORTEDINMEM: pos->current = pos->markpos.mempos; pos->eof_reached = pos->markpos_eof; break; case TSS_SORTEDONTAPE: AssertEquivalent(pos == &state->pos, pos->cur_work_tape == NULL); { LogicalTape *work_tape = pos->cur_work_tape == NULL ? state->result_tape : pos->cur_work_tape; bool fSeekOK = LogicalTapeSeek(state->tapeset, work_tape, &pos->markpos.tapepos); if (!fSeekOK) elog(ERROR, "tuplesort_restorepos failed"); pos->eof_reached = pos->markpos_eof; } break; default: elog(ERROR, "invalid tuplesort state"); break; } MemoryContextSwitchTo(oldcontext); } void tuplesort_restorepos_mk(Tuplesortstate_mk *state) { tuplesort_restorepos_pos_mk(state, &state->pos); } /* * tuplesort_get_stats_mk - extract summary statistics * * This can be called after tuplesort_performsort_mk() finishes to obtain * printable summary information about how the sort was performed. * spaceUsed is measured in kilobytes. */ static void tuplesort_get_stats_mk(Tuplesortstate_mk* state, const char **sortMethod, const char **spaceType, long *spaceUsed) { /* * Note: it might seem we should provide both memory and disk usage for a * disk-based sort. However, the current code doesn't track memory space * accurately once we have begun to return tuples to the caller (since we * don't account for pfree's the caller is expected to do), so we cannot * rely on availMem in a disk sort. This does not seem worth the overhead * to fix. Is it worth creating an API for the memory context code to * tell us how much is actually used in sortcontext? */ if (state->tapeset) { *spaceType = "Disk"; *spaceUsed = LogicalTapeSetBlocks(state->tapeset) * (BLCKSZ / 1024); } else { *spaceType = "Memory"; *spaceUsed = (MemoryContextGetCurrentSpace(state->sortcontext) + 1024) / 1024; } switch (state->status) { case TSS_SORTEDINMEM: if (state->mkctxt.boundUsed) *sortMethod = "top-N heapsort"; else *sortMethod = "quicksort"; break; case TSS_SORTEDONTAPE: *sortMethod = "external sort"; break; case TSS_FINALMERGE: *sortMethod = "external merge"; break; default: *sortMethod = "still in progress"; } return; } /* * Tape interface routines */ static uint32 getlen(Tuplesortstate_mk *state, TuplesortPos_mk *pos, LogicalTape *lt, bool eofOK) { uint32 len; size_t readSize; Assert(lt); readSize = LogicalTapeRead(state->tapeset, lt, (void *) &len, sizeof(len)); if (readSize != sizeof(len)) { Assert(!"Catch me"); elog(ERROR, "unexpected end of tape"); } if (len == 0 && !eofOK) elog(ERROR, "unexpected end of data"); return len; } static void markrunend(Tuplesortstate_mk *state, int tapenum) { uint32 len = 0; LogicalTape *lt = LogicalTapeSetGetTape(state->tapeset, tapenum); LogicalTapeWrite(state->tapeset, lt, (void *) &len, sizeof(len)); } /* * Inline-able copy of FunctionCall2() to save some cycles in sorting. */ static inline Datum myFunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2) { FunctionCallInfoData fcinfo; Datum result; InitFunctionCallInfoData(fcinfo, flinfo, 2, NULL, NULL); fcinfo.arg[0] = arg1; fcinfo.arg[1] = arg2; fcinfo.argnull[0] = false; fcinfo.argnull[1] = false; result = FunctionCallInvoke(&fcinfo); /* Check for null result, since caller is clearly not expecting one */ if (fcinfo.isnull) elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid); return result; } /* * Apply a sort function (by now converted to fmgr lookup form) * and return a 3-way comparison result. This takes care of handling * reverse-sort and NULLs-ordering properly. We assume that DESC and * NULLS_FIRST options are encoded in sk_flags the same way btree does it. */ static inline int32 inlineApplySortFunction(FmgrInfo *sortFunction, int sk_flags, Datum datum1, bool isNull1, Datum datum2, bool isNull2) { int32 compare; if (isNull1) { if (isNull2) compare = 0; /* NULL "=" NULL */ else if (sk_flags & SK_BT_NULLS_FIRST) compare = -1; /* NULL "<" NOT_NULL */ else compare = 1; /* NULL ">" NOT_NULL */ } else if (isNull2) { if (sk_flags & SK_BT_NULLS_FIRST) compare = 1; /* NOT_NULL ">" NULL */ else compare = -1; /* NOT_NULL "<" NULL */ } else { compare = DatumGetInt32(myFunctionCall2(sortFunction, datum1, datum2)); if (sk_flags & SK_BT_DESC) compare = -compare; } return compare; } static void copytup_heap(Tuplesortstate_mk *state, MKEntry *e, void *tup) { /* * We expect the passed "tup" to be a TupleTableSlot, and form a * MinimalTuple using the exported interface for that. */ TupleTableSlot *slot = (TupleTableSlot *) tup; slot_getallattrs(slot); e->ptr = (void *) memtuple_form_to(state->mt_bind, slot_get_values(slot), slot_get_isnull(slot), NULL, NULL, false ); state->totalTupleBytes += memtuple_get_size((MemTuple) e->ptr); Assert(state->mt_bind); } /* * Since MinimalTuple already has length in its first word, we don't need * to write that separately. */ static long writetup_heap(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e) { uint32 tuplen = memtuple_get_size(e->ptr); long ret = tuplen; LogicalTapeWrite(state->tapeset, lt, e->ptr, tuplen); if (state->randomAccess) /* need trailing length word? */ { LogicalTapeWrite(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); ret += sizeof(tuplen); } pfree(e->ptr); e->ptr = NULL; return ret; } static void freetup_heap(MKEntry *e) { pfree(e->ptr); e->ptr = NULL; } static void readtup_heap(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len) { uint32 tuplen; size_t readSize; Assert(is_under_sort_or_exec_ctxt(state)); MemSet(e, 0, sizeof(MKEntry)); e->ptr = palloc(memtuple_size_from_uint32(len)); memtuple_set_mtlen((MemTuple) e->ptr, len); Assert(lt); readSize = LogicalTapeRead(state->tapeset, lt, (void *) ((char *) e->ptr + sizeof(uint32)), memtuple_size_from_uint32(len) - sizeof(uint32)); if (readSize != (size_t) (memtuple_size_from_uint32(len) - sizeof(uint32))) elog(ERROR, "unexpected end of data"); if (state->randomAccess) /* need trailing length word? */ { readSize = LogicalTapeRead(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); if (readSize != sizeof(tuplen)) elog(ERROR, "unexpected end of data"); } /* * For shareinput on sort, the reader will not set mt_bind. In this case, * we will not call compare. */ AssertImply(!state->mt_bind, state->status == TSS_SORTEDONTAPE); } static void copytup_index(Tuplesortstate_mk *state, MKEntry *e, void *tup) { IndexTuple tuple = (IndexTuple) tup; uint32 tuplen = IndexTupleSize(tuple); /* copy the tuple into sort storage */ e->ptr = palloc(tuplen); memcpy(e->ptr, tuple, tuplen); state->totalTupleBytes += tuplen; } static long writetup_index(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e) { IndexTuple tuple = (IndexTuple) e->ptr; uint32 tuplen = IndexTupleSize(tuple) + sizeof(tuplen); long ret = tuplen; LogicalTapeWrite(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); LogicalTapeWrite(state->tapeset, lt, (void *) tuple, IndexTupleSize(tuple)); if (state->randomAccess) /* need trailing length word? */ { LogicalTapeWrite(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); ret += sizeof(tuplen); } pfree(tuple); e->ptr = NULL; return ret; } static void freetup_index(MKEntry *e) { pfree(e->ptr); e->ptr = NULL; } static void readtup_index(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len) { uint32 tuplen = len - sizeof(uint32); IndexTuple tuple = (IndexTuple) palloc(tuplen); size_t readSize; Assert(lt); MemSet(e, 0, sizeof(MKEntry)); readSize = LogicalTapeRead(state->tapeset, lt, (void *) tuple, tuplen); if (readSize != tuplen) elog(ERROR, "unexpected end of data"); if (state->randomAccess) /* need trailing length word? */ { readSize = LogicalTapeRead(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); if (readSize != sizeof(tuplen)) elog(ERROR, "unexpected end of data"); } e->ptr = (void *) tuple; } static void copytup_datum(Tuplesortstate_mk *state, MKEntry *e, void *tup) { /* Not currently needed */ elog(ERROR, "copytup_datum() should not be called"); } static long writetup_datum(Tuplesortstate_mk *state, LogicalTape *lt, MKEntry *e) { void *waddr; uint32 tuplen; uint32 writtenlen; bool needfree = false; long ret; if (mke_is_null(e)) { waddr = NULL; tuplen = 0; } else if (state->datumTypeByVal) { waddr = &e->d; tuplen = sizeof(Datum); } else { waddr = DatumGetPointer(e->d); tuplen = datumGetSize(e->d, false, state->datumTypeLen); needfree = true; Assert(tuplen != 0); } writtenlen = tuplen + sizeof(uint32); ret = writtenlen; LogicalTapeWrite(state->tapeset, lt, (void *) &writtenlen, sizeof(writtenlen)); LogicalTapeWrite(state->tapeset, lt, waddr, tuplen); if (state->randomAccess) /* need trailing length word? */ { LogicalTapeWrite(state->tapeset, lt, (void *) &writtenlen, sizeof(writtenlen)); ret += sizeof(writtenlen); } if (needfree) pfree(waddr); return ret; } /** * No-op free: does nothing! */ static void freetup_noop(MKEntry *e) { } /** * Free the datum if non-null, should only be used for by-reference datums */ static void freetup_datum(MKEntry *e) { if (!mke_is_null(e)) { void *waddr = DatumGetPointer(e->d); pfree(waddr); } } static void readtup_datum(Tuplesortstate_mk *state, TuplesortPos_mk *pos, MKEntry *e, LogicalTape *lt, uint32 len) { size_t readSize; uint32 tuplen = len - sizeof(uint32); Assert(lt); MemSet(e, 0, sizeof(MKEntry)); if (tuplen == 0) mke_set_null(e, state->nullfirst); else if (state->datumTypeByVal) { mke_set_not_null(e); Assert(tuplen == sizeof(Datum)); readSize = LogicalTapeRead(state->tapeset, lt, (void *) &e->d, tuplen); if (readSize != tuplen) elog(ERROR, "unexpected end of data"); } else { void *raddr = palloc(tuplen); readSize = LogicalTapeRead(state->tapeset, lt, raddr, tuplen); if (readSize != tuplen) elog(ERROR, "unexpected end of data"); mke_set_not_null(e); e->d = PointerGetDatum(raddr); } if (state->randomAccess) /* need trailing length word? */ { readSize = LogicalTapeRead(state->tapeset, lt, (void *) &tuplen, sizeof(tuplen)); if (readSize != sizeof(tuplen)) elog(ERROR, "unexpected end of data"); } } typedef struct refcnt_locale_str { int ref; short xfrm_pos; char isPrefixOnly; char data[1]; } refcnt_locale_str; typedef struct refcnt_locale_str_k { int ref; short xfrm_pos; char isPrefixOnly; char data[16000]; } refcnt_locale_str_k; /** * Compare the datums for the given level. It is assumed that each entry has been prepared * for the given level. */ int tupsort_compare_datum(MKEntry *v1, MKEntry *v2, MKLvContext *lvctxt, MKContext *context) { Assert(!mke_is_null(v1)); Assert(!mke_is_null(v2)); switch (lvctxt->lvtype) { case MKLV_TYPE_NONE: return inlineApplySortFunction(&lvctxt->scanKey.sk_func, lvctxt->scanKey.sk_flags, v1->d, false, v2->d, false ); case MKLV_TYPE_INT32: { int32 i1 = DatumGetInt32(v1->d); int32 i2 = DatumGetInt32(v2->d); int result = (i1 < i2) ? -1 : ((i1 == i2) ? 0 : 1); return ((lvctxt->scanKey.sk_flags & SK_BT_DESC) != 0) ? -result : result; } default: return tupsort_compare_char(v1, v2, lvctxt, context); } Assert(!"Never reach here"); return 0; } void tupsort_cpfr(MKEntry *dst, MKEntry *src, MKLvContext *lvctxt) { Assert(dst); if (mke_is_refc(dst)) { Assert(dst->d != 0); Assert(!mke_is_copied(dst)); tupsort_refcnt(DatumGetPointer(dst->d), -1); } if (mke_is_copied(dst)) { Assert(dst->d != 0); Assert(!mke_is_refc(dst)); pfree(DatumGetPointer(dst->d)); } mke_clear_refc_copied(dst); if (src) { *dst = *src; if (!mke_is_null(src)) { if (mke_is_refc(src)) tupsort_refcnt(DatumGetPointer(dst->d), 1); else if (!lvctxt->typByVal) { Assert(src->d != 0); dst->d = datumCopy(src->d, lvctxt->typByVal, lvctxt->typLen); mke_set_copied(dst); } } } } static void tupsort_refcnt(void *vp, int ref) { refcnt_locale_str *p = (refcnt_locale_str *) vp; Assert(p && p->ref > 0); Assert(ref == 1 || ref == -1); if (ref == 1) ++p->ref; else { if (--p->ref == 0) pfree(p); } } static int tupsort_compare_char(MKEntry *v1, MKEntry *v2, MKLvContext *lvctxt, MKContext *mkContext) { int result = 0; refcnt_locale_str *p1 = (refcnt_locale_str *) DatumGetPointer(v1->d); refcnt_locale_str *p2 = (refcnt_locale_str *) DatumGetPointer(v2->d); Assert(!mke_is_null(v1)); Assert(!mke_is_null(v2)); Assert(!lc_collate_is_c()); Assert(mkContext->fetchForPrep); Assert(p1->ref > 0 && p2->ref > 0); if (p1 == p2) { Assert(p1->ref >= 2); result = 0; } else { result = strcmp(p1->data + p1->xfrm_pos, p2->data + p2->xfrm_pos); if (result == 0) { if (p1->isPrefixOnly || p2->isPrefixOnly) { /* * only prefixes were equal so we must compare more of the * strings * * do this by getting the true datum and calling the built-in * comparison function */ Datum p1Original, p2Original; bool p1IsNull, p2IsNull; p1Original = (mkContext->fetchForPrep) (v1, mkContext, lvctxt, &p1IsNull); p2Original = (mkContext->fetchForPrep) (v2, mkContext, lvctxt, &p2IsNull); Assert(!p1IsNull); /* should not have been prepared if * null */ Assert(!p2IsNull); result = inlineApplySortFunction(&lvctxt->scanKey.sk_func, lvctxt->scanKey.sk_flags, p1Original, false, p2Original, false); } else { /* * See varstr_cmp for comment on comparing str with locale. * Essentially, for some locale, strcoll may return eq even if * original str are different. */ result = strcmp(p1->data, p2->data); } } /* The values were equal -- de-dupe them */ if (result == 0) { if (p1->ref >= p2->ref) { v2->d = v1->d; tupsort_refcnt(p1, 1); tupsort_refcnt(p2, -1); } else { v1->d = v2->d; tupsort_refcnt(p2, 1); tupsort_refcnt(p1, -1); } } } return ((lvctxt->scanKey.sk_flags & SK_BT_DESC) != 0) ? -result : result; } static int32 estimateMaxPrepareSizeForEntry(MKEntry *a, struct MKContext *mkContext) { int result = 0; int lv; Assert(mkContext->fetchForPrep != NULL); for (lv = 0; lv < mkContext->total_lv; lv++) { MKLvContext *level = mkContext->lvctxt + lv; MKLvType levelType = level->lvtype; if (levelType == MKLV_TYPE_CHAR || levelType == MKLV_TYPE_TEXT) { bool isnull; Datum d = (mkContext->fetchForPrep) (a, mkContext, level, &isnull); if (!isnull) { int amountThisDatum = estimatePrepareSpaceForChar(mkContext, a, d, levelType == MKLV_TYPE_CHAR); if (amountThisDatum > result) result = amountThisDatum; } } } return result; } static Datum tupsort_fetch_datum_mtup(MKEntry *a, MKContext *mkctxt, MKLvContext *lvctxt, bool *isNullOut) { Datum d = memtuple_getattr( (MemTuple) a->ptr, mkctxt->mt_bind, lvctxt->attno, isNullOut ); return d; } static Datum tupsort_fetch_datum_itup(MKEntry *a, MKContext *mkctxt, MKLvContext *lvctxt, bool *isNullOut) { Datum d = index_getattr( (IndexTuple) a->ptr, lvctxt->attno, mkctxt->tupdesc, isNullOut ); return d; } void tupsort_prepare(MKEntry *a, MKContext *mkctxt, int lv) { MKLvContext *lvctxt = mkctxt->lvctxt + lv; bool isnull; Assert(mkctxt->fetchForPrep != NULL); tupsort_cpfr(a, NULL, lvctxt); a->d = (mkctxt->fetchForPrep) (a, mkctxt, lvctxt, &isnull); if (!isnull) mke_set_not_null(a); else mke_set_null(a, (lvctxt->scanKey.sk_flags & SK_BT_NULLS_FIRST) != 0); if (lvctxt->lvtype == MKLV_TYPE_CHAR) tupsort_prepare_char(a, true); else if (lvctxt->lvtype == MKLV_TYPE_TEXT) tupsort_prepare_char(a, false); } /* "True" length (not counting trailing blanks) of a BpChar */ static inline int bcTruelen(char *p, int len) { int i; for (i = len - 1; i >= 0; i--) { if (p[i] != ' ') break; } return i + 1; } /** * should only be called for non-null Datum (caller must check the isnull flag from the fetch) */ static int32 estimatePrepareSpaceForChar(struct MKContext *mkContext, MKEntry *e, Datum d, bool isCHAR) { int len, transformedLength, retlen; if (isCHAR) { char *p; void *toFree; varattrib_untoast_ptr_len(d, &p, &len, &toFree); len = bcTruelen(p, len); if (toFree) pfree(toFree); } else { /* * since we don't need the data for checking the true length, just * unpack enough to get the length this may avoid decompression */ len = varattrib_untoast_len(d); } /* figure out how much space transformed version will take */ transformedLength = len * mkContext->strxfrmScaleFactor + mkContext->strxfrmConstantFactor; if (len > STRXFRM_INPUT_LENGTH_LIMIT) { if (transformedLength > STRXFRM_INPUT_LENGTH_LIMIT) transformedLength = STRXFRM_INPUT_LENGTH_LIMIT; /* * we do not store the raw data for long input strings (in part * because of compression producing a long input string from a much * smaller datum) */ len = 0; } retlen = offsetof(refcnt_locale_str, data) + len + 1 + transformedLength + 1; return retlen; } /** * Prepare a character string by copying the datum out to a null-terminated string and * then also keeping a strxfrmed copy of it. * * If the string is long then the copied out value is not kept and only the prefix of the strxfrm * is kept. * * Note that this must be in sync with the estimation function. */ static void tupsort_prepare_char(MKEntry *a, bool isCHAR) { char *p; void *tofree = NULL; int len; int lenToStore; int transformedLenToStore; int retlen; refcnt_locale_str *ret; refcnt_locale_str_k kstr; int avail = sizeof(kstr.data); bool storePrefixOnly; Assert(!lc_collate_is_c()); if (mke_is_null(a)) return; varattrib_untoast_ptr_len(a->d, &p, &len, &tofree); if (isCHAR) len = bcTruelen(p, len); if (len > STRXFRM_INPUT_LENGTH_LIMIT) { /* * too long? store prefix of strxfrm only and DON'T store copy of * original string */ storePrefixOnly = true; lenToStore = 0; } else { storePrefixOnly = false; lenToStore = len; } /* * This assertion is true because avail is larger than * STRXFRM_INPUT_LENGTH_LIMIT, which is the max of lenToStore ... */ Assert(lenToStore <= avail - 2); Assert(lenToStore < 32768); /* so it will fit in a short (xfrm_pos field) */ Assert(STRXFRM_INPUT_LENGTH_LIMIT < 32768); /* so it will fit in a short * (xfrm_pos field) */ kstr.ref = 1; kstr.xfrm_pos = lenToStore + 1; kstr.isPrefixOnly = storePrefixOnly ? 1 : 0; memcpy(kstr.data, p, lenToStore); kstr.data[lenToStore] = '\0'; avail -= lenToStore + 1; Assert(avail > 0); /* * String transformation. */ if (storePrefixOnly) { /* * prefix only: we haven't copied from p into a null-terminated string * so do that now */ char *possibleStr = kstr.data + kstr.xfrm_pos + STRXFRM_INPUT_LENGTH_LIMIT + 2; char *str; if (avail >= STRXFRM_INPUT_LENGTH_LIMIT + 1 + len + 1) { /* * will segment this so first part is xformed string and next is * the throw-away string to be passed to strxfrm */ str = possibleStr; } else { str = palloc(len + 1); } memcpy(str, p, len); str[len] = '\0'; /* * transform, but limit length of transformed string */ Assert(avail >= STRXFRM_INPUT_LENGTH_LIMIT + 1); transformedLenToStore = (int) gp_strxfrm(kstr.data + kstr.xfrm_pos, str, STRXFRM_INPUT_LENGTH_LIMIT + 1); if (transformedLenToStore > STRXFRM_INPUT_LENGTH_LIMIT) { transformedLenToStore = STRXFRM_INPUT_LENGTH_LIMIT; /* * this is required for linux -- when there is not enough room * then linux does NOT write the \0 */ kstr.data[kstr.xfrm_pos + transformedLenToStore] = '\0'; } if (str != possibleStr) pfree(str); } else transformedLenToStore = (int) gp_strxfrm(kstr.data + kstr.xfrm_pos, kstr.data, avail); /* * Copy or transform into the result as needed */ retlen = offsetof(refcnt_locale_str, data) + lenToStore + 1 + transformedLenToStore + 1; ret = (refcnt_locale_str *) palloc(retlen); if (transformedLenToStore < avail) { memcpy(ret, &kstr, retlen); Assert(ret->ref == 1); Assert(ret->data[ret->xfrm_pos - 1] == '\0'); Assert(ret->data[ret->xfrm_pos + transformedLenToStore] == '\0'); } else { /* * note that when avail (determined by refcnt_locale_str_k.data) is * much larger than STRXFRM_INPUT_LENGTH_LIMIT then this code won't be * hit. */ memcpy(ret, &kstr, offsetof(refcnt_locale_str, data) + lenToStore + 1); avail = retlen - offsetof(refcnt_locale_str, data) - lenToStore - 1; Assert(avail > transformedLenToStore); Assert(ret->ref == 1); Assert(ret->xfrm_pos == len + 1); Assert(ret->data[len] == '\0'); transformedLenToStore = (int) gp_strxfrm(ret->data + ret->xfrm_pos, kstr.data, avail); Assert(transformedLenToStore < avail); Assert(ret->data[ret->xfrm_pos + transformedLenToStore] == '\0'); } if (tofree) pfree(tofree); /* * data string is length zero in this case (could just not even store it * and have xfrm_pos == 0 but that complicates code more) */ AssertImply(storePrefixOnly, ret->data[0] == '\0'); /* * finalize result */ a->d = PointerGetDatum(ret); mke_set_refc(a); } /* * tuplesort_inmem_limit_insert * Adds a tuple for sorting when we are doing LIMIT sort and we (still) fit in memory * If we're in here, it means we haven't exceeded memory yet. * Three cases: * - we're below LIMIT tuples. Then add to unsorted array, increase memory * - we just hit LIMIT tuples. Switch to using a heap instead of array, so * we only keep top LIMIT tuples. * - we're above LIMIT tuples. Then add to heap, don't increase memory usage */ static void tuplesort_inmem_limit_insert(Tuplesortstate_mk *state, MKEntry *entry) { Assert(state->mkctxt.bounded); Assert(is_under_sort_or_exec_ctxt(state)); Assert(!mke_is_empty(entry)); Assert(state->status == TSS_INITIAL); if (state->mkheap == NULL) { Assert(state->entry_count < state->entry_allocsize); /* * We haven't created the heap yet. First add element to unsorted * array so we don't lose it. Then, we have two cases: A. if we're * under limit, we're done, iterate. B. We just hit the limit. Create * heap. Add to heap. */ state->entries[state->entry_count++] = *entry; state->numTuplesInMem++; if (state->entry_count == state->mkctxt.bound) { /* B: just hit limit. Create heap from array */ state->mkheap = mkheap_from_array(state->entries, state->entry_count, state->entry_count, &state->mkctxt); state->entries = NULL; state->entry_allocsize = 0; state->entry_count = 0; } } else { /* * We already have the heap (and it fits in memory). Simply add to the * heap, keeping only top LIMIT elements. */ Assert(state->mkheap && !mkheap_empty(state->mkheap)); Assert(state->mkheap->count == state->numTuplesInMem); Assert(state->entry_count == 0); (void) mkheap_putAndGet(state->mkheap, entry); Assert(!mke_is_empty(entry)); Assert(entry->ptr); pfree(entry->ptr); entry->ptr = NULL; } } /* * tuplesort_inmem_nolimit_insert * Adds a tuple for sorting when we are regular (no LIMIT) sort and we (still) fit in memory * * Simply add to the unsorted in-memory array. We'll either qsort or spill this later. */ static void tuplesort_inmem_nolimit_insert(Tuplesortstate_mk *state, MKEntry *entry) { Assert(state->status == TSS_INITIAL); Assert(!state->mkctxt.bounded); Assert(is_under_sort_or_exec_ctxt(state)); Assert(!mke_is_empty(entry)); Assert(state->entry_count < state->entry_allocsize); state->entries[state->entry_count] = *entry; if (state->mkctxt.fetchForPrep) { state->mkctxt.estimatedExtraForPrep += estimateMaxPrepareSizeForEntry(&state->entries[state->entry_count], &state->mkctxt); } state->entry_count++; state->numTuplesInMem++; } static void tuplesort_heap_insert(Tuplesortstate_mk *state, MKEntry *e) { int ins; Assert(state->mkheap); Assert(is_under_sort_or_exec_ctxt(state)); ins = mkheap_putAndGet_run(state->mkheap, e, state->currentRun); tupsort_cpfr(e, NULL, &state->mkctxt.lvctxt[mke_get_lv(e)]); Assert(ins >= 0); { LogicalTape *lt = LogicalTapeSetGetTape(state->tapeset, state->tp_tapenum[state->destTape]); WRITETUP(state, lt, e); if (!mkheap_run_match(state->mkheap, state->currentRun)) { markrunend(state, state->tp_tapenum[state->destTape]); state->currentRun++; state->tp_runs[state->destTape]++; state->tp_dummy[state->destTape]--; selectnewtape_mk(state); } } } static void tuplesort_limit_sort(Tuplesortstate_mk *state) { Assert(state->mkctxt.bounded); Assert(is_under_sort_or_exec_ctxt(state)); if (!state->mkheap) { Assert(state->entry_count <= state->mkctxt.bound); mk_qsort(state->entries, state->entry_count, &state->mkctxt); return; } else { int i; #ifdef USE_ASSERT_CHECKING mkheap_verify_heap(state->mkheap, 0); #endif state->entry_allocsize = mkheap_cnt(state->mkheap); state->entries = palloc(state->entry_allocsize * sizeof(MKEntry)); /* Put these things to minimum */ for (i = 0; i < state->entry_allocsize; ++i) mke_set_comp_max(state->entries + i); for (i = state->entry_allocsize - 1; i >= 0; --i) { if (QueryFinishPending) break; mkheap_putAndGet(state->mkheap, state->entries + i); } Assert(QueryFinishPending || (mkheap_cnt(state->mkheap) == 0)); state->entry_count = state->entry_allocsize; } mkheap_destroy(state->mkheap); state->mkheap = NULL; } void tuplesort_set_gpmon_mk(Tuplesortstate_mk *state, gpmon_packet_t *gpmon_pkt, int *gpmon_tick) { state->gpmon_pkt = gpmon_pkt; state->gpmon_sort_tick = gpmon_tick; } /* EOF */
apache-2.0
emmettu/pnc
ui/app/common/restclient/services/Build.js
2590
/* * JBoss, Home of Professional Open Source. * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * 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. */ 'use strict'; (function() { var module = angular.module('pnc.common.restclient'); /** * @ngdoc service * @name pnc.common.restclient:Build * @description * */ module.factory('Build', [ 'BuildRecordDAO', 'RunningBuildRecordDAO', '$q', function(BuildRecordDAO, RunningBuildRecordDAO, $q) { return { get: function(spec) { var deffered = $q.defer(); function overrideRejection(response) { return $q.when(response); } /* * In order to return the BuildRecord regardless of whether it is in * progress or compelted we must attempt to fetch both the * RunningBuild and the BuildRecord for the given ID in parralell * (Unless something went wrong one of these requests should succeed * and one fail). As such we have to catch the rejection for the * request that failed and return a resolved promise. We can then * check which request succeeded in the success callback and resolve * the promise returned to the user with it. */ $q.all([ BuildRecordDAO.get(spec).$promise.catch(overrideRejection), RunningBuildRecordDAO.get(spec).$promise.catch(overrideRejection) ]).then( function(results) { // Success - return whichever record we successfully pulled down. if (results[0].id) { deffered.resolve(results[0]); } else if (results[1].id) { deffered.resolve(results[1]); } else { deffered.reject(results); } }, function(results) { // Error deffered.reject(results); } ); return deffered.promise; } }; } ]); })();
apache-2.0
arenadata/ambari
ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
1624
''' 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 unittest import TestCase from resource_management.libraries.functions import get_port_from_url from resource_management.core.exceptions import Fail class TestLibraryFunctions(TestCase): def test_get_port_from_url(self): self.assertEqual("8080",get_port_from_url("protocol://host:8080")) self.assertEqual("8080",get_port_from_url("protocol://host:8080/")) self.assertEqual("8080",get_port_from_url("host:8080")) self.assertEqual("8080",get_port_from_url("host:8080/")) self.assertEqual("8080",get_port_from_url("host:8080/dots_in_url8888:")) self.assertEqual("8080",get_port_from_url("protocol://host:8080/dots_in_url8888:")) self.assertEqual("8080",get_port_from_url("127.0.0.1:8080")) self.assertRaises(Fail, get_port_from_url, "http://host/no_port") self.assertRaises(Fail, get_port_from_url, "127.0.0.1:808080")
apache-2.0
huang-qiao/ApiDemos-ASProject
app/src/main/java/com/example/android/apis/graphics/TriangleActivity.java
1361
/* * Copyright (C) 2008 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 com.example.android.apis.graphics; import android.app.Activity; import android.opengl.GLSurfaceView; import android.os.Bundle; public class TriangleActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLView = new GLSurfaceView(this); mGLView.setEGLConfigChooser(false); mGLView.setRenderer(new StaticTriangleRenderer(this)); setContentView(mGLView); } @Override protected void onPause() { super.onPause(); mGLView.onPause(); } @Override protected void onResume() { super.onResume(); mGLView.onResume(); } private GLSurfaceView mGLView; }
apache-2.0
mirkosertic/Bytecoder
classlib/java.base/src/main/resources/META-INF/modules/java.base/classes/java/util/Vector.java
56351
/* * Copyright (c) 1994, 2019, 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. */ package java.util; import java.io.IOException; import java.io.ObjectInputStream; import java.io.StreamCorruptedException; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; import jdk.internal.util.ArraysSupport; /** * The {@code Vector} class implements a growable array of * objects. Like an array, it contains components that can be * accessed using an integer index. However, the size of a * {@code Vector} can grow or shrink as needed to accommodate * adding and removing items after the {@code Vector} has been created. * * <p>Each vector tries to optimize storage management by maintaining a * {@code capacity} and a {@code capacityIncrement}. The * {@code capacity} is always at least as large as the vector * size; it is usually larger because as components are added to the * vector, the vector's storage increases in chunks the size of * {@code capacityIncrement}. An application can increase the * capacity of a vector before inserting a large number of * components; this reduces the amount of incremental reallocation. * * <p id="fail-fast"> * The iterators returned by this class's {@link #iterator() iterator} and * {@link #listIterator(int) listIterator} methods are <em>fail-fast</em>: * if the vector is structurally modified at any time after the iterator is * created, in any way except through the iterator's own * {@link ListIterator#remove() remove} or * {@link ListIterator#add(Object) add} methods, the iterator will throw a * {@link ConcurrentModificationException}. Thus, in the face of * concurrent modification, the iterator fails quickly and cleanly, rather * than risking arbitrary, non-deterministic behavior at an undetermined * time in the future. The {@link Enumeration Enumerations} returned by * the {@link #elements() elements} method are <em>not</em> fail-fast; if the * Vector is structurally modified at any time after the enumeration is * created then the results of enumerating are undefined. * * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed * as it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators * throw {@code ConcurrentModificationException} on a best-effort basis. * Therefore, it would be wrong to write a program that depended on this * exception for its correctness: <i>the fail-fast behavior of iterators * should be used only to detect bugs.</i> * * <p>As of the Java 2 platform v1.2, this class was retrofitted to * implement the {@link List} interface, making it a member of the * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework"> * Java Collections Framework</a>. Unlike the new collection * implementations, {@code Vector} is synchronized. If a thread-safe * implementation is not needed, it is recommended to use {@link * ArrayList} in place of {@code Vector}. * * @param <E> Type of component elements * * @author Lee Boynton * @author Jonathan Payne * @see Collection * @see LinkedList * @since 1.0 */ public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable { /** * The array buffer into which the components of the vector are * stored. The capacity of the vector is the length of this array buffer, * and is at least large enough to contain all the vector's elements. * * <p>Any array elements following the last element in the Vector are null. * * @serial */ @SuppressWarnings("serial") // Conditionally serializable protected Object[] elementData; /** * The number of valid components in this {@code Vector} object. * Components {@code elementData[0]} through * {@code elementData[elementCount-1]} are the actual items. * * @serial */ protected int elementCount; /** * The amount by which the capacity of the vector is automatically * incremented when its size becomes greater than its capacity. If * the capacity increment is less than or equal to zero, the capacity * of the vector is doubled each time it needs to grow. * * @serial */ protected int capacityIncrement; /** use serialVersionUID from JDK 1.0.2 for interoperability */ @java.io.Serial private static final long serialVersionUID = -2767605614048989439L; /** * Constructs an empty vector with the specified initial capacity and * capacity increment. * * @param initialCapacity the initial capacity of the vector * @param capacityIncrement the amount by which the capacity is * increased when the vector overflows * @throws IllegalArgumentException if the specified initial capacity * is negative */ public Vector(int initialCapacity, int capacityIncrement) { super(); if (initialCapacity < 0) throw new IllegalArgumentException("Illegal Capacity: "+ initialCapacity); this.elementData = new Object[initialCapacity]; this.capacityIncrement = capacityIncrement; } /** * Constructs an empty vector with the specified initial capacity and * with its capacity increment equal to zero. * * @param initialCapacity the initial capacity of the vector * @throws IllegalArgumentException if the specified initial capacity * is negative */ public Vector(int initialCapacity) { this(initialCapacity, 0); } /** * Constructs an empty vector so that its internal data array * has size {@code 10} and its standard capacity increment is * zero. */ public Vector() { this(10); } /** * Constructs a vector containing the elements of the specified * collection, in the order they are returned by the collection's * iterator. * * @param c the collection whose elements are to be placed into this * vector * @throws NullPointerException if the specified collection is null * @since 1.2 */ public Vector(Collection<? extends E> c) { Object[] a = c.toArray(); elementCount = a.length; if (c.getClass() == ArrayList.class) { elementData = a; } else { elementData = Arrays.copyOf(a, elementCount, Object[].class); } } /** * Copies the components of this vector into the specified array. * The item at index {@code k} in this vector is copied into * component {@code k} of {@code anArray}. * * @param anArray the array into which the components get copied * @throws NullPointerException if the given array is null * @throws IndexOutOfBoundsException if the specified array is not * large enough to hold all the components of this vector * @throws ArrayStoreException if a component of this vector is not of * a runtime type that can be stored in the specified array * @see #toArray(Object[]) */ public synchronized void copyInto(Object[] anArray) { System.arraycopy(elementData, 0, anArray, 0, elementCount); } /** * Trims the capacity of this vector to be the vector's current * size. If the capacity of this vector is larger than its current * size, then the capacity is changed to equal the size by replacing * its internal data array, kept in the field {@code elementData}, * with a smaller one. An application can use this operation to * minimize the storage of a vector. */ public synchronized void trimToSize() { modCount++; int oldCapacity = elementData.length; if (elementCount < oldCapacity) { elementData = Arrays.copyOf(elementData, elementCount); } } /** * Increases the capacity of this vector, if necessary, to ensure * that it can hold at least the number of components specified by * the minimum capacity argument. * * <p>If the current capacity of this vector is less than * {@code minCapacity}, then its capacity is increased by replacing its * internal data array, kept in the field {@code elementData}, with a * larger one. The size of the new data array will be the old size plus * {@code capacityIncrement}, unless the value of * {@code capacityIncrement} is less than or equal to zero, in which case * the new capacity will be twice the old capacity; but if this new size * is still smaller than {@code minCapacity}, then the new capacity will * be {@code minCapacity}. * * @param minCapacity the desired minimum capacity */ public synchronized void ensureCapacity(int minCapacity) { if (minCapacity > 0) { modCount++; if (minCapacity > elementData.length) grow(minCapacity); } } /** * Increases the capacity to ensure that it can hold at least the * number of elements specified by the minimum capacity argument. * * @param minCapacity the desired minimum capacity * @throws OutOfMemoryError if minCapacity is less than zero */ private Object[] grow(int minCapacity) { int oldCapacity = elementData.length; int newCapacity = ArraysSupport.newLength(oldCapacity, minCapacity - oldCapacity, /* minimum growth */ capacityIncrement > 0 ? capacityIncrement : oldCapacity /* preferred growth */); return elementData = Arrays.copyOf(elementData, newCapacity); } private Object[] grow() { return grow(elementCount + 1); } /** * Sets the size of this vector. If the new size is greater than the * current size, new {@code null} items are added to the end of * the vector. If the new size is less than the current size, all * components at index {@code newSize} and greater are discarded. * * @param newSize the new size of this vector * @throws ArrayIndexOutOfBoundsException if the new size is negative */ public synchronized void setSize(int newSize) { modCount++; if (newSize > elementData.length) grow(newSize); final Object[] es = elementData; for (int to = elementCount, i = newSize; i < to; i++) es[i] = null; elementCount = newSize; } /** * Returns the current capacity of this vector. * * @return the current capacity (the length of its internal * data array, kept in the field {@code elementData} * of this vector) */ public synchronized int capacity() { return elementData.length; } /** * Returns the number of components in this vector. * * @return the number of components in this vector */ public synchronized int size() { return elementCount; } /** * Tests if this vector has no components. * * @return {@code true} if and only if this vector has * no components, that is, its size is zero; * {@code false} otherwise. */ public synchronized boolean isEmpty() { return elementCount == 0; } /** * Returns an enumeration of the components of this vector. The * returned {@code Enumeration} object will generate all items in * this vector. The first item generated is the item at index {@code 0}, * then the item at index {@code 1}, and so on. If the vector is * structurally modified while enumerating over the elements then the * results of enumerating are undefined. * * @return an enumeration of the components of this vector * @see Iterator */ public Enumeration<E> elements() { return new Enumeration<E>() { int count = 0; public boolean hasMoreElements() { return count < elementCount; } public E nextElement() { synchronized (Vector.this) { if (count < elementCount) { return elementData(count++); } } throw new NoSuchElementException("Vector Enumeration"); } }; } /** * Returns {@code true} if this vector contains the specified element. * More formally, returns {@code true} if and only if this vector * contains at least one element {@code e} such that * {@code Objects.equals(o, e)}. * * @param o element whose presence in this vector is to be tested * @return {@code true} if this vector contains the specified element */ public boolean contains(Object o) { return indexOf(o, 0) >= 0; } /** * Returns the index of the first occurrence of the specified element * in this vector, or -1 if this vector does not contain the element. * More formally, returns the lowest index {@code i} such that * {@code Objects.equals(o, get(i))}, * or -1 if there is no such index. * * @param o element to search for * @return the index of the first occurrence of the specified element in * this vector, or -1 if this vector does not contain the element */ public int indexOf(Object o) { return indexOf(o, 0); } /** * Returns the index of the first occurrence of the specified element in * this vector, searching forwards from {@code index}, or returns -1 if * the element is not found. * More formally, returns the lowest index {@code i} such that * {@code (i >= index && Objects.equals(o, get(i)))}, * or -1 if there is no such index. * * @param o element to search for * @param index index to start searching from * @return the index of the first occurrence of the element in * this vector at position {@code index} or later in the vector; * {@code -1} if the element is not found. * @throws IndexOutOfBoundsException if the specified index is negative * @see Object#equals(Object) */ public synchronized int indexOf(Object o, int index) { if (o == null) { for (int i = index ; i < elementCount ; i++) if (elementData[i]==null) return i; } else { for (int i = index ; i < elementCount ; i++) if (o.equals(elementData[i])) return i; } return -1; } /** * Returns the index of the last occurrence of the specified element * in this vector, or -1 if this vector does not contain the element. * More formally, returns the highest index {@code i} such that * {@code Objects.equals(o, get(i))}, * or -1 if there is no such index. * * @param o element to search for * @return the index of the last occurrence of the specified element in * this vector, or -1 if this vector does not contain the element */ public synchronized int lastIndexOf(Object o) { return lastIndexOf(o, elementCount-1); } /** * Returns the index of the last occurrence of the specified element in * this vector, searching backwards from {@code index}, or returns -1 if * the element is not found. * More formally, returns the highest index {@code i} such that * {@code (i <= index && Objects.equals(o, get(i)))}, * or -1 if there is no such index. * * @param o element to search for * @param index index to start searching backwards from * @return the index of the last occurrence of the element at position * less than or equal to {@code index} in this vector; * -1 if the element is not found. * @throws IndexOutOfBoundsException if the specified index is greater * than or equal to the current size of this vector */ public synchronized int lastIndexOf(Object o, int index) { if (index >= elementCount) throw new IndexOutOfBoundsException(index + " >= "+ elementCount); if (o == null) { for (int i = index; i >= 0; i--) if (elementData[i]==null) return i; } else { for (int i = index; i >= 0; i--) if (o.equals(elementData[i])) return i; } return -1; } /** * Returns the component at the specified index. * * <p>This method is identical in functionality to the {@link #get(int)} * method (which is part of the {@link List} interface). * * @param index an index into this vector * @return the component at the specified index * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ public synchronized E elementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } return elementData(index); } /** * Returns the first component (the item at index {@code 0}) of * this vector. * * @return the first component of this vector * @throws NoSuchElementException if this vector has no components */ public synchronized E firstElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return elementData(0); } /** * Returns the last component of the vector. * * @return the last component of the vector, i.e., the component at index * {@code size() - 1} * @throws NoSuchElementException if this vector is empty */ public synchronized E lastElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return elementData(elementCount - 1); } /** * Sets the component at the specified {@code index} of this * vector to be the specified object. The previous component at that * position is discarded. * * <p>The index must be a value greater than or equal to {@code 0} * and less than the current size of the vector. * * <p>This method is identical in functionality to the * {@link #set(int, Object) set(int, E)} * method (which is part of the {@link List} interface). Note that the * {@code set} method reverses the order of the parameters, to more closely * match array usage. Note also that the {@code set} method returns the * old value that was stored at the specified position. * * @param obj what the component is to be set to * @param index the specified index * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ public synchronized void setElementAt(E obj, int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = obj; } /** * Deletes the component at the specified index. Each component in * this vector with an index greater or equal to the specified * {@code index} is shifted downward to have an index one * smaller than the value it had previously. The size of this vector * is decreased by {@code 1}. * * <p>The index must be a value greater than or equal to {@code 0} * and less than the current size of the vector. * * <p>This method is identical in functionality to the {@link #remove(int)} * method (which is part of the {@link List} interface). Note that the * {@code remove} method returns the old value that was stored at the * specified position. * * @param index the index of the object to remove * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ public synchronized void removeElementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } modCount++; elementCount--; elementData[elementCount] = null; /* to let gc do its work */ } /** * Inserts the specified object as a component in this vector at the * specified {@code index}. Each component in this vector with * an index greater or equal to the specified {@code index} is * shifted upward to have an index one greater than the value it had * previously. * * <p>The index must be a value greater than or equal to {@code 0} * and less than or equal to the current size of the vector. (If the * index is equal to the current size of the vector, the new element * is appended to the Vector.) * * <p>This method is identical in functionality to the * {@link #add(int, Object) add(int, E)} * method (which is part of the {@link List} interface). Note that the * {@code add} method reverses the order of the parameters, to more closely * match array usage. * * @param obj the component to insert * @param index where to insert the new component * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index > size()}) */ public synchronized void insertElementAt(E obj, int index) { if (index > elementCount) { throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); } modCount++; final int s = elementCount; Object[] elementData = this.elementData; if (s == elementData.length) elementData = grow(); System.arraycopy(elementData, index, elementData, index + 1, s - index); elementData[index] = obj; elementCount = s + 1; } /** * Adds the specified component to the end of this vector, * increasing its size by one. The capacity of this vector is * increased if its size becomes greater than its capacity. * * <p>This method is identical in functionality to the * {@link #add(Object) add(E)} * method (which is part of the {@link List} interface). * * @param obj the component to be added */ public synchronized void addElement(E obj) { modCount++; add(obj, elementData, elementCount); } /** * Removes the first (lowest-indexed) occurrence of the argument * from this vector. If the object is found in this vector, each * component in the vector with an index greater or equal to the * object's index is shifted downward to have an index one smaller * than the value it had previously. * * <p>This method is identical in functionality to the * {@link #remove(Object)} method (which is part of the * {@link List} interface). * * @param obj the component to be removed * @return {@code true} if the argument was a component of this * vector; {@code false} otherwise. */ public synchronized boolean removeElement(Object obj) { modCount++; int i = indexOf(obj); if (i >= 0) { removeElementAt(i); return true; } return false; } /** * Removes all components from this vector and sets its size to zero. * * <p>This method is identical in functionality to the {@link #clear} * method (which is part of the {@link List} interface). */ public synchronized void removeAllElements() { final Object[] es = elementData; for (int to = elementCount, i = elementCount = 0; i < to; i++) es[i] = null; modCount++; } /** * Returns a clone of this vector. The copy will contain a * reference to a clone of the internal data array, not a reference * to the original internal data array of this {@code Vector} object. * * @return a clone of this vector */ public synchronized Object clone() { try { @SuppressWarnings("unchecked") Vector<E> v = (Vector<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, elementCount); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(e); } } /** * Returns an array containing all of the elements in this Vector * in the correct order. * * @since 1.2 */ public synchronized Object[] toArray() { return Arrays.copyOf(elementData, elementCount); } /** * Returns an array containing all of the elements in this Vector in the * correct order; the runtime type of the returned array is that of the * specified array. If the Vector fits in the specified array, it is * returned therein. Otherwise, a new array is allocated with the runtime * type of the specified array and the size of this Vector. * * <p>If the Vector fits in the specified array with room to spare * (i.e., the array has more elements than the Vector), * the element in the array immediately following the end of the * Vector is set to null. (This is useful in determining the length * of the Vector <em>only</em> if the caller knows that the Vector * does not contain any null elements.) * * @param <T> type of array elements. The same type as {@code <E>} or a * supertype of {@code <E>}. * @param a the array into which the elements of the Vector are to * be stored, if it is big enough; otherwise, a new array of the * same runtime type is allocated for this purpose. * @return an array containing the elements of the Vector * @throws ArrayStoreException if the runtime type of a, {@code <T>}, is not * a supertype of the runtime type, {@code <E>}, of every element in this * Vector * @throws NullPointerException if the given array is null * @since 1.2 */ @SuppressWarnings("unchecked") public synchronized <T> T[] toArray(T[] a) { if (a.length < elementCount) return (T[]) Arrays.copyOf(elementData, elementCount, a.getClass()); System.arraycopy(elementData, 0, a, 0, elementCount); if (a.length > elementCount) a[elementCount] = null; return a; } // Positional Access Operations @SuppressWarnings("unchecked") E elementData(int index) { return (E) elementData[index]; } @SuppressWarnings("unchecked") static <E> E elementAt(Object[] es, int index) { return (E) es[index]; } /** * Returns the element at the specified position in this Vector. * * @param index index of the element to return * @return object at the specified index * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) * @since 1.2 */ public synchronized E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return elementData(index); } /** * Replaces the element at the specified position in this Vector with the * specified element. * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) * @since 1.2 */ public synchronized E set(int index, E element) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); E oldValue = elementData(index); elementData[index] = element; return oldValue; } /** * This helper method split out from add(E) to keep method * bytecode size under 35 (the -XX:MaxInlineSize default value), * which helps when add(E) is called in a C1-compiled loop. */ private void add(E e, Object[] elementData, int s) { if (s == elementData.length) elementData = grow(); elementData[s] = e; elementCount = s + 1; } /** * Appends the specified element to the end of this Vector. * * @param e element to be appended to this Vector * @return {@code true} (as specified by {@link Collection#add}) * @since 1.2 */ public synchronized boolean add(E e) { modCount++; add(e, elementData, elementCount); return true; } /** * Removes the first occurrence of the specified element in this Vector * If the Vector does not contain the element, it is unchanged. More * formally, removes the element with the lowest index i such that * {@code Objects.equals(o, get(i))} (if such * an element exists). * * @param o element to be removed from this Vector, if present * @return true if the Vector contained the specified element * @since 1.2 */ public boolean remove(Object o) { return removeElement(o); } /** * Inserts the specified element at the specified position in this Vector. * Shifts the element currently at that position (if any) and any * subsequent elements to the right (adds one to their indices). * * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index > size()}) * @since 1.2 */ public void add(int index, E element) { insertElementAt(element, index); } /** * Removes the element at the specified position in this Vector. * Shifts any subsequent elements to the left (subtracts one from their * indices). Returns the element that was removed from the Vector. * * @param index the index of the element to be removed * @return element that was removed * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) * @since 1.2 */ public synchronized E remove(int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); E oldValue = elementData(index); int numMoved = elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--elementCount] = null; // Let gc do its work return oldValue; } /** * Removes all of the elements from this Vector. The Vector will * be empty after this call returns (unless it throws an exception). * * @since 1.2 */ public void clear() { removeAllElements(); } // Bulk Operations /** * Returns true if this Vector contains all of the elements in the * specified Collection. * * @param c a collection whose elements will be tested for containment * in this Vector * @return true if this Vector contains all of the elements in the * specified collection * @throws NullPointerException if the specified collection is null */ public synchronized boolean containsAll(Collection<?> c) { return super.containsAll(c); } /** * Appends all of the elements in the specified Collection to the end of * this Vector, in the order that they are returned by the specified * Collection's Iterator. The behavior of this operation is undefined if * the specified Collection is modified while the operation is in progress. * (This implies that the behavior of this call is undefined if the * specified Collection is this Vector, and this Vector is nonempty.) * * @param c elements to be inserted into this Vector * @return {@code true} if this Vector changed as a result of the call * @throws NullPointerException if the specified collection is null * @since 1.2 */ public boolean addAll(Collection<? extends E> c) { Object[] a = c.toArray(); modCount++; int numNew = a.length; if (numNew == 0) return false; synchronized (this) { Object[] elementData = this.elementData; final int s = elementCount; if (numNew > elementData.length - s) elementData = grow(s + numNew); System.arraycopy(a, 0, elementData, s, numNew); elementCount = s + numNew; return true; } } /** * Removes from this Vector all of its elements that are contained in the * specified Collection. * * @param c a collection of elements to be removed from the Vector * @return true if this Vector changed as a result of the call * @throws ClassCastException if the types of one or more elements * in this vector are incompatible with the specified * collection * (<a href="Collection.html#optional-restrictions">optional</a>) * @throws NullPointerException if this vector contains one or more null * elements and the specified collection does not support null * elements * (<a href="Collection.html#optional-restrictions">optional</a>), * or if the specified collection is null * @since 1.2 */ public boolean removeAll(Collection<?> c) { Objects.requireNonNull(c); return bulkRemove(e -> c.contains(e)); } /** * Retains only the elements in this Vector that are contained in the * specified Collection. In other words, removes from this Vector all * of its elements that are not contained in the specified Collection. * * @param c a collection of elements to be retained in this Vector * (all other elements are removed) * @return true if this Vector changed as a result of the call * @throws ClassCastException if the types of one or more elements * in this vector are incompatible with the specified * collection * (<a href="Collection.html#optional-restrictions">optional</a>) * @throws NullPointerException if this vector contains one or more null * elements and the specified collection does not support null * elements * (<a href="Collection.html#optional-restrictions">optional</a>), * or if the specified collection is null * @since 1.2 */ public boolean retainAll(Collection<?> c) { Objects.requireNonNull(c); return bulkRemove(e -> !c.contains(e)); } /** * @throws NullPointerException {@inheritDoc} */ @Override public boolean removeIf(Predicate<? super E> filter) { Objects.requireNonNull(filter); return bulkRemove(filter); } // A tiny bit set implementation private static long[] nBits(int n) { return new long[((n - 1) >> 6) + 1]; } private static void setBit(long[] bits, int i) { bits[i >> 6] |= 1L << i; } private static boolean isClear(long[] bits, int i) { return (bits[i >> 6] & (1L << i)) == 0; } private synchronized boolean bulkRemove(Predicate<? super E> filter) { int expectedModCount = modCount; final Object[] es = elementData; final int end = elementCount; int i; // Optimize for initial run of survivors for (i = 0; i < end && !filter.test(elementAt(es, i)); i++) ; // Tolerate predicates that reentrantly access the collection for // read (but writers still get CME), so traverse once to find // elements to delete, a second pass to physically expunge. if (i < end) { final int beg = i; final long[] deathRow = nBits(end - beg); deathRow[0] = 1L; // set bit 0 for (i = beg + 1; i < end; i++) if (filter.test(elementAt(es, i))) setBit(deathRow, i - beg); if (modCount != expectedModCount) throw new ConcurrentModificationException(); modCount++; int w = beg; for (i = beg; i < end; i++) if (isClear(deathRow, i - beg)) es[w++] = es[i]; for (i = elementCount = w; i < end; i++) es[i] = null; return true; } else { if (modCount != expectedModCount) throw new ConcurrentModificationException(); return false; } } /** * Inserts all of the elements in the specified Collection into this * Vector at the specified position. Shifts the element currently at * that position (if any) and any subsequent elements to the right * (increases their indices). The new elements will appear in the Vector * in the order that they are returned by the specified Collection's * iterator. * * @param index index at which to insert the first element from the * specified collection * @param c elements to be inserted into this Vector * @return {@code true} if this Vector changed as a result of the call * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index > size()}) * @throws NullPointerException if the specified collection is null * @since 1.2 */ public synchronized boolean addAll(int index, Collection<? extends E> c) { if (index < 0 || index > elementCount) throw new ArrayIndexOutOfBoundsException(index); Object[] a = c.toArray(); modCount++; int numNew = a.length; if (numNew == 0) return false; Object[] elementData = this.elementData; final int s = elementCount; if (numNew > elementData.length - s) elementData = grow(s + numNew); int numMoved = s - index; if (numMoved > 0) System.arraycopy(elementData, index, elementData, index + numNew, numMoved); System.arraycopy(a, 0, elementData, index, numNew); elementCount = s + numNew; return true; } /** * Compares the specified Object with this Vector for equality. Returns * true if and only if the specified Object is also a List, both Lists * have the same size, and all corresponding pairs of elements in the two * Lists are <em>equal</em>. (Two elements {@code e1} and * {@code e2} are <em>equal</em> if {@code Objects.equals(e1, e2)}.) * In other words, two Lists are defined to be * equal if they contain the same elements in the same order. * * @param o the Object to be compared for equality with this Vector * @return true if the specified Object is equal to this Vector */ public synchronized boolean equals(Object o) { return super.equals(o); } /** * Returns the hash code value for this Vector. */ public synchronized int hashCode() { return super.hashCode(); } /** * Returns a string representation of this Vector, containing * the String representation of each element. */ public synchronized String toString() { return super.toString(); } /** * Returns a view of the portion of this List between fromIndex, * inclusive, and toIndex, exclusive. (If fromIndex and toIndex are * equal, the returned List is empty.) The returned List is backed by this * List, so changes in the returned List are reflected in this List, and * vice-versa. The returned List supports all of the optional List * operations supported by this List. * * <p>This method eliminates the need for explicit range operations (of * the sort that commonly exist for arrays). Any operation that expects * a List can be used as a range operation by operating on a subList view * instead of a whole List. For example, the following idiom * removes a range of elements from a List: * <pre> * list.subList(from, to).clear(); * </pre> * Similar idioms may be constructed for indexOf and lastIndexOf, * and all of the algorithms in the Collections class can be applied to * a subList. * * <p>The semantics of the List returned by this method become undefined if * the backing list (i.e., this List) is <i>structurally modified</i> in * any way other than via the returned List. (Structural modifications are * those that change the size of the List, or otherwise perturb it in such * a fashion that iterations in progress may yield incorrect results.) * * @param fromIndex low endpoint (inclusive) of the subList * @param toIndex high endpoint (exclusive) of the subList * @return a view of the specified range within this List * @throws IndexOutOfBoundsException if an endpoint index value is out of range * {@code (fromIndex < 0 || toIndex > size)} * @throws IllegalArgumentException if the endpoint indices are out of order * {@code (fromIndex > toIndex)} */ public synchronized List<E> subList(int fromIndex, int toIndex) { return Collections.synchronizedList(super.subList(fromIndex, toIndex), this); } /** * Removes from this list all of the elements whose index is between * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive. * Shifts any succeeding elements to the left (reduces their index). * This call shortens the list by {@code (toIndex - fromIndex)} elements. * (If {@code toIndex==fromIndex}, this operation has no effect.) */ protected synchronized void removeRange(int fromIndex, int toIndex) { modCount++; shiftTailOverGap(elementData, fromIndex, toIndex); } /** Erases the gap from lo to hi, by sliding down following elements. */ private void shiftTailOverGap(Object[] es, int lo, int hi) { System.arraycopy(es, hi, es, lo, elementCount - hi); for (int to = elementCount, i = (elementCount -= hi - lo); i < to; i++) es[i] = null; } /** * Loads a {@code Vector} instance from a stream * (that is, deserializes it). * This method performs checks to ensure the consistency * of the fields. * * @param in the stream * @throws java.io.IOException if an I/O error occurs * @throws ClassNotFoundException if the stream contains data * of a non-existing class */ @java.io.Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField gfields = in.readFields(); int count = gfields.get("elementCount", 0); Object[] data = (Object[])gfields.get("elementData", null); if (count < 0 || data == null || count > data.length) { throw new StreamCorruptedException("Inconsistent vector internals"); } elementCount = count; elementData = data.clone(); } /** * Saves the state of the {@code Vector} instance to a stream * (that is, serializes it). * This method performs synchronization to ensure the consistency * of the serialized data. * * @param s the stream * @throws java.io.IOException if an I/O error occurs */ @java.io.Serial private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { final java.io.ObjectOutputStream.PutField fields = s.putFields(); final Object[] data; synchronized (this) { fields.put("capacityIncrement", capacityIncrement); fields.put("elementCount", elementCount); data = elementData.clone(); } fields.put("elementData", data); s.writeFields(); } /** * Returns a list iterator over the elements in this list (in proper * sequence), starting at the specified position in the list. * The specified index indicates the first element that would be * returned by an initial call to {@link ListIterator#next next}. * An initial call to {@link ListIterator#previous previous} would * return the element with the specified index minus one. * * <p>The returned list iterator is <a href="#fail-fast"><i>fail-fast</i></a>. * * @throws IndexOutOfBoundsException {@inheritDoc} */ public synchronized ListIterator<E> listIterator(int index) { if (index < 0 || index > elementCount) throw new IndexOutOfBoundsException("Index: "+index); return new ListItr(index); } /** * Returns a list iterator over the elements in this list (in proper * sequence). * * <p>The returned list iterator is <a href="#fail-fast"><i>fail-fast</i></a>. * * @see #listIterator(int) */ public synchronized ListIterator<E> listIterator() { return new ListItr(0); } /** * Returns an iterator over the elements in this list in proper sequence. * * <p>The returned iterator is <a href="#fail-fast"><i>fail-fast</i></a>. * * @return an iterator over the elements in this list in proper sequence */ public synchronized Iterator<E> iterator() { return new Itr(); } /** * An optimized version of AbstractList.Itr */ private class Itr implements Iterator<E> { int cursor; // index of next element to return int lastRet = -1; // index of last element returned; -1 if no such int expectedModCount = modCount; public boolean hasNext() { // Racy but within spec, since modifications are checked // within or after synchronization in next/previous return cursor != elementCount; } public E next() { synchronized (Vector.this) { checkForComodification(); int i = cursor; if (i >= elementCount) throw new NoSuchElementException(); cursor = i + 1; return elementData(lastRet = i); } } public void remove() { if (lastRet == -1) throw new IllegalStateException(); synchronized (Vector.this) { checkForComodification(); Vector.this.remove(lastRet); expectedModCount = modCount; } cursor = lastRet; lastRet = -1; } @Override public void forEachRemaining(Consumer<? super E> action) { Objects.requireNonNull(action); synchronized (Vector.this) { final int size = elementCount; int i = cursor; if (i >= size) { return; } final Object[] es = elementData; if (i >= es.length) throw new ConcurrentModificationException(); while (i < size && modCount == expectedModCount) action.accept(elementAt(es, i++)); // update once at end of iteration to reduce heap write traffic cursor = i; lastRet = i - 1; checkForComodification(); } } final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); } } /** * An optimized version of AbstractList.ListItr */ final class ListItr extends Itr implements ListIterator<E> { ListItr(int index) { super(); cursor = index; } public boolean hasPrevious() { return cursor != 0; } public int nextIndex() { return cursor; } public int previousIndex() { return cursor - 1; } public E previous() { synchronized (Vector.this) { checkForComodification(); int i = cursor - 1; if (i < 0) throw new NoSuchElementException(); cursor = i; return elementData(lastRet = i); } } public void set(E e) { if (lastRet == -1) throw new IllegalStateException(); synchronized (Vector.this) { checkForComodification(); Vector.this.set(lastRet, e); } } public void add(E e) { int i = cursor; synchronized (Vector.this) { checkForComodification(); Vector.this.add(i, e); expectedModCount = modCount; } cursor = i + 1; lastRet = -1; } } /** * @throws NullPointerException {@inheritDoc} */ @Override public synchronized void forEach(Consumer<? super E> action) { Objects.requireNonNull(action); final int expectedModCount = modCount; final Object[] es = elementData; final int size = elementCount; for (int i = 0; modCount == expectedModCount && i < size; i++) action.accept(elementAt(es, i)); if (modCount != expectedModCount) throw new ConcurrentModificationException(); } /** * @throws NullPointerException {@inheritDoc} */ @Override public synchronized void replaceAll(UnaryOperator<E> operator) { Objects.requireNonNull(operator); final int expectedModCount = modCount; final Object[] es = elementData; final int size = elementCount; for (int i = 0; modCount == expectedModCount && i < size; i++) es[i] = operator.apply(elementAt(es, i)); if (modCount != expectedModCount) throw new ConcurrentModificationException(); // TODO(8203662): remove increment of modCount from ... modCount++; } @SuppressWarnings("unchecked") @Override public synchronized void sort(Comparator<? super E> c) { final int expectedModCount = modCount; Arrays.sort((E[]) elementData, 0, elementCount, c); if (modCount != expectedModCount) throw new ConcurrentModificationException(); modCount++; } /** * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em> * and <em>fail-fast</em> {@link Spliterator} over the elements in this * list. * * <p>The {@code Spliterator} reports {@link Spliterator#SIZED}, * {@link Spliterator#SUBSIZED}, and {@link Spliterator#ORDERED}. * Overriding implementations should document the reporting of additional * characteristic values. * * @return a {@code Spliterator} over the elements in this list * @since 1.8 */ @Override public Spliterator<E> spliterator() { return new VectorSpliterator(null, 0, -1, 0); } /** Similar to ArrayList Spliterator */ final class VectorSpliterator implements Spliterator<E> { private Object[] array; private int index; // current index, modified on advance/split private int fence; // -1 until used; then one past last index private int expectedModCount; // initialized when fence set /** Creates new spliterator covering the given range. */ VectorSpliterator(Object[] array, int origin, int fence, int expectedModCount) { this.array = array; this.index = origin; this.fence = fence; this.expectedModCount = expectedModCount; } private int getFence() { // initialize on first use int hi; if ((hi = fence) < 0) { synchronized (Vector.this) { array = elementData; expectedModCount = modCount; hi = fence = elementCount; } } return hi; } public Spliterator<E> trySplit() { int hi = getFence(), lo = index, mid = (lo + hi) >>> 1; return (lo >= mid) ? null : new VectorSpliterator(array, lo, index = mid, expectedModCount); } @SuppressWarnings("unchecked") public boolean tryAdvance(Consumer<? super E> action) { Objects.requireNonNull(action); int i; if (getFence() > (i = index)) { index = i + 1; action.accept((E)array[i]); if (modCount != expectedModCount) throw new ConcurrentModificationException(); return true; } return false; } @SuppressWarnings("unchecked") public void forEachRemaining(Consumer<? super E> action) { Objects.requireNonNull(action); final int hi = getFence(); final Object[] a = array; int i; for (i = index, index = hi; i < hi; i++) action.accept((E) a[i]); if (modCount != expectedModCount) throw new ConcurrentModificationException(); } public long estimateSize() { return getFence() - index; } public int characteristics() { return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; } } void checkInvariants() { // assert elementCount >= 0; // assert elementCount == elementData.length || elementData[elementCount] == null; } }
apache-2.0
dwrpayne/zulip
zerver/lib/validator.py
3704
''' This module sets up a scheme for validating that arbitrary Python objects are correctly typed. It is totally decoupled from Django, composable, easily wrapped, and easily extended. A validator takes two parameters--var_name and val--and returns an error if val is not the correct type. The var_name parameter is used to format error messages. Validators return None when there are no errors. Example primitive validators are check_string, check_int, and check_bool. Compound validators are created by check_list and check_dict. Note that those functions aren't directly called for validation; instead, those functions are called to return other functions that adhere to the validator contract. This is similar to how Python decorators are often parameterized. The contract for check_list and check_dict is that they get passed in other validators to apply to their items. This allows you to build up validators for arbitrarily complex validators. See ValidatorTestCase for example usage. A simple example of composition is this: check_list(check_string)('my_list', ['a', 'b', 'c']) == None To extend this concept, it's simply a matter of writing your own validator for any particular type of object. ''' from __future__ import absolute_import import six def check_string(var_name, val): if not isinstance(val, six.string_types): return '%s is not a string' % (var_name,) return None def check_int(var_name, val): if not isinstance(val, int): return '%s is not an integer' % (var_name,) return None def check_bool(var_name, val): if not isinstance(val, bool): return '%s is not a boolean' % (var_name,) return None def check_none_or(sub_validator): def f(var_name, val): if val is None: return None else: return sub_validator(var_name, val) return f def check_list(sub_validator, length=None): def f(var_name, val): if not isinstance(val, list): return '%s is not a list' % (var_name,) if length is not None and length != len(val): return '%s should have exactly %d items' % (var_name, length) if sub_validator: for i, item in enumerate(val): vname = '%s[%d]' % (var_name, i) error = sub_validator(vname, item) if error: return error return None return f def check_dict(required_keys): # required_keys is a list of tuples of # key_name/validator def f(var_name, val): if not isinstance(val, dict): return '%s is not a dict' % (var_name,) for k, sub_validator in required_keys: if k not in val: return '%s key is missing from %s' % (k, var_name) vname = '%s["%s"]' % (var_name, k) error = sub_validator(vname, val[k]) if error: return error return None return f def check_variable_type(allowed_type_funcs): """ Use this validator if an argument is of a variable type (e.g. processing properties that might be strings or booleans). `allowed_type_funcs`: the check_* validator functions for the possible data types for this variable. """ def enumerated_type_check(var_name, val): for func in allowed_type_funcs: if not func(var_name, val): return None return '%s is not an allowed_type' % (var_name,) return enumerated_type_check def equals(expected_val): def f(var_name, val): if val != expected_val: return '%s != %r (%r is wrong)' % (var_name, expected_val, val) return None return f
apache-2.0
audaspace/audaspace
plugins/ffmpeg/FFMPEG.h
1862
/******************************************************************************* * Copyright 2009-2016 Jörg Müller * * 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. ******************************************************************************/ #pragma once #ifdef FFMPEG_PLUGIN #define AUD_BUILD_PLUGIN #endif /** * @file FFMPEG.h * @ingroup plugin * The FFMPEG class. */ #include "file/IFileInput.h" #include "file/IFileOutput.h" AUD_NAMESPACE_BEGIN /** * This plugin class reads and writes sounds via ffmpeg. */ class AUD_PLUGIN_API FFMPEG : public IFileInput, public IFileOutput { private: // delete copy constructor and operator= FFMPEG(const FFMPEG&) = delete; FFMPEG& operator=(const FFMPEG&) = delete; public: /** * Creates a new ffmpeg plugin. */ FFMPEG(); /** * Registers this plugin. */ static void registerPlugin(); virtual std::shared_ptr<IReader> createReader(std::string filename, int stream = 0); virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer, int stream = 0); virtual std::vector<StreamInfo> queryStreams(std::string filename); virtual std::vector<StreamInfo> queryStreams(std::shared_ptr<Buffer> buffer); virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); }; AUD_NAMESPACE_END
apache-2.0
HyvelTjuven/KD405A_Andree_R
KD405A_Lars_H/Example Student List/doc/index.html
1309
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc on Fri Dec 03 15:08:36 CET 2010--> <TITLE> Generated Documentation (Untitled) </TITLE> <SCRIPT type="text/javascript"> targetPage = "" + window.location.search; if (targetPage != "" && targetPage != "undefined") targetPage = targetPage.substring(1); if (targetPage.indexOf(":") != -1) targetPage = "undefined"; function loadFrames() { if (targetPage != "" && targetPage != "undefined") top.classFrame.location = top.targetPage; } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()"> <FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)"> <FRAME src="mah/k3/pfi2/studentlist/package-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes"> <NOFRAMES> <H2> Frame Alert</H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to<A HREF="mah/k3/pfi2/studentlist/package-summary.html">Non-frame version.</A> </NOFRAMES> </FRAMESET> </HTML>
apache-2.0
ispras/binnavi
src/main/java/com/google/security/zynamics/binnavi/debug/connection/packets/replies/BreakpointHitReply.java
1580
/* Copyright 2011-2016 Google Inc. 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. */ package com.google.security.zynamics.binnavi.debug.connection.packets.replies; import com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues; /** * Represents the reply that is sent by the debug client whenever a regular breakpoint was hit in * the target process. */ public final class BreakpointHitReply extends AnyBreakpointHitReply { /** * Creates a new breakpoint hit reply object. * * @param packetId Packet ID of the reply. * @param errorCode Error code of the reply. If this error code is 0, the requested operation was * successful. * @param tid Thread ID of the thread that hit the breakpoint. * @param registerValues Values of all registers when the breakpoints was hit. In case of an * error, this argument is null. */ public BreakpointHitReply(final int packetId, final int errorCode, final long tid, final RegisterValues registerValues) { super(packetId, errorCode, tid, registerValues); } }
apache-2.0
stankovski/azure-sdk-for-net
sdk/keyvault/Azure.Security.KeyVault.Keys/src/Cryptography/RemoteCryptographyClient.cs
16295
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using Azure.Core; using Azure.Core.Pipeline; using System; using System.Threading; using System.Threading.Tasks; namespace Azure.Security.KeyVault.Keys.Cryptography { internal class RemoteCryptographyClient : ICryptographyProvider { private readonly Uri _keyId; protected RemoteCryptographyClient() { } internal RemoteCryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options) { Argument.AssertNotNull(keyId, nameof(keyId)); Argument.AssertNotNull(credential, nameof(credential)); _keyId = keyId; options ??= new CryptographyClientOptions(); string apiVersion = options.GetVersionString(); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new ChallengeBasedAuthenticationPolicy(credential)); Pipeline = new KeyVaultPipeline(keyId, apiVersion, pipeline, new ClientDiagnostics(options)); } internal RemoteCryptographyClient(KeyVaultPipeline pipeline) { Pipeline = pipeline; } internal KeyVaultPipeline Pipeline { get; } public bool SupportsOperation(KeyOperation operation) => true; public virtual async Task<Response<EncryptResult>> EncryptAsync(EncryptionAlgorithm algorithm, byte[] plaintext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = plaintext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Encrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new EncryptResult { Algorithm = algorithm }, cancellationToken, "/encrypt").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<EncryptResult> Encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = plaintext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Encrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new EncryptResult { Algorithm = algorithm }, cancellationToken, "/encrypt"); } catch (Exception e) { scope.Failed(e); throw; } } public virtual async Task<Response<DecryptResult>> DecryptAsync(EncryptionAlgorithm algorithm, byte[] ciphertext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = ciphertext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Decrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new DecryptResult { Algorithm = algorithm }, cancellationToken, "/decrypt").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<DecryptResult> Decrypt(EncryptionAlgorithm algorithm, byte[] ciphertext, CancellationToken cancellationToken = default) { var parameters = new KeyEncryptParameters() { Algorithm = algorithm.ToString(), Value = ciphertext, }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Decrypt)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new DecryptResult { Algorithm = algorithm }, cancellationToken, "/decrypt"); } catch (Exception e) { scope.Failed(e); throw; } } public virtual async Task<Response<WrapResult>> WrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = key }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(WrapKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new WrapResult { Algorithm = algorithm }, cancellationToken, "/wrapKey").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<WrapResult> WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = key }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(WrapKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new WrapResult { Algorithm = algorithm }, cancellationToken, "/wrapKey"); } catch (Exception e) { scope.Failed(e); throw; } } public virtual async Task<Response<UnwrapResult>> UnwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = encryptedKey }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(UnwrapKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new UnwrapResult { Algorithm = algorithm }, cancellationToken, "/unwrapKey").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<UnwrapResult> UnwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken = default) { var parameters = new KeyWrapParameters() { Algorithm = algorithm.ToString(), Key = encryptedKey }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(UnwrapKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new UnwrapResult { Algorithm = algorithm }, cancellationToken, "/unwrapKey"); } catch (Exception e) { scope.Failed(e); throw; } } public virtual async Task<Response<SignResult>> SignAsync(SignatureAlgorithm algorithm, byte[] digest, CancellationToken cancellationToken = default) { var parameters = new KeySignParameters { Algorithm = algorithm.ToString(), Digest = digest }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Sign)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new SignResult { Algorithm = algorithm }, cancellationToken, "/sign").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<SignResult> Sign(SignatureAlgorithm algorithm, byte[] digest, CancellationToken cancellationToken = default) { var parameters = new KeySignParameters { Algorithm = algorithm.ToString(), Digest = digest }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Sign)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new SignResult { Algorithm = algorithm }, cancellationToken, "/sign"); } catch (Exception e) { scope.Failed(e); throw; } } public virtual async Task<Response<VerifyResult>> VerifyAsync(SignatureAlgorithm algorithm, byte[] digest, byte[] signature, CancellationToken cancellationToken = default) { var parameters = new KeyVerifyParameters { Algorithm = algorithm.ToString(), Digest = digest, Signature = signature }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Verify)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Post, parameters, () => new VerifyResult { Algorithm = algorithm, KeyId = _keyId.ToString() }, cancellationToken, "/verify").ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } public virtual Response<VerifyResult> Verify(SignatureAlgorithm algorithm, byte[] digest, byte[] signature, CancellationToken cancellationToken = default) { var parameters = new KeyVerifyParameters { Algorithm = algorithm.ToString(), Digest = digest, Signature = signature }; using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(Verify)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Post, parameters, () => new VerifyResult { Algorithm = algorithm, KeyId = _keyId.ToString() }, cancellationToken, "/verify"); } catch (Exception e) { scope.Failed(e); throw; } } internal virtual async Task<Response<KeyVaultKey>> GetKeyAsync(CancellationToken cancellationToken = default) { using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(GetKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return await Pipeline.SendRequestAsync(RequestMethod.Get, () => new KeyVaultKey(), cancellationToken).ConfigureAwait(false); } catch (Exception e) { scope.Failed(e); throw; } } internal virtual Response<KeyVaultKey> GetKey(CancellationToken cancellationToken = default) { using DiagnosticScope scope = Pipeline.CreateScope($"{nameof(RemoteCryptographyClient)}.{nameof(GetKey)}"); scope.AddAttribute("key", _keyId); scope.Start(); try { return Pipeline.SendRequest(RequestMethod.Get, () => new KeyVaultKey(), cancellationToken); } catch (Exception e) { scope.Failed(e); throw; } } bool ICryptographyProvider.ShouldRemote => false; async Task<EncryptResult> ICryptographyProvider.EncryptAsync(EncryptionAlgorithm algorithm, byte[] plaintext, CancellationToken cancellationToken) { return await EncryptAsync(algorithm, plaintext, cancellationToken).ConfigureAwait(false); } EncryptResult ICryptographyProvider.Encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, CancellationToken cancellationToken) { return Encrypt(algorithm, plaintext, cancellationToken); } async Task<DecryptResult> ICryptographyProvider.DecryptAsync(EncryptionAlgorithm algorithm, byte[] ciphertext, CancellationToken cancellationToken) { return await DecryptAsync(algorithm, ciphertext, cancellationToken).ConfigureAwait(false); } DecryptResult ICryptographyProvider.Decrypt(EncryptionAlgorithm algorithm, byte[] ciphertext, CancellationToken cancellationToken) { return Decrypt(algorithm, ciphertext, cancellationToken); } async Task<WrapResult> ICryptographyProvider.WrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { return await WrapKeyAsync(algorithm, key, cancellationToken).ConfigureAwait(false); } WrapResult ICryptographyProvider.WrapKey(KeyWrapAlgorithm algorithm, byte[] key, CancellationToken cancellationToken) { return WrapKey(algorithm, key, cancellationToken); } async Task<UnwrapResult> ICryptographyProvider.UnwrapKeyAsync(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken) { return await UnwrapKeyAsync(algorithm, encryptedKey, cancellationToken).ConfigureAwait(false); } UnwrapResult ICryptographyProvider.UnwrapKey(KeyWrapAlgorithm algorithm, byte[] encryptedKey, CancellationToken cancellationToken) { return UnwrapKey(algorithm, encryptedKey, cancellationToken); } async Task<SignResult> ICryptographyProvider.SignAsync(SignatureAlgorithm algorithm, byte[] digest, CancellationToken cancellationToken) { return await SignAsync(algorithm, digest, cancellationToken).ConfigureAwait(false); } SignResult ICryptographyProvider.Sign(SignatureAlgorithm algorithm, byte[] digest, CancellationToken cancellationToken) { return Sign(algorithm, digest, cancellationToken); } async Task<VerifyResult> ICryptographyProvider.VerifyAsync(SignatureAlgorithm algorithm, byte[] digest, byte[] signature, CancellationToken cancellationToken) { return await VerifyAsync(algorithm, digest, signature, cancellationToken).ConfigureAwait(false); } VerifyResult ICryptographyProvider.Verify(SignatureAlgorithm algorithm, byte[] digest, byte[] signature, CancellationToken cancellationToken) { return Verify(algorithm, digest, signature, cancellationToken); } } }
apache-2.0
huang303513/GCD-OperationQueue-Exploration
苹果官方文档Socket基础部分翻译/套接字基础.md
50226
# 套接字基础 ## 第一部分简介 <br /> >重要:这是一个为后面内容的准备性的文档。准确的说它会讨论一些技术,但不是最终的。苹果官方提供这个文档的目的是为了让你熟悉这个模块的接口。这里提供的信息可能会改变,这个文档里提到的接口信息会在最终的文档里面确定。想要了解这个文档的更新过程,点击这里[Apple Developer website](http://developer.apple.com/)。进入相关话题的reference library,并且打开它了解。 <br /> 这个文档专门讲关于网络模块的相关知识。至于在这个文档里面提到的一些其他话题,我们假设你已经熟悉一些基本的网络概念。<br /> >重要:大部分开发人员不需要读这个文档,并且大部分网络应用不会需要这个文档里面的知识(估计意思是大部分app用http)。在你读这个文档之前,你需要提前读[Networking Overview](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010220)以便你更能理解这个文档里面的内容。 <br /> ### 1.1如何使用这个文档 这个文档包含如下几节:<br /> 使用套接字(Socket)和套接字stream---描述了如何使用套接字和stream来做底层网络编程,从POSIX标准层到Foundation框架层。这个部分解释了现有的最好解决方法来写客户端和服务端。 <br /> 域名系统(DNS)解析主机---解释了域名解析系统如何工作,以及如何避开域名解析系统的陷阱。 <br /> 传输层安全(TLS)的正确实现---描述了如何安全的操作传输层从而避免让你的软件有严重的安全问题。这个部分包括TCP steam(使用CFStream或者NSStream API)和URL请求(使用NSURLConnection API)。 <br /> 每个部分都是针对要用到相应知识来编码的开发者。 <br /> ### 1.2先决条件<br /> 这个文档假设你已经度过下面的文档或者理解文档里面的相应的知识: <br /> >[Networking Overview](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010220)-讲一个互联网软件工作的基本流程,如何避免一些常见的错误。 <br /> >[Networking Concepts](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingConcepts/Introduction/Introduction.html#//apple_ref/doc/uid/TP40012487)-描述了以套接字为基础的网络操作和基本概念。 <br /> <br /> <br /> ## 第二部分使用套接字和套接字流(stream)<br /> 这部分讲如何用套接字和套接字stream编程,从POSIX协议层到Foundation框架层。 <br /> >重要:这部分将描述如何全面使用套接字连接,有些应用用更高一级的API更好比如NSURLConnection。想了解NSURLConnection,读[Networking Overview](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010220) .<br />这个部分讲一些在Cocoa或者Core Foundation之外的协议,而且这些协议是你必须支持的。 <br /> 在大多数网络层中,软件被分为两类:客户端和服务端。在高级网络层(high-level API)中,这个区分更明显了。大多数用高级网络层的都是客户端。然而,在低级网络层中,这个界限一般很模糊。 <br /> 套接字和数据流(stream)编程一般分为下面的两类:<br /> . 基于分组的通信(Packet-based communication):程序一般一次操作一个数据包,监听到数据包并发送一个数据包作为回应。而且很有可能每个部分都会处理接收到或者发送的数据。网络通讯协议是一致的。 <br /> . 基于流的客户端(Stream-based clients):程序通过TCP来接收或者发送连续的数据流。对于这种模式,客户端和服务端的界限更明显。客户端和服务端对数据的处理很相似,但是他们构建通讯信道(communication channel)的方式截然不同。 <br /> 这个部分分为如下几个部分:<br /> >选择一个API簇(API Family)---描述如何决定使用哪个API簇。<br /> >写一个基于TCP的客户端---描述如何构建优雅地TCP连接到服务器的服务。<br /> >写一个基于TCP的服务端---描述当我们写服务器的事后,如何监听到来的TCP连接。<br /> >工作基于分组的通信的套接字---描述如何在非TCP协议上工作,比如UDP。 <br /> ### 2.1选择一个API簇(API Family)<br /> 对于基于套接字的链接,你选择那个API是根据你是发送一个链接到其他主机还是接受来自其他主机的链接。同时也决定于你是否使用TCP或者其他协议,下面是你做决定的时候需要考虑的一些因素: <br /> .在OS X中,如果你有需要与非MAC平台的系统通讯,你可以用POSIX C网络编程API,这样你就可以在不同平台共用你的网络模块。如果你的程序是基于Core Foundation或者Cocoa (Foundation)的运行时循环(run loop),你也可以使用Core Foundation的 CFStream API来集成POSIX标准的网络模块。另一方面,如果你用GCD,你可以添加一个套接字作为调度源(dispatch source). <br /> .在iOS中,POSIX标准没有被支持,因为这个标准不支持移动蜂窝网络(cellular radio)或者指定的VPN。通常情况下,你需要从平常的数据处理行数中分开网络模块并且用更高一级的API重写网络模块的代码。 <br /> >注意:如果你用POSIX标准的网络模块代码,你需要注意到POSIX标准的网络API不是协议无关的(protocol-agnostic)(你必须处理IPV4和IPV6的不同)。这是一个IP网络层的一个API而一个名字相关(connect-by-name)API,这意味着你必须做一些额外的工作,如果你想实现一些相同的内部链接特性和更高一级的API的健壮性问题。在你决定使用POSIX标准的网络模块以前,你需要读[Avoid Resolving DNS Names Before Connecting to a Host](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/CommonPitfalls/CommonPitfalls.html#//apple_ref/doc/uid/TP40010220-CH4-SW20) <br /> .对于监听一个端口的守护进程、服务、非TCP的链接,使用POSIX标准或者Core Foundation(CFSocket)的网络模块API。 <br /> .对于用Objective-C写的客户端,用它的Foundation框架的API。Foundation框架定义了针对URL链接、套接字流、网络服务和其他网络任务的高级接口。在iOS和OS X中,这个框架同时也是最基础的、UI无关的Objective-C框架,提供运行时循环的各种操作、字符串处理、集合类、文件访问等等。 <br /> . 如果客户端是C语言写的。用Core Foundation的网络API,这个框架和 CFNetwork框架是两个基于C语言的框架。他们一起定义了一些Foundation框架用到的结构体和函数。 <br /> >注意:在OS X中,CFNetwork框架是Core Services框架的子框架;在iOS中,CFNetwork框架是一个独立的一级框架。 <br /> ### 2.2写一个基于TCP的客户端 <br /> 你编写友好的网络连接接口的方式是取决于你选择的编程语言、连接的类型(TCP,UDP等等)、是否要和其他平台分享相同的代码。 <br /> .在Objective-C中用NSStream来建立连接。 <br /> 如果你要连接到一个主机,新建一个CFHost对象(不是NSHost-他们不能无缝桥接(toll-free bridged)),用[CFStreamCreatePairWithSocketToHost](https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFStreamConstants/index.html#//apple_ref/c/func/CFStreamCreatePairWithSocketToHost)和[CFStreamCreatePairWithSocketToCFHost](https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFSocketStreamRef/index.html#//apple_ref/c/func/CFStreamCreatePairWithSocketToCFHost)来开始一个套接字连接到指定主机和端口,并且关联两个CFStream对象。你也可以用NSStream对象。 <br /> 你也可以用 CFStreamCreatePairWithSocketToNetService 函数来连接到一个Bonjour service(好像用于苹果设备之间的通讯)。读[ Discovering and Advertising Network Services](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Discovering,Browsing,AndAdvertisingNetworkServices/Discovering,Browsing,AndAdvertisingNetworkServices.html#//apple_ref/doc/uid/TP40010220-CH9)来获取更多信息。 <br /> .用POSIX标准如果需要支持跨平台。 <br /> 如果你写的代码只用与苹果平台,name你要避免使用POSIX标准的代码,因为他们和高层的协议比起来,他们更难以操作。然而,如果你写的网络模块代码必须在不同平台分享的话,你可以用POSIX标准的网络API从而你能复用同样的代码。 <br /> 千万别在主线程使用POSIX协议网络的同步API。如果你要用这种API,你必须在一个单独的线程里。 <br /> >注意:POSIX协议网络不支持iOS平台的蜂窝网络,因为这个原因,iOS平台不需要POSIX标准的网络API。 <br /> 下面将讲NSStream的用法,除非特别标明,CFStream API一般都有一个同样名字的函数,而且实现也相似。 <br /> 要了解更多POSIX标准的套接字API,读UNIX Socket FAQ在[ http://developerweb.net/](http://developerweb.net/) . <br /> #### 建立一个链接 <br /> 通常情况下,建立一个TCP链接到其他主机用的是数据流。Streams自动处理TCP链接面临的挑战。比如,数据流提供了通过主机名(hostname)链接的能力,在iOS中,数据流会自动唤醒设备得蜂窝模式或者指定的VPN当需要的时候(不像CFSocket 或者 BSD Socket)。相比于底层协议,Streams更相似Cocoa框架的接口,和Cocoa的文件操作API有很大的相似性。 <br /> 你获取或者发送数据流取决于你是否要被链接或者主动链接到一个主机。 <br /> .如果你已经知道了一个主机的DNS名字或者IP地址,使用 Core Foundation来读取或者发送数据流通过 CFStreamCreatePairWithSocketToHost函数。你可以充分利用CFStream和NSStream的无缝转换。把CFReadStreamRef和CFWriteStreamRef对象转换为NSInputStream和 NSOutputStream对象。 <br /> .如果你想通过CFNetServiceBrowser对象来链接到一个主机,你可以通过CFStreamCreatePairWithSocketToNetService函数来接收或者发送数据。读取[Discovering and Advertising Network Services](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Discovering,Browsing,AndAdvertisingNetworkServices/Discovering,Browsing,AndAdvertisingNetworkServices.html#//apple_ref/doc/uid/TP40010220-CH9) <br /> 当你得到输出路和输入流以后,在没有用arc的情况下你必须马上占有他们,把他们引用到一个NSInputStream和NSOutputStream对象,并且设置他们的代理对象(这个对象需要实现NSStreamDelegate协议)。通过调用open方法在当前运行时循环上执行他们。 <br /> >注意:如果你需要同时处理一个以上链接,你需要区分是那个输入流和输出流关联。最直接的方式你新建一个链接对象同时拥有输入流和输出流的引用,并且把这个对象设置为他们的代理。 <br /> #### 事件处理 当NSOutputStream对象的代理方法stream:handleEvent:被调用了,并且设置streamEvent参数的值为NSStreamEventHasSpaceAvailable,最后调用 write:maxLength:来发送数据。write:maxLength:方法要么返回发送的数据的长度,要么返回一个负数表示失败。如果这个方法返回的数据的长度小于你尝试发送的数据的长度,你必须把没有发送的那部分数据发送出去通过调用NSStreamEventHasSpaceAvailable事件。如果发生错误,你需要调用 streamError方法来确认是哪里发生了错误。 <br /> 当NSInputStream对象的代理方法stream:handleEvent:被调用了,并且设置streamEvent参数的值为NSStreamEventHasBytesAvailable。你可以通过 read:maxLength:方法来读取接收到得数据。这个方法返回接收到得数据的长度或者返回一个负数表示接收失败。 <br /> 如果接收到的数据的长度小于你需要的长度,你必须持有数据并且等待直到你收到所有的数据。如果发生错误,你需要调用 streamError方法来确认是哪里发生了错误。 <br /> 如果链接的另一端中断了链接: <br /> &nbsp;&nbsp;&nbsp;&nbsp;你的链接代理方法stream:handleEvent:被调用。并且streamEvent参数设置为NSStreamEventHasBytesAvailable。如果你去读取接收到的数据,你会发现长度为零。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;你的代理方法stream:handleEvent: 会被调用。并且streamEvent参数被设置为 NSStreamEventEndEncountered。 <br /> 当上面两个事件的其中一个发生了,代理方法需要处理链接操作结束工作和清理工作。 <br /> #### 结束链接 <br /> 当结束一个链接的时候,我们首先要把它从当前运行时循环移除,设置链接的代理为nil(代理对象并没有被retain)。通过close方法关闭与链接关联的两个数据流,最后在释放者两个数据流对象(如果你没有使用ARC)或者把他们设置为nil。这就是通常的关闭链接的方式。然而,如果有下面两种情况你需要手动关闭链接: <br /> &nbsp;&nbsp;&nbsp;&nbsp;对于一个数据流,如果你通过 setProperty:forKey: 方法设置 kCFStreamPropertyShouldCloseNativeSocket属性值为kCFBooleanFalse。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;如果你通过CFStreamCreatePairWithSocket方法创建以BSD套接字为基础的数据流。一般情况下,数据流是在一个系统套接字(native socket)的基础上创建的,并且关闭的时候不会关闭底层的套接字。但是,你也可以设置自动关闭底层套接字通过设置kCFStreamPropertyShouldCloseNativeSocket属性值为kCFBooleanTrue。 <br /> #### 更多信息 要了解更多, 读[Stream Programming Guide]和[Using NSStreams For A TCP Connection Without NSHost]中的[Setting Up Socket Streams]部分, 或者下载[SimpleNetworkStreams](https://developer.apple.com/library/ios/samplecode/SimpleNetworkStreams/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008979)工程来看看. <br /> ### 2.3写一个基于TCP的服务器 就如前面提到的那样,服务器和客户端在网络连接部分非常的相似。主要的不同就是客户端传出连接,而服务器创建一个监听套接字--一个专门监听到来的链接--并且接受链接。这个过程以后,其他的链接行为就和在客户端差不多。 <br /> 使用何种API取决于你是否需要和其他非苹果平台分享代码。只有两种API提供监听到来的网络链接:Core Foundation套接字API和POSIX (BSD)套接字API。更高一级的API不能用于接受链接。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;.如果你写的代码只用于苹果平台,用POSIX标准来写套接字。使用GCD或者CFSocket来集成套接字到你的运行时循环。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;.使用纯粹的POSIX标准的网络代码如果夸平台用同一套代码。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;如果你的代码只用于苹果平台,你应该避免使用POSIX标准的网络模块因为它更难以操作。如果你写的代码需要支持跨平台,你需要使用POSIX标准的网络API。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;.千万别在套接字连接中使用NSSocketPort和NSFileHandle。详情请看:[ Do Not Use NSSocketPort (OS X) or NSFileHandle for General Socket Communication](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/CommonPitfalls/CommonPitfalls.html#//apple_ref/doc/uid/TP40010220-CH4-SW3) <br /> 下面部分描述如何使用API来监听到来的网络链接。 <br /> #### 通过Core Foundation来监听 <br /> 使用Core Foundation API来监听传入链接,你必须做如下步骤:<br /> 1 添加头文件:<br /> ```Objective-C #include <CoreFoundation/CoreFoundation.h> #include <sys/socket.h> #include <netinet/in.h> ``` <br /> 2创建一个套接字对象(返回一个CFSocketRef对象)通过 CFSocketCreate或者CFSocketCreateWithNative函数。把callBackTypes参数的值设置为kCFSocketAcceptCallBack。用一个指针指向CFSocketCallBack的回调函数。 ```Objective-C CFSocketRef myipv4cfsock = CFSocketCreate( kCFAllocatorDefault, PF_INET, SOCK_STREAM, IPPROTO_TCP, kCFSocketAcceptCallBack, handleConnect, NULL); CFSocketRef myipv6cfsock = CFSocketCreate( kCFAllocatorDefault, PF_INET6, SOCK_STREAM, IPPROTO_TCP, kCFSocketAcceptCallBack, handleConnect, NULL); ``` <br /> <br /> 3绑定一个套接字用CFSocketSetAddress函数。提供一个包含sockaddr结构体的CFData对象来指定端口号和协议类型。 ```Objective-C struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; /* Address family */ sin.sin_port = htons(0); /* Or a specific port */ sin.sin_addr.s_addr= INADDR_ANY; CFDataRef sincfd = CFDataCreate( kCFAllocatorDefault, (UInt8 *)&sin, sizeof(sin)); CFSocketSetAddress(myipv4cfsock, sincfd); CFRelease(sincfd); struct sockaddr_in6 sin6; memset(&sin6, 0, sizeof(sin6)); sin6.sin6_len = sizeof(sin6); sin6.sin6_family = AF_INET6; /* Address family */ sin6.sin6_port = htons(0); /* Or a specific port */ sin6.sin6_addr = in6addr_any; CFDataRef sin6cfd = CFDataCreate( kCFAllocatorDefault, (UInt8 *)&sin6, sizeof(sin6)); CFSocketSetAddress(myipv6cfsock, sin6cfd); CFRelease(sin6cfd); ``` <br /> 4开始监听网络链接通过添加一个套接字到运行时循环。 通过CFSocketCreateRunLoopSource函数来为运行时循环的事件源。并且通过 CFRunLoopAddSource把套接字添加到运行时循环上。 <br /> ```Objective-C CFRunLoopSourceRef socketsource = CFSocketCreateRunLoopSource( kCFAllocatorDefault, myipv4cfsock, 0); CFRunLoopAddSource( CFRunLoopGetCurrent(), socketsource, kCFRunLoopDefaultMode); CFRunLoopSourceRef socketsource6 = CFSocketCreateRunLoopSource( kCFAllocatorDefault, myipv6cfsock, 0); CFRunLoopAddSource( CFRunLoopGetCurrent(), socketsource6, kCFRunLoopDefaultMode); ``` <br /> 接下来,你可以得到底层的BSD套接字描述符通过 CFSocketGetNative函数。 <br /> 完成以后,你必须通过CFSocketInvalidate来关闭。 <br /> 套接字监听回调函数handleConnect里面,你需要核实callbackType参数的值是kCFSocketAcceptCallBack,这个参数意意味着接受了一个新链接。在这里,得到的数据的指针是一个 CFSocketNativeHandle(一个套接字整数)值代表了一个套接字。 <br /> 要处理新的传入的链接,你需要用CFStream, NSStream, 或者 CFSocket APIs。基于数据流的API是被推荐的并通过下面几个步骤: <br /> >1 为套接字创建一个读和写的数据流 用CFStreamCreatePairWithSocket方法。 <br /> >2把数据流对象转换为 NSInputStream和 NSOutputStream对象,如果你是基于Cocao框架工作的。 <br /> >3数据流的使用方式和## 写一个基于TCP的客户端里面的用法一样。 <br /> 要了解更多更多,看[CFSocket Reference](https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFSocketRef/index.html#//apple_ref/doc/uid/20001445).要看代码,点击[WiTap](https://developer.apple.com/library/ios/samplecode/WiTap/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007321)下载demo。 <br /> #### 通过POSIX Socket API来监听 <br /> POSIX标准的网络模块和CFSocket的API非常相似,你需要自己实现运行时循环处理(run-loop-handling)代码。 <br /> >重要:在应用中千万别再主线程使用POSIX网络API,如果你要使用这些API,你必须在非主线程里面。 <br /> 下面是创建一个基于POSIX标准的服务器: <br /> 1通过[socket](https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html#//apple_ref/doc/man/2/socket)函数创建一个套接字,如: <br /> ```Objective-C int ipv4_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); int ipv6_socket = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP); ``` <br /> 2绑定一个端口。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;.如果你已经在心里指定了一个默认端口,那么直接使用。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;.如果你没有指定默认端口,把端口设置为0并且操作系统会给你设置一个临时的端口号。(如果你的服务是用Bonjour,我们建议你使用临时端口.)。 <br /> 例如如下: <br /> ```Objective-C struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; // or AF_INET6 (address family) sin.sin_port = htons(0); sin.sin_addr.s_addr= INADDR_ANY; if (bind(listen_sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) { // Handle the error. } ``` <br /> 3如果你使用一个临时端口,调用`getsockname`函数来找出你使用的端口号。你可以通过Bonjour来注册这个端口号,例如; <br /> ```Objective-C socklen_t len = sizeof(sin); if (getsockname(listen_sock, (struct sockaddr *)&sin, &len) < 0) { // Handle error here } // You can now get the port number with ntohs(sin.sin_port). ``` <br /> 4在前面的端口号上使用`listen`来监听传入链接。 <br /> 下一步取决与你使用POSIX套接字代码或者高等级的抽象接口。 <br /> <br /> 用Core Foundation处理事件 <br /> 通过改变上面`Listening with Core Foundation`中的第三步调用CFSocketCreateWithNative来实现。 <br /> <br /> 通过GCD来处理事件 <br /> GCD允许你执行异步操作和提供一个事件处理链机制来决定何时读取数据给套机子。创建监听套机子以后,一个基于GCD的服务需要做如下操作: <br /> &nbsp;&nbsp;&nbsp;&nbsp;1调用dispatch_source_create来创建一个调度源(dispatch source)为监听套接字,指定DISPATCH_SOURCE_TYPE_READ作为源的类型。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;2调用dispatch_source_set_event_handler(或者 dispatch_source_set_event_handler_f 和 dispatch_set_context)来处理任何时候到来的链接。 <br /> &nbsp;&nbsp;&nbsp;&nbsp;3当监听套接字的处理方法被调用了(对于新链接),它需要做如下处理: <br /> >.调用`accept`方法,这个方法填充链接的`sockaddr`结构体并且返回一个套接字。如果有必要,调用ntohl(my_sockaddr_obj.sin_addr.s_addr)来决定客户端的IP地址。 <br /> .调用dispatch_source_create为客户端的调度源。指定为DISPATCH_SOURCE_TYPE_READ类型。 <br /> .调用setsockopt来设置套接字的SO_NOSIGPIPE标志。 <br /> 调用dispatch_source_set_event_handler(或者 dispatch_source_set_event_handler_f 和 dispatch_set_context)来设置套接字句柄,这个函数将被调用无论何时链接状态改变。 <br /> <br /> 4 在客户端套接字句柄中,在dispatch_async或者dispatch_async_f的block里面调用套接字的`read`来获取任何新的数据,并且对数据进行适当的处理。同时也可以用这个block来调用套接字的`write`函数。 <br /> 通过纯粹POSIX标准代码做事件处理 <br /> 1 当一个链接到来时,创建一个文件描述符(file descriptor)并且添加一个套接字在上面。 <br /> ```Objective-C fd_set incoming_connections; memset(&incoming_connections, 0, sizeof(incoming_connections)); ``` <br /> 2 如果你需要在你的网络线程执行周期性的工作,构建一个`timeval`结构体对象作为超时时间。 <br /> ```Objective-C struct timeval tv; tv.tv_sec = 1; /* 1 second timeout */ tv.tv_usec = 0; /* no microseconds. */ ``` <br /> 选择一个合理的超时时间很总要。太短的超时时间会导致系统频繁地处理你的任务而导致系统效率下降。 除非你某些特殊的任务,你执行的任务在每秒执行的次数最好是几次,并且在iOS上,你应该尽量避免这样做。更多信息,读https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/CommonPitfalls/CommonPitfalls.html#//apple_ref/doc/uid/TP40010220-CH4-SW2。 <br /> 如果你需要执行周期性的任务,传入NULL即可。 <br /> 3 复制读和写文件描述符(通过函数FD_COPY)作为参数传入`select`函数从而在运行时循环中调用。`select`这个系统调用会处理这些文件描述符,清除任何没有准备好的文件描述符。 <br /> 对于`timeout`参数,传入前面的`timeval`结构体对象。虽然OS X和iOS不会改变这个结构体,其他一些操作系统会用剩余时间来替代这个结构体。所以对于跨平台的代码,在每次调用`select`的时候你都需要处理这个参数值。 <br /> 对于`nfds`参数,传入一个大于系统文件描述符最大值的数字作为参数值。 <br /> 4 要从套接字中读取数据,通过调用`FD_ISSET`函数来决定是否某个套接字有挂起的数据。当要从套接字写数据,通过调用`FD_ISSET`来决定是否某个套接字有存数据的空间。通过恰当的队列来管理读入和写出的数据。 <br /> 对于基于BSD的平台有一个`kqueue`函数和POSIX标准的`select`函数能相互替代。 <br /> 要了解更多信息,读socket, listen, FD_SET,和 select这些函数所在的文档。 <br /> ### 2.4基于分组的套接字 <br /> 可以通过POSIX API、 CFSocket、GCD APIs来做UDP数据包的接收和发送。使用这些API的步骤如下: <br /> 1 通过`socket`函数来创建一个套接字。 <br /> 2 调用`bind`函数来绑定一个`sockaddr`结构的对象。这个对象指定了套接字连接另一端的端口和协议族。 <br /> 3 通过`connect`函数来连接套接字。 <br /> * UDP的连接不是字面意义上的连接,因为陶氏利用两个非连接的套接字来实现的。首先 你每次发送一个消息的时候都必须指定目的地址。其次,你发送的数据有可能不能正常到达目的地,并且这个错误UDP不负责处理,然而,这些错误是取决于网络环境并且超出了你的app的控制。 接下来,你可以用以下三种方法来处理链接: * 如果你使用GCD的运行时,通过方法`dispatch_source_create`创建一个调度源(dispatch source)。为调度源指定一个事件处理函数。可以选择性的实现一个链接处理函数。最后,通过`dispatch_resume`函数来开始调度源的事件处理。 * 如果你使用CFSocket,这个接口要稍微复杂一点,但是让你的代码更容易集成到Cocoa框架的API。CFSocket使用单个对象来代表一个链接(和POSIX层的socket很像),然而大多数Cocoa API是用基于数据流的PAI并且用分开的对象来发送和接收。导致的结果就是,一些用于处理数据读取或者获取的Cocoa API和CFSocketRef对象的使用方式不同。 * 要使用CFSocket: * 1创建一个对象来管理链接,如果你是用Objective-C写代码,这一般是一个类来实现。如果你是用纯C语言,这是一个Core Foundation对象,比如可变字典。 * 2创建一个上下文对象用于描述第一步中的对象: ```Objective-C CFSocketContext ctxt; ctxt.version = 0; ctxt.info = my_context_object; ctxt.retain = CFRetain; ctxt.release = CFRelease; ctxt.copyDescription = NULL; ``` * 3为CFSocketNativeHandle对象创建一个CFSocket对象(CFSocketRef) ,这可以通过`CFSocketCreateWithNative`方法实现。 确保`callBackTypes`参数的值设置为kCFSocketDataCallBack,别设置为 kCFSocketAcceptCallBack。 你也需要为`CFSocketCallBack`回调函数指定一个指针,这个指针作为`callout`参数的值。 列如: ```Objective-C CFSocketRef connection = CFSocketCreateWithNative(kCFAllocatorDefault, sock, kCFSocketDataCallBack, handleNetworkData, &ctxt); ``` * 4设置Core Foundation被允许关闭socket当Core Foundation的核心基础对象无效。 ```Objective-C CFOptionFlags sockopt = CFSocketGetSocketFlags(connection); sockopt |= kCFSocketCloseOnInvalidate | kCFSocketAutomaticallyReenableReadCallBack; CFSocketSetSocketFlags(connection, sockopt); ``` * 5为socket创建一个事件源并且在运行时循环中用它。 ```Objective-C CFRunLoopSourceRef socketsource = CFSocketCreateRunLoopSource( kCFAllocatorDefault, connection, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), socketsource, kCFRunLoopDefaultMode); ``` 当新数据到达以后,数据处理函数的回调被调用。在你的回调函数中,如果参数`callbackType`的值是 kCFSocketConnectCallBack,确保这个参数被传入回调函数,如果是NULL,你已经连接到了远程主机。这是你可以发送数据通过CFSocketSendData函数。 当套接字连接结束以后,通过CFSocketInvalidate函数关闭并释放它。 任何时候,你都可以通过CFSocketGetNative函数来访问底层的BSD套接字。 更多信息,请看[CFSocket Reference](https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFSocketRef/index.html#//apple_ref/doc/uid/20001445).相应Demo是`UDPEcho`. * 如果你使用纯粹的POSIX套接字,使用`select`这个系统调用来等待数据,并且通过`read`和`write`这两个系统调用来执行I/O操作。要了解POSIX套接字的UDP数据包的接收和发送,读http://developerweb.net/。 ### 2.5获取本地套接字句柄的套接字数据流 有时当工作于基于套接字的数据流(NSInputStream, NSOutputStream, CFReadStream, or CFWriteStream),你需要获取和这些数据流关联的底层套接字句柄。比如,在每个数据流结束的时候你也许想得到IP地址和端口号,这可以通过函数`getsockname`和`getpeername`来获取或者设置套接字选项通过函数`setsockopt`。 要取得一个数据流的本地套接字句柄,调用下面的方法: ```Objective-C -(int) socknumForNSInputStream: (NSStream *)stream { int sock = -1; NSData *sockObj = [stream propertyForKey: (__bridge NSString *)kCFStreamPropertySocketNativeHandle]; if ([sockObj isKindOfClass:[NSData class]] && ([sockObj length] == sizeof(int)) ) { const int *sockptr = (const int *)[sockObj bytes]; sock = *sockptr; } return sock; } ``` 你也可以对一个输出流做一些操作,但是你只能处理他们之间的一个,因为输出流和输入流使用同一个底层本地套接字。 >注意:如果你是用Core Foundation框架的数据流,你可以做这些操作通过CFReadStreamCopyProperty, CFDataGetLength,和 CFDataGetBytes. ##解析DNS主机名 这部分将探讨如何以最灵活地方式解析DNS主机名。 >重要:在OS X和iOS中大多数高层协议的API允许你通过DNS名字来建立连接,同时也建议你这样做。一个主机名可以同时映射到多个IP地址。如果你要自己解析主机名,你需要选择一个IP地址来作为链接远程主机用。作为对照,如果你通过名字来链接,你需要允许操作系统来选择最好的链接方式。尤其对于Bonjour服务更是这样,因为IP地址随时都在变化。 > >然而,通过主机名来链接并不是总是可以。如果你使用的API必须用IP地址的话,OS X和iOS提供几种方法来获取一个或者多个IP地址根据给定的DNS主机名。这一节会描述这些技术。 > >在你读下面内容之前,你可以读一下 Avoid Resolving DNS Names Before Connecting to a Host。 在OS X和iOS中有三种API来处理主机名的解析:NSHost(只用于OS X),CFHost和POSIX标准的API。 * NSHost---即使通过NSHost是一个常用方法来解析主机名,但是现在并不推荐用它因为他是一个同步API。也就是说,用它会导致系统系能下降。因为它不推荐使用,这里不会对他讲解。 * CFHost---这个API是一个异步方法,是一个解析主机名的比较理想的方法如果你必须解析的话。 * POSIX--- 这个标准提供几个函数来解析主机名。这些方法只有当你需要用于处理跨平台的代码时才用,比如你需要集成你的代码到已存在的POSIX标准的网络模块。 ### 3.1通过CFHost解析主机名 通过CFHost解析主机名: * 1创建一个CFHostRef对象通过调用CFHostCreateWithName。 * 2调用 CFHostSetClient 并且提供一个上下文对象和回调函数,这个回调函数在解析结束的时候会被调用。 * 3调用CFHostScheduleWithRunLoop用于执行具体的解析操作,在你的运行时循环中。 * 4调用CFHostStartInfoResolution来告诉解析器开始解析,把它的第二个参数设置为 kCFHostAddresses对象表明你想要返回一个IP地址。 * 5等待解析器调用你的回调函数,通过你的回调函数,调用 CFHostGetAddressing函数来获取解析结果。这个函数返回 CFDataRef对象的一个列表,其中的每一个都包含一个POSIX的`sockaddr`结构体。 反向域名解析的过程(通过IP地址得到主机名)与上面相似,你可以调用CFHostCreateWithAddress来创建一个对象,把 kCFHostNames传入CFHostStartInfoResolution,然后调用 CFHostGetNames来检索结果。 ###3.2通过POSIX解析主机名 如果打算通过POSIX调用来解析主机名,你需要知道这些调用是同步的并且不能用在图形应用的主线程上。相反,你需要创建一个单独的POSIX线程或者一个GCD任务并且在这个上下文中执行它。 >重要:在你的iOS应用的主线程中执行主机名解析会导致你的应用被系统终止,如果超过了规定的时间。 POSIX在`<netdb.h>`文件里面定义了三个方法来解析主机名: `getaddrinfo` * 返回所有已经解析好的地址信息,这个方法是一个非常好的在POSIX标准上获取地址信息的函数,你可以在他的主页上获取想要的代码段. >重要:一些老的NDS服务器没有遵循IPv6协议会返回一个错误。POISX的`getaddrinfo`函数会尝试隐藏这个错误,通过在成功接收到一个IPv4请求以后取消IPv6请求。当然,如果你的应用能获取IPv6地址,那是再好不过的了(相对于你获取一个IPv4地址以后就停止查询),你可以通过一个异步API比如CFHost。 `gethostbyname` * 根据传入的主机名返回IPv4地址。这个方法目前是不推荐的因为它只能查询IPv4的地址。 `gethostbyname2` * 根据传入的主机名,返回在一些指定的协议(AF_INET, AF_INET6等等)下的地址信息。即使这个方法允许你得到IPv4的地址信息就像`gethostbyname`提供的那样,但是它无法一次获取多个地址和选择最快的。所以,这个方法可以考虑为在已经存在的代码的`gethostbyname`方法的一个替代。在新代码中最好使用`getaddrinfo`函数。 对于逆向名字解析(通过IP地址得到主机名),POSIX提供 getnameinfo 和gethostbyaddr方法。getnameinfo方法是推荐选项因为它更灵活。 要了解更多信息,读取上面的链接中这个模块的主页。 ##传输层安全(TLS)链的验证处理 这部分将讨论如何验证传输层安全(Transport Layer Security)并且正确地的处理传输层安全。 >重要:这部分假设你已经读了[ Cryptographic Services](https://developer.apple.com/library/ios/documentation/Security/Conceptual/Security_Overview/CryptographicServices/CryptographicServices.html#//apple_ref/doc/uid/TP30000976-CH3)部分或者对认证、签名和信任链(chains of trust). >大部分软件不用确保链确认(chain validation)。然而,在开发中做这个处理很正常。通过这里所讲的技术来确保链确认正确地执行。你的用户没有保护措施如果你非故意的发布一个没有调试的软件版本。 当一个TLS证书被证实了,操作系统会证实信任链。如果信任链只包含有效的证书并且以一个可信证书结尾,这个证书被认为是有效地。如果不是这样,证书就是无效的。如果你从一个一般的证书颁发结构请求一个证书,这个证书只被认为是“能工作的”。 然而,如果你通过一些可靠证书为你的用户提供服务,为多个局域网提供服务通过一个证书并且不被这些局域网,用一个自签名证书,通过IP地址连接(这样的话网络堆栈不会知道主机的名字),等等---你需要做一些额外的操作来让操作系统接受证书。 在高层网络层上,TLS链可以通过一个认证对象来执行(SecTrustRef)。这个对象包含一些标志来确认那种类型的认证被执行了。你不能手动修改这些标志,但是你可以意识到他们的存在。另外,认证对象包含一个策略(SecPolicyRef)允许你提供主机名,这个主机名会在执行TLS证书的事后被使用。最后,认证对象包含一些安全的证书,这些证书是你的应用可以转换的。 这部分被分为几个小的部分。第一部分`Manipulating Trust Objects`包括一般的操作认证对象从而改变认证行为。剩下的` Trust Objects and NSURLConnection `和` Trust Objects and NSStream`展示如何集成这些改变通过不同的方式。 ###4.1操作认证对象 操作认证对象的细节很大一部分取决于你具体尝试做什么。通常做的两个操作是主机名(它必须证书一般的名字或者适配一些列名称扩展)和anchor(它通常决定一系列可信任证书认证)。 如果要添加一个证书到信任的证书锚,你必须复制现有的证书锚到一个数组里面,创建这个数据的可变副本,添加新证书到可变数组副本里面,然后告诉认证对象用这个新的数据来做认证处理。下面是一个实现功能的简单地函数: Listing 1 添加一个锚到SecTrustRef对象中 ```Objective-C SecTrustRef addAnchorToTrust(SecTrustRef trust, SecCertificateRef trustedCert) { #ifdef PRE_10_6_COMPAT CFArrayRef oldAnchorArray = NULL; /* In OS X prior to 10.6, copy the built-in anchors into a new array. */ if (SecTrustCopyAnchorCertificates(&oldAnchorArray) != errSecSuccess) { /* Something went wrong. */ return NULL; } CFMutableArrayRef newAnchorArray = CFArrayCreateMutableCopy( kCFAllocatorDefault, 0, oldAnchorArray); CFRelease(oldAnchorArray);#else CFMutableArrayRef newAnchorArray = CFArrayCreateMutable ( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)#endif CFArrayAppendValue(newAnchorArray, trustedCert); SecTrustSetAnchorCertificates(trust, newAnchorArray)#ifndef PRE_10_6_COMPAT /* In iOS or OS X v10.6 and later, reenable the built-in anchors after adding your own. */ SecTrustSetAnchorCertificatesOnly(trust, false);#endif return trust; ``` >注意:要为trustedCert对象构建一个SecCertificateRef对象,首先加载一个DER编码的证书到CFData对象中,然后调用SecCertificateCreateWithData。 >更多操作,包括通过其他编码方式加载证书,在OS X 10.7以后你也可以使用`SecItemImport`。 当忽略主机名(允许一个站点证书为另一个站点的证书工作,或者允许允许一个证书工作当你通过IP地址连接到一个主机)的时候,你必须代替认证对象,这个认证对象用于决定如何终止认证。要做这些操作,首先为指定的主机名创建一个新的TLS认证对象。然后创建一个包括那个认证对象的数组。最后让认证对象用这个数组做以后的认证操作。Listing 2 的函数展示了这个过程: Listing 2 为一个SecTrustRef对象改变远程主机名 ```Objective-C SecTrustRef changeHostForTrust(SecTrustRef trust) { CFMutableArrayRef newTrustPolicies = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); SecPolicyRef sslPolicy = SecPolicyCreateSSL(true, CFSTR("www.example.com")); CFArrayAppendValue(newTrustPolicies, sslPolicy); #ifdef MAC_BACKWARDS_COMPATIBILITY /* This technique works in OS X (v10.5 and later) */ SecTrustSetPolicies(trust, newTrustPolicies); CFRelease(oldTrustPolicies); return trust; #else /* This technique works in iOS 2 and later, or OS X v10.7 and later */ CFMutableArrayRef certificates = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); /* Copy the certificates from the original trust object */ CFIndex count = SecTrustGetCertificateCount(trust); CFIndex i=0; for (i = 0; i < count; i++) { SecCertificateRef item = SecTrustGetCertificateAtIndex(trust, i); CFArrayAppendValue(certificates, item); } /* Create a new trust object */ SecTrustRef newtrust = NULL; if (SecTrustCreateWithCertificates(certificates, newTrustPolicies, &newtrust) != errSecSuccess) { /* Probably a good spot to log something. */ return NULL; } return newtrust; #endif } ``` ###4.2认证对象和NSURLConnection 如果要重载NSURLConnection的认证链行为,你必须重载下面两个方法: * connection:canAuthenticateAgainstProtectionSpace: * 这个方法让NSURLConnection知道如何处理特定类型的认证。当你的应用决定是否信任一个服务器证书的事后,这也是一种认证方式---你的应用认证了服务器。 *connection:didReceiveAuthenticationChallenge: * 在这个方法中,你的应用需要转换信任策略,键。服务器或者客户端提供的主机名以便让信任策略被成功的执行。 listing 3 下面是这两个方法的使用。 listing 3 重载被NSURLConnection对象使用的信任对象 ```Objective-C // If you are building for OS X 10.7 and later or iOS 5 and later, // leave out the first method and use the second method as the // connection:willSendRequestForAuthenticationChallenge: method. // For earlier operating systems, include the first method, and // use the second method as the connection:didReceiveAuthenticationChallenge: // method. #ifndef NEW_STYLE - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { #pragma unused(connection) NSString *method = [protectionSpace authenticationMethod]; if (method == NSURLAuthenticationMethodServerTrust) { return YES; } return NO; } -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge #else -(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge #endif { NSURLProtectionSpace *protectionSpace = [challenge protectionSpace]; if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodServerTrust) { SecTrustRef trust = [protectionSpace serverTrust]; /***** Make specific changes to the trust policy here. *****/ /* Re-evaluate the trust policy. */ SecTrustResultType secresult = kSecTrustResultInvalid; if (SecTrustEvaluate(trust, &secresult) != errSecSuccess) { /* Trust evaluation failed. */ [connection cancel]; // Perform other cleanup here, as needed. return; } switch (secresult) { case kSecTrustResultUnspecified: // The OS trusts this certificate implicitly. case kSecTrustResultProceed: // The user explicitly told the OS to trust it. { NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; [challenge.sender useCredential:credential forAuthenticationChallenge:challenge]; return; } default: /* It's somebody else's key. Fall through. */ } /* The server sent a key other than the trusted key. */ [connection cancel]; // Perform other cleanup here, as needed. } } ``` ###4.3信任对象和NSStream 你重载NSStream对象的方式取决于你要做的事情。 如果你需要指定一个不同的TLS主机名,你可以通过下面的几行代码细致的执行在你打开一个数据流之前。 listing 4 通过NSStream重载TLS主机名 ```Objective-C NSDictionary *sslSettings = [NSDictionary dictionaryWithObjectsAndKeys: @"www.gatwood.net", (__bridge id)kCFStreamSSLPeerName, nil]; if (![myInputStream setProperty: sslSettings forKey: (__bridge NSString *)kCFStreamPropertySSLSettings]) { // Handle the error here. } ``` 上面的代码改变数据流的主机名,从而当数据流接下来创建信任对象的时候,它可以提供新的主机名。 如果你需要提供准确的`trusted anchors`,处理过程就更复杂了。当一个数据流创建信任对象的时候,数据流会评估信任对象。如果信任对象评估失败,数据流会在代码正确转换信任对象之前关闭。所以,要重载信任评估过程,你需要执行: * 禁止TLS链的确认。因为数据流永远不会执行TLS链,执行永远不会失败,所以数据流永远不会被关闭。 * 在数据流的代理方法里面手动执行TLS链的确认(在转换信任对象以后)。 当数据流代理的事件处理句柄被调用来表明某个空间可以被套接字使用的时候,操作系统已经构建了一个TLS通道,从其他链接的结尾取得一个认证链,并且创建一个信任对象来执行它。这个时候,你有一个开放的TLS数据流,但是你不知道是否你能信任远程的主机。通过禁止TLS链确认,认证另一端的远程主机是否被信任变成`你的职责`。换句话说,意味着: * 通过创建一个非TLS策略来允许主机核查或者把主机名指定为一个NULL指针。如果你打算链接到一个主机通过主机名并且这个主机名是在信任证书列表里面的一个名字。只有在你收到的证书来自某个`你能控制的地方`时,你才会允许这个操作。 * 不要轻率的信任自签名证书作为anchors(kSecTrustOptionImplicitAnchors)。添加你自己的CA证书到信任列表。 * 不要任意的禁止其他证书选项,比如失效证书和根证书的核实。有一些特定的操作也许可以起作用(比如把文档标记回到2001如果这个文档在2001是有效的),但是对于网络通讯过程来讲,默认选项一般不用管。 通过上面提到的规则,Listing 5 展示了如何用NSSream对象来使用自定义TLS anchor。这个列表页也用到列表1的函数`addAnchorToTrust `。 Listing 5 通过NSStream使用自定义TLS anchor。 ```Objective-C /* Code executed after creating the socket: */ [inStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey]; NSDictionary *sslSettings = [NSDictionary dictionaryWithObjectsAndKeys: (id)kCFBooleanFalse, (id)kCFStreamSSLValidatesCertificateChain, nil]; [inStream setProperty: sslSettings forKey: (__bridge NSString *)kCFStreamPropertySSLSettings]; ... /* Methods in your stream delegate class */ NSString *kAnchorAlreadyAdded = @"AnchorAlreadyAdded"; - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent { if (streamEvent == NSStreamEventHasBytesAvailable || streamEvent == NSStreamEventHasSpaceAvailable) { /* Check it. */ NSArray *certs = [theStream propertyForKey: (__bridge NSString *)kCFStreamPropertySSLPeerCertificates]; SecTrustRef trust = (SecTrustRef)[theStream propertyForKey: (__bridge NSString *)kCFStreamPropertySSLPeerTrust]; /* Because you don't want the array of certificates to keep growing, you should add the anchor to the trust list only upon the initial receipt of data (rather than every time). */ NSNumber *alreadyAdded = [theStream propertyForKey: kAnchorAlreadyAdded]; if (!alreadyAdded || ![alreadyAdded boolValue]) { trust = addAnchorToTrust(trust, self.trustedCert); // defined earlier. [theStream setProperty: [NSNumber numberWithBool: YES] forKey: kAnchorAlreadyAdded]; } SecTrustResultType res = kSecTrustResultInvalid; if (SecTrustEvaluate(trust, &res)) { /* The trust evaluation failed for some reason. This probably means your certificate was broken in some way or your code is otherwise wrong. */ /* Tear down the input stream. */ [theStream removeFromRunLoop: ... forMode: ...]; [theStream setDelegate: nil]; [theStream close]; /* Tear down the output stream. */ ... return; } if (res != kSecTrustResultProceed && res != kSecTrustResultUnspecified) { /* The host is not trusted. */ /* Tear down the input stream. */ [theStream removeFromRunLoop: ... forMode: ...]; [theStream setDelegate: nil]; [theStream close]; /* Tear down the output stream. */ ... } else { // Host is trusted. Handle the data callback normally. } } } ``` <br /> <br /> <br /> <br /> <br /> <br /> <!--&nbsp;&nbsp;&nbsp;&nbsp;. ```Objective-C ```-->
apache-2.0
ollie314/gocd
server/webapp/WEB-INF/rails.new/app/presenters/api_v3/config/timer_representer.rb
1014
########################################################################## # Copyright 2016 ThoughtWorks, 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. ########################################################################## module ApiV3 module Config class TimerRepresenter < ApiV3::BaseRepresenter alias_method :timer, :represented error_representer({"timerSpec" => "spec"}) property :timer_spec, as: :spec property :onlyOnChanges, as: :only_on_changes end end end
apache-2.0
tequalsme/nifi
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
55421
/* * 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. */ /* global define, module, require, exports */ (function (root, factory) { if (typeof define === 'function' && define.amd) { define(['jquery', 'Slick', 'nf.ErrorHandler', 'nf.Common', 'nf.Client', 'nf.CanvasUtils', 'nf.ng.Bridge', 'nf.Dialog', 'nf.Shell'], function ($, Slick, nfErrorHandler, nfCommon, nfClient, nfCanvasUtils, nfNgBridge, nfDialog, nfShell) { return (nf.PolicyManagement = factory($, Slick, nfErrorHandler, nfCommon, nfClient, nfCanvasUtils, nfNgBridge, nfDialog, nfShell)); }); } else if (typeof exports === 'object' && typeof module === 'object') { module.exports = (nf.PolicyManagement = factory(require('jquery'), require('Slick'), require('nf.ErrorHandler'), require('nf.Common'), require('nf.Client'), require('nf.CanvasUtils'), require('nf.ng.Bridge'), require('nf.Dialog'), require('nf.Shell'))); } else { nf.PolicyManagement = factory(root.$, root.Slick, root.nf.ErrorHandler, root.nf.Common, root.nf.Client, root.nf.CanvasUtils, root.nf.ng.Bridge, root.nf.Dialog, root.nf.Shell); } }(this, function ($, Slick, nfErrorHandler, nfCommon, nfClient, nfCanvasUtils, nfNgBridge, nfDialog, nfShell) { 'use strict'; var config = { urls: { api: '../nifi-api', searchTenants: '../nifi-api/tenants/search-results' } }; var initialized = false; var initAddTenantToPolicyDialog = function () { $('#new-policy-user-button').on('click', function () { $('#search-users-dialog').modal('show'); $('#search-users-field').focus(); }); $('#delete-policy-button').on('click', function () { promptToDeletePolicy(); }); $('#search-users-dialog').modal({ scrollableContentStyle: 'scrollable', headerText: 'Add Users/Groups', buttons: [{ buttonText: 'Add', color: { base: '#728E9B', hover: '#004849', text: '#ffffff' }, handler: { click: function () { // add to table and update policy var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); // begin the update policyData.beginUpdate(); // add all users/groups $.each(getTenantsToAdd($('#allowed-users')), function (_, user) { // remove the user policyData.addItem(user); }); $.each(getTenantsToAdd($('#allowed-groups')), function (_, group) { // remove the user policyData.addItem(group); }); // end the update policyData.endUpdate(); // update the policy updatePolicy(); // close the dialog $('#search-users-dialog').modal('hide'); } } }, { buttonText: 'Cancel', color: { base: '#E3E8EB', hover: '#C7D2D7', text: '#004849' }, handler: { click: function () { // close the dialog $('#search-users-dialog').modal('hide'); } } }], handler: { close: function () { // reset the search fields $('#search-users-field').userSearchAutocomplete('reset').val(''); // clear the selected users/groups $('#allowed-users, #allowed-groups').empty(); } } }); // listen for removal requests $(document).on('click', 'div.remove-allowed-entity', function () { $(this).closest('li').remove(); }); // configure the user auto complete $.widget('nf.userSearchAutocomplete', $.ui.autocomplete, { reset: function () { this.term = null; }, _create: function() { this._super(); this.widget().menu('option', 'items', '> :not(.search-no-matches)' ); }, _normalize: function (searchResults) { var items = []; items.push(searchResults); return items; }, _renderMenu: function (ul, items) { // results are normalized into a single element array var searchResults = items[0]; var allowedGroups = getAllAllowedGroups(); var allowedUsers = getAllAllowedUsers(); var nfUserSearchAutocomplete = this; $.each(searchResults.userGroups, function (_, tenant) { // see if this match is not already selected if ($.inArray(tenant.id, allowedGroups) === -1) { nfUserSearchAutocomplete._renderGroup(ul, $.extend({ type: 'group' }, tenant)); } }); $.each(searchResults.users, function (_, tenant) { // see if this match is not already selected if ($.inArray(tenant.id, allowedUsers) === -1) { nfUserSearchAutocomplete._renderUser(ul, $.extend({ type: 'user' }, tenant)); } }); // ensure there were some results if (ul.children().length === 0) { ul.append('<li class="unset search-no-matches">No users matched the search terms</li>'); } }, _resizeMenu: function () { var ul = this.menu.element; ul.width($('#search-users-field').outerWidth() - 2); }, _renderUser: function (ul, match) { var userContent = $('<a></a>').text(match.component.identity); return $('<li></li>').data('ui-autocomplete-item', match).append(userContent).appendTo(ul); }, _renderGroup: function (ul, match) { var groupLabel = $('<span></span>').text(match.component.identity); var groupContent = $('<a></a>').append('<div class="fa fa-users" style="margin-right: 5px;"></div>').append(groupLabel); return $('<li></li>').data('ui-autocomplete-item', match).append(groupContent).appendTo(ul); } }); // configure the autocomplete field $('#search-users-field').userSearchAutocomplete({ minLength: 0, appendTo: '#search-users-results', position: { my: 'left top', at: 'left bottom', offset: '0 1' }, source: function (request, response) { // create the search request $.ajax({ type: 'GET', data: { q: request.term }, dataType: 'json', url: config.urls.searchTenants }).done(function (searchResponse) { response(searchResponse); }); }, select: function (event, ui) { addAllowedTenant(ui.item); // reset the search field $(this).val(''); // stop event propagation return false; } }); }; /** * Gets all allowed groups including those already in the policy and those selected while searching (not yet saved). * * @returns {Array} */ var getAllAllowedGroups = function () { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); var userGroups = []; // consider existing groups in the policy table var items = policyData.getItems(); $.each(items, function (_, item) { if (item.type === 'group') { userGroups.push(item.id); } }); // also consider groups already selected in the search users dialog $.each(getTenantsToAdd($('#allowed-groups')), function (_, group) { userGroups.push(group.id); }); return userGroups; }; /** * Gets the user groups that will be added upon applying the changes. * * @param {jQuery} container * @returns {Array} */ var getTenantsToAdd = function (container) { var tenants = []; // also consider groups already selected in the search users dialog container.children('li').each(function (_, allowedTenant) { var tenant = $(allowedTenant).data('tenant'); if (nfCommon.isDefinedAndNotNull(tenant)) { tenants.push(tenant); } }); return tenants; }; /** * Gets all allowed users including those already in the policy and those selected while searching (not yet saved). * * @returns {Array} */ var getAllAllowedUsers = function () { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); var users = []; // consider existing users in the policy table var items = policyData.getItems(); $.each(items, function (_, item) { if (item.type === 'user') { users.push(item.id); } }); // also consider users already selected in the search users dialog $.each(getTenantsToAdd($('#allowed-users')), function (_, user) { users.push(user.id); }); return users; }; /** * Added the specified tenant to the listing of users/groups which will be added when applied. * * @param allowedTenant user/group to add */ var addAllowedTenant = function (allowedTenant) { var allowedTenants = allowedTenant.type === 'user' ? $('#allowed-users') : $('#allowed-groups'); // append the user var tenant = $('<span></span>').addClass('allowed-entity ellipsis').text(allowedTenant.component.identity).ellipsis(); var tenantAction = $('<div></div>').addClass('remove-allowed-entity fa fa-trash'); $('<li></li>').data('tenant', allowedTenant).append(tenant).append(tenantAction).appendTo(allowedTenants); }; /** * Determines whether the specified global policy type supports read/write options. * * @param policyType global policy type * @returns {boolean} whether the policy supports read/write options */ var globalPolicySupportsReadWrite = function (policyType) { return policyType === 'controller' || policyType === 'counters' || policyType === 'policies' || policyType === 'tenants'; }; /** * Determines whether the specified global policy type only supports write. * * @param policyType global policy type * @returns {boolean} whether the policy only supports write */ var globalPolicySupportsWrite = function (policyType) { return policyType === 'proxy' || policyType === 'restricted-components'; }; /** * Initializes the policy table. */ var initPolicyTable = function () { $('#override-policy-dialog').modal({ headerText: 'Override Policy', buttons: [{ buttonText: 'Override', color: { base: '#728E9B', hover: '#004849', text: '#ffffff' }, handler: { click: function () { // create the policy, copying if appropriate createPolicy($('#copy-policy-radio-button').is(':checked')); $(this).modal('hide'); } } }, { buttonText: 'Cancel', color: { base: '#E3E8EB', hover: '#C7D2D7', text: '#004849' }, handler: { click: function () { $(this).modal('hide'); } } }], handler: { close: function () { // reset the radio button $('#copy-policy-radio-button').prop('checked', true); } } }); // create/add a policy $('#create-policy-link, #add-local-admin-link').on('click', function () { createPolicy(false); }); // override a policy $('#override-policy-link').on('click', function () { $('#override-policy-dialog').modal('show'); }); // policy type listing $('#policy-type-list').combo({ options: [ nfCommon.getPolicyTypeListing('flow'), nfCommon.getPolicyTypeListing('controller'), nfCommon.getPolicyTypeListing('provenance'), nfCommon.getPolicyTypeListing('restricted-components'), nfCommon.getPolicyTypeListing('policies'), nfCommon.getPolicyTypeListing('tenants'), nfCommon.getPolicyTypeListing('site-to-site'), nfCommon.getPolicyTypeListing('system'), nfCommon.getPolicyTypeListing('proxy'), nfCommon.getPolicyTypeListing('counters')], select: function (option) { if (initialized) { // record the policy type $('#selected-policy-type').text(option.value); // if the option is for a specific component if (globalPolicySupportsReadWrite(option.value)) { // update the policy target and let it relaod the policy $('#controller-policy-target').combo('setSelectedOption', { 'value': 'read' }).show(); } else { $('#controller-policy-target').hide(); // record the action if (globalPolicySupportsWrite(option.value)) { $('#selected-policy-action').text('write'); } else { $('#selected-policy-action').text('read'); } // reload the policy loadPolicy(); } } } }); // controller policy target $('#controller-policy-target').combo({ options: [{ text: 'view', value: 'read' }, { text: 'modify', value: 'write' }], select: function (option) { if (initialized) { // record the policy action $('#selected-policy-action').text(option.value); // reload the policy loadPolicy(); } } }); // component policy target $('#component-policy-target').combo({ options: [{ text: 'view the component', value: 'read-component', description: 'Allows users to view component configuration details' }, { text: 'modify the component', value: 'write-component', description: 'Allows users to modify component configuration details' }, { text: 'view the data', value: 'read-data', description: 'Allows users to view metadata and content for this component through provenance data and flowfile queues in outbound connections' }, { text: 'modify the data', value: 'write-data', description: 'Allows users to empty flowfile queues in outbound connections and submit replays' }, { text: 'receive data via site-to-site', value: 'write-receive-data', description: 'Allows this port to receive data from these NiFi instances', disabled: true }, { text: 'send data via site-to-site', value: 'write-send-data', description: 'Allows this port to send data to these NiFi instances', disabled: true }, { text: 'view the policies', value: 'read-policies', description: 'Allows users to view the list of users who can view/modify this component' }, { text: 'modify the policies', value: 'write-policies', description: 'Allows users to modify the list of users who can view/modify this component' }], select: function (option) { if (initialized) { var resource = $('#selected-policy-component-type').text(); if (option.value === 'read-component') { $('#selected-policy-action').text('read'); } else if (option.value === 'write-component') { $('#selected-policy-action').text('write'); } else if (option.value === 'read-data') { $('#selected-policy-action').text('read'); resource = ('data/' + resource); } else if (option.value === 'write-data') { $('#selected-policy-action').text('write'); resource = ('data/' + resource); } else if (option.value === 'read-policies') { $('#selected-policy-action').text('read'); resource = ('policies/' + resource); } else if (option.value === 'write-policies') { $('#selected-policy-action').text('write'); resource = ('policies/' + resource); } else if (option.value === 'write-receive-data') { $('#selected-policy-action').text('write'); resource = 'data-transfer/input-ports'; } else if (option.value === 'write-send-data') { $('#selected-policy-action').text('write'); resource = 'data-transfer/output-ports'; } // set the resource $('#selected-policy-type').text(resource); // reload the policy loadPolicy(); } } }); // function for formatting the user identity var identityFormatter = function (row, cell, value, columnDef, dataContext) { var markup = ''; if (dataContext.type === 'group') { markup += '<div class="fa fa-users" style="margin-right: 5px;"></div>'; } markup += dataContext.component.identity; return markup; }; // function for formatting the actions column var actionFormatter = function (row, cell, value, columnDef, dataContext) { var markup = ''; // see if the user has permissions for the current policy var currentEntity = $('#policy-table').data('policy'); var isPolicyEditable = $('#delete-policy-button').is(':disabled') === false; if (currentEntity.permissions.canWrite === true && isPolicyEditable) { markup += '<div title="Remove" class="pointer delete-user fa fa-trash"></div>'; } return markup; }; // initialize the templates table var usersColumns = [ { id: 'identity', name: 'User', sortable: true, resizable: true, formatter: identityFormatter }, { id: 'actions', name: '&nbsp;', sortable: false, resizable: false, formatter: actionFormatter, width: 100, maxWidth: 100 } ]; var usersOptions = { forceFitColumns: true, enableTextSelectionOnCells: true, enableCellNavigation: true, enableColumnReorder: false, autoEdit: false }; // initialize the dataview var policyData = new Slick.Data.DataView({ inlineFilters: false }); policyData.setItems([]); // initialize the sort sort({ columnId: 'identity', sortAsc: true }, policyData); // initialize the grid var policyGrid = new Slick.Grid('#policy-table', policyData, usersColumns, usersOptions); policyGrid.setSelectionModel(new Slick.RowSelectionModel()); policyGrid.registerPlugin(new Slick.AutoTooltips()); policyGrid.setSortColumn('identity', true); policyGrid.onSort.subscribe(function (e, args) { sort({ columnId: args.sortCol.id, sortAsc: args.sortAsc }, policyData); }); // configure a click listener policyGrid.onClick.subscribe(function (e, args) { var target = $(e.target); // get the node at this row var item = policyData.getItem(args.row); // determine the desired action if (policyGrid.getColumns()[args.cell].id === 'actions') { if (target.hasClass('delete-user')) { promptToRemoveUserFromPolicy(item); } } }); // wire up the dataview to the grid policyData.onRowCountChanged.subscribe(function (e, args) { policyGrid.updateRowCount(); policyGrid.render(); // update the total number of displayed policy users $('#displayed-policy-users').text(args.current); }); policyData.onRowsChanged.subscribe(function (e, args) { policyGrid.invalidateRows(args.rows); policyGrid.render(); }); // hold onto an instance of the grid $('#policy-table').data('gridInstance', policyGrid); // initialize the number of displayed items $('#displayed-policy-users').text('0'); }; /** * Sorts the specified data using the specified sort details. * * @param {object} sortDetails * @param {object} data */ var sort = function (sortDetails, data) { // defines a function for sorting var comparer = function (a, b) { if(a.permissions.canRead && b.permissions.canRead) { var aString = nfCommon.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : ''; var bString = nfCommon.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : ''; return aString === bString ? 0 : aString > bString ? 1 : -1; } else { if (!a.permissions.canRead && !b.permissions.canRead){ return 0; } if(a.permissions.canRead){ return 1; } else { return -1; } } }; // perform the sort data.sort(comparer, sortDetails.sortAsc); }; /** * Prompts for the removal of the specified user. * * @param item */ var promptToRemoveUserFromPolicy = function (item) { nfDialog.showYesNoDialog({ headerText: 'Update Policy', dialogContent: 'Remove \'' + nfCommon.escapeHtml(item.component.identity) + '\' from this policy?', yesHandler: function () { removeUserFromPolicy(item); } }); }; /** * Removes the specified item from the current policy. * * @param item */ var removeUserFromPolicy = function (item) { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); // begin the update policyData.beginUpdate(); // remove the user policyData.deleteItem(item.id); // end the update policyData.endUpdate(); // save the configuration updatePolicy(); }; /** * Prompts for the deletion of the selected policy. */ var promptToDeletePolicy = function () { nfDialog.showYesNoDialog({ headerText: 'Delete Policy', dialogContent: 'By deleting this policy, the permissions for this component will revert to the inherited policy if applicable.', yesText: 'Delete', noText: 'Cancel', yesHandler: function () { deletePolicy(); } }); }; /** * Deletes the current policy. */ var deletePolicy = function () { var currentEntity = $('#policy-table').data('policy'); if (nfCommon.isDefinedAndNotNull(currentEntity)) { $.ajax({ type: 'DELETE', url: currentEntity.uri + '?' + $.param(nfClient.getRevision(currentEntity)), dataType: 'json' }).done(function () { loadPolicy(); }).fail(function (xhr, status, error) { nfErrorHandler.handleAjaxError(xhr, status, error); resetPolicy(); loadPolicy(); }); } else { nfDialog.showOkDialog({ headerText: 'Delete Policy', dialogContent: 'No policy selected' }); } }; /** * Gets the currently selected resource. */ var getSelectedResourceAndAction = function () { var componentId = $('#selected-policy-component-id').text(); var resource = $('#selected-policy-type').text(); if (componentId !== '') { resource += ('/' + componentId); } return { 'action': $('#selected-policy-action').text(), 'resource': '/' + resource }; }; /** * Populates the table with the specified users and groups. * * @param users * @param userGroups */ var populateTable = function (users, userGroups) { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); // begin the update policyData.beginUpdate(); var policyUsers = []; // add each user $.each(users, function (_, user) { policyUsers.push($.extend({ type: 'user' }, user)); }); // add each group $.each(userGroups, function (_, group) { policyUsers.push($.extend({ type: 'group' }, group)); }); // set the rows policyData.setItems(policyUsers); // end the update policyData.endUpdate(); // re-sort and clear selection after updating policyData.reSort(); policyGrid.invalidate(); policyGrid.getSelectionModel().setSelectedRows([]); }; /** * Converts the specified resource into human readable form. * * @param resource */ var getResourceMessage = function (resource) { if (resource === '/policies') { return $('<span>Showing effective policy inherited from all policies.</span>'); } else if (resource === '/controller') { return $('<span>Showing effective policy inherited from the controller.</span>'); } else { // extract the group id var processGroupId = nfCommon.substringAfterLast(resource, '/'); var processGroupName = processGroupId; // attempt to resolve the group name var breadcrumbs = nfNgBridge.injector.get('breadcrumbsCtrl').getBreadcrumbs(); $.each(breadcrumbs, function (_, breadcrumbEntity) { if (breadcrumbEntity.id === processGroupId) { processGroupName = breadcrumbEntity.label; return false; } }); // build the mark up return $('<span>Showing effective policy inherited from Process Group </span>') .append( $('<span class="link ellipsis" style="max-width: 200px; vertical-align: top;"></span>') .text(processGroupName) .attr('title', processGroupName) .on('click', function () { // close the shell $('#shell-close-button').click(); // load the correct group and unselect everything if necessary nfCanvasUtils.getComponentByType('ProcessGroup').enterGroup(processGroupId).done(function () { nfCanvasUtils.getSelection().classed('selected', false); // inform Angular app that values have changed nfNgBridge.digest(); }); }) ).append('<span>.</span>'); } }; /** * Populates the specified policy. * * @param policyEntity */ var populatePolicy = function (policyEntity) { var policy = policyEntity.component; // get the currently selected policy var resourceAndAction = getSelectedResourceAndAction(); // reset of the policy message resetPolicyMessage(); // store the current policy version $('#policy-table').data('policy', policyEntity); // see if the policy is for this resource if (resourceAndAction.resource === policy.resource) { // allow remove when policy is not inherited $('#delete-policy-button').prop('disabled', policyEntity.permissions.canWrite === false); // allow modification if allowed $('#new-policy-user-button').prop('disabled', policyEntity.permissions.canWrite === false); } else { $('#policy-message').append(getResourceMessage(policy.resource)); // policy is inherited, we do not know if the user has permissions to modify the desired policy... show button and let server decide $('#override-policy-message').show(); // do not support policy deletion/modification $('#delete-policy-button').prop('disabled', true); $('#new-policy-user-button').prop('disabled', true); } // populate the table populateTable(policy.users, policy.userGroups); }; /** * Loads the configuration for the specified process group. */ var loadPolicy = function () { var resourceAndAction = getSelectedResourceAndAction(); var policyDeferred; if (resourceAndAction.resource.startsWith('/policies')) { $('#admin-policy-message').show(); policyDeferred = $.Deferred(function (deferred) { $.ajax({ type: 'GET', url: '../nifi-api/policies/' + resourceAndAction.action + resourceAndAction.resource, dataType: 'json' }).done(function (policyEntity) { // update the refresh timestamp $('#policy-last-refreshed').text(policyEntity.generated); // ensure appropriate actions for the loaded policy if (policyEntity.permissions.canRead === true) { var policy = policyEntity.component; // if the return policy is for the desired policy (not inherited, show it) if (resourceAndAction.resource === policy.resource) { // populate the policy details populatePolicy(policyEntity); } else { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('No component specific administrators.'); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide $('#add-local-admin-message').show(); } } else { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('No component specific administrators.'); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide $('#add-local-admin-message').show(); } deferred.resolve(); }).fail(function (xhr, status, error) { if (xhr.status === 404) { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('No component specific administrators.'); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide $('#add-local-admin-message').show(); deferred.resolve(); } else if (xhr.status === 403) { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('Not authorized to access the policy for the specified resource.'); deferred.resolve(); } else { // reset the policy resetPolicy(); deferred.reject(); nfErrorHandler.handleAjaxError(xhr, status, error); } }); }).promise(); } else { $('#admin-policy-message').hide(); policyDeferred = $.Deferred(function (deferred) { $.ajax({ type: 'GET', url: '../nifi-api/policies/' + resourceAndAction.action + resourceAndAction.resource, dataType: 'json' }).done(function (policyEntity) { // return OK so we either have access to the policy or we don't have access to an inherited policy // update the refresh timestamp $('#policy-last-refreshed').text(policyEntity.generated); // ensure appropriate actions for the loaded policy if (policyEntity.permissions.canRead === true) { // populate the policy details populatePolicy(policyEntity); } else { // reset the policy resetPolicy(); // since we cannot read, the policy may be inherited or not... we cannot tell $('#policy-message').text('Not authorized to view the policy.'); // allow option to override because we don't know if it's supported or not $('#override-policy-message').show(); } deferred.resolve(); }).fail(function (xhr, status, error) { if (xhr.status === 404) { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('No policy for the specified resource.'); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide $('#new-policy-message').show(); deferred.resolve(); } else if (xhr.status === 403) { // reset the policy resetPolicy(); // show an appropriate message $('#policy-message').text('Not authorized to access the policy for the specified resource.'); deferred.resolve(); } else { resetPolicy(); deferred.reject(); nfErrorHandler.handleAjaxError(xhr, status, error); } }); }).promise(); } return policyDeferred; }; /** * Creates a new policy for the current selection. * * @param copyInheritedPolicy Whether or not to copy the inherited policy */ var createPolicy = function (copyInheritedPolicy) { var resourceAndAction = getSelectedResourceAndAction(); var users = []; var userGroups = []; if (copyInheritedPolicy === true) { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); var items = policyData.getItems(); $.each(items, function (_, item) { var itemCopy = $.extend({}, item); if (itemCopy.type === 'user') { users.push(itemCopy); } else { userGroups.push(itemCopy); } // remove the type as it was added client side to render differently and is not part of the actual schema delete itemCopy.type; }); } var entity = { 'revision': nfClient.getRevision({ 'revision': { 'version': 0 } }), 'component': { 'action': resourceAndAction.action, 'resource': resourceAndAction.resource, 'users': users, 'userGroups': userGroups } }; $.ajax({ type: 'POST', url: '../nifi-api/policies', data: JSON.stringify(entity), dataType: 'json', contentType: 'application/json' }).done(function (policyEntity) { // ensure appropriate actions for the loaded policy if (policyEntity.permissions.canRead === true) { // populate the policy details populatePolicy(policyEntity); } else { // the request succeeded but we don't have access to the policy... reset/reload the policy resetPolicy(); loadPolicy(); } }).fail(nfErrorHandler.handleAjaxError); }; /** * Updates the policy for the current selection. */ var updatePolicy = function () { var policyGrid = $('#policy-table').data('gridInstance'); var policyData = policyGrid.getData(); var users = []; var userGroups = []; var items = policyData.getItems(); $.each(items, function (_, item) { var itemCopy = $.extend({}, item); if (itemCopy.type === 'user') { users.push(itemCopy); } else { userGroups.push(itemCopy); } // remove the type as it was added client side to render differently and is not part of the actual schema delete itemCopy.type; }); var currentEntity = $('#policy-table').data('policy'); if (nfCommon.isDefinedAndNotNull(currentEntity)) { var entity = { 'revision': nfClient.getRevision(currentEntity), 'component': { 'id': currentEntity.id, 'users': users, 'userGroups': userGroups } }; $.ajax({ type: 'PUT', url: currentEntity.uri, data: JSON.stringify(entity), dataType: 'json', contentType: 'application/json' }).done(function (policyEntity) { // ensure appropriate actions for the loaded policy if (policyEntity.permissions.canRead === true) { // populate the policy details populatePolicy(policyEntity); } else { // the request succeeded but we don't have access to the policy... reset/reload the policy resetPolicy(); loadPolicy(); } }).fail(function (xhr, status, error) { nfErrorHandler.handleAjaxError(xhr, status, error); resetPolicy(); loadPolicy(); }).always(function () { nfCanvasUtils.reload({ 'transition': true }); }); } else { nfDialog.showOkDialog({ headerText: 'Update Policy', dialogContent: 'No policy selected' }); } }; /** * Shows the process group configuration. */ var showPolicy = function () { // show the configuration dialog nfShell.showContent('#policy-management').always(function () { reset(); }); // adjust the table size nfPolicyManagement.resetTableSize(); }; /** * Reset the policy message. */ var resetPolicyMessage = function () { $('#policy-message').text('').empty(); $('#new-policy-message').hide(); $('#override-policy-message').hide(); $('#add-local-admin-message').hide(); }; /** * Reset the policy. */ var resetPolicy = function () { resetPolicyMessage(); // reset button state $('#delete-policy-button').prop('disabled', true); $('#new-policy-user-button').prop('disabled', true); // reset the current policy $('#policy-table').removeData('policy'); // populate the table with no users populateTable([], []); } /** * Resets the policy management dialog. */ var reset = function () { resetPolicy(); // clear the selected policy details $('#selected-policy-type').text(''); $('#selected-policy-action').text(''); $('#selected-policy-component-id').text(''); $('#selected-policy-component-type').text(''); // clear the selected component details $('div.policy-selected-component-container').hide(); }; var nfPolicyManagement = { /** * Initializes the settings page. */ init: function () { initAddTenantToPolicyDialog(); initPolicyTable(); $('#policy-refresh-button').on('click', function () { loadPolicy(); }); // reset the policy to initialize resetPolicy(); // mark as initialized initialized = true; }, /** * Update the size of the grid based on its container's current size. */ resetTableSize: function () { var policyTable = $('#policy-table'); if (policyTable.is(':visible')) { var policyGrid = policyTable.data('gridInstance'); if (nfCommon.isDefinedAndNotNull(policyGrid)) { policyGrid.resizeCanvas(); } } }, /** * Shows the controller service policy. * * @param d */ showControllerServicePolicy: function (d) { // reset the policy message resetPolicyMessage(); // update the policy controls visibility $('#component-policy-controls').show(); $('#global-policy-controls').hide(); // update the visibility if (d.permissions.canRead === true) { $('#policy-selected-controller-service-container div.policy-selected-component-name').text(d.component.name); } else { $('#policy-selected-controller-service-container div.policy-selected-component-name').text(d.id); } $('#policy-selected-controller-service-container').show(); // populate the initial resource $('#selected-policy-component-id').text(d.id); $('#selected-policy-component-type').text('controller-services'); $('#component-policy-target') .combo('setOptionEnabled', { value: 'write-receive-data' }, false) .combo('setOptionEnabled', { value: 'write-send-data' }, false) .combo('setOptionEnabled', { value: 'read-data' }, false) .combo('setOptionEnabled', { value: 'write-data' }, false) .combo('setSelectedOption', { value: 'read-component' }); return loadPolicy().always(showPolicy); }, /** * Shows the reporting task policy. * * @param d */ showReportingTaskPolicy: function (d) { // reset the policy message resetPolicyMessage(); // update the policy controls visibility $('#component-policy-controls').show(); $('#global-policy-controls').hide(); // update the visibility if (d.permissions.canRead === true) { $('#policy-selected-reporting-task-container div.policy-selected-component-name').text(d.component.name); } else { $('#policy-selected-reporting-task-container div.policy-selected-component-name').text(d.id); } $('#policy-selected-reporting-task-container').show(); // populate the initial resource $('#selected-policy-component-id').text(d.id); $('#selected-policy-component-type').text('reporting-tasks'); $('#component-policy-target') .combo('setOptionEnabled', { value: 'write-receive-data' }, false) .combo('setOptionEnabled', { value: 'write-send-data' }, false) .combo('setOptionEnabled', { value: 'read-data' }, false) .combo('setOptionEnabled', { value: 'write-data' }, false) .combo('setSelectedOption', { value: 'read-component' }); return loadPolicy().always(showPolicy); }, /** * Shows the template policy. * * @param d */ showTemplatePolicy: function (d) { // reset the policy message resetPolicyMessage(); // update the policy controls visibility $('#component-policy-controls').show(); $('#global-policy-controls').hide(); // update the visibility if (d.permissions.canRead === true) { $('#policy-selected-template-container div.policy-selected-component-name').text(d.template.name); } else { $('#policy-selected-template-container div.policy-selected-component-name').text(d.id); } $('#policy-selected-template-container').show(); // populate the initial resource $('#selected-policy-component-id').text(d.id); $('#selected-policy-component-type').text('templates'); $('#component-policy-target') .combo('setOptionEnabled', { value: 'write-receive-data' }, false) .combo('setOptionEnabled', { value: 'write-send-data' }, false) .combo('setOptionEnabled', { value: 'read-data' }, false) .combo('setOptionEnabled', { value: 'write-data' }, false) .combo('setSelectedOption', { value: 'read-component' }); return loadPolicy().always(showPolicy); }, /** * Shows the component policy dialog. */ showComponentPolicy: function (selection) { // reset the policy message resetPolicyMessage(); // update the policy controls visibility $('#component-policy-controls').show(); $('#global-policy-controls').hide(); // update the visibility $('#policy-selected-component-container').show(); var resource; if (selection.empty()) { $('#selected-policy-component-id').text(nfCanvasUtils.getGroupId()); resource = 'process-groups'; // disable site to site option $('#component-policy-target') .combo('setOptionEnabled', { value: 'write-receive-data' }, false) .combo('setOptionEnabled', { value: 'write-send-data' }, false) .combo('setOptionEnabled', { value: 'read-data' }, true) .combo('setOptionEnabled', { value: 'write-data' }, true); } else { var d = selection.datum(); $('#selected-policy-component-id').text(d.id); if (nfCanvasUtils.isProcessor(selection)) { resource = 'processors'; } else if (nfCanvasUtils.isProcessGroup(selection)) { resource = 'process-groups'; } else if (nfCanvasUtils.isInputPort(selection)) { resource = 'input-ports'; } else if (nfCanvasUtils.isOutputPort(selection)) { resource = 'output-ports'; } else if (nfCanvasUtils.isRemoteProcessGroup(selection)) { resource = 'remote-process-groups'; } else if (nfCanvasUtils.isLabel(selection)) { resource = 'labels'; } else if (nfCanvasUtils.isFunnel(selection)) { resource = 'funnels'; } // enable site to site option $('#component-policy-target') .combo('setOptionEnabled', { value: 'write-receive-data' }, nfCanvasUtils.isInputPort(selection) && nfCanvasUtils.getParentGroupId() === null) .combo('setOptionEnabled', { value: 'write-send-data' }, nfCanvasUtils.isOutputPort(selection) && nfCanvasUtils.getParentGroupId() === null) .combo('setOptionEnabled', { value: 'read-data' }, !nfCanvasUtils.isLabel(selection)) .combo('setOptionEnabled', { value: 'write-data' }, !nfCanvasUtils.isLabel(selection)); } // populate the initial resource $('#selected-policy-component-type').text(resource); $('#component-policy-target').combo('setSelectedOption', { value: 'read-component' }); return loadPolicy().always(showPolicy); }, /** * Shows the global policies dialog. */ showGlobalPolicies: function () { // reset the policy message resetPolicyMessage(); // update the policy controls visibility $('#component-policy-controls').hide(); $('#global-policy-controls').show(); // reload the current policies var policyType = $('#policy-type-list').combo('getSelectedOption').value; $('#selected-policy-type').text(policyType); if (globalPolicySupportsReadWrite(policyType)) { $('#selected-policy-action').text($('#controller-policy-target').combo('getSelectedOption').value); } else if (globalPolicySupportsWrite(policyType)) { $('#selected-policy-action').text('write'); } else { $('#selected-policy-action').text('read'); } return loadPolicy().always(showPolicy); } }; return nfPolicyManagement; }));
apache-2.0
aws/aws-sdk-cpp
aws-cpp-sdk-connect/source/model/ListInstanceStorageConfigsRequest.cpp
1489
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/connect/model/ListInstanceStorageConfigsRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/http/URI.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <utility> using namespace Aws::Connect::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws::Http; ListInstanceStorageConfigsRequest::ListInstanceStorageConfigsRequest() : m_instanceIdHasBeenSet(false), m_resourceType(InstanceStorageResourceType::NOT_SET), m_resourceTypeHasBeenSet(false), m_nextTokenHasBeenSet(false), m_maxResults(0), m_maxResultsHasBeenSet(false) { } Aws::String ListInstanceStorageConfigsRequest::SerializePayload() const { return {}; } void ListInstanceStorageConfigsRequest::AddQueryStringParameters(URI& uri) const { Aws::StringStream ss; if(m_resourceTypeHasBeenSet) { ss << InstanceStorageResourceTypeMapper::GetNameForInstanceStorageResourceType(m_resourceType); uri.AddQueryStringParameter("resourceType", ss.str()); ss.str(""); } if(m_nextTokenHasBeenSet) { ss << m_nextToken; uri.AddQueryStringParameter("nextToken", ss.str()); ss.str(""); } if(m_maxResultsHasBeenSet) { ss << m_maxResults; uri.AddQueryStringParameter("maxResults", ss.str()); ss.str(""); } }
apache-2.0
ggeorg/chillverse
src/org/apache/pivot/beans/BindException.java
1323
/* * 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.pivot.beans; /** * Thrown when an error is encountered during binding. */ public class BindException extends RuntimeException { private static final long serialVersionUID = 7245531555497832713L; public BindException() { super(); } public BindException(String message) { super(message); } public BindException(Throwable cause) { super(cause); } public BindException(String message, Throwable cause) { super(message, cause); } }
apache-2.0
mhurne/aws-sdk-java
aws-java-sdk-lambda/src/main/java/com/amazonaws/services/lambda/model/transform/CreateEventSourceMappingRequestMarshaller.java
5568
/* * Copyright 2010-2016 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. */ package com.amazonaws.services.lambda.model.transform; import static com.amazonaws.util.StringUtils.UTF8; import static com.amazonaws.util.StringUtils.COMMA_SEPARATOR; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.regex.Pattern; import com.amazonaws.AmazonClientException; import com.amazonaws.Request; import com.amazonaws.DefaultRequest; import com.amazonaws.http.HttpMethodName; import com.amazonaws.services.lambda.model.*; import com.amazonaws.transform.Marshaller; import com.amazonaws.util.BinaryUtils; import com.amazonaws.util.StringUtils; import com.amazonaws.util.StringInputStream; import com.amazonaws.util.json.*; /** * Create Event Source Mapping Request Marshaller */ public class CreateEventSourceMappingRequestMarshaller implements Marshaller<Request<CreateEventSourceMappingRequest>, CreateEventSourceMappingRequest> { private static final String RESOURCE_PATH_TEMPLATE; private static final Map<String, String> STATIC_QUERY_PARAMS; private static final Map<String, String> DYNAMIC_QUERY_PARAMS; static { String path = "/2015-03-31/event-source-mappings/"; Map<String, String> staticMap = new HashMap<String, String>(); Map<String, String> dynamicMap = new HashMap<String, String>(); int index = path.indexOf("?"); if (index != -1) { String queryString = path.substring(index + 1); path = path.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { String name = s.substring(0, index); String value = s.substring(index + 1); if (value.startsWith("{") && value.endsWith("}")) { dynamicMap.put(value.substring(1, value.length() - 1), name); } else { staticMap.put(name, value); } } } } RESOURCE_PATH_TEMPLATE = path; STATIC_QUERY_PARAMS = Collections.unmodifiableMap(staticMap); DYNAMIC_QUERY_PARAMS = Collections.unmodifiableMap(dynamicMap); } public Request<CreateEventSourceMappingRequest> marshall(CreateEventSourceMappingRequest createEventSourceMappingRequest) { if (createEventSourceMappingRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateEventSourceMappingRequest> request = new DefaultRequest<CreateEventSourceMappingRequest>(createEventSourceMappingRequest, "AWSLambda"); String target = "AWSLambda.CreateEventSourceMapping"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = RESOURCE_PATH_TEMPLATE; request.setResourcePath(uriResourcePath.replaceAll("//", "/")); for (Map.Entry<String, String> entry : STATIC_QUERY_PARAMS.entrySet()) { request.addParameter(entry.getKey(), entry.getValue()); } try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (createEventSourceMappingRequest.getEventSourceArn() != null) { jsonWriter.key("EventSourceArn").value(createEventSourceMappingRequest.getEventSourceArn()); } if (createEventSourceMappingRequest.getFunctionName() != null) { jsonWriter.key("FunctionName").value(createEventSourceMappingRequest.getFunctionName()); } if (createEventSourceMappingRequest.isEnabled() != null) { jsonWriter.key("Enabled").value(createEventSourceMappingRequest.isEnabled()); } if (createEventSourceMappingRequest.getBatchSize() != null) { jsonWriter.key("BatchSize").value(createEventSourceMappingRequest.getBatchSize()); } if (createEventSourceMappingRequest.getStartingPosition() != null) { jsonWriter.key("StartingPosition").value(createEventSourceMappingRequest.getStartingPosition()); } jsonWriter.endObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", "application/x-amz-json-1.1"); } catch(Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; } }
apache-2.0
foryou2030/incubator-carbondata
core/src/main/java/org/apache/carbondata/scan/model/QueryDimension.java
1715
/* * 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.carbondata.scan.model; import java.io.Serializable; import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonDimension; /** * query plan dimension which will holds the information about the query plan dimension * this is done to avoid heavy object serialization */ public class QueryDimension extends QueryColumn implements Serializable { /** * serialVersionUID */ private static final long serialVersionUID = -8492704093776645651L; /** * actual dimension column */ private transient CarbonDimension dimension; public QueryDimension(String columName) { super(columName); } /** * @return the dimension */ public CarbonDimension getDimension() { return dimension; } /** * @param dimension the dimension to set */ public void setDimension(CarbonDimension dimension) { this.dimension = dimension; } }
apache-2.0
jt70471/aws-sdk-cpp
aws-cpp-sdk-ce/source/model/GetReservationCoverageResult.cpp
1482
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/ce/model/GetReservationCoverageResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::CostExplorer::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; GetReservationCoverageResult::GetReservationCoverageResult() { } GetReservationCoverageResult::GetReservationCoverageResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } GetReservationCoverageResult& GetReservationCoverageResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("CoveragesByTime")) { Array<JsonView> coveragesByTimeJsonList = jsonValue.GetArray("CoveragesByTime"); for(unsigned coveragesByTimeIndex = 0; coveragesByTimeIndex < coveragesByTimeJsonList.GetLength(); ++coveragesByTimeIndex) { m_coveragesByTime.push_back(coveragesByTimeJsonList[coveragesByTimeIndex].AsObject()); } } if(jsonValue.ValueExists("Total")) { m_total = jsonValue.GetObject("Total"); } if(jsonValue.ValueExists("NextPageToken")) { m_nextPageToken = jsonValue.GetString("NextPageToken"); } return *this; }
apache-2.0
windbender/dropwizard-auth-jwt
src/test/java/com/github/toastshaman/dropwizard/auth/jwt/example/JwtAuthApplication.java
3798
package com.github.toastshaman.dropwizard.auth.jwt.example; import com.github.toastshaman.dropwizard.auth.jwt.JWTAuthFilter; import com.github.toastshaman.dropwizard.auth.jwt.JsonWebTokenParser; import com.github.toastshaman.dropwizard.auth.jwt.JsonWebTokenValidator; import com.github.toastshaman.dropwizard.auth.jwt.hmac.HmacSHA512Verifier; import com.github.toastshaman.dropwizard.auth.jwt.model.JsonWebToken; import com.github.toastshaman.dropwizard.auth.jwt.parser.DefaultJsonWebTokenParser; import com.github.toastshaman.dropwizard.auth.jwt.validator.ExpiryValidator; import com.google.common.base.Optional; import io.dropwizard.Application; import io.dropwizard.auth.AuthDynamicFeature; import io.dropwizard.auth.AuthValueFactoryProvider; import io.dropwizard.auth.Authenticator; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature; import java.security.Principal; /** * A sample dropwizard application that shows how to set up the JWT Authentication provider. * <p/> * The Authentication Provider will parse the tokens supplied in the "Authorization" HTTP header in each HTTP request * given your resource is protected with the @Auth annotation. */ public class JwtAuthApplication extends Application<MyConfiguration> { @Override public void initialize(Bootstrap<MyConfiguration> configurationBootstrap) { } @Override public void run(MyConfiguration configuration, Environment environment) throws Exception { final JsonWebTokenParser tokenParser = new DefaultJsonWebTokenParser(); final HmacSHA512Verifier tokenVerifier = new HmacSHA512Verifier(configuration.getJwtTokenSecret()); environment.jersey().register(new AuthDynamicFeature( new JWTAuthFilter.Builder<>() .setTokenParser(tokenParser) .setTokenVerifier(tokenVerifier) .setRealm("realm") .setPrefix("Bearer") .setAuthenticator(new JwtAuthApplication.ExampleAuthenticator()) .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); environment.jersey().register(RolesAllowedDynamicFeature.class); environment.jersey().register(new SecuredResource(configuration.getJwtTokenSecret())); } private static class ExampleAuthenticator implements Authenticator<JsonWebToken, Principal> { @Override public Optional<Principal> authenticate(JsonWebToken token) { final JsonWebTokenValidator expiryValidator = new ExpiryValidator(); // Provide your own implementation to lookup users based on the principal attribute in the // JWT Token. E.g.: lookup users from a database etc. // This method will be called once the token's signature has been verified // In case you want to verify different parts of the token you can do that here. // E.g.: Verifying that the provided token has not expired. // All JsonWebTokenExceptions will result in a 401 Unauthorized response. expiryValidator.validate(token); if ("good-guy".equals(token.claim().subject())) { final Principal principal = new Principal() { @Override public String getName() { return "good-guy"; } }; return Optional.of(principal); } return Optional.absent(); } } public static void main(String[] args) throws Exception { new JwtAuthApplication().run(new String[]{"server"}); } }
apache-2.0
sunjob/sensor
src/mina/MyLog.java
948
package mina; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyLog { private static final Logger log = LoggerFactory.getLogger(MyLog.class); public static void log_cmd(byte[] data){ //int cmd_type = CommandParser.getCommandType(data); //System.out.println("cmd_type:" + cmd_type); } public static void log_data(String sPrefix, byte[] data){ int iLen = data.length; log.debug(sPrefix + "length:" + iLen); StringBuilder sDebug = new StringBuilder(); String sHex; for(int i = 0; i < iLen; i++){ sHex = String.format("0x%02x", data[i]&0xff); sDebug.append(sHex); //sDebug.append(Integer.toHexString(data[i]&0xff)); sDebug.append(" "); } log.debug(sDebug.toString()); log.debug(" "); } public static void log_output(byte[] data){ //log_data("<<<<<<output<<<<<", data); } public static void log_input(byte[] data){ //log_cmd(data); //log_data(">>>>>>input>>>>>>", data); } }
apache-2.0
reaction1989/roslyn
src/EditorFeatures/TestUtilities2/Intellisense/TestStateFactory.vb
3692
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.Completion Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Friend Class TestStateFactory Public Shared Function CreateCSharpTestState(documentElement As XElement, Optional excludedTypes As List(Of Type) = Nothing, Optional extraExportedTypes As List(Of Type) = Nothing, Optional includeFormatCommandHandler As Boolean = False, Optional languageVersion As CodeAnalysis.CSharp.LanguageVersion = CodeAnalysis.CSharp.LanguageVersion.Default, Optional showCompletionInArgumentLists As Boolean = True) As TestState Dim testState = New TestState(<Workspace> <Project Language="C#" CommonReferences="true" LanguageVersion=<%= DirectCast(languageVersion, Integer) %>> <Document> <%= documentElement.Value %> </Document> </Project> </Workspace>, excludedTypes, extraExportedTypes, includeFormatCommandHandler, workspaceKind:=Nothing) testState.Workspace.SetOptions( testState.Workspace.Options.WithChangedOption(CompletionOptions.TriggerInArgumentLists, LanguageNames.CSharp, showCompletionInArgumentLists)) Return testState End Function Public Shared Function CreateVisualBasicTestState(documentElement As XElement, Optional extraExportedTypes As List(Of Type) = Nothing) As TestState Return New TestState(<Workspace> <Project Language="Visual Basic" CommonReferences="true"> <Document> <%= documentElement.Value %> </Document> </Project> </Workspace>, excludedTypes:=Nothing, extraExportedTypes, includeFormatCommandHandler:=False, workspaceKind:=Nothing) End Function Public Shared Function CreateTestStateFromWorkspace(workspaceElement As XElement, Optional extraExportedTypes As List(Of Type) = Nothing, Optional workspaceKind As String = Nothing, Optional showCompletionInArgumentLists As Boolean = True) As TestState Dim testState = New TestState( workspaceElement, excludedTypes:=Nothing, extraExportedTypes, includeFormatCommandHandler:=False, workspaceKind) testState.Workspace.SetOptions( testState.Workspace.Options.WithChangedOption(CompletionOptions.TriggerInArgumentLists, LanguageNames.CSharp, showCompletionInArgumentLists)) Return testState End Function End Class End Namespace
apache-2.0
jwoyame/node-gdal
deps/libgdal/gdal/ogr/ogrpgeogeometry.cpp
64965
/****************************************************************************** * $Id: ogrpgeogeometry.cpp 33631 2016-03-04 06:28:09Z goatbar $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Implements decoder of shapebin geometry for PGeo * Author: Frank Warmerdam, [email protected] * Paul Ramsey, pramsey at cleverelephant.ca * ****************************************************************************** * Copyright (c) 2005, Frank Warmerdam <[email protected]> * Copyright (c) 2011, Paul Ramsey <pramsey at cleverelephant.ca> * Copyright (c) 2011-2014, Even Rouault <even dot rouault at mines-paris dot org> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * 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 "ogrpgeogeometry.h" #include "ogr_p.h" #include "cpl_string.h" #include <limits> CPL_CVSID("$Id: ogrpgeogeometry.cpp 33631 2016-03-04 06:28:09Z goatbar $"); #define SHPP_TRISTRIP 0 #define SHPP_TRIFAN 1 #define SHPP_OUTERRING 2 #define SHPP_INNERRING 3 #define SHPP_FIRSTRING 4 #define SHPP_RING 5 #define SHPP_TRIANGLES 6 /* Multipatch 9.0 specific */ /************************************************************************/ /* OGRCreateFromMultiPatchPart() */ /************************************************************************/ void OGRCreateFromMultiPatchPart(OGRMultiPolygon *poMP, OGRPolygon*& poLastPoly, int nPartType, int nPartPoints, double* padfX, double* padfY, double* padfZ) { nPartType &= 0xf; if( nPartType == SHPP_TRISTRIP ) { if( poLastPoly != NULL ) { poMP->addGeometryDirectly( poLastPoly ); poLastPoly = NULL; } for( int iBaseVert = 0; iBaseVert < nPartPoints-2; iBaseVert++ ) { OGRPolygon *poPoly = new OGRPolygon(); OGRLinearRing *poRing = new OGRLinearRing(); int iSrcVert = iBaseVert; poRing->setPoint( 0, padfX[iSrcVert], padfY[iSrcVert], padfZ[iSrcVert] ); poRing->setPoint( 1, padfX[iSrcVert+1], padfY[iSrcVert+1], padfZ[iSrcVert+1] ); poRing->setPoint( 2, padfX[iSrcVert+2], padfY[iSrcVert+2], padfZ[iSrcVert+2] ); poRing->setPoint( 3, padfX[iSrcVert], padfY[iSrcVert], padfZ[iSrcVert] ); poPoly->addRingDirectly( poRing ); poMP->addGeometryDirectly( poPoly ); } } else if( nPartType == SHPP_TRIFAN ) { if( poLastPoly != NULL ) { poMP->addGeometryDirectly( poLastPoly ); poLastPoly = NULL; } for( int iBaseVert = 0; iBaseVert < nPartPoints-2; iBaseVert++ ) { OGRPolygon *poPoly = new OGRPolygon(); OGRLinearRing *poRing = new OGRLinearRing(); int iSrcVert = iBaseVert; poRing->setPoint( 0, padfX[0], padfY[0], padfZ[0] ); poRing->setPoint( 1, padfX[iSrcVert+1], padfY[iSrcVert+1], padfZ[iSrcVert+1] ); poRing->setPoint( 2, padfX[iSrcVert+2], padfY[iSrcVert+2], padfZ[iSrcVert+2] ); poRing->setPoint( 3, padfX[0], padfY[0], padfZ[0] ); poPoly->addRingDirectly( poRing ); poMP->addGeometryDirectly( poPoly ); } } else if( nPartType == SHPP_OUTERRING || nPartType == SHPP_INNERRING || nPartType == SHPP_FIRSTRING || nPartType == SHPP_RING ) { if( poLastPoly != NULL && (nPartType == SHPP_OUTERRING || nPartType == SHPP_FIRSTRING) ) { poMP->addGeometryDirectly( poLastPoly ); poLastPoly = NULL; } if( poLastPoly == NULL ) poLastPoly = new OGRPolygon(); OGRLinearRing *poRing = new OGRLinearRing; poRing->setPoints( nPartPoints, padfX, padfY, padfZ ); poRing->closeRings(); poLastPoly->addRingDirectly( poRing ); } else if ( nPartType == SHPP_TRIANGLES ) { if( poLastPoly != NULL ) { poMP->addGeometryDirectly( poLastPoly ); poLastPoly = NULL; } for( int iBaseVert = 0; iBaseVert < nPartPoints-2; iBaseVert+=3 ) { OGRPolygon *poPoly = new OGRPolygon(); OGRLinearRing *poRing = new OGRLinearRing(); int iSrcVert = iBaseVert; poRing->setPoint( 0, padfX[iSrcVert], padfY[iSrcVert], padfZ[iSrcVert] ); poRing->setPoint( 1, padfX[iSrcVert+1], padfY[iSrcVert+1], padfZ[iSrcVert+1] ); poRing->setPoint( 2, padfX[iSrcVert+2], padfY[iSrcVert+2], padfZ[iSrcVert+2] ); poRing->setPoint( 3, padfX[iSrcVert], padfY[iSrcVert], padfZ[iSrcVert] ); poPoly->addRingDirectly( poRing ); poMP->addGeometryDirectly( poPoly ); } } else CPLDebug( "OGR", "Unrecognized parttype %d, ignored.", nPartType ); } /************************************************************************/ /* OGRCreateFromMultiPatch() */ /* */ /* Translate a multipatch representation to an OGR geometry */ /* Mostly copied from shape2ogr.cpp */ /************************************************************************/ static OGRGeometry* OGRCreateFromMultiPatch(int nParts, GInt32* panPartStart, GInt32* panPartType, int nPoints, double* padfX, double* padfY, double* padfZ) { OGRMultiPolygon *poMP = new OGRMultiPolygon(); int iPart; OGRPolygon *poLastPoly = NULL; for( iPart = 0; iPart < nParts; iPart++ ) { int nPartPoints, nPartStart; // Figure out details about this part's vertex list. if( panPartStart == NULL ) { nPartPoints = nPoints; nPartStart = 0; } else { if( iPart == nParts - 1 ) nPartPoints = nPoints - panPartStart[iPart]; else nPartPoints = panPartStart[iPart+1] - panPartStart[iPart]; nPartStart = panPartStart[iPart]; } OGRCreateFromMultiPatchPart(poMP, poLastPoly, panPartType[iPart], nPartPoints, padfX + nPartStart, padfY + nPartStart, padfZ + nPartStart); } if( poLastPoly != NULL ) { poMP->addGeometryDirectly( poLastPoly ); poLastPoly = NULL; } return poMP; } /************************************************************************/ /* OGRWriteToShapeBin() */ /* */ /* Translate OGR geometry to a shapefile binary representation */ /************************************************************************/ OGRErr OGRWriteToShapeBin( OGRGeometry *poGeom, GByte **ppabyShape, int *pnBytes ) { int nShpSize = 4; /* All types start with integer type number */ int nShpZSize = 0; /* Z gets tacked onto the end */ GUInt32 nPoints = 0; GUInt32 nParts = 0; /* -------------------------------------------------------------------- */ /* Null or Empty input maps to SHPT_NULL. */ /* -------------------------------------------------------------------- */ if ( ! poGeom || poGeom->IsEmpty() ) { *ppabyShape = (GByte*)VSI_MALLOC_VERBOSE(nShpSize); if( *ppabyShape == NULL ) return OGRERR_FAILURE; GUInt32 zero = SHPT_NULL; memcpy(*ppabyShape, &zero, nShpSize); *pnBytes = nShpSize; return OGRERR_NONE; } OGRwkbGeometryType nOGRType = wkbFlatten(poGeom->getGeometryType()); const bool b3d = wkbHasZ(poGeom->getGeometryType()); const bool bHasM = wkbHasM(poGeom->getGeometryType()); const int nCoordDims = poGeom->CoordinateDimension(); /* -------------------------------------------------------------------- */ /* Calculate the shape buffer size */ /* -------------------------------------------------------------------- */ if ( nOGRType == wkbPoint ) { nShpSize += 8 * nCoordDims; } else if ( nOGRType == wkbLineString ) { OGRLineString *poLine = (OGRLineString*)poGeom; nPoints = poLine->getNumPoints(); nParts = 1; nShpSize += 16 * nCoordDims; /* xy(z)(m) box */ nShpSize += 4; /* nparts */ nShpSize += 4; /* npoints */ nShpSize += 4; /* parts[1] */ nShpSize += 8 * nCoordDims * nPoints; /* points */ nShpZSize = 16 + 8 * nPoints; } else if ( nOGRType == wkbPolygon ) { poGeom->closeRings(); OGRPolygon *poPoly = (OGRPolygon*)poGeom; nParts = poPoly->getNumInteriorRings() + 1; for ( GUInt32 i = 0; i < nParts; i++ ) { OGRLinearRing *poRing; if ( i == 0 ) poRing = poPoly->getExteriorRing(); else poRing = poPoly->getInteriorRing(i-1); nPoints += poRing->getNumPoints(); } nShpSize += 16 * nCoordDims; /* xy(z)(m) box */ nShpSize += 4; /* nparts */ nShpSize += 4; /* npoints */ nShpSize += 4 * nParts; /* parts[nparts] */ nShpSize += 8 * nCoordDims * nPoints; /* points */ nShpZSize = 16 + 8 * nPoints; } else if ( nOGRType == wkbMultiPoint ) { OGRMultiPoint *poMPoint = (OGRMultiPoint*)poGeom; for ( int i = 0; i < poMPoint->getNumGeometries(); i++ ) { OGRPoint *poPoint = (OGRPoint*)(poMPoint->getGeometryRef(i)); if ( poPoint->IsEmpty() ) continue; nPoints++; } nShpSize += 16 * nCoordDims; /* xy(z)(m) box */ nShpSize += 4; /* npoints */ nShpSize += 8 * nCoordDims * nPoints; /* points */ nShpZSize = 16 + 8 * nPoints; } else if ( nOGRType == wkbMultiLineString ) { OGRMultiLineString *poMLine = (OGRMultiLineString*)poGeom; for ( int i = 0; i < poMLine->getNumGeometries(); i++ ) { OGRLineString *poLine = (OGRLineString*)(poMLine->getGeometryRef(i)); /* Skip empties */ if ( poLine->IsEmpty() ) continue; nParts++; nPoints += poLine->getNumPoints(); } nShpSize += 16 * nCoordDims; /* xy(z)(m) box */ nShpSize += 4; /* nparts */ nShpSize += 4; /* npoints */ nShpSize += 4 * nParts; /* parts[nparts] */ nShpSize += 8 * nCoordDims * nPoints ; /* points */ nShpZSize = 16 + 8 * nPoints; } else if ( nOGRType == wkbMultiPolygon ) { poGeom->closeRings(); OGRMultiPolygon *poMPoly = (OGRMultiPolygon*)poGeom; for( int j = 0; j < poMPoly->getNumGeometries(); j++ ) { OGRPolygon *poPoly = (OGRPolygon*)(poMPoly->getGeometryRef(j)); int nRings = poPoly->getNumInteriorRings() + 1; /* Skip empties */ if ( poPoly->IsEmpty() ) continue; nParts += nRings; for ( int i = 0; i < nRings; i++ ) { OGRLinearRing *poRing; if ( i == 0 ) poRing = poPoly->getExteriorRing(); else poRing = poPoly->getInteriorRing(i-1); nPoints += poRing->getNumPoints(); } } nShpSize += 16 * nCoordDims; /* xy(z)(m) box */ nShpSize += 4; /* nparts */ nShpSize += 4; /* npoints */ nShpSize += 4 * nParts; /* parts[nparts] */ nShpSize += 8 * nCoordDims * nPoints ; /* points */ nShpZSize = 16 + 8 * nPoints; } else { return OGRERR_UNSUPPORTED_OPERATION; } /* Allocate our shape buffer */ *ppabyShape = (GByte*)VSI_MALLOC_VERBOSE(nShpSize); if ( ! *ppabyShape ) return OGRERR_FAILURE; /* Fill in the output size. */ *pnBytes = nShpSize; /* Set up write pointers */ unsigned char *pabyPtr = *ppabyShape; unsigned char *pabyPtrZ = NULL; unsigned char *pabyPtrM = NULL; if( bHasM ) pabyPtrM = pabyPtr + nShpSize - nShpZSize; if ( b3d ) { if( bHasM ) pabyPtrZ = pabyPtrM - nShpZSize; else pabyPtrZ = pabyPtr + nShpSize - nShpZSize; } /* -------------------------------------------------------------------- */ /* Write in the Shape type number now */ /* -------------------------------------------------------------------- */ GUInt32 nGType = SHPT_NULL; switch(nOGRType) { case wkbPoint: { nGType = (b3d && bHasM) ? SHPT_POINTZM : (b3d) ? SHPT_POINTZ : (bHasM) ? SHPT_POINTM : SHPT_POINT; break; } case wkbMultiPoint: { nGType = (b3d && bHasM) ? SHPT_MULTIPOINTZM : (b3d) ? SHPT_MULTIPOINTZ : (bHasM) ? SHPT_MULTIPOINTM : SHPT_MULTIPOINT; break; } case wkbLineString: case wkbMultiLineString: { nGType = (b3d && bHasM) ? SHPT_ARCZM : (b3d) ? SHPT_ARCZ : (bHasM) ? SHPT_ARCM : SHPT_ARC; break; } case wkbPolygon: case wkbMultiPolygon: { nGType = (b3d && bHasM) ? SHPT_POLYGONZM : (b3d) ? SHPT_POLYGONZ : (bHasM) ? SHPT_POLYGONM : SHPT_POLYGON; break; } default: { return OGRERR_UNSUPPORTED_OPERATION; } } /* Write in the type number and advance the pointer */ nGType = CPL_LSBWORD32( nGType ); memcpy( pabyPtr, &nGType, 4 ); pabyPtr += 4; /* -------------------------------------------------------------------- */ /* POINT and POINTZ */ /* -------------------------------------------------------------------- */ if ( nOGRType == wkbPoint ) { OGRPoint *poPoint = (OGRPoint*)poGeom; double x = poPoint->getX(); double y = poPoint->getY(); /* Copy in the raw data. */ memcpy( pabyPtr, &x, 8 ); memcpy( pabyPtr+8, &y, 8 ); if( b3d ) { double z = poPoint->getZ(); memcpy( pabyPtr+8+8, &z, 8 ); } if( bHasM ) { double m = poPoint->getM(); memcpy( pabyPtr+8+((b3d) ? 16 : 8), &m, 8 ); } /* Swap if needed. Shape doubles always LSB */ if( OGR_SWAP( wkbNDR ) ) { CPL_SWAPDOUBLE( pabyPtr ); CPL_SWAPDOUBLE( pabyPtr+8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtr+8+8 ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtr+8+((b3d) ? 16 : 8) ); } return OGRERR_NONE; } /* -------------------------------------------------------------------- */ /* All the non-POINT types require an envelope next */ /* -------------------------------------------------------------------- */ OGREnvelope3D envelope; poGeom->getEnvelope(&envelope); memcpy( pabyPtr, &(envelope.MinX), 8 ); memcpy( pabyPtr+8, &(envelope.MinY), 8 ); memcpy( pabyPtr+8+8, &(envelope.MaxX), 8 ); memcpy( pabyPtr+8+8+8, &(envelope.MaxY), 8 ); /* Swap box if needed. Shape doubles are always LSB */ if( OGR_SWAP( wkbNDR ) ) { for ( int i = 0; i < 4; i++ ) CPL_SWAPDOUBLE( pabyPtr + 8*i ); } pabyPtr += 32; /* Write in the Z bounds at the end of the XY buffer */ if ( b3d ) { memcpy( pabyPtrZ, &(envelope.MinZ), 8 ); memcpy( pabyPtrZ+8, &(envelope.MaxZ), 8 ); /* Swap Z bounds if necessary */ if( OGR_SWAP( wkbNDR ) ) { for ( int i = 0; i < 2; i++ ) CPL_SWAPDOUBLE( pabyPtrZ + 8*i ); } pabyPtrZ += 16; } /* Reserve space for the M bounds at the end of the XY buffer */ GByte* pabyPtrMBounds = NULL; double dfMinM = std::numeric_limits<double>::max(); double dfMaxM = -dfMinM; if ( bHasM ) { pabyPtrMBounds = pabyPtrM; pabyPtrM += 16; } /* -------------------------------------------------------------------- */ /* LINESTRING and LINESTRINGZ */ /* -------------------------------------------------------------------- */ if ( nOGRType == wkbLineString ) { const OGRLineString *poLine = (OGRLineString*)poGeom; /* Write in the nparts (1) */ GUInt32 nPartsLsb = CPL_LSBWORD32( nParts ); memcpy( pabyPtr, &nPartsLsb, 4 ); pabyPtr += 4; /* Write in the npoints */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; /* Write in the part index (0) */ GUInt32 nPartIndex = 0; memcpy( pabyPtr, &nPartIndex, 4 ); pabyPtr += 4; /* Write in the point data */ poLine->getPoints((OGRRawPoint*)pabyPtr, (double*)pabyPtrZ); if( bHasM ) { for( GUInt32 k = 0; k < nPoints; k++ ) { double dfM = poLine->getM(k); memcpy( pabyPtrM + 8*k, &dfM, 8); if( dfM < dfMinM ) dfMinM = dfM; if( dfM > dfMaxM ) dfMaxM = dfM; } } /* Swap if necessary */ if( OGR_SWAP( wkbNDR ) ) { for( GUInt32 k = 0; k < nPoints; k++ ) { CPL_SWAPDOUBLE( pabyPtr + 16*k ); CPL_SWAPDOUBLE( pabyPtr + 16*k + 8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtrZ + 8*k ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtrM + 8*k ); } } } /* -------------------------------------------------------------------- */ /* POLYGON and POLYGONZ */ /* -------------------------------------------------------------------- */ else if ( nOGRType == wkbPolygon ) { OGRPolygon *poPoly = (OGRPolygon*)poGeom; /* Write in the part count */ GUInt32 nPartsLsb = CPL_LSBWORD32( nParts ); memcpy( pabyPtr, &nPartsLsb, 4 ); pabyPtr += 4; /* Write in the total point count */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; /* -------------------------------------------------------------------- */ /* Now we have to visit each ring and write an index number into */ /* the parts list, and the coordinates into the points list. */ /* to do it in one pass, we will use three write pointers. */ /* pabyPtr writes the part indexes */ /* pabyPoints writes the xy coordinates */ /* pabyPtrZ writes the z coordinates */ /* -------------------------------------------------------------------- */ /* Just past the partindex[nparts] array */ unsigned char* pabyPoints = pabyPtr + 4*nParts; int nPointIndexCount = 0; for( GUInt32 i = 0; i < nParts; i++ ) { /* Check our Ring and condition it */ OGRLinearRing *poRing; if ( i == 0 ) { poRing = poPoly->getExteriorRing(); /* Outer ring must be clockwise */ if ( ! poRing->isClockwise() ) poRing->reverseWindingOrder(); } else { poRing = poPoly->getInteriorRing(i-1); /* Inner rings should be anti-clockwise */ if ( poRing->isClockwise() ) poRing->reverseWindingOrder(); } int nRingNumPoints = poRing->getNumPoints(); /* Cannot write un-closed rings to shape */ if( nRingNumPoints <= 2 || ! poRing->get_IsClosed() ) return OGRERR_FAILURE; /* Write in the part index */ GUInt32 nPartIndex = CPL_LSBWORD32( nPointIndexCount ); memcpy( pabyPtr, &nPartIndex, 4 ); /* Write in the point data */ poRing->getPoints((OGRRawPoint*)pabyPoints, (double*)pabyPtrZ); if( bHasM ) { for( int k = 0; k < nRingNumPoints; k++ ) { double dfM = poRing->getM(k); memcpy( pabyPtrM + 8*k, &dfM, 8); if( dfM < dfMinM ) dfMinM = dfM; if( dfM > dfMaxM ) dfMaxM = dfM; } } /* Swap if necessary */ if( OGR_SWAP( wkbNDR ) ) { for( int k = 0; k < nRingNumPoints; k++ ) { CPL_SWAPDOUBLE( pabyPoints + 16*k ); CPL_SWAPDOUBLE( pabyPoints + 16*k + 8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtrZ + 8*k ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtrM + 8*k ); } } nPointIndexCount += nRingNumPoints; /* Advance the write pointers */ pabyPtr += 4; pabyPoints += 16 * nRingNumPoints; if ( b3d ) pabyPtrZ += 8 * nRingNumPoints; if ( bHasM ) pabyPtrM += 8 * nRingNumPoints; } } /* -------------------------------------------------------------------- */ /* MULTIPOINT and MULTIPOINTZ */ /* -------------------------------------------------------------------- */ else if ( nOGRType == wkbMultiPoint ) { OGRMultiPoint *poMPoint = (OGRMultiPoint*)poGeom; /* Write in the total point count */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; /* -------------------------------------------------------------------- */ /* Now we have to visit each point write it into the points list */ /* We will use two write pointers. */ /* pabyPtr writes the xy coordinates */ /* pabyPtrZ writes the z coordinates */ /* -------------------------------------------------------------------- */ for( GUInt32 i = 0; i < nPoints; i++ ) { const OGRPoint *poPt = (OGRPoint*)(poMPoint->getGeometryRef(i)); /* Skip empties */ if ( poPt->IsEmpty() ) continue; /* Write the coordinates */ double x = poPt->getX(); double y = poPt->getY(); memcpy(pabyPtr, &x, 8); memcpy(pabyPtr+8, &y, 8); if ( b3d ) { double z = poPt->getZ(); memcpy(pabyPtrZ, &z, 8); } if ( bHasM ) { double dfM = poPt->getM(); memcpy(pabyPtrM, &dfM, 8); if( dfM < dfMinM ) dfMinM = dfM; if( dfM > dfMaxM ) dfMaxM = dfM; } /* Swap if necessary */ if( OGR_SWAP( wkbNDR ) ) { CPL_SWAPDOUBLE( pabyPtr ); CPL_SWAPDOUBLE( pabyPtr + 8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtrZ ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtrM ); } /* Advance the write pointers */ pabyPtr += 16; if ( b3d ) pabyPtrZ += 8; if ( bHasM ) pabyPtrM += 8; } } /* -------------------------------------------------------------------- */ /* MULTILINESTRING and MULTILINESTRINGZ */ /* -------------------------------------------------------------------- */ else if ( nOGRType == wkbMultiLineString ) { OGRMultiLineString *poMLine = (OGRMultiLineString*)poGeom; /* Write in the part count */ GUInt32 nPartsLsb = CPL_LSBWORD32( nParts ); memcpy( pabyPtr, &nPartsLsb, 4 ); pabyPtr += 4; /* Write in the total point count */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; /* Just past the partindex[nparts] array */ unsigned char* pabyPoints = pabyPtr + 4*nParts; int nPointIndexCount = 0; for( GUInt32 i = 0; i < nParts; i++ ) { const OGRLineString *poLine = (OGRLineString*)(poMLine->getGeometryRef(i)); /* Skip empties */ if ( poLine->IsEmpty() ) continue; int nLineNumPoints = poLine->getNumPoints(); /* Write in the part index */ GUInt32 nPartIndex = CPL_LSBWORD32( nPointIndexCount ); memcpy( pabyPtr, &nPartIndex, 4 ); /* Write in the point data */ poLine->getPoints((OGRRawPoint*)pabyPoints, (double*)pabyPtrZ); if( bHasM ) { for( int k = 0; k < nLineNumPoints; k++ ) { double dfM = poLine->getM(k); memcpy( pabyPtrM + 8*k, &dfM, 8); if( dfM < dfMinM ) dfMinM = dfM; if( dfM > dfMaxM ) dfMaxM = dfM; } } /* Swap if necessary */ if( OGR_SWAP( wkbNDR ) ) { for( int k = 0; k < nLineNumPoints; k++ ) { CPL_SWAPDOUBLE( pabyPoints + 16*k ); CPL_SWAPDOUBLE( pabyPoints + 16*k + 8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtrZ + 8*k ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtrM + 8*k ); } } nPointIndexCount += nLineNumPoints; /* Advance the write pointers */ pabyPtr += 4; pabyPoints += 16 * nLineNumPoints; if ( b3d ) pabyPtrZ += 8 * nLineNumPoints; if ( bHasM ) pabyPtrM += 8 * nLineNumPoints; } } /* -------------------------------------------------------------------- */ /* MULTIPOLYGON and MULTIPOLYGONZ */ /* -------------------------------------------------------------------- */ else /* if ( nOGRType == wkbMultiPolygon ) */ { OGRMultiPolygon *poMPoly = (OGRMultiPolygon*)poGeom; /* Write in the part count */ GUInt32 nPartsLsb = CPL_LSBWORD32( nParts ); memcpy( pabyPtr, &nPartsLsb, 4 ); pabyPtr += 4; /* Write in the total point count */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; /* -------------------------------------------------------------------- */ /* Now we have to visit each ring and write an index number into */ /* the parts list, and the coordinates into the points list. */ /* to do it in one pass, we will use three write pointers. */ /* pabyPtr writes the part indexes */ /* pabyPoints writes the xy coordinates */ /* pabyPtrZ writes the z coordinates */ /* -------------------------------------------------------------------- */ /* Just past the partindex[nparts] array */ unsigned char* pabyPoints = pabyPtr + 4*nParts; int nPointIndexCount = 0; for( int i = 0; i < poMPoly->getNumGeometries(); i++ ) { OGRPolygon *poPoly = (OGRPolygon*)(poMPoly->getGeometryRef(i)); /* Skip empties */ if ( poPoly->IsEmpty() ) continue; int nRings = 1 + poPoly->getNumInteriorRings(); for( int j = 0; j < nRings; j++ ) { /* Check our Ring and condition it */ OGRLinearRing *poRing; if ( j == 0 ) { poRing = poPoly->getExteriorRing(); /* Outer ring must be clockwise */ if ( ! poRing->isClockwise() ) poRing->reverseWindingOrder(); } else { poRing = poPoly->getInteriorRing(j-1); /* Inner rings should be anti-clockwise */ if ( poRing->isClockwise() ) poRing->reverseWindingOrder(); } int nRingNumPoints = poRing->getNumPoints(); /* Cannot write closed rings to shape */ if( nRingNumPoints <= 2 || ! poRing->get_IsClosed() ) return OGRERR_FAILURE; /* Write in the part index */ GUInt32 nPartIndex = CPL_LSBWORD32( nPointIndexCount ); memcpy( pabyPtr, &nPartIndex, 4 ); /* Write in the point data */ poRing->getPoints((OGRRawPoint*)pabyPoints, (double*)pabyPtrZ); if( bHasM ) { for( int k = 0; k < nRingNumPoints; k++ ) { double dfM = poRing->getM(k); memcpy( pabyPtrM + 8*k, &dfM, 8); if( dfM < dfMinM ) dfMinM = dfM; if( dfM > dfMaxM ) dfMaxM = dfM; } } /* Swap if necessary */ if( OGR_SWAP( wkbNDR ) ) { for( int k = 0; k < nRingNumPoints; k++ ) { CPL_SWAPDOUBLE( pabyPoints + 16*k ); CPL_SWAPDOUBLE( pabyPoints + 16*k + 8 ); if( b3d ) CPL_SWAPDOUBLE( pabyPtrZ + 8*k ); if( bHasM ) CPL_SWAPDOUBLE( pabyPtrM + 8*k ); } } nPointIndexCount += nRingNumPoints; /* Advance the write pointers */ pabyPtr += 4; pabyPoints += 16 * nRingNumPoints; if ( b3d ) pabyPtrZ += 8 * nRingNumPoints; if ( bHasM ) pabyPtrM += 8 * nRingNumPoints; } } } if ( bHasM ) { if( dfMinM > dfMaxM ) { dfMinM = 0.0; dfMaxM = 0.0; } memcpy( pabyPtrMBounds, &(dfMinM), 8 ); memcpy( pabyPtrMBounds+8, &(dfMaxM), 8 ); /* Swap M bounds if necessary */ if( OGR_SWAP( wkbNDR ) ) { for ( int i = 0; i < 2; i++ ) CPL_SWAPDOUBLE( pabyPtrMBounds + 8*i ); } } return OGRERR_NONE; } /************************************************************************/ /* OGRWriteMultiPatchToShapeBin() */ /************************************************************************/ OGRErr OGRWriteMultiPatchToShapeBin( OGRGeometry *poGeom, GByte **ppabyShape, int *pnBytes ) { if( wkbFlatten(poGeom->getGeometryType()) != wkbMultiPolygon ) return OGRERR_UNSUPPORTED_OPERATION; poGeom->closeRings(); OGRMultiPolygon *poMPoly = (OGRMultiPolygon*)poGeom; int nParts = 0; int* panPartStart = NULL; int* panPartType = NULL; int nPoints = 0; OGRRawPoint* poPoints = NULL; double* padfZ = NULL; int nBeginLastPart = 0; for( int j = 0; j < poMPoly->getNumGeometries(); j++ ) { OGRPolygon *poPoly = (OGRPolygon*)(poMPoly->getGeometryRef(j)); int nRings = poPoly->getNumInteriorRings() + 1; /* Skip empties */ if ( poPoly->IsEmpty() ) continue; OGRLinearRing *poRing = poPoly->getExteriorRing(); if( nRings == 1 && poRing->getNumPoints() == 4 ) { if( nParts > 0 && poPoints != NULL && ((panPartType[nParts-1] == SHPP_TRIANGLES && nPoints - panPartStart[nParts-1] == 3) || panPartType[nParts-1] == SHPP_TRIFAN) && poRing->getX(0) == poPoints[nBeginLastPart].x && poRing->getY(0) == poPoints[nBeginLastPart].y && poRing->getZ(0) == padfZ[nBeginLastPart] && poRing->getX(1) == poPoints[nPoints-1].x && poRing->getY(1) == poPoints[nPoints-1].y && poRing->getZ(1) == padfZ[nPoints-1] ) { panPartType[nParts-1] = SHPP_TRIFAN; poPoints = (OGRRawPoint*)CPLRealloc(poPoints, (nPoints + 1) * sizeof(OGRRawPoint)); padfZ = (double*)CPLRealloc(padfZ, (nPoints + 1) * sizeof(double)); poPoints[nPoints].x = poRing->getX(2); poPoints[nPoints].y = poRing->getY(2); padfZ[nPoints] = poRing->getZ(2); nPoints ++; } else if( nParts > 0 && poPoints != NULL && ((panPartType[nParts-1] == SHPP_TRIANGLES && nPoints - panPartStart[nParts-1] == 3) || panPartType[nParts-1] == SHPP_TRISTRIP) && poRing->getX(0) == poPoints[nPoints-2].x && poRing->getY(0) == poPoints[nPoints-2].y && poRing->getZ(0) == padfZ[nPoints-2] && poRing->getX(1) == poPoints[nPoints-1].x && poRing->getY(1) == poPoints[nPoints-1].y && poRing->getZ(1) == padfZ[nPoints-1] ) { panPartType[nParts-1] = SHPP_TRISTRIP; poPoints = (OGRRawPoint*)CPLRealloc(poPoints, (nPoints + 1) * sizeof(OGRRawPoint)); padfZ = (double*)CPLRealloc(padfZ, (nPoints + 1) * sizeof(double)); poPoints[nPoints].x = poRing->getX(2); poPoints[nPoints].y = poRing->getY(2); padfZ[nPoints] = poRing->getZ(2); nPoints ++; } else { if( nParts == 0 || panPartType[nParts-1] != SHPP_TRIANGLES ) { nBeginLastPart = nPoints; panPartStart = (int*)CPLRealloc(panPartStart, (nParts + 1) * sizeof(int)); panPartType = (int*)CPLRealloc(panPartType, (nParts + 1) * sizeof(int)); panPartStart[nParts] = nPoints; panPartType[nParts] = SHPP_TRIANGLES; nParts ++; } poPoints = (OGRRawPoint*)CPLRealloc(poPoints, (nPoints + 3) * sizeof(OGRRawPoint)); padfZ = (double*)CPLRealloc(padfZ, (nPoints + 3) * sizeof(double)); for(int i=0;i<3;i++) { poPoints[nPoints+i].x = poRing->getX(i); poPoints[nPoints+i].y = poRing->getY(i); padfZ[nPoints+i] = poRing->getZ(i); } nPoints += 3; } } else { panPartStart = (int*)CPLRealloc(panPartStart, (nParts + nRings) * sizeof(int)); panPartType = (int*)CPLRealloc(panPartType, (nParts + nRings) * sizeof(int)); for ( int i = 0; i < nRings; i++ ) { panPartStart[nParts + i] = nPoints; if ( i == 0 ) { poRing = poPoly->getExteriorRing(); panPartType[nParts + i] = SHPP_OUTERRING; } else { poRing = poPoly->getInteriorRing(i-1); panPartType[nParts + i] = SHPP_INNERRING; } poPoints = (OGRRawPoint*)CPLRealloc(poPoints, (nPoints + poRing->getNumPoints()) * sizeof(OGRRawPoint)); padfZ = (double*)CPLRealloc(padfZ, (nPoints + poRing->getNumPoints()) * sizeof(double)); for( int k = 0; k < poRing->getNumPoints(); k++ ) { poPoints[nPoints+k].x = poRing->getX(k); poPoints[nPoints+k].y = poRing->getY(k); padfZ[nPoints+k] = poRing->getZ(k); } nPoints += poRing->getNumPoints(); } nParts += nRings; } } int nShpSize = 4; /* All types start with integer type number */ nShpSize += 16 * 2; /* xy bbox */ nShpSize += 4; /* nparts */ nShpSize += 4; /* npoints */ nShpSize += 4 * nParts; /* panPartStart[nparts] */ nShpSize += 4 * nParts; /* panPartType[nparts] */ nShpSize += 8 * 2 * nPoints; /* xy points */ nShpSize += 16; /* z bbox */ nShpSize += 8 * nPoints; /* z points */ *pnBytes = nShpSize; *ppabyShape = (GByte*) CPLMalloc(nShpSize); GByte* pabyPtr = *ppabyShape; /* Write in the type number and advance the pointer */ GUInt32 nGType = CPL_LSBWORD32( SHPT_MULTIPATCH ); memcpy( pabyPtr, &nGType, 4 ); pabyPtr += 4; OGREnvelope3D envelope; poGeom->getEnvelope(&envelope); memcpy( pabyPtr, &(envelope.MinX), 8 ); memcpy( pabyPtr+8, &(envelope.MinY), 8 ); memcpy( pabyPtr+8+8, &(envelope.MaxX), 8 ); memcpy( pabyPtr+8+8+8, &(envelope.MaxY), 8 ); int i; /* Swap box if needed. Shape doubles are always LSB */ if( OGR_SWAP( wkbNDR ) ) { for ( i = 0; i < 4; i++ ) CPL_SWAPDOUBLE( pabyPtr + 8*i ); } pabyPtr += 32; /* Write in the part count */ GUInt32 nPartsLsb = CPL_LSBWORD32( nParts ); memcpy( pabyPtr, &nPartsLsb, 4 ); pabyPtr += 4; /* Write in the total point count */ GUInt32 nPointsLsb = CPL_LSBWORD32( nPoints ); memcpy( pabyPtr, &nPointsLsb, 4 ); pabyPtr += 4; for( i = 0; i < nParts; i ++ ) { int nPartStart = CPL_LSBWORD32(panPartStart[i]); memcpy( pabyPtr, &nPartStart, 4 ); pabyPtr += 4; } for( i = 0; i < nParts; i ++ ) { int nPartType = CPL_LSBWORD32(panPartType[i]); memcpy( pabyPtr, &nPartType, 4 ); pabyPtr += 4; } if( poPoints != NULL ) memcpy(pabyPtr, poPoints, 2 * 8 * nPoints); /* Swap box if needed. Shape doubles are always LSB */ if( OGR_SWAP( wkbNDR ) ) { for ( i = 0; i < 2 * nPoints; i++ ) CPL_SWAPDOUBLE( pabyPtr + 8*i ); } pabyPtr += 2 * 8 * nPoints; memcpy( pabyPtr, &(envelope.MinZ), 8 ); memcpy( pabyPtr+8, &(envelope.MaxZ), 8 ); if( OGR_SWAP( wkbNDR ) ) { for ( i = 0; i < 2; i++ ) CPL_SWAPDOUBLE( pabyPtr + 8*i ); } pabyPtr += 16; if( padfZ != NULL ) memcpy(pabyPtr, padfZ, 8 * nPoints); /* Swap box if needed. Shape doubles are always LSB */ if( OGR_SWAP( wkbNDR ) ) { for ( i = 0; i < nPoints; i++ ) CPL_SWAPDOUBLE( pabyPtr + 8*i ); } //pabyPtr += 8 * nPoints; CPLFree(panPartStart); CPLFree(panPartType); CPLFree(poPoints); CPLFree(padfZ); return OGRERR_NONE; } /************************************************************************/ /* OGRCreateFromShapeBin() */ /* */ /* Translate shapefile binary representation to an OGR */ /* geometry. */ /************************************************************************/ OGRErr OGRCreateFromShapeBin( GByte *pabyShape, OGRGeometry **ppoGeom, int nBytes ) { *ppoGeom = NULL; if( nBytes < 4 ) { CPLError(CE_Failure, CPLE_AppDefined, "Shape buffer size (%d) too small", nBytes); return OGRERR_FAILURE; } /* -------------------------------------------------------------------- */ /* Detect zlib compressed shapes and uncompress buffer if necessary */ /* NOTE: this seems to be an undocumented feature, even in the */ /* extended_shapefile_format.pdf found in the FileGDB API documentation*/ /* -------------------------------------------------------------------- */ if( nBytes >= 14 && pabyShape[12] == 0x78 && pabyShape[13] == 0xDA /* zlib marker */) { GInt32 nUncompressedSize, nCompressedSize; memcpy( &nUncompressedSize, pabyShape + 4, 4 ); memcpy( &nCompressedSize, pabyShape + 8, 4 ); CPL_LSBPTR32( &nUncompressedSize ); CPL_LSBPTR32( &nCompressedSize ); if (nCompressedSize + 12 == nBytes && nUncompressedSize > 0) { GByte* pabyUncompressedBuffer = (GByte*)VSI_MALLOC_VERBOSE(nUncompressedSize); if (pabyUncompressedBuffer == NULL) { return OGRERR_FAILURE; } size_t nRealUncompressedSize = 0; if( CPLZLibInflate( pabyShape + 12, nCompressedSize, pabyUncompressedBuffer, nUncompressedSize, &nRealUncompressedSize ) == NULL ) { CPLError(CE_Failure, CPLE_AppDefined, "CPLZLibInflate() failed"); VSIFree(pabyUncompressedBuffer); return OGRERR_FAILURE; } OGRErr eErr = OGRCreateFromShapeBin(pabyUncompressedBuffer, ppoGeom, static_cast<int>(nRealUncompressedSize)); VSIFree(pabyUncompressedBuffer); return eErr; } } int nSHPType = pabyShape[0]; /* -------------------------------------------------------------------- */ /* Return a NULL geometry when SHPT_NULL is encountered. */ /* Watch out, null return does not mean "bad data" it means */ /* "no geometry here". Watch the OGRErr for the error status */ /* -------------------------------------------------------------------- */ if ( nSHPType == SHPT_NULL ) { *ppoGeom = NULL; return OGRERR_NONE; } // CPLDebug( "PGeo", // "Shape type read from PGeo data is nSHPType = %d", // nSHPType ); const bool bIsExtended = ( nSHPType >= SHPT_GENERALPOLYLINE && nSHPType <= SHPT_GENERALMULTIPATCH ); const bool bHasZ = ( nSHPType == SHPT_POINTZ || nSHPType == SHPT_POINTZM || nSHPType == SHPT_MULTIPOINTZ || nSHPType == SHPT_MULTIPOINTZM || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_POLYGONZM || nSHPType == SHPT_ARCZ || nSHPType == SHPT_ARCZM || nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM || (bIsExtended && (pabyShape[3] & 0x80) != 0 ) ); const bool bHasM = ( nSHPType == SHPT_POINTM || nSHPType == SHPT_POINTZM || nSHPType == SHPT_MULTIPOINTM || nSHPType == SHPT_MULTIPOINTZM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_POLYGONZM || nSHPType == SHPT_ARCM || nSHPType == SHPT_ARCZM || nSHPType == SHPT_MULTIPATCHM || (bIsExtended && (pabyShape[3] & 0x40) != 0 ) ); /* -------------------------------------------------------------------- */ /* TODO: These types include additional attributes including */ /* non-linear segments and such. They should be handled. */ /* This is documented in the extended_shapefile_format.pdf */ /* from the FileGDB API */ /* -------------------------------------------------------------------- */ switch( nSHPType ) { case SHPT_GENERALPOLYLINE: nSHPType = SHPT_ARC; break; case SHPT_GENERALPOLYGON: nSHPType = SHPT_POLYGON; break; case SHPT_GENERALPOINT: nSHPType = SHPT_POINT; break; case SHPT_GENERALMULTIPOINT: nSHPType = SHPT_MULTIPOINT; break; case SHPT_GENERALMULTIPATCH: nSHPType = SHPT_MULTIPATCH; } /* ==================================================================== */ /* Extract vertices for a Polygon or Arc. */ /* ==================================================================== */ if( nSHPType == SHPT_ARC || nSHPType == SHPT_ARCZ || nSHPType == SHPT_ARCM || nSHPType == SHPT_ARCZM || nSHPType == SHPT_POLYGON || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_POLYGONZM || nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM) { GInt32 nPoints, nParts; int i, nOffset; GInt32 *panPartStart; GInt32 *panPartType = NULL; if (nBytes < 44) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nBytes=%d, nSHPType=%d", nBytes, nSHPType); return OGRERR_FAILURE; } /* -------------------------------------------------------------------- */ /* Extract part/point count, and build vertex and part arrays */ /* to proper size. */ /* -------------------------------------------------------------------- */ memcpy( &nPoints, pabyShape + 40, 4 ); memcpy( &nParts, pabyShape + 36, 4 ); CPL_LSBPTR32( &nPoints ); CPL_LSBPTR32( &nParts ); if (nPoints < 0 || nParts < 0 || nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nPoints=%d, nParts=%d.", nPoints, nParts); return OGRERR_FAILURE; } int bIsMultiPatch = ( nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM ); /* With the previous checks on nPoints and nParts, */ /* we should not overflow here and after */ /* since 50 M * (16 + 8 + 8) = 1 600 MB */ int nRequiredSize = 44 + 4 * nParts + 16 * nPoints; if ( bHasZ ) { nRequiredSize += 16 + 8 * nPoints; } if ( bHasM ) { nRequiredSize += 16 + 8 * nPoints; } if( bIsMultiPatch ) { nRequiredSize += 4 * nParts; } if (nRequiredSize > nBytes) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nPoints=%d, nParts=%d, nBytes=%d, nSHPType=%d, nRequiredSize=%d", nPoints, nParts, nBytes, nSHPType, nRequiredSize); return OGRERR_FAILURE; } panPartStart = (GInt32 *) VSI_CALLOC_VERBOSE(nParts,sizeof(GInt32)); if (panPartStart == NULL) { return OGRERR_FAILURE; } /* -------------------------------------------------------------------- */ /* Copy out the part array from the record. */ /* -------------------------------------------------------------------- */ memcpy( panPartStart, pabyShape + 44, 4 * nParts ); for( i = 0; i < nParts; i++ ) { CPL_LSBPTR32( panPartStart + i ); /* We check that the offset is inside the vertex array */ if (panPartStart[i] < 0 || panPartStart[i] >= nPoints) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : panPartStart[%d] = %d, nPoints = %d", i, panPartStart[i], nPoints); CPLFree(panPartStart); return OGRERR_FAILURE; } if (i > 0 && panPartStart[i] <= panPartStart[i-1]) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : panPartStart[%d] = %d, panPartStart[%d] = %d", i, panPartStart[i], i - 1, panPartStart[i - 1]); CPLFree(panPartStart); return OGRERR_FAILURE; } } nOffset = 44 + 4*nParts; /* -------------------------------------------------------------------- */ /* If this is a multipatch, we will also have parts types. */ /* -------------------------------------------------------------------- */ if( bIsMultiPatch ) { panPartType = (GInt32 *) VSI_CALLOC_VERBOSE(nParts,sizeof(GInt32)); if (panPartType == NULL) { CPLFree(panPartStart); return OGRERR_FAILURE; } memcpy( panPartType, pabyShape + nOffset, 4*nParts ); for( i = 0; i < nParts; i++ ) { CPL_LSBPTR32( panPartType + i ); } nOffset += 4*nParts; } /* -------------------------------------------------------------------- */ /* Copy out the vertices from the record. */ /* -------------------------------------------------------------------- */ double *padfX = (double *) VSI_MALLOC_VERBOSE(sizeof(double)*nPoints); double *padfY = (double *) VSI_MALLOC_VERBOSE(sizeof(double)*nPoints); double *padfZ = (double *) VSI_CALLOC_VERBOSE(sizeof(double),nPoints); double *padfM = (double *) (bHasM ? VSI_CALLOC_VERBOSE(sizeof(double),nPoints) : NULL); if (padfX == NULL || padfY == NULL || padfZ == NULL || (bHasM && padfM == NULL)) { CPLFree( panPartStart ); CPLFree( panPartType ); CPLFree( padfX ); CPLFree( padfY ); CPLFree( padfZ ); CPLFree( padfM ); return OGRERR_FAILURE; } for( i = 0; i < nPoints; i++ ) { memcpy(padfX + i, pabyShape + nOffset + i * 16, 8 ); memcpy(padfY + i, pabyShape + nOffset + i * 16 + 8, 8 ); CPL_LSBPTR64( padfX + i ); CPL_LSBPTR64( padfY + i ); } nOffset += 16*nPoints; /* -------------------------------------------------------------------- */ /* If we have a Z coordinate, collect that now. */ /* -------------------------------------------------------------------- */ if( bHasZ ) { for( i = 0; i < nPoints; i++ ) { memcpy( padfZ + i, pabyShape + nOffset + 16 + i*8, 8 ); CPL_LSBPTR64( padfZ + i ); } nOffset += 16 + 8*nPoints; } /* -------------------------------------------------------------------- */ /* If we have a M coordinate, collect that now. */ /* -------------------------------------------------------------------- */ if( bHasM ) { for( i = 0; i < nPoints; i++ ) { memcpy( padfM + i, pabyShape + nOffset + 16 + i*8, 8 ); CPL_LSBPTR64( padfM + i ); } //nOffset += 16 + 8*nPoints; } /* -------------------------------------------------------------------- */ /* Build corresponding OGR objects. */ /* -------------------------------------------------------------------- */ if( nSHPType == SHPT_ARC || nSHPType == SHPT_ARCZ || nSHPType == SHPT_ARCM || nSHPType == SHPT_ARCZM ) { /* -------------------------------------------------------------------- */ /* Arc - As LineString */ /* -------------------------------------------------------------------- */ if( nParts == 1 ) { OGRLineString *poLine = new OGRLineString(); *ppoGeom = poLine; poLine->setPoints( nPoints, padfX, padfY, padfZ, padfM ); } /* -------------------------------------------------------------------- */ /* Arc - As MultiLineString */ /* -------------------------------------------------------------------- */ else { OGRMultiLineString *poMulti = new OGRMultiLineString; *ppoGeom = poMulti; for( i = 0; i < nParts; i++ ) { OGRLineString *poLine = new OGRLineString; int nVerticesInThisPart; if( i == nParts-1 ) nVerticesInThisPart = nPoints - panPartStart[i]; else nVerticesInThisPart = panPartStart[i+1] - panPartStart[i]; poLine->setPoints( nVerticesInThisPart, padfX + panPartStart[i], padfY + panPartStart[i], padfZ + panPartStart[i], (padfM != NULL) ? padfM + panPartStart[i] : NULL ); poMulti->addGeometryDirectly( poLine ); } } } /* ARC */ /* -------------------------------------------------------------------- */ /* Polygon */ /* -------------------------------------------------------------------- */ else if( nSHPType == SHPT_POLYGON || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_POLYGONZM ) { if (nParts != 0) { if (nParts == 1) { OGRPolygon *poOGRPoly = new OGRPolygon; *ppoGeom = poOGRPoly; OGRLinearRing *poRing = new OGRLinearRing; int nVerticesInThisPart = nPoints - panPartStart[0]; poRing->setPoints( nVerticesInThisPart, padfX + panPartStart[0], padfY + panPartStart[0], padfZ + panPartStart[0], (padfM != NULL) ? padfM + panPartStart[0] : NULL ); poOGRPoly->addRingDirectly( poRing ); } else { OGRGeometry *poOGR = NULL; OGRPolygon** tabPolygons = new OGRPolygon*[nParts]; for( i = 0; i < nParts; i++ ) { tabPolygons[i] = new OGRPolygon(); OGRLinearRing *poRing = new OGRLinearRing; int nVerticesInThisPart; if( i == nParts-1 ) nVerticesInThisPart = nPoints - panPartStart[i]; else nVerticesInThisPart = panPartStart[i+1] - panPartStart[i]; poRing->setPoints( nVerticesInThisPart, padfX + panPartStart[i], padfY + panPartStart[i], padfZ + panPartStart[i], (padfM != NULL) ? padfM + panPartStart[i] : NULL ); tabPolygons[i]->addRingDirectly(poRing); } int isValidGeometry; const char* papszOptions[] = { "METHOD=ONLY_CCW", NULL }; poOGR = OGRGeometryFactory::organizePolygons( (OGRGeometry**)tabPolygons, nParts, &isValidGeometry, papszOptions ); if (!isValidGeometry) { CPLError(CE_Warning, CPLE_AppDefined, "Geometry of polygon cannot be translated to Simple Geometry. " "All polygons will be contained in a multipolygon.\n"); } *ppoGeom = poOGR; delete[] tabPolygons; } } } /* polygon */ /* -------------------------------------------------------------------- */ /* Multipatch */ /* -------------------------------------------------------------------- */ else if( bIsMultiPatch ) { *ppoGeom = OGRCreateFromMultiPatch( nParts, panPartStart, panPartType, nPoints, padfX, padfY, padfZ ); } CPLFree( panPartStart ); CPLFree( panPartType ); CPLFree( padfX ); CPLFree( padfY ); CPLFree( padfZ ); CPLFree( padfM ); if (*ppoGeom != NULL) { if( !bHasZ ) (*ppoGeom)->set3D(FALSE); } return OGRERR_NONE; } /* ==================================================================== */ /* Extract vertices for a MultiPoint. */ /* ==================================================================== */ else if( nSHPType == SHPT_MULTIPOINT || nSHPType == SHPT_MULTIPOINTM || nSHPType == SHPT_MULTIPOINTZ || nSHPType == SHPT_MULTIPOINTZM ) { GInt32 nPoints; GInt32 nOffsetZ; GInt32 nOffsetM = 0; int i; memcpy( &nPoints, pabyShape + 36, 4 ); CPL_LSBPTR32( &nPoints ); if (nPoints < 0 || nPoints > 50 * 1000 * 1000 ) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nPoints=%d.", nPoints); return OGRERR_FAILURE; } nOffsetZ = 40 + 2*8*nPoints + 2*8; if( bHasM ) nOffsetM = (bHasZ) ? nOffsetZ + 2*8 * 8*nPoints : nOffsetZ; OGRMultiPoint *poMultiPt = new OGRMultiPoint; *ppoGeom = poMultiPt; for( i = 0; i < nPoints; i++ ) { double x, y; OGRPoint *poPt = new OGRPoint; /* Copy X */ memcpy(&x, pabyShape + 40 + i*16, 8); CPL_LSBPTR64(&x); poPt->setX(x); /* Copy Y */ memcpy(&y, pabyShape + 40 + i*16 + 8, 8); CPL_LSBPTR64(&y); poPt->setY(y); /* Copy Z */ if ( bHasZ ) { double z; memcpy(&z, pabyShape + nOffsetZ + i*8, 8); CPL_LSBPTR64(&z); poPt->setZ(z); } /* Copy M */ if ( bHasM ) { double m; memcpy(&m, pabyShape + nOffsetM + i*8, 8); CPL_LSBPTR64(&m); poPt->setM(m); } poMultiPt->addGeometryDirectly( poPt ); } poMultiPt->set3D( bHasZ ); poMultiPt->setMeasured( bHasM ); return OGRERR_NONE; } /* ==================================================================== */ /* Extract vertices for a point. */ /* ==================================================================== */ else if( nSHPType == SHPT_POINT || nSHPType == SHPT_POINTM || nSHPType == SHPT_POINTZ || nSHPType == SHPT_POINTZM ) { /* int nOffset; */ double dfX, dfY, dfZ = 0, dfM = 0; if (nBytes < 4 + 8 + 8 + ((bHasZ) ? 8 : 0) + ((bHasM) ? 8 : 0)) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nBytes=%d, nSHPType=%d", nBytes, nSHPType); return OGRERR_FAILURE; } memcpy( &dfX, pabyShape + 4, 8 ); memcpy( &dfY, pabyShape + 4 + 8, 8 ); CPL_LSBPTR64( &dfX ); CPL_LSBPTR64( &dfY ); /* nOffset = 20 + 8; */ if( bHasZ ) { memcpy( &dfZ, pabyShape + 4 + 16, 8 ); CPL_LSBPTR64( &dfZ ); } if( bHasM ) { memcpy( &dfM, pabyShape + 4 + 16 + ((bHasZ) ? 8 : 0), 8 ); CPL_LSBPTR64( &dfM ); } if( bHasZ && bHasM ) *ppoGeom = new OGRPoint( dfX, dfY, dfZ, dfM ); else if( bHasZ ) *ppoGeom = new OGRPoint( dfX, dfY, dfZ ); else if( bHasM ) { OGRPoint* poPoint = new OGRPoint( dfX, dfY ); poPoint->setM(dfM); *ppoGeom = poPoint; } else *ppoGeom = new OGRPoint( dfX, dfY ); return OGRERR_NONE; } CPLError(CE_Failure, CPLE_AppDefined, "Unsupported geometry type: %d", nSHPType ); return OGRERR_FAILURE; }
apache-2.0
ScHaFeR/AndePUCRS-WebService
andePuc/target/andePuc-1.0/js/controllers/estabelecimentoViewController.js
497
var estabelecimentoViewCtrl = angular.module('estabelecimentoViewCtrl', ['ngResource']); estabelecimentoViewCtrl.controller('estabelecimentoViewCtrl', ['$scope', '$http', function ($scope, $http) { $scope.estabelecimentos = []; $scope.carregarPontosCriticos = function(){ $http.get("../webresources/com.andepuc.estabelecimentos").success(function (data, status){ $scope.estabelecimentos = data; }); }; }]);
apache-2.0
ngrebenshikov/SisyphusHill
src/pyramid-xcode/Pyramid/Pods/Socialize/Socialize-noarc/SocializeProfileEditTableViewImageCell.h
537
// // SocializeProfileEditTableViewImageCell.h // SocializeSDK // // Created by Nathaniel Griswold on 11/1/11. // Copyright (c) 2011 Socialize, Inc. All rights reserved. // #import <UIKit/UIKit.h> extern NSInteger SocializeProfileEditTableViewImageCellHeight; @interface SocializeProfileEditTableViewImageCell : UITableViewCell @property (nonatomic, retain) IBOutlet UIImageView *imageView; @property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner; @property (nonatomic, retain) IBOutlet UILabel *valueLabel; @end
apache-2.0
mc-server/MCServer
src/Blocks/BlockCake.h
1106
#pragma once #include "BlockHandler.h" class cBlockCakeHandler final : public cBlockHandler { using Super = cBlockHandler; public: using Super::Super; private: virtual bool OnUse( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos ) const override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos); if (!a_Player.Feed(2, 0.4)) { return false; } a_Player.GetStatistics().Custom[CustomStatistic::EatCakeSlice]++; if (Meta >= 5) { a_ChunkInterface.DigBlock(a_WorldInterface, a_BlockPos, &a_Player); } else { a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta + 1); } return true; } virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // Give nothing return {}; } virtual bool IsUseable(void) const override { return true; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); return 14; } } ;
apache-2.0
goodwinnk/intellij-community
platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedPsiCachedValueProvider.java
3537
/* * Copyright 2000-2015 JetBrains s.r.o. * * 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.intellij.psi.impl.source.tree.injected; import com.intellij.lang.injection.MultiHostInjector; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.ParameterizedCachedValueProvider; import com.intellij.psi.util.PsiModificationTracker; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; class InjectedPsiCachedValueProvider implements ParameterizedCachedValueProvider<InjectionResult, PsiElement> { @Override public CachedValueProvider.Result<InjectionResult> compute(PsiElement element) { PsiFile hostPsiFile = element.getContainingFile(); if (hostPsiFile == null) return null; FileViewProvider viewProvider = hostPsiFile.getViewProvider(); if (viewProvider instanceof InjectedFileViewProvider) return null; // no injection inside injection final DocumentEx hostDocument = (DocumentEx)viewProvider.getDocument(); if (hostDocument == null) return null; PsiManager psiManager = viewProvider.getManager(); final Project project = psiManager.getProject(); InjectedLanguageManagerImpl injectedManager = InjectedLanguageManagerImpl.getInstanceImpl(project); InjectionResult result = doCompute(element, injectedManager, project, hostPsiFile); return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT, hostDocument); } @Nullable static InjectionResult doCompute(@NotNull final PsiElement element, @NotNull InjectedLanguageManagerImpl injectedManager, @NotNull Project project, @NotNull PsiFile hostPsiFile) { MyInjProcessor processor = new MyInjProcessor(project, hostPsiFile); injectedManager.processInPlaceInjectorsFor(element, processor); InjectionRegistrarImpl registrar = processor.hostRegistrar; return registrar == null ? null : registrar.getInjectedResult(); } private static class MyInjProcessor implements InjectedLanguageManagerImpl.InjProcessor { private InjectionRegistrarImpl hostRegistrar; private final Project myProject; private final PsiFile myHostPsiFile; private MyInjProcessor(@NotNull Project project, @NotNull PsiFile hostPsiFile) { myProject = project; myHostPsiFile = hostPsiFile; } @Override public boolean process(@NotNull PsiElement element, @NotNull MultiHostInjector injector) { if (hostRegistrar == null) { hostRegistrar = new InjectionRegistrarImpl(myProject, myHostPsiFile, element); } injector.getLanguagesToInject(hostRegistrar, element); return hostRegistrar.getInjectedResult() == null; } } }
apache-2.0
chubbymaggie/binnavi
src/main/java/com/google/security/zynamics/reil/algorithms/mono/valuetracking/elements/Symbol.java
1988
/* Copyright 2011-2016 Google Inc. 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. */ package com.google.security.zynamics.reil.algorithms.mono.valuetracking.elements; import java.math.BigInteger; import java.util.Set; import com.google.common.collect.Sets; import com.google.security.zynamics.zylib.disassembly.IAddress; import com.google.security.zynamics.zylib.general.Convert; public class Symbol implements IValueElement { private final String m_value; private final IAddress m_address; public Symbol(final IAddress address, final String value) { if (Convert.isDecString(value)) { throw new IllegalStateException(); } m_address = address; m_value = value; } @Override public Symbol clone() { return new Symbol(m_address, m_value); } @Override public boolean equals(final Object rhs) { return (rhs instanceof Symbol) && ((Symbol) rhs).m_value.equals(m_value) && ((Symbol) rhs).m_address.equals(m_address); } @Override public BigInteger evaluate() { // TODO Auto-generated method stub throw new IllegalStateException("Not yet implemented"); } @Override public IValueElement getSimplified() { return this; } @Override public Set<String> getVariables() { return Sets.newHashSet(m_value); } @Override public int hashCode() { return m_address.hashCode() * m_value.hashCode(); } @Override public String toString() { return m_value + "/" + m_address.toHexString(); } }
apache-2.0
SKA-ScienceDataProcessor/RC
MS6/visualize/csv_generator.py
744
#!/usr/bin/python """ Program for creating HTML plots """ import os import sys import json import time from readevtlog import * def imaging_iters(logs): start_time = 40.0 start_msg = "kernel init" end_msg = "imaging cleanup" got_start = False for k in sorted(logs): tt = logs[k].time for e in tt : if e.msg == start_msg: start = e.t1 got_start = True if got_start and e.msg == end_msg: print e.t2-start, ",", print "" data_commands = { "imaging_iters" : imaging_iters, } # Get parameters cmd = sys.argv[1] nm = sys.argv[2] # Open input files logs = read_timelines(nm) # Write table data_commands[cmd](logs)
apache-2.0