Java Library类代码示例(java中org.bridj.ann.library类典型用法代码示例汇总)

本文整理汇总了Java中org.bridj.ann.Library的典型用法代码示例。如果您正苦于以下问题:Java Library类的具体用法?Java Library怎么用?Java Library使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Java Library类代码示例(java中org.bridj.ann.library类典型用法代码示例汇总)

Library类属于org.bridj.ann包,在下文中一共展示了Library类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: register

import org.bridj.ann.Library; //导入依赖的package包/类
@Override
public void register(Type type) {
    Class<?> typeClass = Utils.getClass(type);
    typeClass.getAnnotation(Library.class);
    Library libAnn = typeClass.getAnnotation(Library.class);
    if (libAnn != null) {
        String name = libAnn.value();
        File libraryFile = BridJ.getNativeLibraryFile(name);
        if (libraryFile != null) {
            System.load(libraryFile.toString());
        }
        if (ObjCObject.class.isAssignableFrom(typeClass)) {
            bridjClassesByObjCName.put(typeClass.getSimpleName(), (Class<? extends ObjCObject>) typeClass);
        }
    }

    super.register(type);
} 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:19,代码来源:ObjectiveCRuntime.java

示例2: getNamespaceClass

import org.bridj.ann.Library; //导入依赖的package包/类
public JDefinedClass getNamespaceClass(String namespace, ParsingContext context) {
	if (namespace == null) {
		return null;
	}
	
	JDefinedClass ret = namespaceClasses.get(namespace);
	if (ret == null) {
		try {
			ret = context.getCm()._class("generated." + namespace);
			ret.init().add(context.getCm().ref(BridJ.class).staticInvoke("register"));
			Map<String, String> nsToLib =
					(Map<String, String>) context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE_TO_LIB);
			String libName = nsToLib.get(namespace);
			if (libName != null) {
				ret.annotate(Library.class).param("value", libName);
			}
			namespaceClasses.put(namespace, ret);
		} catch (JClassAlreadyExistsException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return ret;
} 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:25,代码来源:TypeRegistry.java

示例3: getNativeLibrary

import org.bridj.ann.Library; //导入依赖的package包/类
@Override
protected NativeLibrary getNativeLibrary(Class<?> type) throws IOException {
    Library libAnn = type.getAnnotation(Library.class);
    if (libAnn != null) {
        try {
            String name = libAnn.value();
            return BridJ.getNativeLibrary(name, new File("/System/Library/Frameworks/" + name + ".framework/" + name));
        } catch (FileNotFoundException ex) {
        }
    }

    return super.getNativeLibrary(type);
} 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:14,代码来源:ObjectiveCRuntime.java

示例4: getNativeLibrary

import org.bridj.ann.Library; //导入依赖的package包/类
public static synchronized NativeLibrary getNativeLibrary(AnnotatedElement type) throws IOException {
    NativeLibrary lib = librariesByClass.get(type);
    if (lib == null) {
        Library libraryAnnotation = getLibrary(type);
        if (libraryAnnotation != null) {
            String libraryName = libraryAnnotation.value();
            String dependenciesEnv = getDependenciesEnv(libraryName);
            List<String> dependencies = libraryDependencies.get(libraryName);
            List<String> staticDependencies = Arrays.asList(
                    dependenciesEnv == null ? libraryAnnotation.dependencies() : dependenciesEnv.split(","));
            if (dependencies == null) {
                dependencies = staticDependencies;
            } else {
                dependencies.addAll(staticDependencies);
            }

            for (String dependency : dependencies) {
                if (verbose) {
                    info("Trying to load dependency '" + dependency + "' of '" + libraryName + "'");
                }
                NativeLibrary depLib = getNativeLibrary(dependency);
                if (depLib == null) {
                    throw new RuntimeException("Failed to load dependency '" + dependency + "' of library '" + libraryName + "'");
                }
            }
            lib = getNativeLibrary(libraryName);
            if (lib != null) {
                librariesByClass.put(type, lib);
            }
        }
    }
    return lib;
} 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:34,代码来源:BridJ.java

示例5: malloc

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("c")
protected static native @Ptr
long malloc(@Ptr long size); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:4,代码来源:list.java

示例6: free

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("c")
protected static native void free(@Ptr long address); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:3,代码来源:list.java

示例7: whatever

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("test")
@Optional
public static native void whatever(SizeT v); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:4,代码来源:MiscBugsTest.java

示例8: getSomeWString

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("test")
public static native Pointer<Character> getSomeWString(); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:3,代码来源:MiscBugsTest.java

示例9: fabs

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("m")
public static native double fabs(double x); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:3,代码来源:LibCTest.java

示例10: setLastWindowsError

import org.bridj.ann.Library; //导入依赖的package包/类
@Optional // only on Windows
@Library("test")
public static native void setLastWindowsError() throws LastError; 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:4,代码来源:LibCTest.java

示例11: SendMessage

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("user32")
   @Optional
public static native void SendMessage(Pointer<?> hwnd, int Msg, int wParam, Pointer<?> lParam); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:4,代码来源:WindowsTest.java

示例12:

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("c")
@Name("strtol")
@SetsLastError
public static native long strtol_sets(@Ptr long str, @Ptr long endptr, int base); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:5,代码来源:MemoryTest.java

示例13: incrPointer

import org.bridj.ann.Library; //导入依赖的package包/类
@Library("test")
public static native Pointer<Byte> incrPointer(Pointer<Byte> ptr); 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:3,代码来源:MemoryTest.java

示例14: parseEnumeration

import org.bridj.ann.Library; //导入依赖的package包/类
@SuppressWarnings("unused")
private void parseEnumeration(Element root, ParsingContext context) {
	String enumName = root.getAttributeValue("name");
	String enumCType = root.getAttributeValue("type", Constants.GIR_XMLNS_C);
	JCodeModel cm = (JCodeModel)context.getCmNode();
	
	try {
		String enumFqcn = context.getCurrentPackage() + '.' + context.getExtra(Constants.CONTEXT_EXTRA_PREFIX) + NameUtils.neutralizeKeyword(enumName);
		JDefinedClass enumClass = cm._class(enumFqcn, ClassType.ENUM);
		System.out.println("New enum: " + enumFqcn);
		
		enumClass.init().add(cm.ref(BridJ.class).staticInvoke("register"));
		enumClass.annotate(Library.class).param("value", context.getLibraryName());

		Set<String> foundTypes = (Set<String>)context.getExtra(Constants.CONTEXT_EXTRA_DEFINED_TYPES);
		foundTypes.add("" + context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE) + '.' + enumName);
		
		//implements IntValuedEnum<ThisEnum>
		JClass intValuedEnumClass = context.getCm().ref(org.bridj.IntValuedEnum.class);
		JClass concreteIntValuedEnumClass = intValuedEnumClass.narrow(enumClass);
		enumClass._implements(concreteIntValuedEnumClass);
		
		//value field, public final long
		JFieldVar valueField = enumClass.field(JMod.PUBLIC | JMod.FINAL, long.class, "value");
		
		//arbitrary value constructor
		JMethod ctor = enumClass.constructor(JMod.NONE);
		JVar ctorParam = ctor.param(long.class, "value");
		JBlock ctorBody = ctor.body();
		ctorBody.assign(JExpr._this().ref(valueField), ctorParam);
		
		//value getter
		JMethod valueGetter = enumClass.method(JMod.PUBLIC, long.class, "value");
		valueGetter.body()._return(JExpr._this().ref(valueField));
		
		//iterator method
		JClass iteratorClass = cm.ref(Iterator.class).narrow(enumClass);
		JMethod iteratorMethod = enumClass.method(JMod.PUBLIC, iteratorClass, "iterator");
		JClass collectionsClass = cm.ref(Collections.class);
		JInvocation iteratorCall = collectionsClass.staticInvoke("singleton").arg(JExpr._this()).invoke("iterator");
		iteratorMethod.body()._return(iteratorCall);
		
		//fromValue method
		JMethod fromValue = enumClass.method(JMod.PUBLIC | JMod.STATIC, concreteIntValuedEnumClass, "fromValue");
		
		JVar fromValueParam = fromValue.param(int.class, "value");
		JClass flagSetClass = cm.ref(FlagSet.class);
		JInvocation fromValueCall = flagSetClass.staticInvoke("fromValue")
				.arg(fromValueParam)
				.arg(enumClass.staticInvoke("values"));
		fromValue.body()._return(fromValueCall);
		
		//enum instances
		parseElements(root.getChildElements(), context.withCmNode(enumClass));
		
		//register the type
		ConvertedType regType = new ConvertedType(
				cm,
				(String)context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE),
				enumName,
				enumCType,
				true
		);
		regType.setJType(cm.ref(IntValuedEnum.class).narrow(enumClass));
		context.registerType(regType);
		
	} catch (JClassAlreadyExistsException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
} 
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:72,代码来源:GirParser.java

示例15: getNativeLibraryName

import org.bridj.ann.Library; //导入依赖的package包/类
/**
 * Gets the name of the library declared for an annotated element. Recurses
 * up to parents of the element (class, enclosing classes) to find any
 * {@link org.bridj.ann.Library} annotation.
 */
public static String getNativeLibraryName(AnnotatedElement m) {
    Library lib = getLibrary(m);
    return lib == null ? null : lib.value();
} 
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:10,代码来源:BridJ.java

本文标签属性:

示例:示例志愿表

代码:代码转换器

java:java游戏

Library:library复数

上一篇:海南一河面发现男尸(海南海边淹死人)(关于海南一河面发现男尸的1点解答)
下一篇:黑医生是什么职业(什么是医美行业的“黑医生”?)

为您推荐