Generate the client class
540178
private function generateClient(): void
    {
        $this->printer->writeln('Generating client.');
        $this->generator->setNamespace($this->getNamespace());

        $code = $this->generator->generateClient($this->wsdl);
        $className = $this->findClassName($code);
        $filename = $this->destination . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';

        $this->writer->writeFile($filename, $code);
        $this->printer->writeln("  |- Wrote $className to $filename");
    }
958532
def create_new_client(self, give_focus=True, filename='', is_cython=False,
                          is_pylab=False, is_sympy=False, given_name=None):
        """"""
        self.master_clients += 1
        client_id = dict(int_id=to_text_string(self.master_clients),
                         str_id='A')
        cf = self._new_connection_file()
        show_elapsed_time = self.get_option('show_elapsed_time')
        reset_warning = self.get_option('show_reset_namespace_warning')
        ask_before_restart = self.get_option('ask_before_restart')
        client = ClientWidget(self, id_=client_id,
                              history_filename=get_conf_path('history.py'),
                              config_options=self.config_options(),
                              additional_options=self.additional_options(
                                      is_pylab=is_pylab,
                                      is_sympy=is_sympy),
                              interpreter_versions=self.interpreter_versions(),
                              connection_file=cf,
                              menu_actions=self.menu_actions,
                              options_button=self.options_button,
                              show_elapsed_time=show_elapsed_time,
                              reset_warning=reset_warning,
                              given_name=given_name,
                              ask_before_restart=ask_before_restart,
                              css_path=self.css_path)

        # Change stderr_dir if requested
        if self.test_dir is not None:
            client.stderr_dir = self.test_dir

        self.add_tab(client, name=client.get_name(), filename=filename)

        if cf is None:
            error_msg = self.permission_error_msg.format(jupyter_runtime_dir())
            client.show_kernel_error(error_msg)
            return

        # Check if ipykernel is present in the external interpreter.
        # Else we won't be able to create a client
        if not CONF.get('main_interpreter', 'default'):
            pyexec = CONF.get('main_interpreter', 'executable')
            has_spyder_kernels = programs.is_module_installed(
                                                        'spyder_kernels',
                                                        interpreter=pyexec,
                                                        version='>=1.0.0')
            if not has_spyder_kernels:
                client.show_kernel_error(
                        _("Your Python environment or installation doesn't "
                          "have the <tt>spyder-kernels</tt> module or the "
                          "right version of it installed. "
                          "Without this module is not possible for "
                          "Spyder to create a console for you.<br><br>"
                          "You can install it by running in a system terminal:"
                          "<br><br>"
                          "<tt>conda install spyder-kernels</tt>"
                          "<br><br>or<br><br>"
                          "<tt>pip install spyder-kernels</tt>"))
                return

        self.connect_client_to_kernel(client, is_cython=is_cython,
                                      is_pylab=is_pylab, is_sympy=is_sympy)
        if client.shellwidget.kernel_manager is None:
            return
        self.register_client(client)
310325
def generate_signature_class(cls):
    
    return type("%sSigs" % cls.__name__, (Base,),
                {'__tablename__': "%s_sigs" % cls.__tablename__,
                 'id': sa.Column(sa.Integer,
                                 sa.Sequence('%s_id_seq' % cls.__tablename__),
                                 primary_key=True,
                                 doc="primary key"),
                 'data': sa.Column(sa.Text(), nullable=False,
                                   doc="The signed data"),
                 '%s_id' % cls.__tablename__: sa.Column(sa.Integer,
                                                        sa.ForeignKey("%s.id" % cls.__tablename__),
                                                        nullable=False)})
522240
def execute_with_client(quiet=False,
                        bootstrap_server=False,
                        create_client=True):
    """"""
    def wrapper(f):

        def wrapper2(self, *args, **kwargs):
            client = self.current_client(
                quiet=quiet,
                bootstrap_server=bootstrap_server,
                create_client=create_client)
            if client and client.running:
                return f(self, client, *args, **kwargs)
        return wrapper2

    return wrapper
1103089
def create_client(self, name):
        ''''''
        client = {'client':{
            'name': name,
        }}
        response = self.post_request('clients/', client, follow = True)
        if response:
            return Client(self, response['client'])
1279956
function generateClient(clientObj) {
    var client;
    client = new Player(clientObj);
    if ('undefined' === typeof client.valid) client.valid = true;
    if ('undefined' === typeof client.connected) client.connected = false;
    // if ('undefined' === typeof client.history) client.history = [];
    if ('undefined' === typeof client.checkedOut) client.checkedOut = false;
    if ('undefined' === typeof client.dropOut) client.dropOut = false;
    return client;
}
498362
public static<T extends Object> T getWrapper(Class<T> clientType){
        return getWrapper(clientType,generateClientId(clientType));
    }
129135
protected void generateServiceDescriptor(String className, GeneratedFile generatedFile) throws IOException {
        CharSequence contents = generatedFile.getTextContent();
        if (contents != null) {
            String[] entries = contents.toString().split("\\n");
            if (!Arrays.asList(entries).contains(className)) {
                try (BufferedWriter w = new BufferedWriter(generatedFile.openWriter())) {
                    w.newLine();
                    w.write(className);
                }
            }
        } else {
            try (BufferedWriter w = new BufferedWriter(generatedFile.openWriter())) {
                w.write(className);
            }
        }
    }
405101
private void generateClass(TreeLogger logger, GeneratorContext context) throws Throwable {

        // get print writer that receives the source code
        PrintWriter printWriter = context.tryCreate(logger, packageName, className);

        // print writer if null, source code has ALREADY been generated, return
        if (printWriter == null) { return; }

        // init composer, set class properties, create source writer
        ClassSourceFileComposerFactory composerFactory =
                new ClassSourceFileComposerFactory(packageName, className);

        // Imports
        composerFactory.addImport("org.jboss.as.console.client.Console");
        composerFactory.addImport("org.jboss.as.console.client.ProductConfig");

        composerFactory.addImport("java.util.*");

        // Interfaces
        composerFactory.addImplementedInterface("org.jboss.as.console.client.ProductConfig");

        // SourceWriter
        SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter);

        // ctor
        generateConstructor(sourceWriter);

        // Methods
        generateMethods(logger, sourceWriter, context);

        // close generated class
        sourceWriter.outdent();
        sourceWriter.println("}");

        // commit generated class
        context.commit(logger, printWriter);
    }
655267
def generate_classes(outf, msgs):
    
    print("Generating class definitions")
    wrapper = textwrap.TextWrapper(initial_indent="", subsequent_indent="")
    outf.write("\nmavlink.messages = {};\n\n");

    def field_descriptions(fields):
        ret = ""
        for f in fields:
            ret += "                %-18s        : %s (%s)\n" % (f.name, f.description.strip(), f.type)
        return ret

    for m in msgs:

        comment = "%s\n\n%s" % (wrapper.fill(m.description.strip()), field_descriptions(m.fields))

        selffieldnames = 'self, '
        for f in m.fields:
            # if f.omit_arg:
            #    selffieldnames += '%s=%s, ' % (f.name, f.const_value)
            #else:
            # -- Omitting the code above because it is rarely used (only once?) and would need some special handling
            # in javascript.  Specifically, inside the method definition, it needs to check for a value then assign
            # a default.
            selffieldnames += '%s, ' % f.name
        selffieldnames = selffieldnames[:-2]

        sub = {'NAMELOWER'      : m.name.lower(),
               'SELFFIELDNAMES' : selffieldnames,
               'COMMENT'        : comment,
               'FIELDNAMES'     : ", ".join(m.fieldnames)}

        t.write(outf, """
/* 
${COMMENT}
*/
""", sub)

        # function signature + declaration
        outf.write("mavlink.messages.%s = function(" % (m.name.lower()))
        if len(m.fields) != 0:
                outf.write(", ".join(m.fieldnames))
        outf.write(") {")

        # body: set message type properties    
        outf.write("""

    this.format = '%s';
    this.id = mavlink.MAVLINK_MSG_ID_%s;
    this.order_map = %s;
    this.crc_extra = %u;
    this.name = '%s';

""" % (m.fmtstr, m.name.upper(), m.order_map, m.crc_extra, m.name.upper()))
        
        # body: set own properties
        if len(m.fieldnames) != 0:
                outf.write("    this.fieldnames = ['%s'];\n" % "', '".join(m.fieldnames))
        outf.write("""

    this.set(arguments);

}
        """)

        # inherit methods from the base message class
        outf.write("""
mavlink.messages.%s.prototype = new mavlink.message;
""" % m.name.lower())

        # Implement the pack() function for this message
        outf.write("""
mavlink.messages.%s.prototype.pack = function(mav) {
    return mavlink.message.prototype.pack.call(this, mav, this.crc_extra, jspack.Pack(this.format""" % m.name.lower())
        if len(m.fields) != 0:
                outf.write(", [ this." + ", this.".join(m.ordered_fieldnames) + ']')
        outf.write("));\n}\n\n")
1274996
def make_client(api_version, session=None,
                endpoint=None, service_type='monitoring'):
    """"""

    client_cls = utils.get_client_class('monitoring', api_version, VERSION_MAP)
    c = client_cls(
        session=session,
        service_type=service_type,
        endpoint=endpoint,
        app_name='monascaclient',
        app_version=version.version_string,
    )

    return c
876762
private static Object makeClientWrapper(Class<?> clientType,String clientId,Class<? extends InvokeHandler> handlerClass){
        String clientName = clientType.getSimpleName();
        long id = WRAPPER_COUNTER.getAndIncrement();
        if(clientType==DCW.class){
            throw new IllegalArgumentException("not support generate wrapper for interface "+clientName);
        }
        if(!clientType.isInterface()){
            throw new IllegalArgumentException("only support interface to generate wrapper,but type "+clientName+" is not interface");
        }
        JavassistClassGenerator generator = JavassistClassGenerator.newInstance(clientType.getClassLoader());
        generator.addInterface(clientType.getName());
        generator.addInterface(DCW.class.getName());
        StringBuilder className = new StringBuilder();
        className.append(clientType.getSimpleName()).append("$DCW").append(id);
        generator.setClassName(className.toString());
        Method[] methods = clientType.getDeclaredMethods();
        StringBuilder methodCode = new StringBuilder();
        for(Method method:methods){
            methodCode.append("public ");
            Class<?> returnType = method.getReturnType();
            Class<?>[] argsTypes = method.getParameterTypes();
            if(returnType== Void.TYPE){
                methodCode.append("void ");
            }else{
                methodCode.append(returnType.getName()).append(" ");
            }
            methodCode.append(method.getName()).append("(");
            //append arguments
            if(argsTypes.length!=0){
                for(int i=0;i<argsTypes.length;i++){
                    methodCode.append(argsTypes[i].getName()).append(" arg").append(i).append(",");
                }
                methodCode.setLength(methodCode.length()-1);
            }
            Class<?>[] exceptionTypes = method.getExceptionTypes();
            methodCode.append(")");
            if(exceptionTypes.length!=0){
                methodCode.append("throws ");
                for(Class<?> exceptionType:exceptionTypes){
                    methodCode.append(exceptionType.getName()).append(",");
                }
                methodCode.setLength(methodCode.length()-1);
            }
            methodCode.append("{");
            methodCode.append("try{");
            //append method body
            //handle invoke before
            if(argsTypes.length==0){
                methodCode.append("invokeHandler.beforeInvoke(clientType,\"" + method.getName() + "\",null);");
            }else{
                methodCode.append("invokeHandler.beforeInvoke(clientType,\"" + method.getName() + "\",$args);");
            }
            //handle invoke complete
            if(returnType== Void.TYPE){
                methodCode.append("(($w)clientRef).").append(method.getName()).append("($$);");
                if(argsTypes.length==0){
                    methodCode.append("invokeHandler.completeInvoke(clientType,\"" + method.getName() + "\",null,null);");
                }else{
                    methodCode.append("invokeHandler.completeInvoke(clientType,\"" + method.getName() + "\",null,$args);");
                }
            }else{
                methodCode.append("Object result=(($w)clientRef).").append(method.getName()).append("($$);");
                if(argsTypes.length==0){
                    methodCode.append("invokeHandler.completeInvoke(clientType,\"" + method.getName() + "\",(Object)result,null);");
                }else{
                    methodCode.append("invokeHandler.completeInvoke(clientType,\"" + method.getName() + "\",(Object)result,$args);");
                }
                methodCode.append("return ($r)result;");
            }
            methodCode.append("}catch(Throwable t){");
            //handle invoke exception
            if(argsTypes.length==0){
                methodCode.append("invokeHandler.caughtException(clientType,\"" + method.getName() + "\",t,null);");
            }else{
                methodCode.append("invokeHandler.caughtException(clientType,\"" + method.getName() + "\",t,$args);");
            }

            methodCode.append("throw new ").append(InvokeTargetException.class.getName()).append("(clientType,\""+method.getName()+"\",t);");
            methodCode.append("}");
            methodCode.append("}");
            generator.addMethod(methodCode.toString());
            methodCode.setLength(0);
        }
        generator.addField("public static "+clientType.getName()+" clientRef;");
        generator.addField("public static "+InvokeHandler.class.getName()+" invokeHandler;");
        generator.addField("public static "+Class.class.getName()+" clientType;");
        Class<?> clazz = generator.toClass();
        try {
            ReferenceConfig config = new ReferenceConfig();
            config.setId(clientId);
            config.setCheck(false);
            config.setInterface(clientType.getName());
            clazz.getField("clientRef").set(null,config.get());
            if(!HANDLER_CACHE.containsKey(handlerClass)){
                HANDLER_CACHE.putIfAbsent(handlerClass,handlerClass.newInstance());
            }
            clazz.getField("invokeHandler").set(null,HANDLER_CACHE.get(handlerClass));
            clazz.getField("clientType").set(null,clientType);
            return clazz.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
    }
1133241
@Override
    public void generate() throws CodeGenerationException
    {
        super.generate();

        /*
        The annotation processor may be passed multiple control client types.  Build a map that
        links each control client type with the set of control types that it uses.
        */

        Map<TypeDeclaration,Set<TypeMirror>> clientsMap = new HashMap<TypeDeclaration,Set<TypeMirror>>();

        for (AnnotationTypeDeclaration atd : _atds)
        {
            if (atd.getSimpleName().equals("Control") )
            {
                AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
                Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd);
                for (Declaration decl : decls)
                {
                    if ( decl instanceof FieldDeclaration )
                    {
                        FieldDeclaration fd = (FieldDeclaration)decl;
                        TypeDeclaration clientType = fd.getDeclaringType();
                        TypeMirror controlFieldType = fd.getType();
                        addControlType( clientsMap, clientType, controlFieldType );

                        /*
                        Add the control type to any derived class.  Fields with
                        private and default (package) access are also included
                        here as the controls in superclasses may be exposed
                        through public or protected methods to subclasses.
                        */
                        Collection<TypeDeclaration> specifiedTypeDeclartions = env.getSpecifiedTypeDeclarations();
                        for (TypeDeclaration td : specifiedTypeDeclartions)
                        {
                            if (td instanceof ClassDeclaration)
                            {
                                ClassType superclass = ((ClassDeclaration) td).getSuperclass();
                                while (superclass != null)
                                {
                                    if (superclass.getDeclaration().equals(clientType))
                                    {
                                        addControlType(clientsMap, td, controlFieldType);
                                        break;
                                    }

                                    superclass = superclass.getSuperclass();
                                }
                            }
                        }
                    }
                }
            }
            else if (atd.getSimpleName().equals("ControlReferences"))
            {
                Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
                for (Declaration decl : decls)
                {
                    if ( decl instanceof TypeDeclaration )
                    {
                        TypeDeclaration clientType = (TypeDeclaration)decl;
                        Set<TypeMirror> controlTypes = clientsMap.get( clientType );
                        if ( controlTypes == null )
                        {
                            controlTypes = new HashSet<TypeMirror>();
                            clientsMap.put( clientType, controlTypes );
                        }

                        // Read ControlReferences annotation
                        AnnotationMirror controlMirror = null;
                        for (AnnotationMirror annot : clientType.getAnnotationMirrors())
                        {
                            if (annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
                                    "org.apache.beehive.controls.api.bean.ControlReferences"))
                            {
                                controlMirror = annot;
                                break;
                            }
                        }

                        assert( controlMirror != null );

                        // Add each control type listed in the ControlReferences annotation
                        AptAnnotationHelper controlAnnot = new AptAnnotationHelper(controlMirror);
                        Collection<AnnotationValue> references = (Collection<AnnotationValue>)controlAnnot.getObjectValue("value");
                        if ( references != null )
                        {
                            for ( AnnotationValue av : references )
                            {
                                TypeMirror crType = (TypeMirror)av.getValue();
                                controlTypes.add( crType );
                            }
                        }
                    }
                }
            }
        }

        // For each client type:
        //   1 - emit a controls client manifest in the same dir as the client type's class.
        //   2 - emit a controls client initializer class in the same pkg/dir as the client type's class

        Filer f = getAnnotationProcessorEnvironment().getFiler();
        Set<TypeDeclaration> clientTypes = clientsMap.keySet();
        for ( TypeDeclaration clientType : clientTypes )
        {
            // Emit manifest

            String clientPkg = clientType.getPackage().getQualifiedName();
            File clientManifestName =
                new File( clientType.getSimpleName() + ControlClientManifest.FILE_EXTENSION );

            ControlClientManifest mf = new ControlClientManifest( clientType.getQualifiedName() );

            try
            {
                Set<TypeMirror> controlTypes = clientsMap.get( clientType );
                for ( TypeMirror controlType : controlTypes )
                {
                    InterfaceDeclaration controlIntfOrExt = getControlInterfaceOrExtension(controlType);
                    InterfaceDeclaration controlIntf = getMostDerivedControlInterface( controlIntfOrExt );

                    assert controlIntf != null : "Can't find most derived control intf for=" + controlIntfOrExt;

                    ControlInterface annot = controlIntf.getAnnotation(ControlInterface.class);
                    String defBinding = annot.defaultBinding();

                    defBinding = ControlUtils.resolveDefaultBinding( defBinding, controlIntf.getQualifiedName() );

                    mf.addControlType( controlIntfOrExt.getQualifiedName(), defBinding );
                }

                mf.emit( f, clientPkg, clientManifestName, null );
            }
            catch ( IOException ie )
            {
                printError( clientType, "controls.client.manifest.ioerror" );
                ie.printStackTrace( );
            }

            // Emit initializer

            AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
            Generator genClass = new AptControlClient( clientType, this );

            if ( genClass != null )
            {
                try
                {
                    List<GeneratorOutput> genList = genClass.getGenerateOutput(env.getFiler());
                    if (genList == null || genList.size() == 0)
                        return;

                    for (GeneratorOutput genOut : genList)
                    {
                        getGenerator().generate(genOut);
                    }
                }
                catch (IOException ioe)
                {
                    throw new CodeGenerationException("Code generation failure: ", ioe);
                }
            }
        }
    }
1026430
function Client(opts) {

    this.opts = new clientOptions(opts)
    this.streamData = {}
    this.currentIndex = 0
    this.cachedItems = new lru({maxSize: this.opts.maxCacheSize})
}
413502
def _GenerateClientInfo(self, client_id, client_fd):
    """"""
    summary_dict = client_fd.ToPrimitiveDict(stringify_leaf_fields=True)
    summary = yaml.Dump(summary_dict).encode("utf-8")

    client_info_path = os.path.join(self.prefix, client_id, "client_info.yaml")
    st = os.stat_result((0o644, 0, 0, 0, 0, 0, len(summary), 0, 0, 0))
    yield self.archive_generator.WriteFileHeader(client_info_path, st=st)
    yield self.archive_generator.WriteFileChunk(summary)
    yield self.archive_generator.WriteFileFooter()
337288
private function generateClasses()
    {
        foreach($this->ref->getClasses() as $class)
        {
            if($class->isInterface())
            {
                $this->generateInterface($class);
            }
            else if($class->isTrait())
            {
                $this->generateTrait($class);
            }
            else
            {
                $this->generateClass($class);
            }
        }
    }
792010
private static CtClass[] generateClassField(Class<?>... classes) throws NotFoundException {
        CtClass[] result = new CtClass[classes.length];
        for (int i = 0; i < classes.length; i++) {
            result[i] = cp.get(classes[i].getName());
        }
        return result;
    }