Пример #1
0
  protected void createFunctions(TypeInfoUtil typeInfoUtil, String bindingMode) {
    TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
    int cFuncs = typeAttr.cFuncs.intValue();
    for (int i = 0; i < cFuncs; i++) {
      // Get the function description
      FUNCDESC funcDesc = typeInfoUtil.getFuncDesc(i);

      TlbAbstractMethod method = null;
      if (funcDesc.invkind.value == INVOKEKIND.INVOKE_FUNC.value) {
        if (this.isVTableMode()) {
          method = new TlbFunctionVTable(i, index, typeLibUtil, funcDesc, typeInfoUtil);
        } else {
          method = new TlbFunctionDispId(i, index, typeLibUtil, funcDesc, typeInfoUtil);
        }
      } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYGET.value) {
        method = new TlbPropertyGet(i, index, typeLibUtil, funcDesc, typeInfoUtil);
      } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUT.value) {
        method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, typeInfoUtil);
      } else if (funcDesc.invkind.value == INVOKEKIND.INVOKE_PROPERTYPUTREF.value) {
        method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc, typeInfoUtil);
      }

      if (!isReservedMethod(method.getMethodName())) {
        this.content += method.getClassBuffer();

        if (i < cFuncs - 1) this.content += CR;
      }

      // Release our function description stuff
      typeInfoUtil.ReleaseFuncDesc(funcDesc);
    }
  }
Пример #2
0
  /**
   * Instantiates a new tlb class.
   *
   * @param index the index
   * @param typeLibUtil the type lib util
   */
  public TlbCoClass(int index, String packagename, TypeLibUtil typeLibUtil, String bindingMode) {
    super(index, typeLibUtil, null);

    TypeInfoUtil typeInfoUtil = typeLibUtil.getTypeInfoUtil(index);

    TypeLibDoc typeLibDoc = this.typeLibUtil.getDocumentation(index);
    String docString = typeLibDoc.getDocString();

    if (typeLibDoc.getName().length() > 0) this.name = typeLibDoc.getName();

    this.logInfo("Type of kind 'CoClass' found: " + this.name);

    this.createPackageName(packagename);
    this.createClassName(this.name);
    this.setFilename(this.name);

    String guidStr = this.typeLibUtil.getLibAttr().guid.toGuidString();
    int majorVerNum = this.typeLibUtil.getLibAttr().wMajorVerNum.intValue();
    int minorVerNum = this.typeLibUtil.getLibAttr().wMinorVerNum.intValue();
    String version = majorVerNum + "." + minorVerNum;
    String clsid = typeInfoUtil.getTypeAttr().guid.toGuidString();

    this.createJavaDocHeader(guidStr, version, docString);
    this.createCLSID(clsid);
    this.createCLSIDName(this.name);

    // Get the TypeAttributes
    TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
    int cImplTypes = typeAttr.cImplTypes.intValue();
    String interfaces = "";

    for (int i = 0; i < cImplTypes; i++) {
      HREFTYPE refTypeOfImplType = typeInfoUtil.getRefTypeOfImplType(i);
      ITypeInfo refTypeInfo = typeInfoUtil.getRefTypeInfo(refTypeOfImplType);
      TypeInfoUtil refTypeInfoUtil = new TypeInfoUtil(refTypeInfo);
      this.createFunctions(refTypeInfoUtil, bindingMode);
      TypeInfoDoc documentation = refTypeInfoUtil.getDocumentation(new MEMBERID(-1));
      interfaces += documentation.getName();

      if (i < cImplTypes - 1) interfaces += ", ";
    }

    this.createInterfaces(interfaces);
    this.createContent(this.content);
  }
Пример #3
0
  /**
   * Instantiates a new tlb function.
   *
   * @param index the index
   * @param typeLibUtil the type lib util
   * @param funcDesc the func desc
   * @param typeInfoUtil the type info util
   */
  public TlbFunctionDispId(
      int count, int index, TypeLibUtil typeLibUtil, FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
    super(index, typeLibUtil, funcDesc, typeInfoUtil);

    String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);

    for (int i = 0; i < paramCount; i++) {
      ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i];
      String methodName = names[i + 1].toLowerCase();
      String type = this.getType(elemdesc.tdesc);
      String _methodName = this.replaceJavaKeyword(methodName);
      methodparams += type + " " + _methodName;

      // wrap all in a VARIANT
      if (type.equals("VARIANT")) methodvariables += _methodName;
      else methodvariables += "new VARIANT(" + _methodName + ")";

      // if there is more than 1 param
      if (i < (paramCount - 1)) {
        methodparams += ", ";
        methodvariables += ", ";
      }
    }

    String returnValue;
    if (this.returnType.equalsIgnoreCase("VARIANT")) returnValue = "pResult";
    else returnValue = "((" + returnType + ") pResult.getValue())";

    this.replaceVariable("helpstring", docStr);
    this.replaceVariable("returntype", returnType);
    this.replaceVariable("returnvalue", returnValue);
    this.replaceVariable("methodname", methodName);
    this.replaceVariable("methodparams", methodparams);
    this.replaceVariable("methodvariables", methodvariables);
    this.replaceVariable("vtableid", String.valueOf(vtableId));
    this.replaceVariable("memberid", String.valueOf(memberid));
    this.replaceVariable("functionCount", String.valueOf(count));
  }