使用 cffi-libffi 按值传递结构?

2023-12-25

我的印象是 CFFI 无法按值传递结构,但 CFFI 文档说:

要将结构按值传递或返回给函数,请加载 cffi-libffi 系统并将结构指定为(:struct structure-name)。要传递或返回指针,您可以使用:pointer or (:pointer (:struct structure-name)).

我正在重新包装 cl-opencv 函数get-size,它是这个 opencv 函数的包装器:

CvSize cvGetSize(const CvArr* arr)

由于当 cl-opencv 的作者编写该库时,我认为 CFFI 不具备通过 cffi-libffi 系统按值传递结构的能力,因此他必须使用以下所有代码来包装cvGetSize:

 (defmacro make-structure-serializers (struct slot1 slot2)
  "Create a serialization and deserialization function for the
structure STRUCT with integer slots SLOT1 and SLOT2. These functions
will pack and unpack the structure into an INT64."
  (let ((pack-fn (intern (concatenate 'string (string struct) 
                       (string '->int64))))
    (slot1-fn (intern (concatenate 'string (string struct) "-" 
                        (string slot1))))
    (slot2-fn (intern (concatenate 'string (string struct) "-" 
                        (string slot2))))
    (unpack-fn (intern (concatenate 'string (string 'int64->) 
                    (string struct))))
    (make-fn (intern (concatenate 'string (string 'make-) 
                       (string struct)))))
     `(progn
        (defun ,pack-fn (s)
     (+ (,slot1-fn s) (ash (,slot2-fn s) 32)))
        (defun ,unpack-fn (n)
     (,make-fn ,slot1 (logand n #x00000000ffffffff)
            ,slot2 (ash n -32))))))


;; CvSize - Input = (defparameter a (make-size :width 640 :height 480)) Output = #S(SIZE :WIDTH 640 :HEIGHT 480) for 
;; following the two.
(defstruct size (width 0) (height 0))
(make-structure-serializers :size :width :height)

;; CvSize cvGetSize(const CvArr* arr)
(cffi:defcfun ("cvGetSize" %get-size) :int64
  (arr cv-array))

(defun get-size (arr)
  "Get the dimensions of the OpenCV array ARR. Return a size struct with the
dimensions."
  (let ((nsize (%get-size arr)))
     (int64->size nsize)))

鉴于上面引用的 CFFI 文档,我将如何通过这个cvGetSize struct CvSize按价值?

我打算更新cl-opencv https://github.com/ryepup/cl-opencv包,我想知道在 cl-opencv 包中的何处以及如何根据 CFFI 文档“加载 cffi-libffi 系统”,以及在何处“将结构指定为(:struct structure-name)”和“使用 :pointer 或 (:pointer (:struct 结构名称))”“传递或返回指针。”

我可以使用有关如何使用上述内容执行此操作的详细说明cvGetSize包装:

;; CvSize cvGetSize(const CvArr* arr)
(cffi:defcfun ("cvGetSize" %get-size) :int64
  (arr cv-array))

(defun get-size (arr)
  "Get the dimensions of the OpenCV array ARR. Return a size struct with the
dimensions."
  (let ((nsize (%get-size arr)))
     (int64->size nsize)))

编辑@Rörd

我很欣赏你的良心回应

无论哪种方式,我都会遇到相同的错误...但出于测试目的,假设我加载 cffi-libffi 像这样进入我当前的会话(带输出)

CL-OPENCV> (asdf:oos 'asdf:load-op :cffi-libffi) 
#<ASDF:LOAD-OP NIL {10076CCF13}>
NIL

它加载,所以我只运行您提供的 defcfun 和 defcstruct 像这样(带输出):

 CL-OPENCV> (cffi:defcstruct cv-size
           (width :int)
           (height :int))

  (:STRUCT CV-SIZE)
  CL-OPENCV> 
  (defcfun ("cvGetSize" %get-size) (:struct cv-size)
    (arr cv-array))
  ; in: DEFCFUN ("cvGetSize" %GET-SIZE)
  ;     ("cvGetSize" CL-OPENCV::%GET-SIZE)
  ; 
  ; caught ERROR:
  ;   illegal function call
  ; 
  ; compilation unit finished
  ;   caught 1 ERROR condition

  Execution of a form compiled with errors.
  Form:
    ("cvGetSize" %GET-SIZE)
  Compile-time error:
    illegal function call
     [Condition of type SB-INT:COMPILED-PROGRAM-ERROR]

  Restarts:
   0: [RETRY] Retry SLIME REPL evaluation request.
   1: [*ABORT] Return to SLIME's top level.
   2: [ABORT] Abort thread (#<THREAD "repl-thread" RUNNING {1007BA8063}>)

      Backtrace:
             0: ((LAMBDA ()))
                 [No Locals]
             1: (SB-INT:SIMPLE-EVAL-IN-LEXENV ("cvGetSize" %GET-SIZE) #<NULL-LEXENV>)
                 Locals:
                   SB-DEBUG::ARG-0 = ("cvGetSize" %GET-SIZE)
                   SB-DEBUG::ARG-1 = #<NULL-LEXENV>
             2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEFCFUN ("cvGetSize" %GET-SIZE) (:STRUCT CV-SIZE) (ARR CV-ARRAY)) #<NULL-LEXENV>)
                 Locals:
                   SB-DEBUG::ARG-0 = (DEFCFUN ("cvGetSize" %GET-SIZE) (:STRUCT CV-SIZE) (ARR CV-ARRAY))
                   SB-DEBUG::ARG-1 = #<NULL-LEXENV>
             3: (EVAL (DEFCFUN ("cvGetSize" %GET-SIZE) (:STRUCT CV-SIZE) (ARR CV-ARRAY)))
                 Locals:

我知道 libffi 已正确安装,因为加载了 gsll(使用 cffi-libffi) 我运行 gsll 测试,它们都通过了此处显示的(带有输出)

(ql:quickload "lisp-unit")
  (in-package :gsl)
  (lisp-unit:run-tests)
To load "lisp-unit":
  Load 1 ASDF system:
    lisp-unit
     Loading "lisp-unit"
..................................
Unit Test Summary
 | 4023 assertions total
 | 4022 passed
 | 1 failed
 | 0 execution errors
 | 0 missing tests

#<TEST-RESULTS-DB Total(4023) Passed(4022) Failed(1) Errors(0)>

它似乎没有使用 (:struct cv-size) 调用 defcfun 作为问题,因为当我这样称呼它时

(defcfun ("cvGetSize" %get-size) cv-size
  (arr cv-array))

我得到同样的错误

Execution of a form compiled with errors.
Form:
  ("cvGetSize" %GET-SIZE)
Compile-time error:

我可以像这样运行我的 ipl-image 结构

CL-OPENCV> ;; ;(cffi:foreign-type-size '(:struct ipl-image)) = 144
(cffi:defcstruct ipl-image
(n-size :int)
(id :int)
(n-channels :int)
(alpha-channel :int)
(depth :int)
(color-model :pointer) 
(channel-seq :pointer) 
(data-order :int)
(origin :int)
(align :int)
(width :int)
(height :int)
(roi :pointer)
(mask-roi :pointer)
(image-id :pointer)
(tile-info :pointer)
(image-size :int)
(image-data :string)
(width-step :int)
(border-mode :pointer)
(border-const :pointer)
(image-data-origin :string))

   output>(:STRUCT IPL-IMAGE)

我的 create-image 包装器现在已加载 cffi-libffi 且您的 (:struct ipl-image) 已打开 它运行良好,但...显示输出

;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" %create-image) (:struct ipl-image)
  (size :int64)
  (depth :int)
  (channels :int))

(defun create-image (size depth channels)
  "Create an image with dimensions given by SIZE, DEPTH bits per
channel, and CHANNELS number of channels."
 (let ((nsize (size->int64 size)))
    (%create-image nsize depth channels)))

创建图像

但当我跑步时

(defparameter img-size (make-size :width 640 :height 480))

(defparameter img (create-image img-size +ipl-depth-8u+ 1))

在 repl 创建一个图像没有任何反应,repl 只是挂起......

但是当我使用 ipl-image 而不是 (:struct ipl-image) 运行创建图像包装器时

我可以运行:

 (defparameter img-size (make-size :width 640 :height 480))

 (defparameter img (create-image img-size +ipl-depth-8u+ 1))

很好,然后运行它来访问结构值(带输出)

 (cffi:with-foreign-slots ((
  n-size
  id
  n-channels
  alpha-channel
  depth
  color-model
  channel-seq
  data-order
  origin
  align
  width
  height
  roi
  mask-roi
  image-id
  tile-info
  image-size
  image-data
  width-step
  border-mode
  border-const
  image-data-origin) img (:struct ipl-image))
            (cffi:mem-ref img :char )
            (format t "n-size ~a ~%" n-size)
            (format t "id ~a ~%" id)
            (format t "n-channels ~a ~%" n-channels)
            (format t "alpha-channel ~a ~%" alpha-channel)
            (format t "depth ~a ~%" depth)
            (format t "color-model ~a ~%" color-model)
            (format t "channel-seq ~a ~%" channel-seq)
            (format t "data-order ~a ~%" data-order)
            (format t "origin ~a ~%" origin)
            (format t "align ~a ~%" align)
            (format t "width ~a ~%" width)
            (format t "height ~a ~%" height)
            (format t "roi ~a ~%" roi)
            (format t "mask-roi ~a ~%" mask-roi)
            (format t "image-id ~a ~%" image-id)
            (format t "tile-info ~a ~%" tile-info)
            (format t "image-size ~a ~%" image-size)
            (format t "image-data ~a ~%" image-data)
            (format t "width-step ~a ~%" width-step)
            (format t "border-mode ~a ~%" border-mode)
            (format t "border-const ~a ~%" border-const)
            (format t "image-data-origin ~a ~%" image-data-origin))
  output>
  n-size 144 
  id 0 
  n-channels 1 
  alpha-channel 0 
  depth 8 
  color-model #.(SB-SYS:INT-SAP #X59415247) 
  channel-seq #.(SB-SYS:INT-SAP #X400000000) 
  data-order 640 
  origin 480 
  align 0 
  width 0 
  height 0 
  roi #.(SB-SYS:INT-SAP #X00000000) 
  mask-roi #.(SB-SYS:INT-SAP #X00000000) 
  image-id #.(SB-SYS:INT-SAP #X0004B000) 
  tile-info #.(SB-SYS:INT-SAP #X7FFFF7F04020) 
  image-size 640 
  image-data NIL 
  width-step 0 
  border-mode #.(SB-SYS:INT-SAP #X00000000) 
  border-const #.(SB-SYS:INT-SAP #X00000000) 
  image-data-origin  

但我没有按我得到的值得到结构

 color-model #.(SB-SYS:INT-SAP #X59415247) 

当我用这个在 c 中计算出该值 img->colorModel 时

IplImage* img=cvCreateImage(cvSize(640,480), IPL_DEPTH_8U, 3);
cout << "colorModel = " << endl << " " << img->colorModel << endl << endl;

output> colorModel = 
 RGB

所以任何帮助将不胜感激

好的,还有 1 个编辑:

我又试了一次,它在这里工作是我的输出

  CL-OPENCV> (asdf:oos 'asdf:load-op :cffi-libffi)
  #<ASDF:LOAD-OP NIL {1006D7B1F3}>
  NIL
  CL-OPENCV> 
  ;; ;(cffi:foreign-type-size '(:struct cv-size)) = 8
  (cffi:defcstruct cv-size
      (width :int)
      (height :int))

  ;; CvSize cvGetSize(const CvArr* arr)
  (cffi:defcfun ("cvGetSize" %get-size) (:struct cv-size)
    (arr cv-array))

  STYLE-WARNING: redefining CL-OPENCV::%GET-SIZE in DEFUN
  %GET-SIZE
  CL-OPENCV> 

   (defparameter img-size (make-size :width 640 :height 480))

  (defparameter img (create-image img-size +ipl-depth-8u+ 1))

  IMG
  CL-OPENCV> 

   (defparameter size (%get-size img))
  SIZE
  CL-OPENCV> size
  (HEIGHT 480 WIDTH 640)
  CL-OPENCV> 

不知道我第一次做错了什么,但是...如果您可以检查我的结果并验证我刚刚按值传递了一个结构,我将永远感激不已

谢谢罗德

如果您仍然有兴趣帮助我调试 Rord,请再次编辑

如果出现错误:

  The value (HEIGHT 480 WIDTH 640)
   is not of type
   SB-SYS:SYSTEM-AREA-POINTER.
   [Condition of type TYPE-ERROR]

这是导致它的历史记录(这发生在我发布上一个编辑之后,所以我的 emacs 仍然加载了所有上一个编辑代码):

   CL-OPENCV> (defun get-size (arr)
    "Get the dimensions of the OpenCV array ARR. Return a size struct with the
  dimensions."
    (cffi:with-foreign-slots ((width height) (%get-size arr) (:struct cv-size))
      (make-size :width width :height height)))
  STYLE-WARNING: redefining CL-OPENCV:GET-SIZE in DEFUN
  GET-SIZE
  CL-OPENCV> 

   (defparameter img-size (make-size :width 640 :height 480))

  (defparameter img (create-image img-size +ipl-depth-8u+ 1))

  IMG
  CL-OPENCV> 

   (defparameter size (get-size img))


  The value (HEIGHT 480 WIDTH 640)
   is not of type
   SB-SYS:SYSTEM-AREA-POINTER.
   [Condition of type TYPE-ERROR]

我明白是因为:

(defparameter size (get-size img)) 

访问你的 defun...我跟踪了它,所以当我刚刚运行时 - 显示输出:

CL-OPENCV> 
;; ;(cffi:foreign-type-size '(:struct cv-size)) = 8
(cffi:defcstruct cv-size
        (width :int)
        (height :int))

;; CvSize cvGetSize(const CvArr* arr)
 (cffi:defcfun ("cvGetSize" %get-size) (:struct cv-size)
  (arr cv-array))

STYLE-WARNING: redefining CL-OPENCV::%GET-SIZE in DEFUN
%GET-SIZE
CL-OPENCV> (defparameter capture (create-camera-capture 0))
CAPTURE
CL-OPENCV> (defparameter frame (query-frame capture))
FRAME
CL-OPENCV> 

(defparameter size (%get-size frame))
SIZE
CL-OPENCV> size
(HEIGHT 480 WIDTH 640)
CL-OPENCV> (cffi:with-foreign-slots ((width height) size (:struct cv-size))
        (list width height ))

我收到错误:

The value (HEIGHT 480 WIDTH 640)
  is not of type
    SB-SYS:SYSTEM-AREA-POINTER.
     [Condition of type 

我认为这是因为 defcfun 的输出只是一个列表,而 with-foreign-slots 需要一个指针

我跑了这个:

(HEIGHT 480 WIDTH 640)
CL-OPENCV> (first size)
HEIGHT

进行验证,这只是一个列表

顺便说一句,我使用这些函数进行测试

(defparameter capture (create-camera-capture 0))

(defparameter frame (query-frame capture))

因为有更纯粹的输出...create-image 使用了我最初发布在本文顶部的 get-size 的黑客技术?

我想使用 create-image 和 get-size 而不使用所有黑客技术,只使用结构进行返回,这样我就可以停止使用 make-size 并使其更纯粹......所以对此的任何建议都会是金子...这就是我想要创建图像的方式...我只需让它接受你的(Rord's)defcfun 的输出...我现在正在尝试转动你的 defcfun 输出((高度480 WIDTH 640)) 到一个指针...所以它只会在这个中运行

;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" %create-image) ipl-image
  (size cv-size)
  (depth :int)
  (channels :int))

或者整个制作尺寸的事情将是必要的......

另外仅供参考,我更改了您添加的 defun

(defun get-size (arr)
  "Get the dimensions of the OpenCV array ARR. Return a size struct with the
dimensions."
  (setf arr (%get-size arr))
  (make-size :width (cadddr arr) :height (cadr arr)))

现在它可以工作了...仍然好奇我是否搞砸了一些东西以及如果你的 defun 会更好

编辑!!!我已经弄清楚了!!!!

here is the repl output :

; SLIME 2012-05-25
CL-OPENCV> ;; CvSize cvGetSize(const CvArr* arr)
(cffi:defcfun ("cvGetSize" get-size) (:pointer (:struct cv-size))
  (arr cv-array))
STYLE-WARNING: redefining CL-OPENCV:GET-SIZE in DEFUN
GET-SIZE
CL-OPENCV> ;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" create-image) (:pointer (:struct ipl-image))
   (size (:pointer (:struct ipl-image)))
  (depth :int)
  (channels :int))


STYLE-WARNING: redefining CL-OPENCV:CREATE-IMAGE in DEFUN
CREATE-IMAGE
CL-OPENCV> (defun detect-red-objects (&optional (camera-index 0))
   "Uses IN-RANGE-SCALAR to detect red objects"
  (with-capture (capture (create-camera-capture camera-index))
    (let ((window-name-1 "Video")
          (window-name-2 "Ball"))
           (named-window window-name-1)
           (named-window window-name-2)
           (move-window window-name-1 290 225)
           (move-window window-name-2 940 225)
      (do* ((frame (query-frame capture) (query-frame capture))
             (img (clone-image frame))
              (frame (clone-image img))
              (img-size (get-size frame))          
              (img-hsv (create-image img-size +ipl-depth-8u+ 3))
              (img-hsv-size (get-size img-hsv))
            (img-thresh (create-image img-hsv-size +ipl-depth-8u+ 1))
             (scalar-1 (make-cv-scalar 170.0 160.0 60.0))
             (scalar-2 (make-cv-scalar 180.0 256.0 256.0)))
         ((plusp (wait-key *millis-per-frame*)) nil)
             (smooth frame frame +gaussian+ 3 3)
             (cvt-color frame img-hsv +bgr2hsv+)
             (in-range-s img-hsv scalar-1 scalar-2 img-thresh)
             (smooth img-thresh img-thresh +gaussian+ 3 3)
             (show-image window-name-1 frame)
             (show-image window-name-2 img-thresh))
          (destroy-all-windows))))
DETECT-RED-OBJECTS

(the function detect-red-objects runs btw!...

编辑!!!!!我已经全部弄清楚了!!!!!!...部分....II - 甚至更好!

I messed up the struct on create-image the first time but it still ran...weird...but it runs when put the create-image struct back to cv-size....so no prob there...here is revised repl output


; SLIME 2012-05-25
CL-OPENCV> ;; CvSize cvGetSize(const CvArr* arr)
(cffi:defcfun ("cvGetSize" get-size) (:pointer (:struct cv-size))
  (arr cv-array))
STYLE-WARNING: redefining CL-OPENCV:GET-SIZE in DEFUN
GET-SIZE
CL-OPENCV> ;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" create-image) (:pointer (:struct ipl-image))
  (size (:pointer (:struct cv-size)))
  (depth :int)
  (channels :int))

STYLE-WARNING: redefining CL-OPENCV:CREATE-IMAGE in DEFUN
CREATE-IMAGE
CL-OPENCV> (defun detect-red-objects (&optional (camera-index 0))
   "Uses IN-RANGE-SCALAR to detect red objects"
  (with-capture (capture (create-camera-capture camera-index))
    (let ((window-name-1 "Video")
          (window-name-2 "Ball"))
           (named-window window-name-1)
           (named-window window-name-2)
           (move-window window-name-1 290 225)
           (move-window window-name-2 940 225)
      (do* ((frame (query-frame capture) (query-frame capture))
             (img (clone-image frame))
              (frame (clone-image img))
              (img-size (get-size frame))           
              (img-hsv (create-image img-size +ipl-depth-8u+ 3))
              (img-hsv-size (get-size img-hsv))
            (img-thresh (create-image img-hsv-size +ipl-depth-8u+ 1))
             (scalar-1 (make-cv-scalar 170.0 160.0 60.0))
             (scalar-2 (make-cv-scalar 180.0 256.0 256.0)))
         ((plusp (wait-key *millis-per-frame*)) nil)
             (smooth frame frame +gaussian+ 3 3)
             (cvt-color frame img-hsv +bgr2hsv+)
             (in-range-s img-hsv scalar-1 scalar-2 img-thresh)
             (smooth img-thresh img-thresh +gaussian+ 3 3)
             (show-image window-name-1 frame)
             (show-image window-name-2 img-thresh)) 
          (destroy-all-windows))))
DETECT-RED-OBJECTS

@利亚姆编辑

好的,我尝试了你的从外国翻译的方法,它确实有效 我在 structs.lisp 文件中定义了这些

(cffi:defcstruct (cv-size :class cv-size-type)
  (width :int)
  (height :int))

(defmethod cffi:translate-from-foreign (p (type cv-size-type))
  (let ((plist (call-next-method)))
    (make-size :width (getf plist 'width)
               :height (getf plist 'height))))

get-size 和 create-image 的定义如下

;; CvSize cvGetSize(const CvArr* arr)
 (cffi:defcfun ("cvGetSize" get-size) (:struct cv-size)
   (arr cv-arr))

 ;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
 (cffi:defcfun ("cvCreateImage" %create-image) ipl-image
   (size :int64)
   (depth :int)
   (channels :int))

 (defun create-image (size depth channels)
   "Create an image with dimensions given by SIZE, DEPTH bits per
 channel, and CHANNELS number of channels."
   (let ((nsize (size->int64 size)))
     (%create-image nsize depth channels)))

这是 size->int64 的定义

  (DEFUN SIZE->INT64 (S) (+ (SIZE-WIDTH S) (ASH (SIZE-HEIGHT S) 32)))

但我喜欢翻译外国定义方法的想法

所以我想知道你是否可以向我展示如何从方法中制作下面的翻译成外国版本,这真的会让我的库唱歌......我的目标是为opencv制作一个完整的cffi包装器,就像gsll一样好是 gsl,所以这真的会帮助更快地发生......再次感谢您迄今为止对这一切的帮助

(defmethod cffi:translate-from-foreign (p (type cv-size-type))
  (let ((plist (call-next-method)))
    (make-size :width (getf plist 'width)
               :height (getf plist 'height))))

要“加载 cffi-libffi 系统”,您需要将其指定为库的依赖项.asd文件。 (注意:cffi-libffi 需要在您的系统上安装 C 库 libffi。)

为了能够使用(:struct structure-name),您需要首先定义结构cffi:defcstruct,像这样(我在这里假设cffi:defcstruct, cffi:defcfun, and cffi:with-foreign-slots在当前包中导入):

(defcstruct cv-size
  (width :int)
  (height :int))

然后你可以使用(:struct cv-size) in the defcfun像这样:

(defcfun ("cvGetSize" %get-size) (:struct cv-size)
  (arr cv-array))

EDIT: Fixed get-size对于按值传递的结构。

最后定义get-size像这样:

(defun get-size (arr)
  "Get the dimensions of the OpenCV array ARR. Return a size struct with the
dimensions."
  (let ((%size (%get-size arr)))
    (make-size :width (getf %size 'width)
               :height (getf %size 'height))))

EDIT 2:

如果我正确理解利亚姆的答案,这就是如何写一个translate-from-foreign方法,以便直接创建结构体,而不创建中间 plist:

(defmethod cffi:translate-from-foreign (p (type cv-size-type))
  (with-foreign-slots ((width height) p (:struct cv-size))
    (make-size :width width :height height)))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 cffi-libffi 按值传递结构? 的相关文章

随机推荐

  • 未能@AutoWire @WebServlet 中的成员

    我似乎无法将我的 servlet 的字段传递给 AutoWire 他们最终归零 我有一个纯注释配置的 web 应用程序 没有 XML 文件 我的 servlet 看起来像这样 WebServlet service public class
  • 将 python Webserver 作为 Windows 服务运行

    我有服务器和控制台scripts http svn python org projects python trunk Lib CGIHTTPServer py它继续监听端口上的控制台和服务器请求 在 UNIX 环境中 我将服务器和控制台脚本
  • 在脚本中使用临时函数或过程

    我在用SQL Server 2012 我有一个脚本 通过它我可以将值插入到表中 在该脚本中我必须转换某些值的格式DateTime基于两个参数的变量 我可以使用CASE or if条件在sql 我不被允许做任何Function or proc
  • 如何在卡片操作中单击时调用特定回调 - Bot Framework

    我展示了一个带有一些产品的轮播 每个产品都有一个带有代码的按钮 卡片操作类型为 ImBack 但一旦通过 postAsync 方法显示轮播 单击按钮将再次调用根对话框 有没有办法定义按钮单击的回调或显示相同的轮播但使用 PromptDial
  • Windows Vista 中的安装文件名

    我在这篇文章中读到 http technet microsoft com en us library cc709628 aspx http technet microsoft com en us library cc709628 aspx
  • QTableView:当用户使用鼠标单击特定单元格时如何获取数据

    其实我是Qt新手 无法匹配QMouseEvent with QTableview 请帮助解决这个问题 下面是一个示例 说明如何在单击表格单元格时获取该单元格的文本 假设一个QTableView定义在一些MyClass班级 你需要connec
  • 如何使用 Bower 安装 Bootstrap v4 alpha? [复制]

    这个问题在这里已经有答案了 The v4 alpha 文档 http v4 alpha getbootstrap com getting started download states Bootstrap v4 0 0 alpha 可以通过
  • 如何运行将数据加载到其他项目 BigQuery Table 的云编辑器任务

    我在项目 A 下创建了云编辑器环境 我想将数据加载到其他项目 B BigQuery 表中 我知道任务 GCSToBigQueryOperator 但它没有成功 它失败了 我想知道如何实现这一点 我想从项目 A 运行一个将数据加载到项目 B
  • 滚动到 angular2 时动画进入视图

    我找到了一个库 用于在滚动到 aos https github com michalsnik aos 但它似乎没有任何 angular2 绑定可供使用 有谁知道如何在 Angular2 中完成类似的事情 或者至少配置 aos 在 Angul
  • 如何在iPhone中创建应用程序包?

    我使用 XCode 制作了一个小型应用程序 我如何创建一个应用程序包以将其安装在 iPhone 中 谁能帮我解决这个问题 提前致谢 是的 如上所述 您需要支付 99 美元的开发者费用 完成此操作后 您可以通过 XCode 直接部署到使用配置
  • PHP 中的数组打乱顺序

    我有以下代码 输出如下 域名 com image1 jpg 域名 com image2 jpg 域名 com image3 jpg 我正在尝试随机化输出的顺序 在 foreach 语句之前 我尝试使用 shuffle bb 对数组进行洗牌
  • 创建与 DetailView 相反的视图

    上传图像后 我试图从 CreateView 反转到 DetailView 我收到同样的消息 NoReverseMatch 位于 photo image add 未找到带有参数 和关键字参数 pk 50 的 image view 的反向操作
  • SailsJS Waterline 与 Bluebird Promises

    使用 Waterline ORM 时 如果我想使用默认提供的 bluebird Promise api 如何将处理传递回控制器 下面是代码 module exports Authenticate auth function req res
  • 如何衡量两个数据的相似度

    我正在测量两个大小相同的数据的相似度为20 即 A 0 915450999999999 0 908220499999997 0 900374999999996 0 890547499999996 0 880455499999997 0 86
  • 如何让 Firestore 索引合并发挥作用?

    我在使用 firestore 索引合并来减少所需索引的数量时遇到问题 考虑这个示例情况 Firestore 集合 测试 somedoc a 1 b 1 c 1 d 1 这将导致 Firestore 在测试时为字段 a 到 d 创建 4 个自
  • scala.js 与 jscala 有什么区别?

    有两个工具可以直接在 JavaScript 中编译 Scala 代码 Scala js http www scala js org and JScala https github com nau jscala 它们看起来都很棒 并且可以使用
  • issubclass 的用法

    gt gt gt import sys gt gt gt sys version info 2 4 4 final 0 gt gt gt class C pass gt gt gt issubclass C C True gt gt gt
  • 处理 Akka actor 中的错误

    我有一个非常简单的例子 我有一个演员 SimpleActor 通过向自身发送消息来执行周期性任务 该消息在参与者的构造函数中安排 在正常情况下 即没有故障 一切正常 但如果 Actor 必须处理错误怎么办 我还有另一个演员 SimpleAc
  • 捕获 C++ CLI 应用程序中登录的异常

    我试图捕获 C CLI 应用程序中的所有异常 以便我可以记录它们 包括堆栈跟踪 到目前为止 我有一些看起来很有希望的代码 STAThreadAttribute int main array
  • 使用 cffi-libffi 按值传递结构?

    我的印象是 CFFI 无法按值传递结构 但 CFFI 文档说 要将结构按值传递或返回给函数 请加载 cffi libffi 系统并将结构指定为 struct structure name 要传递或返回指针 您可以使用 pointer or