Search in sources :

Example 21 with Label

use of com.google.api.ads.admanager.axis.v202108.Label in project intellij-community by JetBrains.

the class AdvancedEnhancer method emitMethods.

private void emitMethods(final ClassEmitter ce, Map<Method, MethodInfo> methodMap, final Map<Method, Method> covariantMethods) {
    CallbackGenerator[] generators = CallbackInfo.getGenerators(callbackTypes);
    Map<MethodInfo, MethodInfo> covariantInfoMap = new HashMap<>();
    for (Method method : methodMap.keySet()) {
        final Method delegate = covariantMethods.get(method);
        if (delegate != null) {
            covariantInfoMap.put(methodMap.get(method), ReflectUtils.getMethodInfo(delegate, delegate.getModifiers()));
        }
    }
    BridgeMethodGenerator bridgeMethodGenerator = new BridgeMethodGenerator(covariantInfoMap);
    Map<CallbackGenerator, List<MethodInfo>> groups = new HashMap<>();
    final Map<MethodInfo, Integer> indexes = new HashMap<>();
    final Map<MethodInfo, Integer> originalModifiers = new HashMap<>();
    final Map positions = CollectionUtils.getIndexMap(new ArrayList<>(methodMap.values()));
    for (Method actualMethod : methodMap.keySet()) {
        MethodInfo method = methodMap.get(actualMethod);
        int index = filter.accept(actualMethod);
        if (index >= callbackTypes.length) {
            throw new IllegalArgumentException("Callback filter returned an index that is too large: " + index);
        }
        originalModifiers.put(method, (actualMethod != null) ? actualMethod.getModifiers() : method.getModifiers());
        indexes.put(method, index);
        final CallbackGenerator generator = covariantMethods.containsKey(actualMethod) ? bridgeMethodGenerator : generators[index];
        List<MethodInfo> group = groups.get(generator);
        if (group == null) {
            groups.put(generator, group = new ArrayList<>(methodMap.size()));
        }
        group.add(method);
    }
    CodeEmitter se = ce.getStaticHook();
    se.new_instance(THREAD_LOCAL);
    se.dup();
    se.invoke_constructor(THREAD_LOCAL, CSTRUCT_NULL);
    se.putfield(THREAD_CALLBACKS_FIELD);
    CallbackGenerator.Context context = new CallbackGenerator.Context() {

        public ClassLoader getClassLoader() {
            return AdvancedEnhancer.this.getClassLoader();
        }

        public int getOriginalModifiers(MethodInfo method) {
            return originalModifiers.get(method);
        }

        public int getIndex(MethodInfo method) {
            return indexes.get(method);
        }

        public void emitCallback(CodeEmitter e, int index) {
            emitCurrentCallback(e, index);
        }

        public Signature getImplSignature(MethodInfo method) {
            return rename(method.getSignature(), (Integer) positions.get(method));
        }

        @Override
        public void emitInvoke(CodeEmitter codeEmitter, MethodInfo methodInfo) {
            codeEmitter.super_invoke(methodInfo.getSignature());
        }

        public CodeEmitter beginMethod(ClassEmitter ce, MethodInfo method) {
            CodeEmitter e = EmitUtils.begin_method(ce, method);
            if (!interceptDuringConstruction && !TypeUtils.isAbstract(method.getModifiers())) {
                $Label constructed = e.make_label();
                e.load_this();
                e.getfield(CONSTRUCTED_FIELD);
                e.if_jump(e.NE, constructed);
                e.load_this();
                e.load_args();
                e.super_invoke();
                e.return_value();
                e.mark(constructed);
            }
            return e;
        }
    };
    Set<CallbackGenerator> seenGen = new HashSet<>();
    for (int i = 0; i < callbackTypes.length + 1; i++) {
        CallbackGenerator gen = i == callbackTypes.length ? bridgeMethodGenerator : generators[i];
        if (!seenGen.contains(gen)) {
            seenGen.add(gen);
            final List<MethodInfo> fmethods = groups.get(gen);
            if (fmethods != null) {
                try {
                    gen.generate(ce, context, fmethods);
                    gen.generateStatic(se, context, fmethods);
                } catch (RuntimeException x) {
                    throw x;
                } catch (Exception x) {
                    throw new CodeGenerationException(x);
                }
            }
        }
    }
    se.return_value();
    se.end_method();
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) net.sf.cglib.asm.$Label(net.sf.cglib.asm.$Label)

Example 22 with Label

use of com.google.api.ads.admanager.axis.v202108.Label in project intellij-community by JetBrains.

the class AdvancedEnhancer method emitCurrentCallback.

private static void emitCurrentCallback(CodeEmitter e, int index) {
    e.load_this();
    e.getfield(getCallbackField(index));
    e.dup();
    $Label end = e.make_label();
    e.ifnonnull(end);
    // stack height
    e.pop();
    e.load_this();
    e.invoke_static_this(BIND_CALLBACKS);
    e.load_this();
    e.getfield(getCallbackField(index));
    e.mark(end);
}
Also used : net.sf.cglib.asm.$Label(net.sf.cglib.asm.$Label)

Example 23 with Label

use of com.google.api.ads.admanager.axis.v202108.Label in project sirix by sirixdb.

the class AbstractSunburstGUI method style.

/**
 * Style menu.
 */
protected void style() {
    final Group ctrl = mControlP5.addGroup("menu", 15, 25, 35);
    ctrl.setColorLabel(mParent.color(255));
    ctrl.setColorBackground(mParent.color(100));
    ctrl.close();
    mParent.colorMode(PConstants.RGB, 255, 255, 255);
    final int backgroundColor = 0x99ffffff;
    int i = 0;
    for (final Slider slider : mSliders) {
        slider.setGroup(ctrl);
        slider.setId(i);
        final Label label = slider.getCaptionLabel();
        label.toUpperCase(true);
        label.setColor(mParent.color(0));
        label.setColorBackground(backgroundColor);
        final ControllerStyle style = label.getStyle();
        style.padding(4, 0, 1, 3);
        style.marginTop = -4;
        style.marginLeft = 0;
        style.marginRight = -14;
        slider.plugTo(mControl);
        i++;
    }
    i = 0;
    for (final Range range : mRanges) {
        range.setGroup(ctrl);
        range.setId(i);
        final Label label = range.getCaptionLabel();
        label.toUpperCase(true);
        label.setColor(mParent.color(0));
        label.setColorBackground(backgroundColor);
        final ControllerStyle style = label.getStyle();
        style.padding(4, 0, 1, 3);
        style.marginTop = -4;
        range.plugTo(mControl);
        i++;
    }
    i = 0;
    for (final Toggle toggle : mToggles) {
        toggle.setGroup(ctrl);
        toggle.setId(i);
        final Label label = toggle.getCaptionLabel();
        label.setColor(mParent.color(0));
        label.setColorBackground(backgroundColor);
        final ControllerStyle style = label.getStyle();
        style.padding(4, 3, 1, 3);
        style.marginTop = -19;
        style.marginLeft = 18;
        style.marginRight = 5;
        toggle.plugTo(mControl);
        i++;
    }
    mParent.colorMode(PConstants.HSB, 360, 100, 100);
    mParent.textLeading(14);
    mParent.textAlign(PConstants.LEFT, PConstants.TOP);
    mParent.cursor(PConstants.CROSS);
}
Also used : Group(controlP5.Group) ControllerStyle(controlP5.ControllerStyle) Slider(controlP5.Slider) Toggle(controlP5.Toggle) Label(controlP5.Label) Range(controlP5.Range)

Example 24 with Label

use of com.google.api.ads.admanager.axis.v202108.Label in project tomee by apache.

the class Cmp2Generator method createOpenEJB_deleted.

private void createOpenEJB_deleted() {
    final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "OpenEJB_deleted", "()V", null, null);
    mv.visitCode();
    /* if (deleted) return; */
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, implClassName, DELETED, "Z");
    final Label notDeleted = new Label();
    mv.visitJumpInsn(IFEQ, notDeleted);
    mv.visitInsn(RETURN);
    mv.visitLabel(notDeleted);
    // deleted = true;
    mv.visitVarInsn(ALOAD, 0);
    mv.visitInsn(ICONST_1);
    mv.visitFieldInsn(PUTFIELD, implClassName, DELETED, "Z");
    for (final CmrField cmrField : cmrFields) {
        // ${cmrField.accessor}.delete(${cmrField.name});
        createOpenEJB_deleted(mv, cmrField);
    }
    // return;
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : Label(org.apache.xbean.asm9.Label) MethodVisitor(org.apache.xbean.asm9.MethodVisitor)

Example 25 with Label

use of com.google.api.ads.admanager.axis.v202108.Label in project tomee by apache.

the class Cmp2Generator method createOpenEJB_addCmr.

private void createOpenEJB_addCmr() {
    final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "OpenEJB_addCmr", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;", null, null);
    mv.visitCode();
    // if (deleted) return null;
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, implClassName, DELETED, "Z");
    final Label notDeleted = new Label();
    mv.visitJumpInsn(IFEQ, notDeleted);
    mv.visitInsn(ACONST_NULL);
    mv.visitInsn(ARETURN);
    mv.visitLabel(notDeleted);
    for (final CmrField cmrField : cmrFields) {
        // if ("${cmrField.name}".equals(name)) {
        // ${cmrField.name}.add((${cmrField.type})value);
        // return null;
        // }
        // 
        // OR
        // 
        // if ("${cmrField.name}".equals(name)) {
        // Object oldValue = ${cmrField.name};
        // ${cmrField.name} = (${cmrField.type}) bean;
        // return oldValue;
        // }
        createOpenEJB_addCmr(mv, cmrField);
    }
    // throw new IllegalArgumentException("Unknown cmr field " + name + " on entity bean of type " + getClass().getName());
    mv.visitTypeInsn(NEW, "java/lang/IllegalArgumentException");
    mv.visitInsn(DUP);
    mv.visitTypeInsn(NEW, "java/lang/StringBuilder");
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false);
    mv.visitLdcInsn("Unknown cmr field ");
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
    mv.visitLdcInsn(" on entity bean of type ");
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getName", "()Ljava/lang/String;", false);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/IllegalArgumentException", "<init>", "(Ljava/lang/String;)V", false);
    mv.visitInsn(ATHROW);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : Label(org.apache.xbean.asm9.Label) MethodVisitor(org.apache.xbean.asm9.MethodVisitor)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)7 Label (org.apache.xbean.asm9.Label)7 Label (com.google.api.ads.admanager.axis.v202108.Label)5 LabelServiceInterface (com.google.api.ads.admanager.axis.v202108.LabelServiceInterface)5 Label (com.google.api.ads.admanager.axis.v202111.Label)5 LabelServiceInterface (com.google.api.ads.admanager.axis.v202111.LabelServiceInterface)5 Label (com.google.api.ads.admanager.axis.v202202.Label)5 LabelServiceInterface (com.google.api.ads.admanager.axis.v202202.LabelServiceInterface)5 MethodVisitor (org.apache.xbean.asm9.MethodVisitor)5 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 CreativeWrapper (com.google.api.ads.admanager.axis.v202108.CreativeWrapper)4 CreativeWrapperServiceInterface (com.google.api.ads.admanager.axis.v202108.CreativeWrapperServiceInterface)4 LabelPage (com.google.api.ads.admanager.axis.v202108.LabelPage)4 LabelPage (com.google.api.ads.admanager.axis.v202111.LabelPage)4 LabelPage (com.google.api.ads.admanager.axis.v202202.LabelPage)4 CreativeWrapperPage (com.google.api.ads.admanager.axis.v202108.CreativeWrapperPage)3 Random (java.util.Random)3 net.sf.cglib.asm.$Label (net.sf.cglib.asm.$Label)3 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)2