Switch to custom class generator.
342369
private function processClassGenerator(ContainerBuilder $container)
    {
        $definition = new Definition('Drupal\DrupalExtension\Context\ContextClass\ClassGenerator');
        $container->setDefinition(ContextExtension::CLASS_GENERATOR_TAG . '.simple', $definition);
    }
277531
def generate(self, vars=None, env=None):
        """"""
        def defined(v, default=None):
            _v = default
            if v in vars:
                _v = vars[v]
            elif v in env:
                _v = env[v]
            return _v

        namespace = {
            # __name__ and __loader__ allow the traceback mechanism to find
            # the generated source code.
            "defined": defined,
            #fix RuntimeWarning: Parent module 'a/b/c' not found while handling absolute import warning
            "__name__": self.name.replace('.', '_'),
            # "__name__": self.name,
            "__loader__": ObjectDict(get_source=lambda name: self.code),
        }
        namespace.update(default_namespace)
        namespace.update(env or {})
        namespace.update(self.namespace)
        namespace.update(vars or {})
        namespace['_vars'] = vars
        exec_in(self.compiled, namespace)
        execute = namespace["_tt_execute"]
        # Clear the traceback module's cache of source data now that
        # we've generated a new template (mainly for this module's
        # unittests, where different tests reuse the same name).
        linecache.clearcache()
        return execute()
405785
private Map<String, CompiledClass> extractClassFileMap() {
    if (context instanceof StandardGeneratorContext) {
      StandardGeneratorContext standardContext = (StandardGeneratorContext) context;
      return standardContext.getCompilationState().getClassFileMap();
    } else {
      logger.log(TreeLogger.Type.WARN,
          String.format("Could not load generated classes from GWT context, "
              + "encountered unexpected generator type %s.", context.getClass()));
      return null;
    }
  }
872373
def generate(node, environment, name, filename, stream=None,
             defer_init=False, optimized=True):
    """"""
    if not isinstance(node, nodes.Template):
        raise TypeError('Can\'t compile non template nodes')
    generator = environment.code_generator_class(environment, name, filename,
                                                 stream, defer_init,
                                                 optimized)
    generator.visit(node)
    if stream is None:
        return generator.stream.getvalue()
515999
def generate(node, environment, name, filename, stream=None,
             defer_init=False):
    """"""
    if not isinstance(node, nodes.Template):
        raise TypeError('Can\'t compile non template nodes')
    generator = CodeGenerator(environment, name, filename, stream, defer_init)
    generator.visit(node)
    if stream is None:
        return generator.stream.getvalue()
341730
def generate
      generators.each do |generator|
        start = Time.now
        generator.generate(self)
        Bunto.logger.debug "Generating:",
          "#{generator.class} finished in #{Time.now - start} seconds."
      end
    end
1108531
def make_item_class_for_custom_generator_class(cls):
    
    clsname = cls.__tohu_items_name__
    attr_names = cls.field_gens.keys()
    return make_item_class(clsname, attr_names)
1329643
def generate(self, blueprint, context, interactive=True):
        """"""
        if not isinstance(blueprint, Blueprint):
            bp = self.blueprints.get(blueprint)
            if not bp:
                raise ValueError('%s is not a valid blueprint' % blueprint)
            blueprint = bp

        self.stdout.write(
            style.format_command(
                'Generating',
                blueprint.full_name
            )
        )
        generator = Generator(
            self,
            blueprint,
            context,
            interactive=interactive
        )
        result = generator.generate()
        if blueprint.name == 'init':
            # try re-setting the name
            self.refresh()
        return result
1122949
public void generateClass(TreeLogger logger, GeneratorContext context, List<JClassType> subclasses) {

        PrintWriter printWriter = context.tryCreate(logger, PACKAGE_NAME, CLASS_NAME);
        if (printWriter == null) {
            return;
        }
        ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(PACKAGE_NAME, CLASS_NAME);
        composer.addImplementedInterface(INIT_INTERFACE_NAME);
        SourceWriter sourceWriter = composer.createSourceWriter(context, printWriter);
        sourceWriter.println("public java.util.Map<String, " + COMMAND_INTERFACE + "> initCommands() {");
        sourceWriter.indent();
        sourceWriter.println(
            "java.util.Map<String, "
                + COMMAND_INTERFACE
                + "> result=new java.util.HashMap<String, "
                + COMMAND_INTERFACE
                + ">();");
        for (JClassType type : subclasses) {
            sourceWriter.println(
                "result.put(\""
                    + type.getQualifiedSourceName()
                    + "\","
                    + type.getQualifiedSourceName()
                    + "."
                    + GET_COMMAND_METHOD
                    + "());");
        }
        sourceWriter.println("return result;");
        sourceWriter.outdent();
        sourceWriter.println("}");
        sourceWriter.outdent();
        sourceWriter.println("}");
        context.commit(logger, printWriter);
    }
1164690
def transform_generator(fn):
    """"""
    if six.PY2:
        fn.func_dict['is_transform_generator'] = True
    else:
        # py3
        fn.__dict__['is_transform_generator'] = True
    return fn
866140
def class_register(cls):
    """"""
    cls.handler_registry = {}
    for method_name in dir(cls):
        method = getattr(cls, method_name)
        if hasattr(method, '_handle'):
            cls.handler_registry.update({method._handle: method_name})
    return cls
764059
protected function generateClasses()
    {
        $this->display(' * Generate classes files for Data & Mapper ' . PHP_EOL);

        $this->display('  > generate [  0%]: Data File      ' . "\r");
        $this->generateDataFiles();

        $this->display('  > generate [ 50%]: Data File      ' . "\r");
        $this->generateMapperFiles();

        $this->display('  > generate [100%]: done !    ' . "\r");
        $this->display(PHP_EOL . PHP_EOL);
    }
396005
def _filter_classes(cls_list, cls_type):
    """"""
    for cls in cls_list:
        if isinstance(cls, type) and issubclass(cls, cls_type):
            if cls_type == TempyPlace and cls._base_place:
                pass
            else:
                yield cls
395128
private void generateClasses() throws IOException {
		for (BindEntity entity : model.getEntities()) {
			final BindEntity item = entity;

			BindTypeBuilder.generate(filer, item);
		}
	}
884072
@SuppressWarnings("unchecked")
    public final Generator<Object> getGenerator() {
        if (generator != null) {
            return generator;
        }
        LOG.info("Creating generator: {}", className);
        if (className == null) {
            throw new IllegalStateException("Class name was not set: " + getName());
        }
        if (context == null) {
            throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className);
        }
        final Object obj = Utils4J.createInstance(className, context.getClassLoader());
        if (!(obj instanceof Generator<?>)) {
            throw new IllegalStateException("Expected class to be of type '" + Generator.class.getName() + "', but was: " + className);
        }
        generator = (Generator<Object>) obj;
        generator.initialize(this);
        return generator;
    }
1356172
def gen_parents(parents):
    """"""
    for idx, parent in enumerate(parents):
        if isinstance(parent, Interface):
            parent = parent.id
        elif isinstance(parent, int):
            pass
        else:
            raise TypeError(
                'parent[%d] must be an Interface or int, not %s' % (
                    idx, type(parent).__name__))
        yield parent
552073
def factory(cls, attrs):
        """"""
        name = attrs['identifier'].capitalize()
        return type(name, (cls,), attrs)