当前位置: 首页>>代码示例>>Java>>正文


Java Pointer.getPointer方法代码示例

本文整理汇总了Java中org.bridj.Pointer.getPointer方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.getPointer方法的具体用法?Java Pointer.getPointer怎么用?Java Pointer.getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bridj.Pointer的用法示例。


在下文中一共展示了Pointer.getPointer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.bridj.Pointer; //导入方法依赖的package包/类
public static Clingo create(int messageLimit, final ClingoLogger logger, String... parameters) throws ClingoException {
    Pointer<ClingoLibrary.clingo_logger_t> p_logger = null;
    if (logger != null) {
        clingo_logger_t log = new clingo_logger_t() {
            public void apply(int code, Pointer<Byte> message, Pointer<?> data) {
                try {
                    logger.warn(EnumValue.valueOfInt(WarningCode.class, code), message.getCString());
                } catch (Exception e) {
                    // ignore
                }
            }
        };
        p_logger = Pointer.getPointer(log);
    }

    // create a control object and pass command line arguments
    Pointer<Pointer<clingo_control>> control = Pointer.allocatePointer(clingo_control.class);
    handleError(LIB.clingo_control_new(null, 0, p_logger, null, messageLimit, control), "Could not create clingo controller");
    return new Clingo(control.get());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:21,代码来源:Clingo.java

示例2: parseTerm

import org.bridj.Pointer; //导入方法依赖的package包/类
public static Symbol parseTerm(String term, ClingoLogger logger, int messageLimit) throws ClingoException {
    Pointer<Long> ret = Pointer.allocateLong();

    Pointer<ClingoLibrary.clingo_logger_t> p_logger = null;
    if (logger != null) {
        clingo_logger_t log = new clingo_logger_t() {
            public void apply(int code, Pointer<Byte> message, Pointer<?> data) {
                try {
                    logger.warn(EnumValue.valueOfInt(WarningCode.class, code), message.getCString());
                } catch (Exception e) {
                    // ignore
                }
            }
        };
        p_logger = Pointer.getPointer(log);
    }
    handleError(LIB.clingo_parse_term(Pointer.pointerToCString(term), p_logger, null, messageLimit, ret), "Error parse term!");
    return new Symbol(ret.get());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:20,代码来源:Clingo.java

示例3: parseProgram

import org.bridj.Pointer; //导入方法依赖的package包/类
public static void parseProgram(String program, StatementCallback cb, ClingoLogger logger, int messageLimit) throws ClingoException {

        Pointer<ClingoLibrary.clingo_logger_t> p_logger = null;
        if (logger != null) {
            clingo_logger_t log = new clingo_logger_t() {
                public void apply(int code, Pointer<Byte> message, Pointer<?> data) {
                    try {
                        logger.warn(EnumValue.valueOfInt(WarningCode.class, code), message.getCString());
                    } catch (Exception e) {
                        // ignore
                    }
                }
            };
            p_logger = Pointer.getPointer(log);
        }

        Pointer<clingo_ast_callback_t> p_callback = null;
        if (cb != null) {
            clingo_ast_callback_t call = new clingo_ast_callback_t() {
                @Override
                public boolean apply(Pointer<clingo_ast_statement> stm, Pointer<?> voidPtr1) {
                    try {
                        if (stm != null && stm.get() != null) {
                            cb.callback(new Statement(stm.get()));
                        }
                    } catch (Throwable t) {
                        return false;
                    }
                    return true;
                }
            };
            p_callback = Pointer.getPointer(call);
        }
        handleError(LIB.clingo_parse_program(Pointer.pointerToCString(program), p_callback, null, p_logger, null, messageLimit), "Error parse program!");
    }
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:36,代码来源:Clingo.java

示例4: ground

import org.bridj.Pointer; //导入方法依赖的package包/类
public void ground(List<Part> parts, GroundCallback callback) throws ClingoException {

        Pointer<ClingoLibrary.clingo_ground_callback_t> p_ground_callback = null;
        if (callback != null) {
            ClingoLibrary.clingo_ground_callback_t ground_callback = new ClingoLibrary.clingo_ground_callback_t() {
                @Override
                public boolean apply(Pointer<clingo_location> clocation, Pointer<Byte> cname, Pointer<Long> carguments, long carguments_size, Pointer<?> cdata, Pointer<ClingoLibrary.clingo_symbol_callback_t> csymbol_callback, Pointer<?> csymbol_callback_data) {

                    String name = cname.getCString();
                    Location loc = new Location(clocation.get());
                    List<Symbol> symbols = Symbol.list(carguments, carguments_size);

                    boolean result = true;
                    try {
                        callback.groundCallback(loc, name, symbols, (List<Symbol> symbols1) -> {

                            long v_size = size(symbols1);

                            if (v_size == 0) {
                                return;
                            }

                            Pointer<Long> v_symbols = Symbol.array(symbols1);

                            handleError((csymbol_callback.get().apply(v_symbols, v_size, csymbol_callback_data)), "Error symbol callback apply!");
                        });
                    } catch (ClingoException ex) {
                        result = false;
                    }
                    return result;
                }

            };
            p_ground_callback = Pointer.getPointer(ground_callback);
        }

        Pointer<clingo_part> p_parts = Part.array(parts);
        int partsSize = size(parts);

        // ground the base part
        handleError(LIB.clingo_control_ground(pointer, p_parts, partsSize, p_ground_callback, null), "Error ground the program");

    }
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:44,代码来源:Clingo.java

示例5: createPointer

import org.bridj.Pointer; //导入方法依赖的package包/类
default Pointer<T> createPointer() {
    return Pointer.getPointer(create());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:4,代码来源:ASTObject.java


注:本文中的org.bridj.Pointer.getPointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。