Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a comment for @boundclass in extgen.crk

  • Loading branch information...
commit 0b7319c3ea99b43534ede33f8952c2e3454f8811 1 parent ad92698
@hengestone hengestone authored
Showing with 24 additions and 0 deletions.
  1. +22 −0 lib/crack/extgen.crk
  2. +2 −0  opt/_cairo.cc
View
22 lib/crack/extgen.crk
@@ -777,6 +777,26 @@ $(generic.getParamCount()) parameters.`;
constClasses.append(constClassInfo(args[0], args[1]));
}
else if (ann == 'boundclass' && symbolFilename) {
+ /// For C libraries with consistent function names, produces
+ /// a Crack class definition of all functions with a specified
+ /// prefix and first argument
+ /// E.g. @boundclass(Cairo, cr, cairo, _, cairo_t)
+ /// The arguments are:
+ /// - Crack class name
+ /// - object's C name in the library
+ /// - prefix of the functions to put in the class
+ /// - separator after prefix
+ /// - type of the C object
+
+ /// For the function
+ /// cairo_move_to(cairo_t cr, float64 x, float64 y)
+ /// example produces
+ /// class Cairo {
+ /// cairo_t cr;
+ /// move_to(float64 x, float64 y) {
+ /// cairo_move_to(cr, x, y);
+ /// }
+ /// }
args := _parseArgList(ctx);
if (args.count() != 5)
error(ctx, tok) `boundclass annotation takes 5 arguments`;
@@ -788,6 +808,8 @@ $(generic.getParamCount()) parameters.`;
_parseIfdef(ann, ctx);
}
else if (ann == 'cname') {
+ /// Specifies the C name of a function if different from the
+ /// Crack name
tok = ctx.getToken();
if (!tok.isIdent())
error(ctx, tok) `Expected identifier in cname annotation`;
View
2  opt/_cairo.cc
@@ -90,8 +90,10 @@ void crack_ext__cairo_cinit(crack::ext::Module *mod) {
crack::ext::Type *type_bool = mod->getBoolType();
crack::ext::Type *type_byteptr = mod->getByteptrType();
crack::ext::Type *type_byte = mod->getByteType();
+ crack::ext::Type *type_int16 = mod->getInt16Type();
crack::ext::Type *type_int32 = mod->getInt32Type();
crack::ext::Type *type_int64 = mod->getInt64Type();
+ crack::ext::Type *type_uint16 = mod->getUint16Type();
crack::ext::Type *type_uint32 = mod->getUint32Type();
crack::ext::Type *type_uint64 = mod->getUint64Type();
crack::ext::Type *type_int = mod->getIntType();
Please sign in to comment.
Something went wrong with that request. Please try again.