Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
feat(sassfilecontext): implement compile
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 12, 2018
1 parent 5c520d3 commit a800261
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/interop/file/sassFileContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { log } from '../../util/logger';
import { StringMethodInterface } from '../interopUtility';
import { SassOptions, SassOptionsInterface } from '../options/sassOptions';
import { wrapSassContext } from '../wrapSassContext';
import { SassContext, SassContextInterface } from './sassContext';

interface SassFileContextInterface {
/**
Expand Down Expand Up @@ -28,14 +30,12 @@ interface SassFileContextInterface {
class SassFileContext implements SassFileContextInterface {
private readonly sassFileContextPtr: number;
private sassOptions: SassOptionsInterface | null;
private sassContext: SassContextInterface | null;

constructor(
inputPath: string,
private readonly cwrapCtx: ReturnType<typeof wrapSassContext>,
private readonly strMethod: {
alloc: (value: string) => number;
ptrToString: (value: number) => string;
}
private readonly strMethod: StringMethodInterface
) {
const inputPathPtr = this.strMethod.alloc(inputPath);
this.sassFileContextPtr = this.cwrapCtx.make_file_context(inputPathPtr);
Expand Down Expand Up @@ -66,13 +66,18 @@ class SassFileContext implements SassFileContextInterface {
}

public getContext(): SassContextInterface {
this.cwrapCtx.file_context_get_context(this.sassFileContextPtr);
const sassContextPtr = this.cwrapCtx.file_context_get_context(this.sassFileContextPtr);
if (!!this.sassContext && (this.sassContext as SassContext).sassContextPtr !== sassContextPtr) {
throw new Error(`Unexpected: context has changed`);
}

throw new Error('m');
return !!this.sassContext
? this.sassContext
: (this.sassContext = new SassContext(sassContextPtr, this.cwrapCtx, this.strMethod) as SassContextInterface);
}

public compile(): void {
throw new Error('meh');
public compile(): number {
return this.cwrapCtx.compile_file_context(this.sassFileContextPtr);
}

public dispose(): void {
Expand Down

0 comments on commit a800261

Please sign in to comment.