@@ -56,10 +56,48 @@ public Plugin(byte[] manifestBytes, boolean withWASI, HostFunction[] functions)
56
56
this .pluginPointer = p ;
57
57
}
58
58
59
+
60
+ public Plugin (byte [] manifestBytes , boolean withWASI , HostFunction [] functions , long fuelLimit ) {
61
+
62
+ Objects .requireNonNull (manifestBytes , "manifestBytes" );
63
+
64
+ Pointer [] ptrArr = new Pointer [functions == null ? 0 : functions .length ];
65
+
66
+ if (functions != null )
67
+ for (int i = 0 ; i < functions .length ; i ++) {
68
+ ptrArr [i ] = functions [i ].pointer ;
69
+ }
70
+
71
+ Pointer [] errormsg = new Pointer [1 ];
72
+ Pointer p = LibExtism .INSTANCE .extism_plugin_new_with_fuel_limit (manifestBytes , manifestBytes .length ,
73
+ ptrArr ,
74
+ functions == null ? 0 : functions .length ,
75
+ withWASI ,
76
+ fuelLimit ,
77
+ errormsg );
78
+ if (p == null ) {
79
+ if (functions != null ) {
80
+ for (int i = 0 ; i < functions .length ; i ++) {
81
+ LibExtism .INSTANCE .extism_function_free (functions [i ].pointer );
82
+ }
83
+ }
84
+ String msg = errormsg [0 ].getString (0 );
85
+ LibExtism .INSTANCE .extism_plugin_new_error_free (errormsg [0 ]);
86
+ throw new ExtismException (msg );
87
+ }
88
+
89
+ this .functions = functions ;
90
+ this .pluginPointer = p ;
91
+ }
92
+
59
93
public Plugin (Manifest manifest , boolean withWASI , HostFunction [] functions ) {
60
94
this (serialize (manifest ), withWASI , functions );
61
95
}
62
96
97
+
98
+ public Plugin (Manifest manifest , boolean withWASI , HostFunction [] functions , long fuelLimit ) {
99
+ this (serialize (manifest ), withWASI , functions , fuelLimit );
100
+ }
63
101
64
102
private static byte [] serialize (Manifest manifest ) {
65
103
Objects .requireNonNull (manifest , "manifest" );
0 commit comments