Skip to content

Instantly share code, notes, and snippets.

@20kdc
Last active April 28, 2023 12:20
Show Gist options
  • Save 20kdc/f77eecded79493f3ef2afa178ed9a11b to your computer and use it in GitHub Desktop.
Save 20kdc/f77eecded79493f3ef2afa178ed9a11b to your computer and use it in GitHub Desktop.
Making a common event using R48 internal stuff
import r48.io.IObjectBackend
import r48.io.data.IRIOFixnum
import r48.io.data.IRIO
import r48.io.r2k.dm2chk.DM2SparseArrayH
import r48.io.r2k.files.DatabaseIO
import r48.io.r2k.obj.ldb.CommonEvent
import r48.io.r2k.obj.ldb.Database
import java.io.FileOutputStream
IObjectBackend.Factory.encoding = "UTF-8"
// The r2k backend uses some complex packing/unpacking to save memory.
// This means touching it outside of the IRIO interface can lead to ... 'interesting side-effects',
// outside of controlled circumstances.
Database n = new Database()
IRIO ce = n.getIVar("@common_events").addHashVal(new IRIOFixnum(0))
ce.getIVar("@name").setString("My Common Event")
FileOutputStream fos = new FileOutputStream("Hello.ldb")
DatabaseIO.writeLdb(fos, n)
fos.close()
@20kdc
Copy link
Author

20kdc commented Apr 28, 2023

This is now out of date. For the better, at least -- much in the way of globals misuse was removed, for instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment